(function(e){let f=window.WPD.ajaxsearchpro.helpers;e.fn.extend(window.WPD.ajaxsearchpro.plugin,{liveLoad:function(d,k,b,l){function n(c){c=f.Hooks.applyFilters("asp/live_load/raw_data",c,a);var g=new DOMParser;let p=g.parseFromString(c,"text/html"),m=e(p);a.o.statistics&&a.stat_addKeyword(a.o.id,a.n.text.val());if(""!=c&&0<m.length&&0<m.find(d).length){c=c.replace(/&asp_force_reset_pagination=1/gmi,"");c=c.replace(/%26asp_force_reset_pagination%3D1/gmi,"");c=c.replace(/&#038;asp_force_reset_pagination=1/gmi,
"");f.isSafari()&&(c=c.replace(/srcset/gmi,"nosrcset"));c=f.Hooks.applyFilters("asp_live_load_html",c,a.o.id,a.o.iid);c=f.wp_hooks_apply_filters("asp_live_load_html",c,a.o.id,a.o.iid);m=e(g.parseFromString(c,"text/html"));g=m.find(d).get(0);g=f.Hooks.applyFilters("asp/live_load/replacement_node",g,a,h.get(0),c);null!=g&&h.get(0).parentNode.replaceChild(g,h.get(0));h=e(d).first();b&&(document.title=p.title,history.pushState({},null,k));e(d).first().find(".woocommerce-ordering").on("change","select.orderby",
function(){e(this).closest("form").trigger("submit")});if(1==a.o.singleHighlight)e(d).find("a").on("click",function(){localStorage.removeItem("asp_phrase_highlight");""!=f.unqoutePhrase(a.n.text.val())&&localStorage.setItem("asp_phrase_highlight",JSON.stringify({phrase:f.unqoutePhrase(a.n.text.val()),id:a.o.id}))});f.Hooks.applyFilters("asp/live_load/finished",k,a,d,h.get(0));ASP.initialize();a.lastSuccesfulSearch=e("form",a.n.searchsettings).serialize()+a.n.text.val().trim();a.lastSearchData=c}a.n.s.trigger("asp_search_end",
[a.o.id,a.o.iid,a.n.text.val(),c],!0,!0);a.gaEvent("search_end",{results_count:"unknown"});a.gaPageview(a.n.text.val());a.hideLoader();h.css("opacity",1);a.searching=!1;""!=a.n.text.val()&&a.n.proclose.css({display:"block"})}if("body"==d||"html"==d)return console.log("Ajax Search Pro: Do not use html or body as the live loader selector."),!1;""==ASP.pageHTML&&"undefined"===typeof ASP._ajax_page_html&&(ASP._ajax_page_html=!0,e.fn.ajax({url:location.href,method:"GET",success:function(c){ASP.pageHTML=
c},dataType:"html"}));b="undefined"==typeof b?!0:b;l="undefined"==typeof l?!1:l;let q=".search-content #content #Content div[role=main] main[role=main] div.theme-content div.td-ss-main-content main.l-content #primary".split(" ");"#main"!=d&&q.unshift("#main");if(1>e(d).length&&(q.forEach(function(c,g){if(0<e(g).length)return d=g,!1}),1>e(d).length))return console.log("Ajax Search Pro: The live search selector does not exist on the page."),!1;d=f.Hooks.applyFilters("asp/live_load/selector",d,this);
let h=e(d).first(),a=this;a.searchAbort();h.css("opacity",.4);f.Hooks.applyFilters("asp/live_load/start",k,a,d,h.get(0));l||1!=a.n.searchsettings.find("input[name=filters_initial]").val()||""!=a.n.text.val()?(a.searching=!0,a.post=e.fn.ajax({url:k,method:"GET",success:function(c){n(c)},dataType:"html",fail:function(c){h.css("opacity",1);c.aborted||(h.html("This request has failed. Please check your connection."),a.hideLoader(),a.searching=!1,a.n.proclose.css({display:"block"}))}})):window.WPD.intervalUntilExecute(function(){n(ASP.pageHTML)},
function(){return""!=ASP.pageHTML})},getCurrentLiveURL:function(){var d="asp_ls="+f.nicePhrase(this.n.text.val());let k="&",b=window.location.href;b=-1<b.indexOf("asp_ls=")?b.slice(0,b.indexOf("asp_ls=")):b;b=-1<b.indexOf("asp_ls&")?b.slice(0,b.indexOf("asp_ls&")):b;b=-1<b.indexOf("p_asid=")?b.slice(0,b.indexOf("p_asid=")):b;b=-1<b.indexOf("asp_")?b.slice(0,b.indexOf("asp_")):b;-1===b.indexOf("?")&&(k="?");d=b+k+d+"&asp_active=1&asp_force_reset_pagination=1&p_asid="+this.o.id+"&p_asp_data=1&"+e("form",
this.n.searchsettings).serialize();return d=d.replace("?&","?")}})})(WPD.dom);
