1import{sectionRenderer}from"@theme/section-renderer";import{Component}from"@theme/component";import{FilterUpdateEvent,ThemeEvents}from"@theme/events";import{debounce,formatMoney,startViewTransition}from"@theme/utilities";const SEARCH_QUERY="q";class FacetsFormComponent extends Component{requiredRefs=["facetsForm"];createURLParameters(formData=new FormData(this.refs.facetsForm)){let newParameters=new URLSearchParams(formData);newParameters.get("filter.v.price.gte")===""&&newParameters.delete("filter.v.price.gte"),newParameters.get("filter.v.price.lte")===""&&newParameters.delete("filter.v.price.lte"),newParameters.delete("page");const searchQuery=this.#getSearchQuery();return searchQuery&&newParameters.set(SEARCH_QUERY,searchQuery),newParameters}#getSearchQuery(){return new URL(window.location.href).searchParams.get(SEARCH_QUERY)??""}get sectionId(){const id=this.getAttribute("section-id");if(!id)throw new Error("Section ID is required");return id}#updateURLHash(){const url=new URL(window.location.href),urlParameters=this.createURLParameters();url.search="";for(const[param,value]of urlParameters.entries())url.searchParams.append(param,value);history.pushState({urlParameters:urlParameters.toString()},"",url.toString())}updateFilters=()=>{this.#updateURLHash(),this.dispatchEvent(new FilterUpdateEvent(this.createURLParameters())),this.#updateSection()};#updateSection(){!this.closest("dialog")?startViewTransition(()=>sectionRenderer.renderSection(this.sectionId),["product-grid"]):sectionRenderer.renderSection(this.sectionId)}updateFiltersByURL(url){history.pushState("","",url),this.dispatchEvent(new FilterUpdateEvent(this.createURLParameters())),this.#updateSection()}}customElements.get("facets-form-component")||customElements.define("facets-form-component",FacetsFormComponent);class FacetInputsComponent extends Component{get sectionId(){const id=this.closest(".shopify-section")?.id;if(!id)throw new Error("FacetInputs component must be a child of a section");return id}updateFilters(){const facetsForm=this.closest("facets-form-component");facetsForm instanceof FacetsFormComponent&&(facetsForm.updateFilters(),this.#updateSelectedFacetSummary())}handleKeyDown(event){if(!(event.target instanceof HTMLElement))return;const closestInput=event.target.querySelector("input");closestInput instanceof HTMLInputElement&&(event.key==="Enter"||event.key===" ")&&(event.preventDefault(),closestInput.checked=!closestInput.checked,this.updateFilters())}prefetchPage=debounce(event=>{if(!(event.target instanceof HTMLElement))return;const form=this.closest("form");if(!form)return;const formData=new FormData(form),inputElement=event.target.querySelector("input");if(!(inputElement instanceof HTMLInputElement))return;inputElement.checked||formData.append(inputElement.name,inputElement.value);const facetsForm=this.closest("facets-form-component");if(!(facetsForm instanceof FacetsFormComponent))return;const urlParameters=facetsForm.createURLParameters(formData),url=new URL(window.location.pathname,window.location.origin);for(const[key,value]of urlParameters)url.searchParams.append(key,value);inputElement.checked&&url.searchParams.delete(inputElement.name,inputElement.value),sectionRenderer.getSectionHTML(this.sectionId,!0,url)},200);cancelPrefetchPage=()=>this.prefetchPage.cancel();#updateSelectedFacetSummary(){if(!this.refs.facetInputs)return;const checkedInputElements=this.refs.facetInputs.filter(input=>input.checked),statusComponent=this.closest("details")?.querySelector("facet-status-component");statusComponent instanceof FacetStatusComponent&&statusComponent.updateListSummary(checkedInputElements)}}customElements.get("facet-inputs-component")||customElements.define("facet-inputs-component",FacetInputsComponent);class PriceFacetComponent extends Component{connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this.#onKeyDown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this.#onKeyDown)}#onKeyDown=event=>{if(event.metaKey)return;const pattern=/[0-9]|\.|,|'| |Tab|Backspace|Enter|ArrowUp|ArrowDown|ArrowLeft|ArrowRight|Delete|Escape/;event.key.match(pattern)||event.preventDefault()};updatePriceFilterAndResults(){const{minInput,maxInput}=this.refs;this.#adjustToValidValues(minInput),this.#adjustToValidValues(maxInput);const facetsForm=this.closest("facets-form-component");facetsForm instanceof FacetsFormComponent&&(facetsForm.updateFilters(),this.#setMinAndMaxValues(),this.#updateSummary())}#adjustToValidValues(input){if(input.value.trim()==="")return;const value=Number(input.value),min=Number(formatMoney(input.getAttribute("data-min")??"")),max=Number(formatMoney(input.getAttribute("data-max")??""));value<min&&(input.value=min.toString()),value>max&&(input.value=max.toString())}#setMinAndMaxValues(){const{minInput,maxInput}=this.refs;maxInput.value&&minInput.setAttribute("data-max",maxInput.value),minInput.value&&maxInput.setAttribute("data-min",minInput.value),minInput.value===""&&maxInput.setAttribute("data-min","0"),maxInput.value===""&&minInput.setAttribute("data-max",maxInput.getAttribute("data-max")??"")}#updateSummary(){const{minInput,maxInput}=this.refs,statusComponent=this.closest("details")?.querySelector("facet-status-component");statusComponent instanceof FacetStatusComponent&&statusComponent?.updatePriceSummary(minInput,maxInput)}}customElements.get("price-facet-component")||customElements.define("price-facet-component",PriceFacetComponent);class FacetClearComponent extends Component{requiredRefs=["clearButton"];connectedCallback(){super.connectedCallback(),this.addEventListener("keyup",this.#handleKeyUp),document.addEventListener(ThemeEvents.FilterUpdate,this.#handleFilterUpdate)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(ThemeEvents.FilterUpdate,this.#handleFilterUpdate)}clearFilter(event){if(!(event.target instanceof HTMLElement))return;if(event instanceof KeyboardEvent){if(event.key!=="Enter"&&event.key!==" ")return;event.preventDefault()}event.target.closest("facet-inputs-component, price-facet-component")?.querySelectorAll('[type="checkbox"]:checked, input').forEach(input=>{input instanceof HTMLInputElement&&(input.checked=!1,input.value="")}
1);const statusComponent=event.target.closest("details")?.querySelector("facet-status-component");if(!(statusComponent instanceof FacetStatusComponent))return;statusComponent.clearSummary();const facetsForm=this.closest("facets-form-component");facetsForm instanceof FacetsFormComponent&&facetsForm.updateFilters()}#handleKeyUp=event=>{event.metaKey||event.key==="Enter"&&this.clearFilter(event)};#handleFilterUpdate=event=>{const{clearButton}=this.refs;clearButton instanceof Element&&clearButton.classList.toggle("facets__clear--active",event.shouldShowClearAll())}}customElements.get("facet-clear-component")||customElements.define("facet-clear-component",FacetClearComponent);class FacetRemoveComponent extends Component{connectedCallback(){super.connectedCallback(),document.addEventListener(ThemeEvents.FilterUpdate,this.#handleFilterUpdate)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener(ThemeEvents.FilterUpdate,this.#handleFilterUpdate)}removeFilter({form},event){if(event instanceof KeyboardEvent){if(event.key!=="Enter"&&event.key!==" ")return;event.preventDefault()}const url=this.dataset.url;if(!url)return;const facetsForm=form?document.getElementById(form):this.closest("facets-form-component");facetsForm instanceof FacetsFormComponent&&facetsForm.updateFiltersByURL(url)}#handleFilterUpdate=event=>{const{clearButton}=this.refs;clearButton instanceof Element&&clearButton.classList.toggle("active",event.shouldShowClearAll())}}customElements.get("facet-remove-component")||customElements.define("facet-remove-component",FacetRemoveComponent);class SortingFilterComponent extends Component{requiredRefs=["details","summary","listbox"];handleKeyDown=event=>{const{listbox}=this.refs;if(!(listbox instanceof Element))return;const options=Array.from(listbox.querySelectorAll('[role="option"]')),currentFocused=options.find(option=>option instanceof HTMLElement&&option.tabIndex===0);let newFocusIndex=currentFocused?options.indexOf(currentFocused):0;switch(event.key){case"ArrowDown":event.preventDefault(),newFocusIndex=Math.min(newFocusIndex+1,options.length-1),this.#moveFocus(options,newFocusIndex);break;case"ArrowUp":event.preventDefault(),newFocusIndex=Math.max(newFocusIndex-1,0),this.#moveFocus(options,newFocusIndex);break;case"Enter":case" ":if(event.target instanceof Element){const targetOption=event.target.closest('[role="option"]');targetOption&&(event.preventDefault(),this.#selectOption(targetOption))}break;case"Escape":event.preventDefault(),this.#closeDropdown();break}};handleToggle=()=>{const{details,summary,listbox}=this.refs;if(!(details instanceof HTMLDetailsElement)||!(summary instanceof HTMLElement))return;const isOpen=details.open;if(summary.setAttribute("aria-expanded",isOpen.toString()),isOpen&&listbox instanceof Element){const selectedOption=listbox.querySelector('[aria-selected="true"]');selectedOption instanceof HTMLElement&&selectedOption.focus()}};#moveFocus(options,newIndex){options.forEach(option=>{option instanceof HTMLElement&&(option.tabIndex=-1)});const targetOption=options[newIndex];targetOption instanceof HTMLElement&&(targetOption.tabIndex=0,targetOption.focus())}#selectOption(option){const input=option.querySelector('input[type="radio"]');input instanceof HTMLInputElement&&option instanceof HTMLElement&&(this.querySelectorAll('[role="option"]').forEach(opt=>{opt.setAttribute("aria-selected","false")}),option.setAttribute("aria-selected","true"),input.click(),this.#closeDropdown())}#closeDropdown(){const{details,summary}=this.refs;if(details instanceof HTMLDetailsElement){const options=this.querySelectorAll('[role="option"]'),selectedOption=this.querySelector('[aria-selected="true"]');options.forEach(opt=>{opt instanceof HTMLElement&&(opt.tabIndex=-1)}),selectedOption instanceof HTMLElement&&(selectedOption.tabIndex=0),details.open=!1,summary instanceof HTMLElement&&summary.focus()}}updateFilterAndSorting(event){const facetsForm=this.closest("facets-form-component")||this.closest(".shopify-section")?.querySelector("facets-form-component");if(!(facetsForm instanceof FacetsFormComponent))return;const isMobile=window.innerWidth<750,shouldDisable=this.dataset.shouldUseSelectOnMobile==="true";if(shouldDisable)if(isMobile)this.querySelectorAll('input[name="sort_by"]').forEach(input=>{input instanceof HTMLInputElement&&(input.disabled=!0)});else{const selectElement=this.querySelector('select[name="sort_by"]');if(!(selectElement instanceof HTMLSelectElement))return;selectElement.disabled=!0}if(facetsForm.updateFilters(),this.updateFacetStatus(event),shouldDisable)if(isMobile)this.querySelectorAll('input[name="sort_by"]').forEach(input=>{input instanceof HTMLInputElement&&(input.disabled=!1)});else{const selectElement=this.querySelector('select[name="sort_by"]');if(!(selectElement instanceof HTMLSelectElement))return;selectElement.disabled=!1}const{details}=this.refs;details instanceof HTMLDetailsElement&&(details.open=!1)}updateFacetStatus(event){if(!(event.target instanceof HTMLSelectElement))return;const details=this.querySelector("details");
1if(!details)return;const facetStatus=details.querySelector("facet-status-component");facetStatus instanceof FacetStatusComponent&&(facetStatus.textContent=event.target.value!==details.dataset.defaultSortBy?event.target.dataset.optionName??"":"")}}customElements.get("sorting-filter-component")||customElements.define("sorting-filter-component",SortingFilterComponent);class FacetStatusComponent extends Component{updateListSummary(checkedInputElements){const checkedInputElementsCount=checkedInputElements.length;this.getAttribute("facet-type")==="swatches"?this.#updateSwatchSummary(checkedInputElements,checkedInputElementsCount):this.#updateBubbleSummary(checkedInputElements,checkedInputElementsCount)}#updateSwatchSummary(checkedInputElements,checkedInputElementsCount){const{facetStatus}=this.refs;if(facetStatus.classList.remove("bubble","facets__bubble"),checkedInputElementsCount===0){facetStatus.innerHTML="";return}if(checkedInputElementsCount>3){facetStatus.innerHTML=checkedInputElementsCount.toString(),facetStatus.classList.add("bubble","facets__bubble");return}facetStatus.innerHTML=Array.from(checkedInputElements).map(inputElement=>inputElement.parentElement?.querySelector("span.swatch")?.outerHTML??"").join("")}#updateBubbleSummary(checkedInputElements,checkedInputElementsCount){const{facetStatus}=this.refs,filterStyle=this.dataset.filterStyle;if(facetStatus.classList.remove("bubble","facets__bubble"),checkedInputElementsCount===0){facetStatus.innerHTML="";return}if(filterStyle==="horizontal"&&checkedInputElementsCount===1){facetStatus.innerHTML=checkedInputElements[0]?.dataset.label??"";return}facetStatus.innerHTML=checkedInputElementsCount.toString(),facetStatus.classList.add("bubble","facets__bubble")}updatePriceSummary(minInput,maxInput){const minInputValue=minInput.value,maxInputValue=maxInput.value,{facetStatus}=this.refs;if(!minInputValue&&!maxInputValue){facetStatus.innerHTML="";return}const minInputNum=this.#parseCents(minInputValue,"0"),maxInputNum=this.#parseCents(maxInputValue,facetStatus.dataset.rangeMax);facetStatus.innerHTML=`${this.#formatMoney(minInputNum)}\u2013${this.#formatMoney(maxInputNum)}`}#parseCents(value,fallback="0"){const parts=value?value.trim().split(/[^0-9]/):(parseInt(fallback,10)/100).toString(),[wholeStr,fractionStr,...rest]=parts;if(typeof wholeStr!="string"||rest.length>0)return parseInt(fallback,10);const whole=parseInt(wholeStr,10);let fraction=parseInt(fractionStr||"0",10);return fraction=fraction*Math.pow(10,2-fraction.toString().length),whole*100+fraction}#formatMoney(moneyValue){if(!(this.refs.moneyFormat instanceof HTMLTemplateElement))return"";const template=this.refs.moneyFormat.content.textContent||"{{amount}}",currency=this.refs.facetStatus.dataset.currency||"";return template.replace(/{{\s*(\w+)\s*}}/g,(_,placeholder)=>{if(typeof placeholder!="string")return"";if(placeholder==="currency")return currency;let thousandsSeparator=",",decimalSeparator=".",precision=CURRENCY_DECIMALS[currency.toUpperCase()]??DEFAULT_CURRENCY_DECIMALS;return placeholder==="amount"||(placeholder==="amount_no_decimals"?precision=0:placeholder==="amount_with_comma_separator"?(thousandsSeparator=".",decimalSeparator=","):placeholder==="amount_no_decimals_with_comma_separator"?(thousandsSeparator=".",precision=0):placeholder==="amount_no_decimals_with_space_separator"?(thousandsSeparator=" ",precision=0):placeholder==="amount_with_space_separator"?(thousandsSeparator=" ",decimalSeparator=","):placeholder==="amount_with_period_and_space_separator"?(thousandsSeparator=" ",decimalSeparator="."):placeholder==="amount_with_apostrophe_separator"&&(thousandsSeparator="'",decimalSeparator=".")),this.#formatCents(moneyValue,thousandsSeparator,decimalSeparator,precision)})}#formatCents(moneyValue,thousandsSeparator,decimalSeparator,precision){const roundedNumber=(moneyValue/100).toFixed(precision);let[a,b]=roundedNumber.split(".");return a||(a="0"),b||(b=""),a=a.replace(/\d(?=(\d\d\d)+(?!\d))/g,digit=>digit+thousandsSeparator),precision<=0?a:a+decimalSeparator+b.padEnd(precision,"0")}clearSummary(){this.refs.facetStatus.innerHTML=""}}customElements.get("facet-status-component")||customElements.define("facet-status-component",FacetStatusComponent);const DEFAULT_CURRENCY_DECIMALS=2,CURRENCY_DECIMALS={BHD:3,BIF:0,BYR:0,CLF:4,CLP:0,DJF:0,GNF:0,IQD:3,ISK:0,JOD:3,JPY:0,KMF:0,KRW:0,KWD:3,LYD:3,MRO:5,OMR:3,PYG:0,RWF:0,TND:3,UGX:0,UYI:0,UYW:4,VND:0,VUV:0,XAF:0,XAG:0,XAU:0,XBA:0,XBB:0,XBC:0,XBD:0,XDR:0,XOF:0,XPD:0,XPF:0,XPT:0,XSU:0,XTS:0,XUA:0}; 2//# sourceMappingURL=/cdn/shop/t/546/assets/facets.js.map?v=66436253990668017921766084391
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.