/**
* Ajax Autocomplete for jQuery, version 1.4.11
* (c) 2017 Tomas Kirda
*
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
* MODIFIED: Removed adjustContainerWidth() function.
Removed g::createNode() position: absolute style.
Removed setOptions() suggestionsContainer styles.
suggest() Product card output.
*/
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(h){"use strict";function s(e,t){var n=this;n.element=e,n.el=h(e),n.suggestions=[],n.badQueries=[],n.selectedIndex=-1,n.currentValue=n.element.value,n.timeoutId=null,n.cachedResponse={},n.onChangeTimeout=null,n.onChange=null,n.isLocal=!1,n.suggestionsContainer=null,n.noSuggestionsContainer=null,n.options=h.extend(!0,{},s.defaults,t),n.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},n.hint=null,n.hintValue="",n.selection=null,n.initialize(),n.setOptions(t)}var o={escapeRegExChars:function(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.display="none",t}},n=27,i=9,a=13,l=38,u=39,r=40,e=h.noop;s.utils=o,(h.Autocomplete=s).defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:3,deferRequestBy:0,params:{},formatResult:function(e,t){if(!t)return e.value;var n="("+o.escapeRegExChars(t)+")";return e.value.replace(new RegExp(n,"gi"),"$1").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/<(\/?strong)>/g,"<$1>")},formatGroup:function(e,t){return'
'+t+"
"},delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:e,onSearchComplete:e,onSearchError:e,preserveInput:!1,containerClass:"autocomplete-suggestions small-block-grid-1 medium-block-grid-3 large-block-grid-3 xlarge-block-grid-4 xxlarge-block-grid-5 ",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:function(e,t,n){return-1!==e.value.toLowerCase().indexOf(n)},paramName:"query",transformResult:function(e){return"string"==typeof e?JSON.parse(e):e},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1},s.prototype={initialize:function(){var e,t=this,n="."+t.classes.suggestion,o=t.classes.selected,i=t.options;t.element.setAttribute("autocomplete","off"),t.noSuggestionsContainer=h('').html(this.options.noSuggestionNotice).get(0),t.suggestionsContainer=s.utils.createNode(i.containerClass),(e=h(t.suggestionsContainer)).appendTo(i.appendTo||"body"),"auto"!==i.width&&e.css("width",i.width),e.on("mouseover.autocomplete",n,function(){t.activate(h(this).data("index"))}),e.on("mouseout.autocomplete",function(){t.selectedIndex=-1,e.children("."+o).removeClass(o)}),e.on("click.autocomplete",n,function(){t.select(h(this).data("index"))}),e.on("click.autocomplete",function(){clearTimeout(t.blurTimeoutId)}),t.fixPositionCapture=function(){t.visible&&t.fixPosition()},h(window).on("resize.autocomplete",t.fixPositionCapture),t.el.on("keydown.autocomplete",function(e){t.onKeyPress(e)}),t.el.on("keyup.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("blur.autocomplete",function(){t.onBlur()}),t.el.on("focus.autocomplete",function(){t.onFocus()}),t.el.on("change.autocomplete",function(e){t.onKeyUp(e)}),t.el.on("input.autocomplete",function(e){t.onKeyUp(e)})},onFocus:function(){var e=this;e.disabled||(e.fixPosition(),e.el.val().length>=e.options.minChars&&e.onValueChange())},onBlur:function(){var e=this,t=e.options,n=e.el.val(),o=e.getQuery(n);e.blurTimeoutId=setTimeout(function(){e.selection&&e.currentValue!==o&&(t.onInvalidateSelection||h.noop).call(e.element)},200)},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(e){var t=this,n=h.extend({},t.options,e);t.isLocal=Array.isArray(n.lookup),t.isLocal&&(n.lookup=t.verifySuggestionsFormat(n.lookup)),n.orientation=t.validateOrientation(n.orientation,"bottom"),this.options=n},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var e=this;e.disabled=!0,clearTimeout(e.onChangeTimeout),e.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var e=this,t=h(e.suggestionsContainer),n=t.parent().get(0);if(n===document.body||e.options.forceFixPosition){var o=e.options.orientation,i=t.outerHeight(),s=e.el.outerHeight(),a=e.el.offset(),l={top:a.top,left:a.left};if("auto"===o){var u=h(window).height(),r=h(window).scrollTop(),c=-r+a.top-i,g=r+u-(a.top+s+i);o=Math.max(c,g)===c?"top":"bottom"}if(l.top+="top"===o?-i:s,n!==document.body){var d,p=t.css("opacity");e.visible||t.css("opacity",0).show(),d=t.offsetParent().offset(),l.top-=d.top,l.top+=n.scrollTop,l.left-=d.left,e.visible||t.css("opacity",p).hide()}"auto"===e.options.width&&(l.width=e.el.outerWidth()+"px"),t.css(l)}},isCursorAtEnd:function(){var e,t=this.el.val().length,n=this.element.selectionStart;return"number"==typeof n?n===t:!document.selection||((e=document.selection.createRange()).moveStart("character",-t),t===e.text.length)},onKeyPress:function(e){var t=this;if(t.disabled||t.visible||e.which!==r||!t.currentValue){if(!t.disabled&&t.visible){switch(e.which){case n:t.el.val(t.currentValue),t.hide();break;case u:if(t.hint&&t.options.onHint&&t.isCursorAtEnd()){t.selectHint();break}return;case i:if(t.hint&&t.options.onHint)return void t.selectHint();if(-1===t.selectedIndex)return void t.hide();if(t.select(t.selectedIndex),!1===t.options.tabDisabled)return;break;case a:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case l:t.moveUp();break;case r:t.moveDown();break;default:return}e.stopImmediatePropagation(),e.preventDefault()}}else t.suggest()},onKeyUp:function(e){var t=this;if(!t.disabled){switch(e.which){case l:case r:return}clearTimeout(t.onChangeTimeout),t.currentValue!==t.el.val()&&(t.findBestHint(),0s&&(e.suggestions=e.suggestions.slice(0,s)),e},getSuggestions:function(o){var e,t,n,i,s=this,a=s.options,l=a.serviceUrl;if(a.params[a.paramName]=o,!1!==a.onSearchStart.call(s.element,a.params)){if(t=a.ignoreParams?null:a.params,h.isFunction(a.lookup))return void a.lookup(o,function(e){s.suggestions=e.suggestions,s.suggest(),a.onSearchComplete.call(s.element,o,e.suggestions)});s.isLocal?e=s.getSuggestionsLocal(o):(h.isFunction(l)&&(l=l.call(s.element,o)),n=l+"?"+h.param(t||{}),e=s.cachedResponse[n]),e&&Array.isArray(e.suggestions)?(s.suggestions=e.suggestions,s.suggest(),a.onSearchComplete.call(s.element,o,e.suggestions)):s.isBadQuery(o)?a.onSearchComplete.call(s.element,o,[]):(s.abortAjax(),i={url:l,data:t,type:a.type,dataType:a.dataType},h.extend(i,a.ajaxSettings),s.currentRequest=h.ajax(i).done(function(e){var t;s.currentRequest=null,t=a.transformResult(e,o),s.processResponse(t,o,n),a.onSearchComplete.call(s.element,o,t.suggestions)}).fail(function(e,t,n){a.onSearchError.call(s.element,o,e,t,n)}))}},isBadQuery:function(e){if(!this.options.preventBadQueries)return!1;for(var t=this.badQueries,n=t.length;n--;)if(0===e.indexOf(t[n]))return!0;return!1},hide:function(){var e=this,t=h(e.suggestionsContainer);jQuery(".search-suggestions-title").hide();h.isFunction(e.options.onHide)&&e.visible&&e.options.onHide.call(e.element,t),e.visible=!1,e.selectedIndex=-1,clearTimeout(e.onChangeTimeout),h(e.suggestionsContainer).hide(),e.signalHint(null)},suggest:function(){if(this.suggestions.length){var a,e=this,l=e.options,u=l.groupBy,r=l.formatResult,c=e.getQuery(e.currentValue),g=e.classes.suggestion,t=e.classes.selected,n=h(e.suggestionsContainer),o=h(e.noSuggestionsContainer),i=l.beforeRender,d="";jQuery(".search-suggestions-title").show();return l.triggerSelectOnValidInput&&e.isExactMatch(c)?void e.select(0):(h.each(e.suggestions,function(e,t){var n,o,i=t.url.trim()&&t.image.trim()?'":"",s=t.url.trim()?''+r(t,c,e)+"":r(t,c,e);u&&(d+=(o=(n=t).data[u],a===o?"":(a=o,l.formatGroup(n,a)))),d+=''+i+' '+s+t.price+"
"}),o.detach(),n.html(d),h.isFunction(i)&&i.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),l.autoSelectFirst&&(e.selectedIndex=0,n.scrollTop(0),n.children("."+g).first().addClass(t)),e.visible=!0,void e.findBestHint())}this.options.showNoSuggestionNotice?this.noSuggestions():this.hide()},noSuggestions:function(){var e=this,t=e.options.beforeRender,n=h(e.suggestionsContainer),o=h(e.noSuggestionsContainer);o.detach(),n.empty(),n.append(o),h.isFunction(t)&&t.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),e.visible=!0},findBestHint:function(){var o=this.el.val().toLowerCase(),i=null;o&&(h.each(this.suggestions,function(e,t){var n=0===t.value.toLowerCase().indexOf(o);return n&&(i=t),!n}),this.signalHint(i))},signalHint:function(e){var t="",n=this;e&&(t=n.currentValue+e.value.substr(n.currentValue.length)),n.hintValue!==t&&(n.hintValue=t,n.hint=e,(this.options.onHint||h.noop)(t))},verifySuggestionsFormat:function(e){return e.length&&"string"==typeof e[0]?h.map(e,function(e){return{value:e,data:null}}):e},validateOrientation:function(e,t){return e=e.trim().toLowerCase(),-1===h.inArray(e,["auto","bottom","top"])&&(e=t),e},processResponse:function(e,t,n){var o=this,i=o.options;e.suggestions=o.verifySuggestionsFormat(e.suggestions),i.noCache||(o.cachedResponse[n]=e,i.preventBadQueries&&!e.suggestions.length&&o.badQueries.push(t)),t===o.getQuery(o.currentValue)&&(o.suggestions=e.suggestions,o.suggest())},activate:function(e){var t,n=this,o=n.classes.selected,i=h(n.suggestionsContainer),s=i.find("."+n.classes.suggestion);return i.find("."+o).removeClass(o),n.selectedIndex=e,-1!==n.selectedIndex&&s.length>n.selectedIndex?(t=s.get(n.selectedIndex),h(t).addClass(o),t):null},selectHint:function(){var e=h.inArray(this.hint,this.suggestions);this.select(e)},select:function(e){this.hide(),this.onSelect(e)},moveUp:function(){var e=this;if(-1!==e.selectedIndex)return 0===e.selectedIndex?(h(e.suggestionsContainer).children("."+e.classes.suggestion).first().removeClass(e.classes.selected),e.selectedIndex=-1,e.ignoreValueChange=!1,e.el.val(e.currentValue),void e.findBestHint()):void e.adjustScroll(e.selectedIndex-1)},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(e){var t=this,n=t.activate(e);if(n){var o,i,s,a=h(n).outerHeight();o=n.offsetTop,s=(i=h(t.suggestionsContainer).scrollTop())+t.options.maxHeight-a,o