!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports&&"function"==typeof require?e(require("jquery")):e(jQuery)}(function(e){"use strict";var t={escapeRegExChars:function(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},createNode:function(e){var t=document.createElement("div");return t.className=e,t.style.position="absolute",t.style.display="none",t.setAttribute("unselectable","on"),t},highlight:function(e,s){if(dgwt_wcas.is_premium){var i,o=s.split(/ /),a=!1;if(o)for(o=o.sort(function(e,t){return t.length-e.length}),i=0;i1){var n=o[i].replace(/[\^\@]/g,"");if(n.length>0){var r="("+t.escapeRegExChars(n.trim())+")";e=e.replace(new RegExp(r,"gi"),"^^$1@@"),a=!0}}a&&(e=(e=e.replace(/\^\^/g,"")).replace(/@@/g,""))}else r="("+t.escapeRegExChars(s)+")",e=e.replace(new RegExp(r,"gi"),"$1");return e},debounce:function(e,t){var i,o=(new Date).getUTCMilliseconds();if(0===s.id.length)return s.id=o,void e();s.id=o,i=setTimeout(function(){o===s.id?(e(),s.id=""):clearTimeout(i)},t)},mouseHoverDebounce:function(t,s,i){var o;o=setTimeout(function(){e(s+":hover").length>0?t():clearTimeout(o)},i)},getActiveInstance:function(){var t,s=e(".dgwt-wcas-search-wrapp.dgwt-wcas-active");return s.length>0&&s.each(function(){var s=e(this).find(".dgwt-wcas-search-input");if("object"==typeof s.data("autocomplete"))return t=s.data("autocomplete"),!1}),t}},s={id:"",callback:null,ajaxSettings:null,object:null},i=27,o=9,a=13,n=38,r=39,l=40,c=e.noop;function d(t,s){this.element=t,this.el=e(t),this.suggestions=[],this.badQueries=[],this.selectedIndex=-1,this.currentValue=this.element.value,this.timeoutId=null,this.cachedResponse={},this.cachedDetails={},this.cachedPrices={},this.detailsRequestsSent=[],this.onChangeTimeout=null,this.onChange=null,this.isLocal=!1,this.suggestionsContainer=null,this.detailsContainer=null,this.autoAligmentprocess=null,this.noSuggestionsContainer=null,this.latestActivateSource="",this.actionTriggerSource="",this.options=e.extend(!0,{},d.defaults,s),this.classes={selected:"dgwt-wcas-suggestion-selected",suggestion:"dgwt-wcas-suggestion",suggestionsContainerOrientTop:"dgwt-wcas-suggestions-wrapp--top"},this.hint=null,this.hintValue="",this.selection=null,this.overlayMobileState="off",this.initialize(),this.setOptions(s)}d.utils=t,e.DgwtWcasAutocompleteSearch=d,d.defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",containerDetailsWidth:"auto",showDetailsPanel:!1,showImage:!1,showPrice:!1,showSKU:!1,showDescription:!1,showSaleBadge:!1,showFeaturedBadge:!1,dynamicPrices:!1,saleBadgeText:"sale",featuredBadgeText:"featured",minChars:3,maxHeight:600,deferRequestBy:0,params:{},formatResult:function(e,s,i,o){if(!s)return e;i&&(e=t.highlight(e,s));if(!o.convertHtml)return e;return e.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/<sup/g,"").replace(/<(\/?(strong|b))>/g,"<$1>")},delimiter:null,zIndex:999999999,type:"GET",noCache:!1,isRtl:!1,onSearchStart:c,onSearchComplete:c,onSearchError:c,preserveInput:!1,searchFormClass:"dgwt-wcas-search-wrapp",containerClass:"dgwt-wcas-suggestions-wrapp",containerDetailsClass:"dgwt-wcas-details-wrapp",searchInputClass:"dgwt-wcas-search-input",preloaderClass:"dgwt-wcas-preloader",closeTrigger:"dgwt-wcas-close",formClass:"dgwt-wcas-search-form",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,isPremium:!1,overlayMobile:!1,preventBadQueries:!0,lookupFilter:function(e,t,s){return-1!==e.value.toLowerCase().indexOf(s)},paramName:"query",transformResult:function(t){return"string"==typeof t?e.parseJSON(t):t},noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1,positionFixed:!1,debounceWaitMs:400,sendGAEvents:!0,enableGASiteSearchModule:!1},d.prototype={initialize:function(){var t=this;t.element.setAttribute("autocomplete","off"),t.createContainers(),t.registerEventsSearchBar(),t.registerEventsSuggestions(),t.registerEventsDetailsPanel(),t.registerIconHandler(),t.registerEventsFixedMenu(),t.fixPositionCapture=function(){t.adjustContainerWidth(),t.visible&&t.fixPosition()},e(window).on("resize.autocomplete",t.fixPositionCapture),t.initMobileMode(),t.hideAfterClickOutsideListener(),t.suggestionsContainer.addClass("js-dgwt-wcas-initialized"),t.detailsContainer&&t.detailsContainer.length>0&&t.detailsContainer.addClass("js-dgwt-wcas-initialized")},createContainers:function(t){var s=this.options;0==e("."+s.containerClass).length?(this.suggestionsContainer=e(d.utils.createNode(s.containerClass)),this.suggestionsContainer.appendTo(s.appendTo||"body"),this.suggestionsContainer.addClass("woocommerce"),!0===s.showImage&&this.suggestionsContainer.addClass("dgwt-wcas-has-img"),!0===s.showPrice&&this.suggestionsContainer.addClass("dgwt-wcas-has-price"),!0===s.showDescription&&this.suggestionsContainer.addClass("dgwt-wcas-has-desc"),!0===s.showSKU&&this.suggestionsContainer.addClass("dgwt-wcas-has-sku"),!0===s.showHeadings&&this.suggestionsContainer.addClass("dgwt-wcas-has-headings"),"auto"!==s.width&&this.suggestionsContainer.width(s.width)):this.suggestionsContainer=e("."+this.options.containerClass),this.canShowDetailsBox()&&(0==e("."+s.containerDetailsClass).length?(this.detailsContainer=e(d.utils.createNode(s.containerDetailsClass)),this.detailsContainer.appendTo(s.appendTo||"body"),this.detailsContainer.addClass("woocommerce")):this.detailsContainer=e("."+s.containerDetailsClass))},registerEventsSearchBar:function(){var s=this;e(document).on("click.autocomplete","."+s.options.closeTrigger,function(){var s=t.getActiveInstance();s.hide(),s.clear(!1),e(this).removeClass(s.options.closeTrigger),e(this).closest("."+s.options.searchFormClass).find("."+s.options.searchInputClass).val("").focus()}),s.el.closest("."+s.options.formClass).on("submit.autocomplete",function(t){s.suggestions.length>0&&e.each(s.suggestions,function(e,i){if(void 0!==i.type&&"product_variation"==i.type)return s.select(e),t.preventDefault(),!1})}),e(window).on("load",function(){s.positionPreloader()}),s.el.on("keydown.autocomplete",function(e){s.onKeyPress(e)}),s.el.on("keyup.autocomplete",function(e){s.onKeyUp(e)}),s.el.on("blur.autocomplete",function(){s.onBlur()}),s.el.on("focus.autocomplete",function(){s.onFocus()}),s.el.on("change.autocomplete",function(e){s.onKeyUp(e)}),s.el.on("input.autocomplete",function(e){s.onKeyUp(e)})},registerEventsSuggestions:function(){var s="."+this.classes.suggestion;this.getSuggestionsContainer().hasClass("js-dgwt-wcas-initialized")||(e(document).on("mouseenter.autocomplete",s,function(){var s=t.getActiveInstance();if(void 0!==s){var i=e(this).data("index"),o='.dgwt-wcas-suggestion[data-index="'+i+'"]',a=s.canShowDetailsBox()?100:1;s.selectedIndex!=i&&t.mouseHoverDebounce(function(){s.selectedIndex!==i&&(s.latestActivateSource="mouse",s.getDetails(s.suggestions[i]),s.activate(i))},o,a)}}),e(document).on("click.autocomplete",s,function(){var s=t.getActiveInstance();s.actionTriggerSource="click",s.select(e(this).data("index"))}),e(document).on("click.autocomplete","."+this.options.containerClass,function(){var e=t.getActiveInstance();clearTimeout(e.blurTimeoutId)}))},registerEventsDetailsPanel:function(){var s=this.getDetailsContainer();this.canShowDetailsBox()&&!s.hasClass("js-dgwt-wcas-initialized")&&(e(document).on("click.autocomplete","."+this.options.containerDetailsClass,function(){var e=t.getActiveInstance();clearTimeout(e.blurTimeoutId)}),e(document).on("change",'[name="js-dgwt-wcas-quantity"]',function(t){e(this).closest(".js-dgwt-wcas-pd-addtc").find("[data-quantity]").attr("data-quantity",e(this).val())}))},registerIconHandler:function(){var s=this,i=s.getFormWrapper(),o=i.find("."+s.options.formClass);i.on("click",".js-dgwt-wcas-search-icon-handler",function(e){var t=i.find("."+s.options.searchInputClass);if(i.hasClass("dgwt-wcas-layout-icon-open"))s.hide(),o.hide(!0),i.removeClass("dgwt-wcas-layout-icon-open");else{var a=i.find(".dgwt-wcas-search-icon-arrow");o.hide(),a.hide(),i.addClass("dgwt-wcas-layout-icon-open"),s.positionIconSearchMode(i),o.fadeIn(200,function(){a.show(),s.positionPreloader(i),t.focus()})}}),0==e(".js-dgwt-wcas-initialized").length&&e(".js-dgwt-wcas-search-icon-handler").length>0&&e(document).click(function(i){if(e(".dgwt-wcas-layout-icon-open").length){var o=e(i.target);if(!(o.closest("."+s.options.searchFormClass).length>0||o.closest("."+s.options.containerClass).length>0||o.closest("."+s.options.containerDetailsClass).length>0)){var a=t.getActiveInstance();if(void 0!==a){var n=a.getFormWrapper().find("."+s.options.formClass);n.hide(),a.hide(!0),n.css({left:"0"})}s.hideIconModeSearch()}}}),e(window).on("resize.autocomplete",function(){s.applyFlexibleMode()}),e(window).on("load",function(){s.applyFlexibleMode()})},registerEventsFixedMenu:function(){var t=this;e(window).on("scroll",function(){if(t.suggestions.length>0&&t.elementOrParentIsFixed(t.getFormWrapper()))if(0===e(window).scrollTop()){[1,10,20,30,40,50,60,70,80,90,120,140,170,200,250,400,700,1e3,2e3].forEach(function(e){setTimeout(function(){t.fixHeight(),t.fixPositionCapture()},e)})}else t.fixHeight(),t.fixPositionCapture()})},initMobileMode:function(){var e=this,t=e.getFormWrapper();t.hasClass("js-dgwt-wcas-mobile-overlay-enabled")&&e.isMobileMode()&&(t.prepend('
'),t.find(".js-dgwt-wcas-enable-mobile-form").on("click",function(t){e.enableOverlayMobile()}))},applyFlexibleMode:function(){var t=e(".js-dgwt-wcas-layout-icon-flexible");t.length&&(this.isMobileMode()?(t.addClass("js-dgwt-wcas-layout-icon"),t.addClass("dgwt-wcas-layout-icon")):(t.removeClass("js-dgwt-wcas-layout-icon"),t.removeClass("dgwt-wcas-layout-icon")),t.addClass("dgwt-wcas-layout-icon-flexible-loaded"))},onFocus:function(){e("."+this.options.searchFormClass).removeClass("dgwt-wcas-active"),this.getFormWrapper().addClass("dgwt-wcas-active"),this.fixPositionCapture(),this.el.val().length>=this.options.minChars&&this.onValueChange()},onBlur:function(){var t=this,s=t.options,i=t.el.val(),o=t.getQuery(i);t.isMobileMode()||(t.blurTimeoutId=setTimeout(function(){t.hide(),t.selection&&t.currentValue!==o&&(s.onInvalidateSelection||e.noop).call(t.element)},200))},abortAjax:function(){this.currentRequest&&(this.currentRequest.abort(),this.currentRequest=null)},setOptions:function(t){var s=this,i=s.getSuggestionsContainer(),o=e.extend({},s.options,t);(s.isLocal=Array.isArray(o.lookup),s.isLocal&&(o.lookup=s.verifySuggestionsFormat(o.lookup)),o.orientation=s.validateOrientation(o.orientation,"bottom"),i.css({"max-height":s.canShowDetailsBox()?"none":o.maxHeight+"px",width:o.width+"px","z-index":o.zIndex}),!0===o.showDetailsPanel)&&s.getDetailsContainer().css({"z-index":o.zIndex-1});o.onSearchComplete=function(){s.getFormWrapper().removeClass("dgwt-wcas-processing"),s.preloader("hide","form","dgwt-wcas-inner-preloader"),s.preloader("show","form",o.closeTrigger)},this.options=o},clearCache:function(){this.cachedResponse={},this.cachedDetails={},this.cachedPrices={},this.badQueries=[]},clear:function(e){e&&this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){this.disabled=!0,clearTimeout(this.onChangeTimeout),this.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var e=this.getFormOffset();this.getSuggestionsContainer().css(e),this.canShowDetailsBox()&&this.fixPositionDetailsBox()},fixPositionDetailsBox:function(){var t=this.getFormWrapper(),s=this.getSuggestionsContainer(),i=this.getDetailsContainer(),o=this.getFormOffset(),a=o.left;if(0==i.length)return!1;var n=!0===this.options.isRtl?1:2,r=Math.round(o.left);if(o.left=r+Math.round(s.width()+n),i.css(o),t.width()>=550)return e("body").removeClass("dgwt-wcas-details-outside"),e("body").removeClass("dgwt-wcas-details-right"),e("body").removeClass("dgwt-wcas-details-left"),void(!0===this.options.isRtl&&(s.css("left",r+Math.round(i.width()+n)+"px"),i.css("left",a+"px")));var l=e(window).width(),c=i.width(),d=i.offset();e("body").addClass("dgwt-wcas-details-outside"),!0===this.options.isRtl&&(o.left=o.left+1);var g=!1,u=!1;l2&&e.fixHeight())},10)}},getFormOffset:function(){var t=this.getFormWrapper(),s=this.getSuggestionsContainer(),i=this.options.orientation,o=t.outerHeight(),a=this.el.outerHeight(),n=this.el.offset(),r={top:n.top,left:n.left};if("auto"===i){var l=e(window).height(),c=e(window).scrollTop(),d=-c+n.top-o,g=c+l-(n.top+a+o);i=Math.max(d,g)===d?"top":"bottom"}if("top"===i){s[0].getBoundingClientRect().top;var u=t[0].getBoundingClientRect().top;s.css("height","auto"),u0?t.onChangeTimeout=setTimeout(function(){t.onValueChange()},t.options.deferRequestBy):t.onValueChange())}},onValueChange:function(){if(this.ignoreValueChange)this.ignoreValueChange=!1;else{var t=this.options,s=this.el.val(),i=this.getQuery(s);this.selection&&this.currentValue!==i&&(this.selection=null,(t.onInvalidateSelection||e.noop).call(this.element)),clearTimeout(this.onChangeTimeout),this.currentValue=s,this.selectedIndex=-1,t.triggerSelectOnValidInput&&this.isExactMatch(i)?this.select(0):i.lengthn&&(s.suggestions=s.suggestions.slice(0,n)),s},getSuggestions:function(i){var o,a,n,r,l=this,c=l.options,d=c.serviceUrl,g=l.getFormWrapper();c.params[c.paramName]=i,void 0!==dgwt_wcas.current_lang&&(c.params.l=dgwt_wcas.current_lang),c.params=l.applyCustomParams(c.params),l.preloader("show","form","dgwt-wcas-inner-preloader"),g.addClass("dgwt-wcas-processing"),!1!==c.onSearchStart.call(l.element,c.params)&&(a=c.ignoreParams?null:c.params,e.isFunction(c.lookup)?c.lookup(i,function(e){l.suggestions=e.suggestions,l.suggest(),l.selectFirstSuggestion(e.suggestions),c.onSearchComplete.call(l.element,i,e.suggestions)}):(l.isLocal?o=l.getSuggestionsLocal(i):(e.isFunction(d)&&(d=d.call(l.element,i)),n=d+"?"+e.param(a||{}),o=l.cachedResponse[n]),o&&Array.isArray(o.suggestions)?(l.suggestions=o.suggestions,l.suggest(),l.selectFirstSuggestion(o.suggestions),c.onSearchComplete.call(l.element,i,o.suggestions)):l.isBadQuery(i)?c.onSearchComplete.call(l.element,i,[]):(l.abortAjax(),r={url:d,data:a,type:c.type,dataType:c.dataType},e.extend(r,c.ajaxSettings),s.object=l,s.ajaxSettings=r,t.debounce(function(){var t=s.object,o=s.ajaxSettings;t.currentRequest=e.ajax(o).done(function(e){var s;t.currentRequest=null,void 0!==(s=t.options.transformResult(e,i)).suggestions&&(t.processResponse(s,i,n),t.selectFirstSuggestion(s.suggestions),1===s.suggestions.length&&void 0!==s.suggestions[0].type&&"no-results"===s.suggestions[0].type?t.gaEvent(i,"Autocomplete Search without results"):t.gaEvent(i,"Autocomplete Search with results")),t.fixPositionCapture(),t.options.onSearchComplete.call(t.element,i,s.suggestions),t.updatePrices()}).fail(function(e,s,o){t.options.onSearchError.call(t.element,i,e,s,o)})},c.debounceWaitMs))))},getDetails:function(t){var s=this;if(!s.canShowDetailsBox())return!1;if(null!=t&&void 0!==t.type&&("string"!=typeof t.more_products||"more_products"!==t.more_products)){s.fixHeight();var i,o=s.getDetailsContainer(),a=s.prepareSuggestionObjectID(t);if(null!=(i=s.cachedDetails[a]))o.html(i.html),s.fixHeight(),s.fixPositionCapture();else{var n={action:dgwt_wcas.action_result_details,items:[]};if(e.each(s.suggestions,function(e,t){if(void 0!==t.type&&"more_products"!=t.type&&"headline"!=t.type){var i={objectID:s.prepareSuggestionObjectID(t),value:null!=t.value?t.value:""};n.items.push(i)}}),o.html(""),s.preloader("show","details","",!0),-1!=e.inArray(a,s.detailsRequestsSent))return;s.detailsRequestsSent.push(a),e.ajax({data:n,type:"post",url:dgwt_wcas.ajax_details_endpoint,success:function(e){var t="string"==typeof e?jQuery.parseJSON(e):e;if(void 0!==t.items)for(var i=0;i0&&(s.cachedPrices[a]=t.items[i].price),void 0!==t.items[i].imageSrc&&t.items[i].imageSrc.length>0)(new Image).src=t.items[i].imageSrc}s.preloader("hide","details","",!0);var n=s.prepareSuggestionObjectID(s.suggestions[s.selectedIndex]);null!=s.cachedDetails[n]?o.html(s.cachedDetails[n].html):o.html(""),s.fixPositionCapture(),s.fixHeight(),s.updatePrices(!0)},error:function(e,t){s.preloader("hide","details","",!0),o.html(e),s.fixPositionCapture(),s.fixHeight()}})}e(document).trigger("dgwtWcasDetailsPanelLoaded",s)}},updatePrices:function(t){var s,i,o=this,a=[];if(o.options.showPrice&&o.options.dynamicPrices&&0!=o.suggestions.length){for(s=0;s0){var r={action:void 0===dgwt_wcas.action_get_prices?"dgwt_wcas_get_prices":dgwt_wcas.action_get_prices,items:a};e.ajax({data:r,type:"post",url:dgwt_wcas.ajax_prices_endpoint,success:function(e){if(void 0!==e.success&&e.success&&e.data.length>0)for(s=0;s0)for(i=0;i
')}},prepareSuggestionObjectID:function(e){var t="";return void 0!==e&&void 0!==e.type&&(null!=e.post_id&&(t=e.type+"__"+e.post_id,"product_variation"===e.type&&(t+="__"+e.variation_id),void 0!==e.post_type&&(t=e.type+"__"+e.post_id+"__"+e.post_type)),null!=e.term_id&&null!=e.taxonomy&&(t=e.type+"__"+e.term_id+"__"+e.taxonomy)),t},selectFirstSuggestion:function(t){var s=0,i=!1;this.canShowDetailsBox()&&("undefined"!=t&&t.length>0&&e.each(this.suggestions,function(e,t){if(void 0!==t.type&&"more_products"!=t.type&&"headline"!=t.type&&"no-results"!=t.type)return s=e,!1;void 0!==t.type&&"no-results"!==t.type||(i=!0)}),i||(this.latestActivateSource="system",this.getDetails(t[s]),this.activate(s)))},isBadQuery:function(e){if(!this.options.preventBadQueries)return!1;for(var t=this.badQueries,s=t.length;s--;)if(0===e.indexOf(t[s]))return!0;return!1},hide:function(t){var s=this.getFormWrapper(),i=this.getSuggestionsContainer(),o=this.getDetailsContainer();if(e.isFunction(this.options.onHide)&&this.visible&&this.options.onHide.call(this.element,container),this.visible=!1,this.selectedIndex=-1,clearTimeout(this.onChangeTimeout),i.hide(),i.removeClass(this.classes.suggestionsContainerOrientTop),o.hide(),e("body").removeClass("dgwt-wcas-open"),e("body").removeClass("dgwt-wcas-block-scroll"),e("body").removeClass("dgwt-wcas-is-details"),e("body").removeClass("dgwt-wcas-full-width"),e("body").removeClass("dgwt-wcas-nores"),e("body").removeClass("dgwt-wcas-details-outside"),e("body").removeClass("dgwt-wcas-details-right"),e("body").removeClass("dgwt-wcas-details-left"),null!=this.autoAligmentprocess&&(clearInterval(this.autoAligmentprocess),this.autoAligmentprocess=null),"boolean"==typeof t&&t){s.find("."+this.options.searchInputClass).val("");var a=s.find("."+this.options.closeTrigger);a.length&&a.removeClass(this.options.closeTrigger),this.currentValue="",this.suggestions=[]}this.signalHint(null)},positionIconSearchMode:function(t){var s,i=t.find("."+this.options.formClass),o=i.width(),a=e(window).width(),n=t[0].getBoundingClientRect().left;i[0].getBoundingClientRect().left;var r=(n+10)/a;s=Math.floor(o*r*-1),i.css({left:s+"px"})},hideIconModeSearch:function(){var t=e(".dgwt-wcas-layout-icon-open");t.length>0&&t.removeClass("dgwt-wcas-layout-icon-open")},hideAfterClickOutsideListener:function(){var t=this;t.isMobileMode()||e(document).mouseup(function(s){if(t.visible){t.getSuggestionsContainer(),t.getDetailsContainer();var i=!(e(s.target).closest("."+t.options.searchFormClass).length>0||e(s.target).hasClass(t.options.searchFormClass)),o=!(e(s.target).closest("."+t.options.containerClass).length>0||e(s.target).hasClass(t.options.containerClass));if(t.canShowDetailsBox()){var a=!(e(s.target).closest("."+t.options.containerDetailsClass).length>0||e(s.target).hasClass(t.options.containerDetailsClass));i&&o&&a&&t.hide()}else i&&o&&t.hide()}})},suggest:function(){if(this.suggestions.length){var t,s=this,i=s.options,o=i.groupBy,a=i.formatResult,n=s.getQuery(s.currentValue),r=s.classes.suggestion,l=s.classes.selected,c=s.getSuggestionsContainer(),d=s.getDetailsContainer(),g=e(s.noSuggestionsContainer),u=i.beforeRender,h="";i.triggerSelectOnValidInput&&s.isExactMatch(n)?s.select(0):(e("body").removeClass("dgwt-wcas-nores"),e.each(s.suggestions,function(s,l){var c="",g=!1;if(o&&(h+=function(e,s){var i=e.data[o];return t===i?"":'
'+(t=i)+"
"}(l,0)),void 0===l.type||"product"!=l.type&&"product_variation"!=l.type){var u=r,p="dgwt-wcas-st",w="",f="",m="",v=!0;"product_cat"===l.taxonomy?(u+=" dgwt-wcas-suggestion-tax dgwt-wcas-suggestion-cat",i.showHeadings||(w+=''+dgwt_wcas.labels.category+""),void 0!==l.breadcrumbs&&l.breadcrumbs&&(m=l.breadcrumbs+" > "+l.value,f+=''+dgwt_wcas.labels.in+" "+l.breadcrumbs+"")):"product_tag"===l.taxonomy?(u+=" dgwt-wcas-suggestion-tax dgwt-wcas-suggestion-tag",i.showHeadings||(w+=''+dgwt_wcas.labels.tag+"")):i.isPremium&&l.taxonomy===i.taxonomyBrands?(u+=" dgwt-wcas-suggestion-tax dgwt-wcas-suggestion-brand",i.showHeadings||(w+=''+dgwt_wcas.labels.brand+"")):i.isPremium&&"post"===l.type?(u+=" dgwt-wcas-suggestion-pt dgwt-wcas-suggestion-tp-post",i.showHeadings||(w+=''+dgwt_wcas.labels.post+"")):i.isPremium&&"page"===l.type?(u+=" dgwt-wcas-suggestion-pt dgwt-wcas-suggestion-pt-page",i.showHeadings||(w+=''+dgwt_wcas.labels.page+"")):"more_products"===l.type?(u+=" js-dgwt-wcas-suggestion-more dgwt-wcas-suggestion-more",p="dgwt-wcas-st-more",l.value=dgwt_wcas.labels.show_more+" ("+l.total+")",v=!1):i.showHeadings&&"headline"===l.type?(u+=" js-dgwt-wcas-suggestion-headline dgwt-wcas-suggestion-headline",void 0!==dgwt_wcas.labels[l.value+"_plu"]&&(l.value=dgwt_wcas.labels[l.value+"_plu"]),v=!1):(u+=" dgwt-wcas-suggestion-nores",l.value=dgwt_wcas.labels.no_results,v=!1,!0===i.showDetailsPanel&&d.html(""),e("body").addClass("dgwt-wcas-nores")),m=m.length>0?' title="'+m+'"':"",h+='
',h+="'+w+a(l.value,n,v,i)+f+"",h+="
"}else!0===i.showImage&&void 0!==l.thumb_html&&(g=!0),c+=void 0!==l.post_id?'data-post-id="'+l.post_id+'" ':"",c+=void 0!==l.taxonomy?'data-taxonomy="'+l.taxonomy+'" ':"",c+=void 0!==l.term_id?'data-term-id="'+l.term_id+'" ':"",h+='
",g&&(h+=''+l.thumb_html+""),h+=g?'
':"",h+='',h+=''+a(l.value,n,!0,i)+"",!0===i.showSKU&&void 0!==l.sku&&l.sku.length>0&&(h+='('+dgwt_wcas.labels.sku_label+" "+a(l.sku,n,!0,i)+")"),!0===i.showDescription&&void 0!==l.desc&&l.desc&&(h+=''+a(l.desc,n,!0,i)+""),h+="",!0===i.showPrice&&void 0!==l.price&&(h+=''+l.price+""),!0===i.showFeaturedBadge&&!0===l.on_sale&&(h+=''+i.saleBadgeText+""),!0===i.showFeaturedBadge&&!0===l.featured&&(h+=''+i.featuredBadgeText+""),h+=g?"
":"",h+="
"}),this.adjustContainerWidth(),g.detach(),c.html(h),e.isFunction(u)&&u.call(s.element,c,s.suggestions),c.show(),e("body").addClass("dgwt-wcas-open"),s.automaticAlignment(),!0===i.showDetailsPanel&&(e("body").addClass("dgwt-wcas-is-details"),d.show(),s.fixHeight()),i.autoSelectFirst&&(s.selectedIndex=0,c.scrollTop(0),c.children("."+r).first().addClass(l)),s.visible=!0,s.fixPositionCapture(),"top"===s.options.orientation&&(s.getSuggestionsContainer().addClass(s.classes.suggestionsContainerOrientTop),e("body").addClass("dgwt-wcas-block-scroll"),setTimeout(function(){s.scrollDownSuggestions()},300)),s.findBestHint())}else this.hide()},adjustContainerWidth:function(){var t,s=this.options,i=e("body"),o=this.getFormWrapper(),a=this.getSuggestionsContainer(),n=this.getDetailsContainer(),r=this.getFormOffset();if(o.length){var l=getComputedStyle(o[0]).width;if(l=Math.round(parseFloat(l.replace("px",""))),"auto"===s.width&&(t=this.el.outerWidth(),a.css("width",t+"px")),this.canShowDetailsBox()){if(o.width()>=550)return i.addClass("dgwt-wcas-full-width"),l%2==0?(a.css("width",Math.round(l/2)),n.css("width",Math.round(l/2))):(a.css("width",Math.floor(l/2)),n.css("width",Math.ceil(l/2))),i.removeClass("dgwt-wcas-details-left"),i.removeClass("dgwt-wcas-details-right"),void(!0===s.isRtl?n.css("left","0"):a.css("left",l/2+r.left+"px"));i.addClass("dgwt-wcas-details-right")}}},positionPreloader:function(t){var s="object"==typeof t?t.find(".dgwt-wcas-search-submit"):e(".dgwt-wcas-search-submit");s.length>0&&s.each(function(){var t=e(this).closest(".dgwt-wcas-search-wrapp").find(".dgwt-wcas-preloader");1==dgwt_wcas.is_rtl?t.css("left",6+e(this).outerWidth()+"px"):t.css("right",e(this).outerWidth()+"px")})},findBestHint:function(){var t=this.el.val().toLowerCase(),s=null;t&&(e.each(this.suggestions,function(e,i){var o=0===i.value.toLowerCase().indexOf(t);return o&&(s=i),!o}),this.signalHint(s))},signalHint:function(t){var s="";t&&(s=this.currentValue+t.value.substr(this.currentValue.length)),this.hintValue!==s&&(this.hintValue=s,this.hint=t,(this.options.onHint||e.noop)(s))},preloader:function(t,s,i,o){var a,n,r="dgwt-wcas-preloader-wrapp",l=null==i?r:r+" "+i;if("form"===s?n=this.getFormWrapper().find(".dgwt-wcas-preloader"):"details"===s&&(n=this.getDetailsContainer()),1==dgwt_wcas.show_preloader&&0!=n.length)if(!0===o)if("hide"!==t){if("show"===t){var c=this.options.isRtl?"-rtl":"";a='
',n.html(a)}}else e(r).remove();else"hide"===t?n.removeClass(i):n.addClass(i)},verifySuggestionsFormat:function(t){return t.length&&"string"==typeof t[0]?e.map(t,function(e){return{value:e,data:null}}):t},validateOrientation:function(t,s){return t=e.trim(t||"").toLowerCase(),-1===e.inArray(t,["auto","bottom","top"])&&(t=s),t},processResponse:function(e,t,s){var i=this.options;e.suggestions=this.verifySuggestionsFormat(e.suggestions),i.noCache||(this.cachedResponse[s]=e,i.preventBadQueries&&!e.suggestions.length&&this.badQueries.push(t)),t===this.getQuery(this.currentValue)&&("top"===this.options.orientation&&e.suggestions.reverse(),this.suggestions=e.suggestions,this.suggest())},activate:function(t){var s,i=this.classes.selected,o=this.getSuggestionsContainer(),a=o.find("."+this.classes.suggestion);return o.find("."+i).removeClass(i),this.selectedIndex=t,-1!==this.selectedIndex&&a.length>this.selectedIndex?(s=a.get(this.selectedIndex),e(s).addClass(i),s):null},selectHint:function(){var t=e.inArray(this.hint,this.suggestions);this.select(t)},select:function(e){this.hide(),this.onSelect(e)},moveUp:function(){if(-1!==this.selectedIndex){if(this.latestActivateSource="key",0===this.selectedIndex)return this.getSuggestionsContainer().children("."+this.classes.suggestion).first().removeClass(this.classes.selected),this.selectedIndex=-1,this.ignoreValueChange=!1,this.el.val(this.currentValue),void this.findBestHint();this.adjustScroll(this.selectedIndex-1,"up")}},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&(this.latestActivateSource="key",this.adjustScroll(this.selectedIndex+1,"down"))},adjustScroll:function(t,s){if("headline"===this.suggestions[t].type&&(t="down"===s?t+1:t-1),void 0!==this.suggestions[t]){var i=this.activate(t);if(this.getDetails(this.suggestions[t]),"more_products"!==this.suggestions[t].type&&i&&!this.canShowDetailsBox()){var o,a,n,r=this.getSuggestionsContainer(),l=e(i).outerHeight();o=i.offsetTop,n=(a=r.scrollTop())+this.options.maxHeight-l,on&&r.scrollTop(o-this.options.maxHeight+l),this.options.preserveInput||(this.ignoreValueChange=!0),this.signalHint(null)}}},onSelect:function(t){var s=this.options.onSelect,i=this.suggestions[t];void 0!==i.type&&"more_products"===i.type||"enter"===this.actionTriggerSource&&"key"!=this.latestActivateSource?this.el.closest("form").trigger("submit"):(this.currentValue=this.getValue(i.value),this.currentValue===this.el.val()||this.options.preserveInput||this.el.val(this.currentValue),i.url.length>0&&(window.location.href=i.url),this.signalHint(null),this.suggestions=[],this.selection=i,e.isFunction(s)&&s.call(this.element,i))},getValue:function(e){var t,s,i=this.options.delimiter;return i?1===(s=(t=this.currentValue).split(i)).length?e:t.substr(0,t.length-s[s.length-1].length)+e:e},dispose:function(){this.el.off(".autocomplete").removeData("autocomplete"),e(window).off("resize.autocomplete",this.fixPositionCapture),e("."+this.options.containerClass).remove(),e("."+this.options.containerDetailsClass).remove()},enableOverlayMobile:function(){var t=this;if("on"!==t.overlayMobileState){t.overlayMobileState="on";var s,i=t.getFormWrapper(),o=t.getSuggestionsContainer();e("html").addClass("dgwt-wcas-overlay-mobile-on"),'
','
','','','',"","","
","
",e(t.options.mobileOverlayWrapper).append('
'),(s=e(".js-dgwt-wcas-overlay-mobile")).css("zIndex",999999),i.after(''),i.appendTo(".js-dgwt-wcas-om-bar"),o.appendTo(".js-dgwt-wcas-om-bar"),i.addClass("dgwt-wcas-search-wrapp-mobile"),i.hasClass("dgwt-wcas-has-submit")&&(i.addClass("dgwt-wcas-has-submit-off"),i.removeClass("dgwt-wcas-has-submit")),i.find("."+t.options.searchInputClass).focus(),e(document).on("click",".js-dgwt-wcas-om-return",function(e){t.disableOverlayMobile(s)})}},disableOverlayMobile:function(t){var s=this,i=s.getSuggestionsContainer(),o=e(".js-dgwt-wcas-om-bar").find("."+s.options.searchFormClass);o.hasClass("dgwt-wcas-has-submit-off")&&(o.removeClass("dgwt-wcas-has-submit-off"),o.addClass("dgwt-wcas-has-submit")),o.removeClass("dgwt-wcas-search-wrapp-mobile"),e("html").removeClass("dgwt-wcas-overlay-mobile-on"),i.appendTo("body"),i.removeAttr("body-scroll-lock-ignore"),e(".js-dgwt-wcas-om-hook").after(o),e(".js-dgwt-wcas-overlay-mobile").remove(),e(".js-dgwt-wcas-om-hook").remove(),setTimeout(function(){o.find("."+s.options.searchInputClass).val("");var e=o.find(".dgwt-wcas-close");o.length>0&&e.removeClass("dgwt-wcas-close"),s.hide()},150),s.overlayMobileState="off"},elementOrParentIsFixed:function(t){var s=t.add(t.parents()),i=!1;return s.each(function(){if("fixed"===e(this).css("position"))return i=!0,!1}),i},gaEvent:function(e,t){if(this.options.sendGAEvents)try{if("undefined"!=typeof gtag)gtag("event","autocomplete_search",{event_label:e,event_category:t});else if("undefined"!=typeof ga){var s=ga.getAll()[0];s&&s.send({hitType:"event",eventCategory:t,eventAction:"autocomplete_search",eventLabel:e})}}catch(e){}if(this.options.enableGASiteSearchModule)try{if("undefined"!=typeof gtag)gtag("event","page_view",{page_path:"/?s="+encodeURI(e)+"&post_type=product&dgwt_wcas=1"});else if("undefined"!=typeof ga){var i=ga.getAll()[0];i&&(i.set("page","/?s="+encodeURI(e)+"&post_type=product&dgwt_wcas=1"),i.send("pageview"))}}catch(e){}}},e.fn.dgwtWcasAutocomplete=function(t,s){return arguments.length?this.each(function(){var i=e(this),o=i.data("autocomplete");"string"==typeof t?o&&"function"==typeof o[t]&&o[t](s):(o&&o.dispose&&o.dispose(),o=new d(this,t),i.data("autocomplete",o))}):this.first().data("autocomplete")},e.fn.autocomplete||(e.fn.autocomplete=e.fn.dgwtWcasAutocomplete),function(){function t(){var t=e(".dgwt-wcas-search-input"),s=[];t.length>1&&t.each(function(){var t=e(this).attr("id");if(-1==e.inArray(t,s))s.push(t);else{var i=Math.random().toString(36).substring(2,6);i="dgwt-wcas-search-input-"+i,e(this).attr("id",i),e(this).closest("form").find("label").attr("for",i)}})}function s(){var t=e(".dgwt-wcas-search-input");t.length>0&&t.each(function(){"object"!=typeof e(this).data("autocomplete")&&e(this).dgwtWcasAutocomplete(window.dgwt_wcas.config)})}e(document).ready(function(){var t=1==dgwt_wcas.show_details_box,s=dgwt_wcas.mobile_breakpoint;(jQuery(window).width()