"use strict";var woostifySearchDelay=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e,a){clearTimeout(t),t=setTimeout(e,a)}}();function woostifyAjaxProductSearch(){var t,e,a=document.querySelectorAll(".search-field");t={link:"aps-link",image:"aps-thumbnail",itemTag:'
',contentTag:'
',priceTag:'
',titleTag:'

',skuTag:'
',closeTag:"
",titleClose:"

",categoryClass:'
',headerTag:'
'},e={dataHtml:function(t,e){var a,s,i,l="",r=jQuery(e).find(".search-dialog-count"),c=t.products,n=t.categories,o=t.tags,h=t.attributes;if(jQuery(".link-search-page").html(t.product_found+" "+woostify_ajax_product_search_data.products),n&&n.length>0){for(l+=this.categoryClass+this.headerTag+woostify_ajax_product_search_data.categories+this.closeTag,a=0,s=n.length;a'+this.contentTag+this.titleTag+i.name_hightline+this.titleClose+this.closeTag+this.closeTag;l+=this.closeTag}if(o&&o.length>0){for(l+=this.categoryClass+this.headerTag+woostify_ajax_product_search_data.tags+this.closeTag,a=0,s=o.length;a'+this.contentTag+this.titleTag+i.name_hightline+this.titleClose+this.closeTag+this.closeTag}l+=this.closeTag}if(h&&h.length>0){for(l+=this.categoryClass+this.headerTag+woostify_ajax_product_search_data.attributes+this.closeTag,a=0,s=h.length;a'+this.contentTag+this.titleTag+i.name_hightline+this.titleClose+this.closeTag+this.closeTag}l+=this.closeTag}if(t.products.length>0){if(r.length>0)r.html(t.product_found+" "+woostify_ajax_product_search_data.products);else{var g=''+t.product_found+" "+woostify_ajax_product_search_data.products+"";jQuery(".dialog-search-title").append(g)}for(l+=this.categoryClass+this.headerTag+woostify_ajax_product_search_data.products+this.closeTag,a=0,s=c.length;a'+i.name+''+this.contentTag+this.titleTag+i.name_hightline+this.titleClose+this.priceTag+i.html_price+this.closeTag+this.skuTag+d+i.sku_hightline+this.closeTag+this.closeTag+this.closeTag}l+=this.closeTag,e.querySelector(".ajax-search-results").innerHTML=l}e.querySelector(".ajax-search-results").innerHTML=l,0==t.products.length&&(!o||o&&0==o.length)&&(!n||n&&0==n.length&&(!h||h&&0==h.length))&&(e.querySelector(".ajax-search-results").innerHTML='
'+woostify_ajax_product_search_data.no_product+"
",r.html(""))}},a.length&&"undefined"!=typeof woostify_ajax_product_search_data&&a.forEach(function(a){var s=a.closest("form"),i=!!s&&s.classList.contains("woocommerce-product-search"),l=!!s&&s.querySelector(".search-field");if(s&&i&&l){l.setAttribute("autocomplete","off");var r=s.closest(".site-search")||s.closest(".dialog-search-content"),c=!!r&&r.querySelector(".ajax-search-results");if(c){var n=document.createElement("span");if(n.setAttribute("class","clear-search-results ti-close"),l.parentNode.insertBefore(n,l.nextSibling),woostify_ajax_product_search_data.lang){var o=document.createElement("input");o.setAttribute("type","hidden"),o.setAttribute("name","lang"),o.setAttribute("value",woostify_ajax_product_search_data.lang),l.parentNode.insertBefore(o,l.nextSibling)}woostify_ajax_product_search_data.select&&(s.insertAdjacentHTML("afterbegin",woostify_ajax_product_search_data.select),s.classList.add("category-filter"));var h=s.querySelector(".ajax-product-search-category-filter"),g=s.querySelector("input[name=lang]"),d=function(){var a,i=void 0!==arguments[0]&&arguments[0],o=h?h.value.trim():"",d=g?g.value.trim():"",u=l.value.trim();if(!u){n.classList.remove("show"),c.classList.add("hide"),jQuery(r).find(".total-result-wrapper").html(""),jQuery(r).find(".search-dialog-count").html("");return}if(n.classList.add("show"),c.classList.remove("hide"),n.onclick=function(){l.value="",n.classList.remove("show"),c.classList.add("hide"),jQuery(r).find(".total-result-wrapper").html(""),jQuery(r).find(".search-dialog-count").html("")},u!==l.getAttribute("data-value")||i){l.setAttribute("data-value",u),s.classList.add("loading"),a=jQuery(s).attr("action")+"?post_type=product&s="+u,o&&(a+="&cat_id="+o),d&&(a+="&lang="+d);var f={token:woostify_ajax_product_search_data.ajax_nonce,keyword:u,cat_id:o,lang:d},p=woostify_ajax_product_search_data.url;woostify_ajax_product_search_data.code_snippets&&(p=woostify_ajax_product_search_data.ajax_url,f.action="ajax_product_search",f.ajax_nonce=woostify_ajax_product_search_data.ajax_nonce),jQuery.ajax({type:"GET",url:p,data:f,beforeSend:function(t){jQuery(s).addClass("loading")},success:function(i){jQuery(s).removeClass("loading"),jQuery(r).find(".total-result-wrapper").html(""),i.data.products.length>0&&jQuery(r).find(".total-result-wrapper").html(''+i.data.size+woostify_ajax_product_search_data.products+""),e.dataHtml.call(t,i.data,r),jQuery(document).on("keyup keypress",function(t){if(13===(t.keyCode||t.which)){if(t.preventDefault(),0==i.data.products.length)return!1;window.location.href=a}})}})}};l.addEventListener("input",function(){woostifySearchDelay(function(){d()},500)}),h&&h.addEventListener("change",function(){d(!0),l.focus()}),window.addEventListener("load",t=>{l.value=""})}}})}document.addEventListener("DOMContentLoaded",function(){woostifyAjaxProductSearch()});