!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports&&"function"==typeof require?e(require("jquery")):e(jQuery)}(function(d){"use strict";var n={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}},s=27,i=9,o=13,a=38,r=39,l=40,e=d.noop;function c(e,t){var n=this;n.element=e,n.el=d(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=d.extend(!0,{},c.defaults,t),n.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},n.hint=null,n.hintValue="",n.selection=null,n.initialize(),n.setOptions(t)}c.utils=n,(d.Autocomplete=c).defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,onHint:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:function(e,t){return t?(t="("+n.escapeRegExChars(t)+")",e.value.replace(new RegExp(t,"gi"),"$1").replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/<(\/?strong)>/g,"<$1>")):e.value},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",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,closeOnOutside:!0,preventBadQueries:!0,lookupFilter:function(e,t,n){return-1!==e.value.toLowerCase().indexOf(n)},paramName:"query",transformResult:function(e){return"string"==typeof e?d.parseJSON(e):e},showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1},c.prototype={initialize:function(){var e,t=this,n="."+t.classes.suggestion,s=t.classes.selected,i=t.options;t.element.setAttribute("autocomplete","off"),t.noSuggestionsContainer=d('
').html(this.options.noSuggestionNotice).get(0),t.suggestionsContainer=c.utils.createNode(i.containerClass),(e=d(t.suggestionsContainer)).appendTo(i.appendTo||"body"),"auto"!==i.width&&e.css("width",i.width),e.on("mouseover.autocomplete",n,function(){t.activate(d(this).data("index"))}),e.on("mouseout.autocomplete",function(){t.selectedIndex=-1,e.children("."+s).removeClass(s)}),e.on("click.autocomplete",n,function(){t.select(d(this).data("index"))}),e.on("click.autocomplete",function(){clearTimeout(t.blurTimeoutId)}),t.fixPositionCapture=function(){t.visible&&t.fixPosition()},d(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(),s=e.getQuery(n);e.blurTimeoutId=setTimeout(function(){t.closeOnOutside&&e.hide(),e.selection&&e.currentValue!==s&&(t.onInvalidateSelection||d.noop).call(e.element)},200)},abortAjax:function(){var e=this;e.currentRequest&&(e.currentRequest.abort(),e.currentRequest=null)},setOptions:function(e){var t=this,e=d.extend({},t.options,e);t.isLocal=Array.isArray(e.lookup),t.isLocal&&(e.lookup=t.verifySuggestionsFormat(e.lookup)),e.orientation=t.validateOrientation(e.orientation,"bottom"),d(t.suggestionsContainer).css({"max-height":e.maxHeight+"px",width:e.width+"px","z-index":e.zIndex}),this.options=e},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,t,n,s,i,o,a,r,l=this,c=d(l.suggestionsContainer),u=c.parent().get(0);u!==document.body&&!l.options.forceFixPosition||(o=l.options.orientation,e=c.outerHeight(),t=l.el.outerHeight(),n={top:(r=l.el.offset()).top,left:r.left},"auto"===o&&(a=d(window).height(),s=-(i=d(window).scrollTop())+r.top-e,i=i+a-(r.top+t+e),o=Math.max(s,i)===s?"top":"bottom"),n.top+="top"===o?-e:t,u!==document.body&&(a=c.css("opacity"),l.visible||c.css("opacity",0).show(),r=c.offsetParent().offset(),n.top-=r.top,n.top+=u.scrollTop,n.left-=r.left,l.visible||c.css("opacity",a).hide()),"auto"===l.options.width&&(n.width=l.el.outerWidth()+"px"),c.css(n))},isCursorAtEnd:function(){var e=this.el.val().length,t=this.element.selectionStart;return"number"==typeof t?t===e:!document.selection||((t=document.selection.createRange()).moveStart("character",-e),e===t.text.length)},onKeyPress:function(e){var t=this;if(t.disabled||t.visible||e.which!==l||!t.currentValue){if(!t.disabled&&t.visible){switch(e.which){case s:t.el.val(t.currentValue),t.hide();break;case r: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 o:if(-1===t.selectedIndex)return void t.hide();t.select(t.selectedIndex);break;case a:t.moveUp();break;case l: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 a:case l:return}clearTimeout(t.onChangeTimeout),t.currentValue!==t.el.val()&&(t.findBestHint(),0i&&(e.suggestions=e.suggestions.slice(0,i)),e},getSuggestions:function(s){var e,t,n,i=this,o=i.options,a=o.serviceUrl;o.params[o.paramName]=s,!1!==o.onSearchStart.call(i.element,o.params)&&(e=o.ignoreParams?null:o.params,d.isFunction(o.lookup)?o.lookup(s,function(e){i.suggestions=e.suggestions,i.suggest(),o.onSearchComplete.call(i.element,s,e.suggestions)}):(n=i.isLocal?i.getSuggestionsLocal(s):(d.isFunction(a)&&(a=a.call(i.element,s)),t=a+"?"+d.param(e||{}),i.cachedResponse[t]))&&Array.isArray(n.suggestions)?(i.suggestions=n.suggestions,i.suggest(),o.onSearchComplete.call(i.element,s,n.suggestions)):i.isBadQuery(s)?o.onSearchComplete.call(i.element,s,[]):(i.abortAjax(),n={url:a,data:e,type:o.type,dataType:o.dataType},d.extend(n,o.ajaxSettings),i.currentRequest=d.ajax(n).done(function(e){i.currentRequest=null,e=o.transformResult(e,s),i.processResponse(e,s,t),o.onSearchComplete.call(i.element,s,e.suggestions)}).fail(function(e,t,n){o.onSearchError.call(i.element,s,e,t,n)})))},isBadQuery:function(e){if(this.options.preventBadQueries)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=d(e.suggestionsContainer);d.isFunction(e.options.onHide)&&e.visible&&e.options.onHide.call(e.element,t),e.visible=!1,e.selectedIndex=-1,clearTimeout(e.onChangeTimeout),d(e.suggestionsContainer).hide(),e.onHint(null)},suggest:function(){var e,i,o,a,r,l,t,n,s,c,u,h;this.suggestions.length?(i=(e=this).options,o=i.groupBy,a=i.formatResult,r=e.getQuery(e.currentValue),l=e.classes.suggestion,t=e.classes.selected,n=d(e.suggestionsContainer),s=d(e.noSuggestionsContainer),c=i.beforeRender,u="",i.triggerSelectOnValidInput&&e.isExactMatch(r)?e.select(0):(d.each(e.suggestions,function(e,t){var n,s;o&&(u+=(s=(n=t).data[o],h===s?"":(h=s,i.formatGroup(n,h)))),u+='
'+a(t,r,e)+"
"}),this.adjustContainerWidth(),s.detach(),n.html(u),d.isFunction(c)&&c.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),i.autoSelectFirst&&(e.selectedIndex=0,n.scrollTop(0),n.children("."+l).first().addClass(t)),e.visible=!0,e.findBestHint())):this.options.showNoSuggestionNotice?this.noSuggestions():this.hide()},noSuggestions:function(){var e=this,t=e.options.beforeRender,n=d(e.suggestionsContainer),s=d(e.noSuggestionsContainer);this.adjustContainerWidth(),s.detach(),n.empty(),n.append(s),d.isFunction(t)&&t.call(e.element,n,e.suggestions),e.fixPosition(),n.show(),e.visible=!0},adjustContainerWidth:function(){var e,t=this.options,n=d(this.suggestionsContainer);"auto"===t.width?(e=this.el.outerWidth(),n.css("width",0t.selectedIndex?(s=i.get(t.selectedIndex),d(s).addClass(n),s):null},selectHint:function(){var e=d.inArray(this.hint,this.suggestions);this.select(e)},select:function(e){this.hide(),this.onSelect(e)},moveUp:function(){var e=this;-1!==e.selectedIndex&&(0===e.selectedIndex?(d(e.suggestionsContainer).children("."+e.classes.suggestion).first().removeClass(e.classes.selected),e.selectedIndex=-1,e.ignoreValueChange=!1,e.el.val(e.currentValue),e.findBestHint()):e.adjustScroll(e.selectedIndex-1))},moveDown:function(){this.selectedIndex!==this.suggestions.length-1&&this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(e){var t,n,s,i=this,o=i.activate(e);o&&(t=d(o).outerHeight(),o=o.offsetTop,s=(n=d(i.suggestionsContainer).scrollTop())+i.options.maxHeight-t,o'
'+` `+''+e.trim()+"
");return n=n.sort(()=>Math.random()-.5),(n=e.trending_searches_limit?.size?n.slice(0,e.trending_searches_limit.size):n).join("")},animatedPlacehoder:function(t,e,n){t.elements.$animatedPlaceholder.on("click",function(){g(this).addClass("hidden"),t.elements.$input.val("").focus(),t.maybeInitInputFocusState(t,e),t.maybeInitTrendingSearches(t,e,n)});let s=t.elements.$animatedPlaceholderItem,i=0,o="";function a(){o=setInterval(()=>{r()},2500)}function r(){i++,t.elements.$animatedPlaceholderItem.removeClass(n.animatedPlaceholderItemActive),t.elements.$animatedPlaceholderItem.eq([s.length-i]).addClass(n.animatedPlaceholderItemActive),s.length==i&&(i=0)}r(),a(),t.elements.$input.on("focus",function(e){t.elements.$animatedPlaceholder.addClass("hidden"),clearInterval(o)}),t.elements.$input.on("blur",function(){""==this.value&&(t.elements.$animatedPlaceholder.removeClass("hidden"),i=0,r(),a())})},initInputFocusState:function(e){e.elements.$input.addClass("focused")},destroyInputFocusState:function(e){e.elements.$input.removeClass("focused")},maybeInitInputFocusState:function(e,t){t.focus_overlay&&e.initInputFocusState(e)},run:function(){var a=this.getElementSettings(),r=this,e=this.getWidgetType(),t=-1{e=jQuery(e.target);e.closest(d.results).length||e.closest(d.input).length||e.closest(d.select).length||e.closest(d.animatedPlaceholder).length||e.closest(d.button).length||e.closest(d.clear).length||(a.trending_searches&&r.searchesShown&&r.destroyTrendingSearchesWrapper(r),a.focus_overlay&&r.destroyInputFocusState(r))}),a.animated_placeholder&&this.animatedPlacehoder(r,a,h),n&&(e=this.elements.$results,s=etConfig.ajaxurl+"?action=etheme_ajax_search",this.elements.$input.val(),o=t?a.post_types.join(","):this.elements.$form.data("post-types"),l=elementorFrontend.isEditMode(),this.popupType&&(s+="&full_screen=yes"),a.product_category&&(s+="&product_category=yes"),a.product_subcategory_path&&(s+="&product_subcategory_path=yes"),s=s+"&shortcode=yes&custom_post_types="+o,a.post_limit?.size&&(s+="&custom_post_limits="+a.post_limit.size),s+="&show_count=true",a.posts_per_page?.size&&(s+="&posts_per_page="+a.posts_per_page.size),this.elements.$select.length&&(a.categories_dynamic_width&&this.elements.$select.on("change",function(){var e=this.options[this.selectedIndex].text;g(this).find("option:selected").html(g(this).find("option:selected").html().replace(/ /g,"")),g(this).css("max-width","calc("+(13+8*e.trim().length)+"px + 45px)")}),""!==this.elements.$select.val())&&(s+="&product_cat="+this.elements.$select.val()),this.elements.$langInput&&this.elements.$langInput.val()&&(s+="&lang="+this.elements.$langInput.val()),this.elements.$input.devbridgeAutocomplete({minChars:a.min_chars?.size?a.min_chars.size:3,appendTo:e,triggerSelectOnValidInput:!1,serviceUrl:s,width:"flex",deferRequestBy:200,maxHeight:a.results_max_height?.size?a.results_max_height.size:350,showNoSuggestionNotice:!0,noSuggestionNotice:etheme_search_config.noResults,closeOnOutside:u,onSearchStart:function(){r.elements.$form.addClass("searching loading"),r.destroyTrendingSearchesWrapper(r,h)},onHide:function(){r.elements.$form.removeClass("searching loading"),r.maybeInitTrendingSearches(r,a,h)},onSearchComplete:function(e,t){r.elements.$input.val();var i=0;let o=!0;if(r.elements.$form.removeClass("loading"),r.elements.$form.find(".ajax-results-title, .ajax-results-more").remove(),t.length&&g.each(a.post_types,function(){var e,t,n=this,s=r.$element.find(d.suggestion).find('[data-type="'+n+'"]').first();s.length&&(e=parseInt(s.attr("data-count-all")),i+=e,"headings"==r.heading_type)&&(t=(r.popupType?etheme_search_config[n+"_found"]:etheme_search_config[1"+t+"",s.parent().before('

'+t+"

"),o=!r.popupType,r.popupType)&&(s=r.$element.find(d.suggestion).find('[data-type="'+n+'"]').length)")}),"tabs"==r.heading_type){let e=[];g.each(t,function(){e.push(r.validatePostType(this.type))}),1<(e=e.filter(function(e,t,n){return n.indexOf(e)===t})).length&&(r.$element.find(d.suggestionsContainer).prepend('
'),g.each(e,function(){var e=etheme_search_config[this]??this;r.elements.$form.find("."+h.tabsWrapper).append(''+e+"")}),g.each(r.$element.find(d.suggestion),function(){g(this).addClass(h.tabContent).attr("data-tab-name",g(this).find("."+h.itemWrapper).attr("data-type"))}),r.initTabs(),r.$element.find("."+h.tab).first().trigger("click"))}r.$element.find("."+h.itemRedirect).length&&r.initRedirect(),o&&t.length")},beforeRender:function(e){},formatResult:function(e,t){l&&(c="mobile"==elementorFrontend.getCurrentDeviceMode());let n="",s="("+g.Autocomplete.utils.escapeRegExChars(t)+")",i=r.validatePostType(e.type);var o;return r.popupType&&!c&&-1',e.img&&r.content_elements.image&&(n+=r.formatImage(e.img,h.itemImg,e.value)),n+='
',r.content_elements.title&&(n+='

'+e.value.replace(new RegExp(s,"gi"),"$1")+"

"),t=[],e.sku&&r.content_elements.product_sku&&t.push(''+e.sku+""),e.stock&&r.content_elements.product_stock&&t.push(e.stock.replace("","")),e.category&&r.content_elements.category&&(o=JSON.parse(e.category),t.push(''+o.title+"")),t.length&&(n+='
'+t.join('|')+"
"),n+="
",e.price&&r.content_elements.product_price&&(n+='
'+e.price+"
"),e.date&&r.content_elements.date&&(n+='
'+e.date+"
"),e.arrow,n+=""),n}}),i=r.elements.$input.devbridgeAutocomplete(),r.elements.$select.length&&r.elements.$select.on("change",function(e){var t=r.elements.$select.val();i.setOptions({serviceUrl:s+(t?"&product_cat="+t:"")}),i.clearCache(),i.hide(),i.onValueChange()}),this.elements.$clear.on("click",function(e){r.elements.$input.attr("value","").val("").focus(),i.hide(),i.onValueChange(),r.elements.$form.removeClass("searching loading")}),a.trending_searches)&&elementorFrontend.elements.$document.on("click",'[data-id="'+r.getID()+'"] .'+h.searchItemWrapper,function(e){e.preventDefault(),r.tagAction(!0,g(this).find("."+h.searchItem)),i.onValueChange()})},formatImage:function(e,t,n){return''+n+''},formatPopupResult:function(e,t,n,s,i){let o="";switch(e){case"product":var a;o=(o=o+('
')+'"+'
',n.product_category&&t.category&&(a=JSON.parse(t.category),o+=''+a.title+""),o+='

'+t.value.replace(new RegExp(i,"gi"),"$1")+"

",n.product_stock&&t.in_stock&&(o+=t.stock),n.product_price&&t.price&&(o+='
'+t.price+"
"),n.product_sku&&t.sku&&(o+=''+t.sku+""),o=o+"
"+"
";break;case"post":o=(o=o+('"}return o},initTabs:function(){var e=this.getSettings("classes");this.$element.find("."+e.tab).on("click",function(){g(this).parent().find("."+e.tab).removeClass("active").end().parent().find("[data-tab-name]").removeClass("active").end().find('[data-tab-name="'+g(this).attr("data-tab")+'"]').addClass("active"),g(this).addClass("active")})},initRedirect:function(){var t=this.getSettings("classes");this.$element.find("."+t.itemLink).on("click",function(e){g(e.target).hasClass(t.itemRedirect)&&e.preventDefault()}),this.$element.find("."+t.itemRedirect).on("click",function(e){e.preventDefault(),window.location.href=g(this).data("redirect")})},validatePostType:function(e){return e.toLowerCase().replace("pages","page").replace("portfolio","etheme_portfolio")},getMoreButtonArrow:function(){let e='',t='';return'\n'+(elementorFrontendConfig.is_rtl?e:t)+""}});g.each(["etheme_ajax_search","theme-etheme_mobile_menu","theme-etheme_ajax_search","theme-etheme_ajax_search_popup"],function(e,t){elementorFrontend.hooks.addAction("frontend/element_ready/"+t+".default",function(e){elementorFrontend.elementsHandler.addHandler(n,{$element:e})})})})}(jQuery);