").append(n).find("#products-result").html();if(t){searchPlaceholder.style.display="none";searchProducts.style.display="block";$("#search-result-products .content-wrapper").html(t);$("#search-result-products").addClass("activeResults");let n;const i=document.querySelector("#small-searchterms");i.addEventListener("keyup",function(){clearTimeout(n);n=setTimeout(()=>{SendGTMSearch()},3e3)})}else searchProducts.style.display="none",searchPlaceholder.style.display="block"},error:function(){console.log("error")},complete:function(){addOverridenPagerHandlers(t);console.log($("#search-result-products").scrollTop);$("#search-result-products").animate({scrollTop:"0"},2e3);$(".add-to-wishlist-button").on("click",function(){$(this).hasClass("active")?$(this).removeClass("active"):$(this).addClass("active")})}})}function addOverridenPagerHandlers(n){$("#search-result-products [data-searchpage]").on("click",function(t){t.preventDefault();let i=$(this).data("searchpage");return $.ajax({cache:!1,type:"GET",url:"/search",data:{q:n,pagenumber:i},success:function(n){let t=$("
").append(n).find("#products-result").html();t?(searchPlaceholder.style.display="none",searchProducts.style.display="block",$("#search-result-products .content-wrapper").html(t),$("#search-result-products").addClass("activeResults")):(searchProducts.style.display="none",searchPlaceholder.style.display="block")},error:function(){console.log("error")},complete:function(){addOverridenPagerHandlers(n)}}),!1})}const searchInput=document.getElementById("small-searchterms");$(document).ready(function(){if(document.location.href.includes("#query")){let n={};n.value=decodeURI(document.location.href).split("=").at(-1);searchInput.value=n.value;handleSearchChange(n);toggleSearchInput()}});const searchPlaceholder=document.getElementById("hide-previous-search"),searchProducts=document.getElementById("search-result-products"),popularSearches=document.querySelectorAll("#search-placeholder .left-search li"),searchPagerLinks=document.querySelectorAll("#search-result-products .pager a");popularSearches.forEach(n=>{n.addEventListener("click",function(t){t.preventDefault();searchInput.value=n.innerHTML;handleSearchChange(n)})})