PageSourceSearch

https://shop.asmonaco.com/cdn/shop/t/93/assets/predictive-search.js?v=52353208861637985851784719345

js asmonaco.com collected 2026-09-24 08:45:09 UTC 7,693 bytes, 2 lines download raw bytes

1class PredictiveSearch extends SearchForm{constructor(){super(),this.cachedResults={},this.predictiveSearchResults=this.querySelector("[data-predictive-search]"),this.allPredictiveSearchInstances=document.querySelectorAll("predictive-search"),this.isOpen=!1,this.abortController=new AbortController,this.searchTerm="",this.body=document.querySelector("body"),this.headerBottom=document.querySelector(".header__bottom"),this.promoModal=document.querySelector(".search__modal"),this.collectionList=document.querySelector(".template-404__collections"),this.headerInput=document.querySelector(".header__search .search__input"),this.setupEventListeners()}setupEventListeners(){this.input.form.addEventListener("submit",this.onFormSubmit.bind(this)),this.input.addEventListener("focus",this.onFocus.bind(this)),this.addEventListener("focusout",this.onFocusOut.bind(this)),this.addEventListener("keyup",this.onKeyup.bind(this))}getQuery(){return this.input.value.trim()}onChange(){const newSearchTerm=this.getQuery();if((!this.searchTerm||!newSearchTerm.startsWith(this.searchTerm))&&this.querySelector("#predictive-search-results-groups-wrapper")?.remove(),this.updateSearchForTerm(this.searchTerm,newSearchTerm),this.searchTerm=newSearchTerm,!this.searchTerm.length){this.close(!0);return}this.getSearchResults(this.searchTerm),this.getQuery().length?this.hidePromoBlock():this.showPromoBlock()}onFormSubmit(event){(!this.getQuery().length||this.querySelector('[aria-selected="true"] a')||event.submitter.classList.contains("card__link"))&&event.preventDefault()}onFormReset(event){super.onFormReset(event),super.shouldResetForm()&&(this.searchTerm="",this.abortController.abort(),this.abortController=new AbortController,this.closeResults(!0))}onFocus(){const currentSearchTerm=this.getQuery();this.classList.contains("search-modal__form")&&(this.headerBottom&&this.headerBottom.classList.add("header__bottom--visible"),this.promoModal&&this.promoModal.classList.remove("search__modal--hidden"),this.collectionList&&this.collectionList.classList.remove("hidden")),currentSearchTerm.length&&(this.searchTerm!==currentSearchTerm?this.onChange():this.getAttribute("results")==="true"?(this.open(),this.promoModal&&this.promoModal.classList.add("search__modal--hidden"),this.collectionList&&this.collectionList.classList.add("hidden")):this.getSearchResults(this.searchTerm))}onFocusOut(){this.classList.contains("search-modal__form")&&this.headerBottom&&this.headerBottom.classList.remove("header__bottom--visible"),this.classList.contains("search-modal__form")||setTimeout(()=>{this.contains(document.activeElement)||this.close()})}onBlur(){this.headerInput.blur()}onKeyup(event){switch(this.getQuery().length||this.close(!0),event.preventDefault(),event.code){case"Enter":event.preventDefault(),this.selectOption();break;case"Escape":this.close(!0),this.closeResults(clearSearchTerm),this.getQuery().length?this.hidePromoBlock():this.showPromoBlock();break}}updateSearchForTerm(previousTerm,newTerm){const searchForTextElement=this.querySelector("[data-predictive-search-search-for-text]"),currentButtonText=searchForTextElement?.innerText;if(currentButtonText){if(currentButtonText.matchAll(new RegExp(previousTerm,"g")).length>1)return;const newButtonText=currentButtonText.replace(previousTerm,newTerm);searchForTextElement.innerText=newButtonText}this.getQuery().length?this.hidePromoBlock():this.showPromoBlock()}selectOption(){const selectedOption=this.querySelector('[aria-selected="true"] a, button[aria-selected="true"]');selectedOption&&selectedOption.click()}getSearchResults(searchTerm){const queryKey=searchTerm.replace(" ","-").toLowerCase();if(this.setLiveRegionLoadingState(),this.cachedResults[queryKey]){this.renderSearchResults(this.cachedResults[queryKey]),this.clickSearchTabs();return}this.promoModal&&this.classList.contains("search-modal__form")&&this.promoModal.classList.add("search__modal--hidden"),this.collectionList&&this.collectionList.classList.add("hidden"),fetch(`${routes.predictive_search_url}?q=${encodeURIComponent(searchTerm)}&section_id=predictive-search`,{signal:this.abortController.signal}).then(response=>{if(!response.ok){var error=new Error(response.status);throw this.close(),error}return response.text()}).then(text=>{const resultsMarkup=new DOMParser().parseFromString(text,"text/html").querySelector("#shopify-section-predictive-search").innerHTML;
1this.allPredictiveSearchInstances.forEach(predictiveSearchInstance=>{predictiveSearchInstance.cachedResults[queryKey]=resultsMarkup}),this.renderSearchResults(resultsMarkup),this.clickSearchTabs();try{colorSwatches()}catch{}}).catch(error=>{if(error?.code!==20)throw this.close(),error}),this.getQuery().length?this.hidePromoBlock():this.showPromoBlock()}setLiveRegionLoadingState(){this.statusElement=this.statusElement||this.querySelector(".predictive-search-status"),this.loadingText=this.loadingText||this.getAttribute("data-loading-text"),this.setLiveRegionText(this.loadingText),this.setAttribute("loading",!0)}setLiveRegionText(statusText){this.statusElement.setAttribute("aria-hidden","false"),this.statusElement.textContent=statusText,setTimeout(()=>{this.statusElement.setAttribute("aria-hidden","true")},1e3)}renderSearchResults(resultsMarkup){this.predictiveSearchResults.innerHTML=resultsMarkup,this.setAttribute("results",!0),this.setLiveRegionResults(),this.open(),this.promoModal&&this.classList.contains("search-modal__form")&&this.promoModal.classList.add("search__modal--hidden"),this.collectionList&&this.collectionList.classList.add("hidden")}clickSearchTabs(){const results=this.querySelectorAll(".predictive-search__results-list");results.length!=0&&(results[0].classList.add("active"),this.querySelector(".predictive-search__result-tab").classList.add("active"),this.querySelectorAll(".predictive-search__result-tab").forEach(tab=>{tab.addEventListener("click",event=>{event.preventDefault();const typeTarget=tab.dataset.typeTarget;this.querySelectorAll(".predictive-search__result-tab").forEach(element=>{element.classList.remove("active")}),tab.classList.add("active"),results.forEach(element=>{element.dataset.type==typeTarget?element.classList.add("active"):element.classList.remove("active")})})}))}hidePromoBlock(){this.classList.contains("search-modal__form")&&(this.promoModal&&this.promoModal.classList.add("search__modal--hidden"),this.collectionList&&this.collectionList.classList.add("hidden"))}showPromoBlock(){this.classList.contains("search-modal__form")&&(this.promoModal&&this.promoModal.classList.remove("search__modal--hidden"),this.collectionList&&this.collectionList.classList.remove("hidden"))}setLiveRegionResults(){this.removeAttribute("loading"),this.setLiveRegionText(this.querySelector("[data-predictive-search-live-region-count-value]").textContent)}open(){this.setAttribute("open",!0),this.input.setAttribute("aria-expanded",!0),this.isOpen=!0,this.getQuery().length?this.hidePromoBlock():this.showPromoBlock()}close(clearSearchTerm2=!1){this.closeResults(clearSearchTerm2),this.isOpen=!1}closeResults(clearSearchTerm2=!1){clearSearchTerm2&&(this.input.value="",this.removeAttribute("results"));const selected=this.querySelector('[aria-selected="true"]');selected&&selected.setAttribute("aria-selected",!1),this.input.setAttribute("aria-activedescendant",""),this.removeAttribute("loading"),this.removeAttribute("open"),this.input.setAttribute("aria-expanded",!1),this.predictiveSearchResults.removeAttribute("style"),this.getQuery().length?this.hidePromoBlock():this.showPromoBlock()}}customElements.define("predictive-search",PredictiveSearch);
2//# sourceMappingURL=/cdn/shop/t/93/assets/predictive-search.js.map?v=52353208861637985851784719345

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.