1document.addEventListener("alpine:init",()=>{Alpine.data("ThemeComponent_PredictiveSearch",resources=>({rootEl:null,cachedResults:{},loading:!1,rawQuery:"",results:!1,resultsMarkup:null,showViewAll:!1,_currentResultsGroup:"",resources,get currentResultsGroup(){return this._currentResultsGroup},set currentResultsGroup(newValue){if(newValue===""){this._currentResultsGroup=newValue;return}if(this._currentResultsGroup===""){this.$refs[`${newValue}Results`]&&(this.$refs[`${newValue}Results`].hidden=!1),this._currentResultsGroup=newValue;return}const currentResultsGroupEl=this.$refs[`${this._currentResultsGroup}Results`];this._currentResultsGroup=newValue;const nextResultsGroupEl=this.$refs[`${newValue}Results`];this.switchResultsGroup(currentResultsGroupEl,nextResultsGroupEl)},get trimmedQuery(){return this.rawQuery.trim()},get shouldAnimate(){return window.matchMedia("(prefers-reduced-motion: no-preference)").matches},init(){this.rootEl=this.$root,this.cachedResults={},document.querySelectorAll("[data-open-search]").forEach(toggle=>{toggle.setAttribute("role","button")}),document.addEventListener("keyup",event=>{event.key==="Escape"&&(this.close(!1,!0),setTimeout(()=>this.$refs.input.focus(),100))}),this.$watch("results",async value=>{if(value===!0)this.$refs.results.hidden=!1,this.showViewAll=!0;else{if(this.shouldAnimate){const keyframes={opacity:[1,0]},options={duration:200,easing:"ease"};await Promise.all([this.$refs.results.animate(keyframes,options).finished,this.$refs.viewAll.animate(keyframes,options).finished])}this.$refs.results.hidden=!0,this.showViewAll=!1}})},close(clearSearchTerm=!1,closeButton=!1){const instant=this.rawQuery.trim().length===0&&clearSearchTerm;clearSearchTerm&&(this.rawQuery="",this.results=!1),closeButton&&(setTimeout(()=>{Alpine.store("modals").close("search")},instant?0:350),setTimeout(()=>{const selected=this.$el.querySelector('[aria-selected="true"]');selected&&selected.setAttribute("aria-selected",!1),this.$refs.input.setAttribute("aria-activedescendant",""),this.$refs.input.setAttribute("aria-expanded",!1),document.documentElement.style.overflowY="auto";const toggleSearch=document.querySelector("[data-open-search]");toggleSearch&&setTimeout(()=>toggleSearch.focus(),100)},585))},getSearchResults(){this.loading=!0;const queryKey=this.trimmedQuery.replace(" ","-").toLowerCase();if(liveRegion(window.theme.strings.loading),this.cachedResults[queryKey]){this.renderSearchResults(this.cachedResults[queryKey].resultsMarkup),liveRegion(this.cachedResults[queryKey].liveRegionText),this.results=!0,this.loading=!1;return}fetch(`${window.theme.routes.predictive_search_url}?q=${encodeURIComponent(this.trimmedQuery)}&${encodeURIComponent("resources[type]")}=${this.resources}&${encodeURIComponent("resources[limit_scope]")}=each§ion_id=predictive-search`).then(response=>{if(!response.ok){const 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,liveRegionText=new DOMParser().parseFromString(text,"text/html").querySelector("#predictive-search-count").textContent;this.cachedResults[queryKey]={resultsMarkup,liveRegionText},this.renderSearchResults(resultsMarkup),liveRegion(liveRegionText),this.results=!0,this.loading=!1}).catch(error=>{throw this.close(),error})},onChange(){this.trimmedQuery.length?this.getSearchResults():this.close(!0)},onFocus(){this.trimmedQuery.length&&this.results!==!0&&this.getSearchResults()},onFormSubmit(event){(!this.trimmedQuery.length||this.$el.querySelector('[aria-selected="true"] a'))&&event.preventDefault()},onKeyup(event){switch(event.preventDefault(),event.code){case"ArrowUp":this.switchOption("up");break;case"ArrowDown":this.switchOption("down");break;case"Enter":this.selectOption();break}},onKeydown(event){(event.code==="ArrowUp"||event.code==="ArrowDown")&&event.preventDefault()},setInitialResultsGroup(){this.$refs.groupToggles?this.currentResultsGroup=this.$refs.groupToggles.querySelector('input[type="radio"]').value:this.currentResultsGroup="products"},renderSearchResults(resultsMarkup){this.$refs.results.innerHTML=resultsMarkup,this.currentResultsGroup="",this.$nextTick(()=>{this.setInitialResultsGroup(),this.$refs.resultsSlot.scrollTo(0,0)})},selectOption(){const selectedOption=this.$root.querySelector('[aria-selected="true"] a, [aria-selected="true"] button');selectedOption&&selectedOption.click()},async switchResultsGroup(fromEl,toEl){this.shouldAnimate&&await fromEl.animate({opacity:[1,0]},{duration:200,easing:"ease"}).finished,fromEl.hidden=!0,toEl.hidden=!1,this.shouldAnimate&&await toEl.animate({opacity:[0,1]},{duration:200,easing:"ease"}).finished;const selectedEl=this.rootEl.querySelector('[aria-selected="true"]');selectedEl&&selectedEl.offsetParent&&selectedEl.scrollIntoView({behavior:this.shouldAnimate?"smooth":"auto",block:"end"})},switchOption(direction){const moveUp=direction==="up",selectedElement=this.$root.querySelector('[aria-selected="true"]'),allElements=Array.from(this.$root.querySelectorAll('[role="option"]'));let activeElement=this.$root.querySelector('[role="option"]');moveUp&&!selectedElement||(!moveUp&&selectedElement?activeElement=allElements[allElements.indexOf(selectedElement)+1]||allElements[0]:moveUp&&(activeElement=allElements[allElements.indexOf(selectedElement)-1]||allElements[allElements.length-1]),activeElement!==selectedElement&&(activeElement.offsetParent||(this.currentResultsGroup=activeElement.closest("[data-results-group]").dataset.resultsGroup),activeElement.setAttribute("aria-selected",!0),activeElement.scrollIntoView({behavior:this.shouldAnimate?"smooth":"auto",block:"end"}),selectedElement&&selectedElement.setAttribute("aria-selected",!1),this.$refs.input.setAttribute("aria-activedescendant",activeElement.id)))}}))}); 2//# sourceMappingURL=/cdn/shop/t/17/assets/predictive-search.js.map?v=110438867846687652631698704196
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.