PageSourceSearch

https://www.lornajane.com/cdn/shop/t/88/assets/predictive-search.C…?v=60578863242925767991790811548

js lornajane.com collected 2026-10-03 20:52:04 UTC 5,958 bytes, 1 lines download raw bytes

1import{l as g}from"./index.DGYHWYEM.min.js";import{n as m}from"./global-notice.C4ZfiLeN.min.js";import{b as v,a as b}from"./body-scroll-lock.CfXZVYDG.min.js";import"./_commonjsHelpers.Cpj98o6Y.min.js";import"./global-events.DtO11sQs.min.js";const h={elements:{predictiveResults:"#predictive-search-results",defaultResults:"#default-search-results",header:".header-main-wrapper",preHeader:".pre-header",suggestedSearch:{categoryLabel:'[data-selector="suggested-search-category-label"]',link:'[data-selector="suggested-search"]'}},controls:{closer:'[data-selector="close-search"]',opener:'[data-selector="open-search"]',clearInput:'[data-selector="clear-search"]',searchInput:'input[type="search"]',searchButton:'[data-selector="search-submit"]',overlay:'[data-selector="predictive-search-overlay"]'},dataAttributes:{active:"data-active"}},s=h.elements,n=h.controls;class f extends HTMLElement{constructor(){super(...arguments),this.config={enableDebounce:this.getAttribute("data-enable-debounce")==="true",debounceDelay:parseInt(this.getAttribute("data-debounce-delay")??"250"),resourceLimit:parseInt(this.getAttribute("data-resource-limit")??"4")},this.searchProvider=window.searchService.searchProvider,this.abortController=new AbortController,this.handleOpen=()=>{v(),this.toggleAttribute(h.dataAttributes.active),this.searchInput.focus()},this.handleClose=()=>{setTimeout(()=>{this.resetResults(),this.handleClearInput()},300),b(),this.toggleAttribute(h.dataAttributes.active)},this.handleClearInput=()=>{this.searchInput.value="",this.searchInput.focus(),this.handleInputChange(),this.resetResults()},this.handleKeyDown=e=>{e.key==="Escape"&&this.hasAttribute(h.dataAttributes.active)&&this.handleClose()},this.handleInputChange=()=>{this.searchInput.value.trim()!==""?(this.searchButton.removeAttribute("disabled"),this.searchButton.style.pointerEvents="auto",this.clearInput.style.display="block"):(this.searchButton.setAttribute("disabled","true"),this.searchButton.style.pointerEvents="none",this.clearInput.style.display="none"),this.debouncedGetInstantSearchResults()},this.getInstantSearchResults=()=>{const e=new FormData(this.form),t=new URL(CHROMA.routes.predictive_search_url,location.href),{resourceUnavailable:l,resourceLimit:i,resourceLimitScope:d,resourceFields:c}=this.dataset;Object.entries({"resources[options][unavailable_products]":l,"resources[limit]":i,"resources[limit_scope]":d,"resources[options][fields]":c}).forEach(([r,a])=>{a&&e.set(r,a)}),t.searchParams.set("section_id","predictive-search");for(const[r,a]of e)typeof a=="string"&&t.searchParams.set(r,a);if(!(t.searchParams.get("q")??"")){this.resetResults();return}const p=t;this.searchProvider.getNewInstantSearch(p).then(r=>{const u=r.data.querySelector(s.predictiveResults);if(!u){console.error("Could not find newResults from getNewInstantSearch"),m.show({type:"warning",message:"Cannot find any results for this search",duration:5e3});return}this.predictiveResults.outerHTML=u.outerHTML,this.predictiveResults=this.querySelector(s.predictiveResults),this.predictiveResults.getAttribute("data-has-results")==="true"?(this.defaultResults.classList.add("hidden"),this.predictiveResults.classList.remove("hidden")):(this.defaultResults.classList.remove("hidden"),this.predictiveResults.querySelector("div")?.classList.add("hidden"))}).catch(r=>{console.error("Error in getInstantSearchResults:",r)})},this.setHeaderHeight=()=>{const e=this.preHeader.offsetHeight,t=this.header.offsetHeight;document.documentElement.style.setProperty("--header-height",`${e+t}px`)}}connectedCallback(){this.getElements(),this.setupDebouncedSearch(),this.setupUI(),this.registerEvents(),this.setHeaderHeight()}disconnectedCallback(){this.abortController.abort()}getElements(){this.form=this.querySelector("form"),this.predictiveResults=this.querySelector(s.predictiveResults),this.defaultResults=this.querySelector(s.defaultResults),this.closer=this.querySelector(n.closer),this.opener=document.querySelectorAll(n.opener),this.clearInput=this.querySelector(n.clearInput),this.searchInput=this.querySelector(n.searchInput),this.searchButton=this.querySelector(n.searchButton),this.templateTrendingSearchLink=this.querySelector(s.suggestedSearch.link),this.templateTrendingSearchCategoryLabel=this.querySelector(s.suggestedSearch.categoryLabel),this.header=document.querySelector(s.header),this.preHeader=document.querySelector(s.preHeader),this.overlay=document.querySelector(n.overlay)}setupDebouncedSearch(){this.debouncedGetInstantSearchResults=this.config.enableDebounce&&this.config.debounceDelay>0?g(this.getInstantSearchResults,this.config.debounceDelay):this.getInstantSearchResults}setupUI(){this.defaultResults.classList.remove("hidden"),this.clearInput.classList.add("hidden"),this.handleInputChange()}registerEvents(){const{signal:e}=this.abortController;this.closer.addEventListener("click",this.handleClose,{signal:e}),this.clearInput.addEventListener("click",this.handleClearInput,{signal:e}),this.searchInput.addEventListener("input",this.handleInputChange,{signal:e}),this.overlay.addEventListener("click",this.handleClose,{signal:e}),this.opener.forEach(t=>{t.addEventListener("click",this.handleOpen,{signal:e})}),window.addEventListener("scroll",this.setHeaderHeight,{signal:e}),window.addEventListener("keydown",this.handleKeyDown,{signal:e})}resetResults(){this.predictiveResults.innerHTML="",this.defaultResults.classList.remove("hidden"),this.predictiveResults.classList.add("hidden")}getSuggestedSearchElements(e,t){const l=new URL(CHROMA.routes.search_url,location.origin);let i;this.templateTrendingSearchCategoryLabel&&(i=this.templateTrendingSearchCategoryLabel?.cloneNode(!0),i.innerText=t);const d=e.map(c=>{const o=this.templateTrendingSearchLink.cloneNode(!1);return l.searchParams.set("q",c),o.innerText=c,o.ariaLabel=c,o.href=l.toString(),o});return i&&d.unshift(i),d}}customElements.get("predictive-search")||customElements.define("predictive-search",f);

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.