!function(e,t){"use strict";ElementsKit_Helper.registerWidget("elementskit-advanced-search.default",(function(t){const i=t.find(".ekit-advanced-search-wrapper"),n=i.find("form"),s=n.attr("action"),o=n.data("settings"),c=n.find(".ekit-search"),a=i.find(".ekit-advanced-search-result"),d=a.find(".ekit-search-result-items"),l=n.find(".ekit-search .ekit-adv-search-closer"),r=n.find(".ekit-search .ekit-adv-search-loader"),f=n.find(".search-field"),u=a.find(".ekit-search-load-more-button > a"),h=a.find(".ekit-popular-keyword"),p=i.find(".ekit-advanced-search-result.after-popular-keyword");function k(){t.find(".select").each((function(){const t=e(this),i=t.find(".select-trigger"),n=t.find(".select-dropdown"),s=t.find(".select-option"),o=t.find(".selected-text"),c=t.find('input[type="hidden"]');function a(){n.css({maxHeight:"0",visibility:"hidden",opacity:"0"}),t.removeClass("open")}i.on("click",(function(){t.hasClass("open")?a():function(){const e=n[0].scrollHeight,s=window.innerHeight,o=i[0].getBoundingClientRect(),c=s-o.bottom,a=o.top;c<e&&a>e?n.css({maxHeight:e+"px",visibility:"visible",opacity:"1",bottom:"100%"}):n.css({maxHeight:e+"px",visibility:"visible",opacity:"1",top:"100%"}),t.addClass("open")}()})),e(document).on("click",(function(e){t.is(e.target)||0!==t.has(e.target).length||a()})),s.on("click",(function(){const t=e(this);o.text(t.text()),c.val(t.data("value")),a(),g()}))}))}function y(){e(".ekit-keyword-list").on("click",".ekit-keyword",(function(t){t.preventDefault(),f.val(e(this).data("keyword")),g()}))}function w(){l.css({display:"none"}),a.hide(),p.show(),h.show()}function g(){if(!f.val())return;const t={formData:n.serialize()},i={...o,...t};e.ajax({type:"POST",url:s,data:i,dataType:"html",beforeSend:function(){r.css({display:"inline-flex"}),l.css({display:"none"})},success:function(t){!function(t){const i=e(t),n=i.data("posts-count"),s=i.data("search-found");o.keywordOff||d.css({paddingTop:"12px"});a.show(),p.hide(),d.html(t),n>o.postsPerPage?u.show():u.hide();s!==undefined?(h.hide(),d.css({display:"flex"})):d.css({display:""})}(t)},complete:function(){r.css({display:"none"}),l.css({display:"inline-flex"}),y(),l.off("click").on("click",(function(){f.val(""),w()}))},error:function(e){console.error("API request failed",e)}})}k(),e(window).on("mouseup",(function(t){e(t.target).closest(i).length||w()})),y(),function(){if("click-expand"===o.styleSelect){const e=n.find(".ekit-submit .ekit-search-button"),t=e.find(".ekit-search-icon"),i=e.find(".ekit-close-icon");c.hide(),e.on("click",(function(e){e.preventDefault(),c.toggleClass("s-show"),c.hasClass("s-show")?(t.hide(),i.show(),c.show()):(t.show(),i.hide(),c.hide())}))}}(),o.styleSelect,n.on("input submit",(function(e){e.preventDefault(),g()})),u.on("click",(function(e){e.preventDefault(),o.postsPerPage+=5,g()}))}))}(jQuery,window.elementorFrontend);