1class I{constructor(){this.moneyFormat=null,this.fromSlider=null,this.toSlider=null,this.fromInput=null,this.toInput=null,this.fromText=null,this.toText=null,this.form=document.getElementById("filters-form"),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.init()):this.init()}init(){try{this.initializeElements(),this.initializePriceSliders(),this.initializeDrawerFunctionality(),this.initializeFilterToggles(),this.initializeSelectedCounts(),this.adjustDrawerMargin(),this.setInitialValues(),this.fixFacetRemoveHref(),this.initializeFilterObserver(),this.onFilterChange(),this.initializeKeyboardSupport()}catch(e){console.error("FilterDrawer initialization failed:",e)}}onFilterChange(){try{const e={};this.form.querySelectorAll('input[type="checkbox"]:checked').forEach(i=>{const l=i.dataset.paramName,a=i.dataset.paramValue;e[l]||(e[l]=[]),e[l].push(a)});const r=this.form.querySelector("#stepSlider");if(r){let i=[];const l=Array.from(document.querySelectorAll("script")).find(a=>a.textContent.includes("const stepSlider = document.getElementById('stepSlider')"));if(l){const a=l.textContent.match(/const stepValues = (\[.*?\]);/s);a&&a[1]&&(i=JSON.parse(a[1].replace(/'/g,'"')))}if(i.length>0){const a=i[parseInt(r.value,10)];a&&a!=="0"&&window.weekRange&&(e["filter.v.m.availability.leadtimeweeks"]=window.weekRange.replace(/%2C/g,","))}}this.fromSlider&&this.toSlider&&(e["filter.v.price.gte"]=this.fromSlider.value,e["filter.v.price.lte"]=this.toSlider.value);const n=new URLSearchParams;for(const[i,l]of Object.entries(e))Array.isArray(l)?l.forEach(a=>n.append(i,a)):n.set(i,l);const o=new URLSearchParams(window.location.search);["q","options[prefix]"].forEach(i=>{o.has(i)&&n.set(i,o.get(i))});const s=document.getElementById("FilterDrawerSortBy");s&&s.value?n.set("sort_by",s.value):o.has("sort_by")&&n.set("sort_by",o.get("sort_by"));let h=`${window.location.origin+window.location.pathname}?${n.toString()}`;h=h.replace(/%2C/g,",");const g=document.querySelector(".show-filtered-products-button");g&&(g.dataset.url=h);const L=i=>{if(!i)return 0;const l=i.match(/(\d[\d,]*)/);return l?Number(l[1].replace(/,/g,"")):0},x=i=>{const l=i.closest&&i.closest("label");if(l){const c=l.querySelector(".drawer-value-count");if(c)return c}const a=i.closest&&i.closest(".filter-section");if(a){const c=a.querySelector(".drawer-value-count");if(c)return c}return i.parentElement?i.parentElement.querySelector(".drawer-value-count"):null},A=i=>{const l=Object.create(null);return Array.from(i.querySelectorAll(".drawer-filter-input, input[data-param-name]")).forEach(c=>{const d=c.getAttribute("data-param-name")||c.name||c.getAttribute("name");if(!d)return;const f=c.getAttribute("data-param-value")??c.value??"",m=x(c),v=L(m?m.textContent:"");l[d]=l[d]||Object.create(null),l[d][String(f)]=v}),l},F=i=>{const l=new Set;return Array.from(i.querySelectorAll('.filter-drawer-range, input[type="range"]')).forEach(a=>{a.id&&l.add(a.id);const c=a.getAttribute("data-param-name")||a.name;c&&l.add(c)}),l},T=(i,l)=>{const a=i.closest&&i.closest("label");if(a){const d=a.querySelector(".drawer-value-count");if(d)return d}if(i.parentElement){const d=i.parentElement.querySelector(".drawer-value-count");if(d)return d}const c=i.closest&&i.closest(".filter-section");if(c){const d=Array.from(c.querySelectorAll(".drawer-value-label"));for(const f of d)if(l&&f.textContent.trim().includes(l)){const m=f.querySelector(".drawer-value-count");if(m)return m}return c.querySelector(".drawer-value-count")}return null},S=(i,l,a)=>{l?(i.removeAttribute("disabled"),i.classList.remove("drawer-value-disabled"),i.setAttribute("aria-disabled","false")):(i.setAttribute("disabled",""),i.classList.add("drawer-value-disabled"),i.setAttribute("aria-disabled","true"));const c=`(${a})`,d=T(i,i.getAttribute("data-param-value")??i.value??"");if(d)d.textContent=c;else if(l&&typeof a=="number"){const f=i.closest&&i.closest("label");if(f){const m=document.createElement("span");m.className="drawer-value-count",m.textContent=c,f.querySelector(".drawer-value-label")?.appendChild(m)||f.appendChild(m)}}};fetch(h,{credentials:"same-origin"}).then(i=>{if(!i.ok)throw console.warn("Fetch failed for",h,i.status),new Error("Fetch failed");return i.text()}).then(i=>{try{const a=new DOMParser().parseFromString(i,"text/html"),c=a.querySelector("#filters-form");if(!c){console.warn("Fetched form not found \u2014 skipping filter sync.");return}const d=A(c),f=F(c);Array.from(document.querySelectorAll(".drawer-filter-input, input[data-param-name]")).forEac
1h(p=>{const w=p.getAttribute("data-param-name")||p.name||p.getAttribute("name");if(!w)return;const E=p.getAttribute("data-param-value")??p.value??"";if(p.classList.contains("filter-drawer-range")||p.type==="range"){const y=p.id,q=y&&f.has(y)||f.has(w);S(p,!!q,0);return}const b=d[w];if(b&&Object.prototype.hasOwnProperty.call(b,String(E))){const y=b[String(E)];S(p,!0,y)}else S(p,!1,0)});const v=a.querySelector("#load-more-button")?.dataset.totalProducts??0;g&&typeof g.textContent=="string"&&(g.textContent=g.textContent.replace(/\d+/,String(v)))}catch(l){console.error("Error syncing filters:",l)}}).catch(i=>{console.error("Network or fetch error while syncing filters:",i)})}catch(e){console.error("Error building filter URL:",e)}}initializeKeyboardSupport(){this.form&&this.form.addEventListener("keydown",e=>{e.key==="Enter"&&e.target.type==="checkbox"&&(e.preventDefault(),e.target.checked=!e.target.checked,e.target.dispatchEvent(new Event("change",{bubbles:!0})))})}initializeFilterObserver(){if(!this.form)return;this.form.addEventListener("change",()=>this.onFilterChange());const e=document.getElementById("FilterDrawerSortBy");e&&e.addEventListener("change",()=>this.onFilterChange())}initializeElements(){const e=document.getElementById("money-format");!e||!e.dataset.format?(console.warn("Money format element not found"),this.moneyFormat="{amount}"):this.moneyFormat=e.dataset.format,this.fromSlider=document.querySelector("#fromSlider"),this.toSlider=document.querySelector("#toSlider"),this.fromInput=document.querySelector("#fromInput"),this.toInput=document.querySelector("#toInput"),this.fromText=document.querySelector("#fromText"),this.toText=document.querySelector("#toText"),[{el:this.fromSlider,name:"fromSlider"},{el:this.toSlider,name:"toSlider"},{el:this.fromInput,name:"fromInput"},{el:this.toInput,name:"toInput"},{el:this.fromText,name:"fromText"},{el:this.toText,name:"toText"}].forEach(({el:r,name:n})=>{r||console.warn(`Required element ${n} not found`)})}formatMoney(e){if(!this.moneyFormat||!e)return e;try{return this.moneyFormat.replace(/\d+([.,]\d+)?/,e)}catch(t){return console.error("Money formatting error:",t),e}}updatePriceGte(e){try{const t=new URL(window.location.href),r=t.searchParams;r.set("filter.v.price.gte",e),t.search=r.toString()}catch(t){console.error("Error updating price gte:",t)}}updatePriceLte(e){try{const t=new URL(window.location.href),r=t.searchParams;r.set("filter.v.price.lte",e),t.search=r.toString()}catch(t){console.error("Error updating price lte:",t)}}controlFromInput(e,t,r,n,o){if(!(!e||!t||!r||!n||!o))try{const[s,u]=this.getParsed(t,r);this.fillSlider(t,r,"#DAD7CE","#2F2B23",n),s>u?(e.value=u,t.value=u,o.innerHTML=this.formatMoney(u)):(e.value=s,o.innerHTML=this.formatMoney(s))}catch(s){console.error("Error in controlFromInput:",s)}}controlToInput(e,t,r,n,o){if(!(!e||!t||!r||!n||!o))try{const[s,u]=this.getParsed(t,r);this.fillSlider(t,r,"#DAD7CE","#2F2B23",n),this.setToggleAccessible(r),s<=u?(e.value=u,r.value=u,o.innerHTML=this.formatMoney(u)):(r.value=s,o.innerHTML=this.formatMoney(s))}catch(s){console.error("Error in controlToInput:",s)}}controlFromSlider(e,t,r,n){if(!(!e||!t||!r||!n))try{const[o,s]=this.getParsed(e,t);this.fillSlider(e,t,"#DAD7CE","#2F2B23",t),o>s?(e.value=s,r.value=s,n.innerHTML=this.formatMoney(s)):(r.value=o,n.innerHTML=this.formatMoney(o))}catch(o){console.error("Error in controlFromSlider:",o)}}controlToSlider(e,t,r,n){if(!(!e||!t||!r||!n))try{const[o,s]=this.getParsed(e,t);this.fillSlider(e,t,"#DAD7CE","#2F2B23",t),this.setToggleAccessible(t),o<=s?(t.value=s,r.value=s,n.innerHTML=this.formatMoney(s)):(r.value=o,t.value=o,n.innerHTML=this.formatMoney(o))}catch(o){console.error("Error in controlToSlider:",o)}}getParsed(e,t){if(!e||!t)return[0,0];try{const r=Number.parseInt(e.value,10)||0,n=Number.parseInt(t.value,10)||0;return[r,n]}catch(r){return console.error("Error parsing values:",r),[0,0]}}fillSlider(e,t,r,n,o){if(!(!e||!t||!o))try{const s=t.max-t.min;if(s<=0)return;const u=e.value-t.min,h=t.value-t.min;o.style.background=`linear-gradient( 2 to right, 3 ${r} 0%, 4 ${r} ${u/s*100}%, 5 ${n} ${u/s*100}%, 6 ${n} ${h/s*100}%, 7 ${r} ${h/s*100}%, 8 ${r} 100%)`}catch(s){console.error("Error filling slider:",s)}}setToggleAccessible(e){if(e)try{const t=document.querySelector("#toSlider");if(!t)return;Number(e.value)<=0?t.style.zIndex=2:t.style.zIndex=0}catch(t){console.error("Error setting toggle accessible:",t)}}initializePriceSliders(){if(!this.fromSlider||!this.toSlider||!this.fromInput||!this.toInput||!this.fromText||!this.toText){console.warn("Price slider elements missing, skipping initialization");return}try{this.fillSlider(this.fromSlider,this.toSlider,"#DAD7CE","#2F2B23",this.toSlider),this.setToggleAccessible(this.toSlider),this.fromSlider.oninput=()=>this.controlFromSlider(this.fromSlider,this.toSlider,this.fromInput,this.fromText),this.toSlider.oninput=()=>this.controlToSlider(this.fromSlider,this.toSlider,this.toInput,this.toText),this.fromInput.oninput=()=>this.controlFromInput(this.fromSlider,this.fromInput,this.toInput,this.toSlider,this.fromText),this.toInput.oninput=()=>this.controlToInput(this.toSlider,this.fromInput,this.toInput,this.toSlider,this.toText),this.fromSlider.addEventListener("change",()=>this.updatePriceGte(this.fromInput.value)),this.toSlider.addEventListener("change",()=>this.updatePriceLte(this.toInput.value)),this.fromInput.addEventListener("change",()=>this.updatePriceGte(this.fromInput.value)),this.toInput.addEventListener("change",()=>this.updatePriceLte(this.toInput.value))}catch(e){console.error("Error initializing price sliders:",e)}}setInitialValues(){try{const t=new URL(window.location.href).searchParams,r=t.get("filter.v.price.gte"),n=t.get("filter.v.price.lte"),o=t.get("filter.v.m.availability.leadtimeweeks")?t.get("filter.v.m.availability.leadtimeweeks").split(","):[],s=o.length>0?o[o.length-1]:null;if(r!==null&&this.fromSlider&&this.fromInput&&this.fromText){this.fromSlider.value=r,this.fromInput.value=r,this.fromText.innerHTML=this.formatMoney(r);const u=document.querySelector(".sticky-buttons"),h=document.querySelector(".price-filter-toggle .selected-labels-number");u&&u.classList.remove("hidden"),h&&(h.textContent="(1)")}if(n!==null&&this.toSlider&&this.toInput&&this.toText){this.toSlider.value=n,this.toInput.value=n,this.toText.innerHTML=this.formatMoney(n);const u=document.querySelector(".sticky-buttons"),h=document.querySelector(".price-filter-toggle .selected-labels-number");u&&u.classList.remove("hidden"),h&&(h.textContent="(1)")}if(s!==null){const u=document.querySelector(".lead-time-button .selected-labels-number");document.querySelector("#stepSlider").value=s,document.getElementById("stepText").innerHTML=s,u&&(u.textContent="(1)")}this.fromSlider&&this.toSlider&&(this.fillSlider(this.fromSlider,this.toSlider,"#DAD7CE","#2F2B23",this.toSlider),this.setToggleAccessible(this.toSlider))}catch(e){console.error("Error setting initial values:",e)}}fixFacetRemoveHref(){try{const e=new URL(window.location.href),t=e.searchParams;t.delete("filter.v.price.gte"),t.delete("filter.v.price.lte");const r=e.origin+e.pathname+(t.toString()?"?"+t.toString():"")+e.hash;document.querySelectorAll(".price-facet").forEach(o=>{o&&o.setAttribute&&o.setAttribute("href",r)})}catch(e){console.error("Error fixing facet remove href:",e)}}adjustDrawerMargin(){try{const e=document.querySelector(".filter-drawer .drawer__inner");if(!e)return;window.innerWidth>document.documentElement.clientWidth?e.style.paddingRight="45px":e.style.paddingRight="30px"}
8catch(e){console.error("Error adjusting drawer margin:",e)}}updateSelectedCounts(){try{document.querySelectorAll(".filter-section").forEach(t=>{if(!t)return;const r=t.querySelectorAll('input[type="checkbox"]:checked'),n=t.querySelector(".selected-labels-number");n&&(r.length>0?n.textContent=`(${r.length})`:n.textContent="")})}catch(e){console.error("Error updating selected counts:",e)}}initializeSelectedCounts(){try{this.updateSelectedCounts(),document.addEventListener("change",e=>{e.target&&e.target.matches&&e.target.matches('.filter-section input[type="checkbox"]')&&this.updateSelectedCounts()})}catch(e){console.error("Error initializing selected counts:",e)}}initializeDrawerFunctionality(){try{const e=document.querySelector(".drawer-filter");e&&e.addEventListener("click",n=>{n.target.closest(".filter-drawer")||(e.classList.remove("active"),e.setAttribute("aria-hidden","true"))}),document.querySelectorAll(".filter-drawer-headline > button").forEach(n=>{n&&n.addEventListener("click",()=>{const o=document.querySelector(".drawer.drawer-filter");o&&o.classList.contains("active")&&(o.classList.remove("active"),o.setAttribute("aria-hidden","true"))})});const r=document.querySelector(".show-filtered-products-button");if(r){const n=o=>{const s=o.dataset.url;s&&(window.location.href=s)};r.addEventListener("click",o=>{n(o.currentTarget)}),r.addEventListener("keydown",o=>{o.key==="Enter"&&(o.preventDefault(),n(o.currentTarget))})}window.addEventListener("load",()=>this.adjustDrawerMargin()),window.addEventListener("resize",()=>this.adjustDrawerMargin())}catch(e){console.error("Error initializing drawer functionality:",e)}}initializeFilterToggles(){try{document.querySelectorAll(".filter-toggle").forEach(t=>{t&&t.addEventListener("click",()=>{try{const r=t.getAttribute("aria-expanded")==="true";t.setAttribute("aria-expanded",!r);const n=t.nextElementSibling;n&&(r?(n.hidden=!0,n.classList.remove("tw-flex")):(n.hidden=!1,n.classList.add("tw-flex")))}catch(r){console.error("Error toggling filter:",r)}})})}catch(e){console.error("Error initializing filter toggles:",e)}}}new I; 9//# sourceMappingURL=/cdn/shop/t/33/assets/novicell_filter-drawer-17902368102.js.map
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.