https://www.bicyclesquilicot.com/cdn/shop/t/64/assets/product.min.js?v=15536174267665891881790822165
1var B=Object.defineProperty,z=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var g=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var T=(o,t,e)=>t in o?B(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,S=(o,t)=>{for(var e in t||(t={}))O.call(t,e)&&T(o,e,t[e]);if(g)for(var e of g(t))q.call(t,e)&&T(o,e,t[e]);return o},w=(o,t)=>z(o,P(t));var k=(o,t)=>{var e={};for(var s in o)O.call(o,s)&&t.indexOf(s)<0&&(e[s]=o[s]);if(o!=null&&g)for(var s of g(o))t.indexOf(s)<0&&q.call(o,s)&&(e[s]=o[s]);return e};var m=(o,t,e)=>new Promise((s,n)=>{var r=d=>{try{a(e.next(d))}catch(c){n(c)}},i=d=>{try{a(e.throw(d))}catch(c){n(c)}},a=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,i);a((e=e.apply(o,t)).next())});class M extends HTMLElement{constructor(){super(),this.modal={available:!1,isOpen:!1,element:null},this.selectors={overlay:".size-chart__overlay",body:".size-chart__body",closeButton:".size-chart__button--close",openButton:".size-chart__button"},this.handleInModalClick=t=>this.handleClick(t),this.handleOpenClick=()=>this.openModal()}connectedCallback(){this.initData(),this.initModal(),this.renderSizeChartContent(),this.renderSizeChartButton(),this.addEventListeners()}disconnectedCallback(){var t,e;(t=this.modal.element)==null||t.removeEventListener("click",this.handleInModalClick),(e=document.querySelector(this.selectors.openButton))==null||e.removeEventListener("click",this.handleOpenClick),this.modal.isOpen&&(document.body.style.overflow="",document.documentElement.style.overflow=""),document.removeChild(this.modal.element),this.modal={available:!1,isOpen:!1,element:null}}initData(){var e,s;if(this.productId=this.getAttribute("data-product-id")||"",!this.productId){console.error("SizeChart: Missing ProductId.");return}const t=this.querySelector("#SizeChartData-"+this.productId);if(this.data=JSON.parse((e=t==null?void 0:t.textContent)!=null?e:"{}"),!((s=this.data.size_chart)!=null&&s.title)){console.error("SizeChart: Missing or invalid data.");return}this.modal.available=!0}initModal(){if(!this.modal.available){console.error("SizeChart: Modal is not available.");return}const t=this.getLang(),e=document.createElement("div");e.className="size-chart size-chart__modal",e.innerHTML=` 2 <div class="size-chart__overlay"></div> 3 <div class="size-chart__content"> 4 <div class="size-chart__header"> 5 <span class="size-chart__header--text">${t==="en"?"Size guide":"Guide des tailles"}</span> 6 <button class="size-chart__button--close material-icons material-icons--small" type="button">close_small</button> 7 </div> 8 <div class="size-chart__body"></div> 9 </div> 10 `,this.modal.element=e,document.body.appendChild(this.modal.element)}renderSizeChartContent(){var n;if(!this.modal.available){console.error("SizeChart: Modal is not available.");return}const t=(n=this.modal.element)==null?void 0:n.querySelector(this.selectors.body);if(!t){console.error("SizeChart: Body element not found in modal.");return}const e=this.getLang(),s=document.createElement("div");if(s.className="size-chart__modal-content",this.data.size_chart.html)s.innerHTML=this.data.size_chart.html;else{const r=e==="fr"?this.data.size_chart.image:this.data.size_chart.image_en,i=e==="fr"?this.data.size_chart.image_mobile:this.data.size_chart.image_mobile_en;r&&(s.innerHTML=` 11 <div class="size-chart__modal-content"> 12 <div class="size-chart__modal-images"> 13 <img class="size-chart__modal-image" src="${r}" alt="${this.data.size_chart.title}" loading="lazy"> 14 ${i?`<img class="size-chart__modal-image size-chart__modal-image--mobile" src="${i}" alt="${this.data.size_chart.title}" loading="lazy">`:""} 15 </div> 16 </div> 17 `)}t.appendChild(s)}renderSizeChartButton(){if(!this.modal.available){console.error("SizeChart: Modal is not available.");return}const t=document.querySelector("."+this.data.block_settings.element_class);if(!t){console.error("SizeChart: Target element not found.");return}const e=document.createElement("div");if(e.className="size-chart",e.innerHTML=` 18 <div class="size-chart__button--container"> 19 <button class="size-chart__button" aria-expanded="false" type="button"> 20 ${this.data.block_settings.button_text||'<span class="size-chart__button--text">Size Chart</span>'} 21 ${this.data.block_settings.button_tooltip&&'<span class="size-chart__tooltip--icon material-icons material-icons--small" aria-hidden="true">info_outlined</span>'} 22 </button> 23 24 ${this.data.block_settings.button_tooltip&&`<div class="size-chart__tooltip--text" role="tooltip" aria-hidden="true">${this.data.block_settings.button_tooltip}</div>`} 25 </div> 26 `,this.data.block_settings.button_placement==="child"){t.appendChild(e);return}else if(this.data.block_settings.button_placement==="before"){t.insertAdjacentElement("beforebegin",e);return}t.insertAdjacentElement("afterend",e)}addEventListeners(){var t;if(!this.modal.available||!this.modal.element){console.error("SizeChart: Modal is not available.");return}(t=document.querySelector(this.selectors.openButton))==null||t.addEventListener("click",this.handleOpenClick),this.modal.element.addEventListener("click",this.handleInModalClick)}handleClick(t){var s,n,r;const e=t.target;if((e.closest(this.selectors.closeButton)||e.closest(this.selectors.overlay))&&this.closeModal(),e.tagName==="A"&&((s=e.getAttribute("href"))!=null&&s.startsWith("#"))){const i=(n=e.getAttribute("href"))==null?void 0:n.substring(1),a=(r=this.modal.element)==null?void 0:r.querySelector(`#${i}`);a&&(t.preventDefault(),t.stopPropagation(),a.textContent===""&&(a.innerHTML="dummy",a.style.display="block",a.style.width="0",a.style.height="0",a.style.overflow="hidden"),a.scrollIntoView({behavior:"smooth"}))}}openModal(){var t;!this.modal.available||this.modal.isOpen||(document.body.style.overflow="hidden",document.documentElement.style.overflow="hidden",this.modal.isOpen=!0,(t=this.modal.element)==null||t.classList.add("is-open"))}closeModal(){var t;!this.modal.available||!this.modal.isOpen||(document.body.style.overflow="",document.documentElement.style.overflow="",this.modal.isOpen=!1,(t=this.modal.element)==null||t.classList.remove("is-open"))}getLang(){return window.location.pathname.split("/")[1]==="en"?"en":"fr"}}customElements.get("size-chart")||customElements.define("size-chart",M);const u=class u extends HTMLElement{constructor(){super(),this.locationsStockInfo=[],this.isStockDataValid=!1,this.drawer={isOpen:!1,element:null,overlay:null,availableOnly:!1},this.handlerOverlayClick=()=>this.closeDrawer(),this.handlerCloseClick=()=>this.closeDrawer(),this.handlerOpenClick=()=>this.openDrawer(),this.handleAvailableOnlyChange=()=>this.toggleAvailableOnly(),this.handleStoreUpdate=()=>this.updateSelectedStore(),this.translations={en:{inStock:"In Stock",lowStock:"Low Stock",notAvailable:"Not Available",distance:"km away"},fr:{inStock:"En stock",lowStock:"Quantité limitée",notAvailable:"Indisponible",distance:"km de distance"}}}connectedCallback(){var n;const t=this.querySelector(u.selectors.storesJson);this.storesJson=JSON.parse((n=t==null?void 0:t.textContent)!=null?n:"{}"),this.showCheckingStockState(),this.processMetafieldStockData();const e=this.locationsStockInfo.some(r=>r.variants.some(i=>i.inventory>0)),s=this.querySelector(".stores-checker__button");s&&!e&&(s.style.display="none"),this.updateTriggerButton(),this.renderDrawer(),this.addEventListeners()}disconnectedCallback(){var t,e,s,n,r,i;(t=this.drawer.overlay)==null||t.removeEventListener("click",this.handlerOverlayClick),(s=(e=this.drawer.element)==null?void 0:e.querySelector(u.selectors.drawerCloseButton))==null||s.removeEventListener("click",this.handlerCloseClick),(n=this.querySelector(u.selectors.buttonTrigger))==null||n.removeEventListener("click",this.handlerOpenClick),(i=(r=this.drawer.element)==null?void 0:r.querySelector(u.selectors.drawerAvailableOnlyCheckbox))==null||i.removeEventListener("change",this.handleAvailableOnlyChange),this.drawer.isOpen&&(document.body.style.overflow="",this.drawer.isOpen=!1),document.removeEventListener("store-info-update",this.handleStoreUpdate)}processMetafieldStockData(){const t={},e=this.storesJson.locations||[];
26this.storesJson.variants.forEach(s=>{let n;try{typeof s.inventoryJson=="string"?n=JSON.parse(s.inventoryJson):typeof s.inventoryJson=="object"&&s.inventoryJson!==null?n=s.inventoryJson:n={locations:[]}}catch(r){console.warn("StockChecker: Failed to parse inventoryJson for variant:",s.title,r),n={locations:[]}}(n.locations||[]).forEach(r=>{const i=e.find(a=>a.name===r.shopifyLocationId||a.gid===r.shopifyLocationId||a.name.toLowerCase()===r.shopifyLocationId.toLowerCase());if(!i){console.warn(`StockChecker: No base location found for shopifyLocationId: ${r.shopifyLocationId}`);return}t[i.name]||(t[i.name]=w(S({},i),{variants:[]})),t[i.name].variants.push({inventory:r.qoh,availability:r.status,variantLightspeedId:s.lightspeedId,variantTitle:s.title})})}),e.forEach(s=>{t[s.name]||(t[s.name]=w(S({},s),{variants:[]})),this.storesJson.variants.forEach(n=>{t[s.name].variants.some(i=>i.variantLightspeedId===n.lightspeedId)||t[s.name].variants.push({inventory:0,availability:"out-of-stock",variantLightspeedId:n.lightspeedId,variantTitle:n.title})})}),this.locationsStockInfo=Object.values(t),this.isStockDataValid=this.locationsStockInfo.length>0,this.isStockDataValid||this.hideStockIndicator()}hideStockIndicator(){const t=this.querySelector(u.selectors.buttonTrigger);t&&(t.style.display="none")}updateTriggerButton(){if(!this.isStockDataValid){this.hideStockIndicator();return}const t=this.querySelector(u.selectors.buttonTrigger),e=t.querySelector(u.selectors.buttonText),s=t.querySelector(u.selectors.availabilityDot);if(this.locationsStockInfo.some(r=>r.variants.some(i=>i.inventory>0))){s.classList.remove("availability-dot__unavailable"),s.classList.remove("availability-dot__low-stock"),s.classList.remove("availability-dot__checking"),s.classList.add("availability-dot__available");const r=this.storesJson.translations.available_all||"Stock Available";e.innerHTML=r}else{s.classList.remove("availability-dot__available"),s.classList.remove("availability-dot__low-stock"),s.classList.remove("availability-dot__checking"),s.classList.add("availability-dot__unavailable");const r=this.storesJson.translations.unavailable_all||"No Stock Available";e.innerHTML=r}}showCheckingStockState(){const t=this.querySelector(u.selectors.buttonText),e=this.querySelector(u.selectors.availabilityDot);if(!t||!e)return;const s=this.querySelector(u.selectors.buttonTrigger);s&&(s.style.display="");const n=this.getCurrentStore();n!=null&&n.isShopAll?this.storesJson.translations.all_stores:n!=null&&n.title,e.classList.remove("availability-dot__available"),e.classList.remove("availability-dot__low-stock"),e.classList.remove("availability-dot__unavailable"),e.classList.add("availability-dot__checking"),this.storesJson.translations.checking_stock_html&&(t.innerHTML=this.storesJson.translations.checking_stock_html)}renderDrawer(){var s;const t=document.querySelector(u.selectors.drawerTemplate);if(!t){console.error("StockChecker: Drawer template not found.");return}const e=t.content.cloneNode(!0);(s=e.querySelector(".stores-checker__drawer"))==null||s.setAttribute("id",u.selectors.drawerTemplate.replace("#","")),document.body.appendChild(e),this.removeChild(t),this.drawer.isOpen=!1,this.drawer.element=document.querySelector(u.selectors.drawerTemplate),this.drawer.overlay=document.querySelector(u.selectors.drawerOverlay),this.addLocationsList()}addLocationsList(){var c;const t=(c=this.drawer.element)==null?void 0:c.querySelector(u.selectors.drawerContent);if(!t){console.error("StockChecker: Drawer content wrapper not found.");return}if(t.innerHTML="",this.locationsStockInfo.length===0){t.innerHTML="<p>No locations available.</p>";return}const e=document.createElement("ul");e.className="stores-checker__locations-list";const s=this.getCurrentLanguage(),n=s==="en"?"customNameEN":"customNameFR",r=s==="en"?"customAddressEN":"customAddressFR",i=this.locationsStockInfo.filter(l=>
26!l[n]&&!l[r]),a=this.locationsStockInfo.filter(l=>l[n]||l[r]);[...i,...a].forEach(l=>{var I;const h=l.variants.reduce((v,b)=>{var E;return v+((E=b.inventory)!=null?E:0)},0),p=this.getGeoLocation(l.lat,l.lng),f=l[n]&&l[n].trim()||l.name,A=l[r]&&l[r].trim()||`${l.address}, ${l.city}, ${l.province} ${l.postalCode}`,y=document.createElement("li");y.className=u.selectors.drawerLocationItem.replace(".",""),y.setAttribute("data-inventory",h.toString()),y.setAttribute("data-store",l.name),y.innerHTML=` 27 <span class="location-info name">${f}</span> 28 <span class="location-info address">${A}</span> 29 ${p?`<span class="location-info distance">${p}</span>`:""} 30 <div class="location-info stock"> 31 <div class="stock-info"> 32 <span class="availability-dot availability-dot__${h>0?"available":"not-available"}"></span> 33 ${this.getTranslatedLabel(h>0?"inStock":"notAvailable")} 34 </div> 35 36 ${h>0?(()=>{const v=l.variants.filter(b=>b.inventory>0);return v.length===1&&v[0].variantTitle==="Default Title"?"":`<div class="stock-variants"> 37 ${v.map(b=>` 38 <span class="stock-variant stock-variant__available"> 39 ${b.variantTitle} 40 </span> 41 `).join("")} 42 </div>`})():""} 43 </div> 44 `,((I=this.getCurrentStore())==null?void 0:I.title)===l.name&&y.classList.add("selected-store"),e.appendChild(y)}),t.appendChild(e)}addEventListeners(){var t,e,s,n,r,i;(t=this.drawer.overlay)==null||t.addEventListener("click",this.handlerOverlayClick),(s=(e=this.drawer.element)==null?void 0:e.querySelector(u.selectors.drawerCloseButton))==null||s.addEventListener("click",this.handlerCloseClick),(n=this.querySelector(u.selectors.buttonTrigger))==null||n.addEventListener("click",this.handlerOpenClick),(i=(r=this.drawer.element)==null?void 0:r.querySelector(u.selectors.drawerAvailableOnlyCheckbox))==null||i.addEventListener("change",this.handleAvailableOnlyChange),document.addEventListener("store-info-update",this.handleStoreUpdate)}openDrawer(){var t;if(!this.drawer.element){console.warn("StockChecker: Drawer is not initialized.");return}if(this.drawer.isOpen){console.warn("StockChecker: Drawer is already open.");return}document.body.style.overflow="hidden",this.drawer.isOpen=!0,this.drawer.element.classList.add("is-open"),(t=this.drawer.overlay)==null||t.classList.add("is-open")}closeDrawer(){var t;if(!this.drawer.element){console.warn("StockChecker: Drawer is not initialized.");return}if(!this.drawer.isOpen){console.warn("StockChecker: Drawer is already closed.");return}document.body.style.overflow="",this.drawer.isOpen=!1,this.drawer.element.classList.remove("is-open"),(t=this.drawer.overlay)==null||t.classList.remove("is-open")}toggleAvailableOnly(){var e,s;const t=(e=this.drawer.element)==null?void 0:e.querySelector(u.selectors.drawerAvailableOnlyCheckbox);this.drawer.availableOnly=t.checked,(s=this.drawer.element)==null||s.querySelectorAll(".stores-checker__location-item[data-inventory]").forEach(n=>{const r=parseInt(n.getAttribute("data-inventory")||"0",10),i=n;i.style.display=this.drawer.availableOnly&&r<=0?"none":""})}getTranslatedLabel(t){var s;const e=this.getCurrentLanguage();return(s=this.translations[e])==null?void 0:s[t]}getCurrentLanguage(){return window.location.pathname.split("/")[1]==="en"?"en":"fr"}getGeoLocation(t,e){if(!window.GeoLocationChecker)return console.warn("StockChecker: GeoLocationChecker is not initialized."),null;const s=window.GeoLocationChecker.getDistanceFromLocation(parseInt(t),parseInt(e));return s?`${s.toFixed(2)} ${this.getTranslatedLabel("distance")}`:null}getCurrentStore(){const t=document.cookie.split("; ").find(e=>e.startsWith("selected_store="));if(t){const e=t.split("=")[1];return JSON.parse(decodeURIComponent(e))}return null}updateSelectedStore(){var e,s,n;this.updateTriggerButton();const t=(s=(e=this.getCurrentStore())==null?void 0:e.title)!=null?s:"";(n=this.drawer.element)==null||n.querySelectorAll(u.selectors.drawerLocationItem).forEach(r=>{const i=r.getAttribute("data-store");t===i?r.classList.add("selected-store"):r.classList.remove("selected-store")})}};u.selectors={storesJson:"script#StoresData",buttonTrigger:".stores-checker__button",buttonText:".stores-checker__button-text",availabilityDot:".stores-checker__button-dot",drawerTemplate:"#StoresChecker-Drawer",drawerOverlay:".stores-checker__drawer
44-overlay",drawerCloseButton:".stores-checker__header-button--close",drawerAvailableOnlyCheckbox:"#StoresChecker-availableOnly",drawerContent:".stores-checker__content",drawerLocationItem:".stores-checker__location-item"};let L=u;customElements.get("stock-checker")||customElements.define("stock-checker",L);class F{constructor(t){this.productForm=null,this.variantIdInput=null,this.submitButton=null,this.isSubmitting=!1,this.config=t,this.init()}getCartElement(){return document.querySelector("cart-drawer")||document.querySelector("cart-notification")}parseInventoryData(t){if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(e){return console.warn("BuyButtons: Failed to parse inventory data:",e),null}}publishCartUpdate(t,e){return m(this,null,function*(){typeof window.publish=="function"&&(yield window.publish("cart-update",w(S({source:"buy-buttons"},e&&{productVariantId:e}),{cartData:t})))})}init(){var t,e;if(this.productForm=document.querySelector(`product-form[data-section-id="${this.config.sectionId}"]`),this.variantIdInput=(t=this.productForm)==null?void 0:t.querySelector(".product-variant-id"),this.submitButton=(e=this.productForm)==null?void 0:e.querySelector(`#ProductSubmitButton-${this.config.sectionId}`),!this.productForm||!this.variantIdInput||!this.submitButton){console.warn("BuyButtons: Required elements not found");return}this.disableProductFormHandler(),this.setupEventListeners(),this.updateButtonText(),this.interceptAddToCart()}disableProductFormHandler(){var e;const t=(e=this.productForm)==null?void 0:e.querySelector("form");t&&t.setAttribute("data-custom-handler","true")}getAvailableQuantity(t){const e=this.parseInventoryData(t);return!(e!=null&&e.locations)||!Array.isArray(e.locations)?0:e.locations.filter(n=>n.status==="available").reduce((n,r)=>n+(Number(r.qoh)||0),0)}getVariantQuantityInCart(t){return m(this,null,function*(){try{const s=yield(yield fetch("/cart.js")).json(),n={regularQty:0,preorderQty:0,regularKey:null,preorderKey:null},r=["Preorder","_Preorder","preorder","_preorder"];return s.items&&Array.isArray(s.items)&&s.items.forEach(i=>{String(i.variant_id)===String(t)&&(r.some(d=>{var c;return((c=i.properties)==null?void 0:c[d])==="true"})?(n.preorderQty+=i.quantity,n.preorderKey=i.key):(n.regularQty+=i.quantity,n.regularKey=i.key))}),n}catch(e){return console.error("BuyButtons: Failed to fetch cart:",e),{regularQty:0,preorderQty:0,regularKey:null,preorderKey:null}}})}calculateSplit(t,e,s,n){const r=t+s.regularQty;if(n)return{regularQty:t,preorderQty:0};if(e===0||s.regularQty>=e)return{regularQty:0,preorderQty:t};if(r>e){const i=Math.max(0,e-s.regularQty),a=t-i;return{regularQty:i,preorderQty:a}}return{regularQty:t,preorderQty:0}}interceptAddToCart(){if(!this.productForm)return;const t=this.productForm.querySelector("form");t&&t.addEventListener("submit",e=>m(this,null,function*(){var s,n;if(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!this.isSubmitting){this.isSubmitting=!0;try{const r=(s=this.variantIdInput)==null?void 0:s.value;if(!r)return;const i=this.config.variantData[r];if(!i)return;const a=t.querySelector('input[name="quantity"]'),d=a?Number(a.value):1,c=this.getAvailableQuantity(i.inventory_data),l=yield this.getVariantQuantityInCart(r),h=this.calculateSplit(d,c,l,(n=i.keep_selling)!=null?n:!1);yield this.addItemsToCart(r,h.regularQty,h.preorderQty,l.regularKey,l.preorderKey)}catch(r){console.error("BuyButtons: Error in interceptAddToCart:",r)}finally{this.isSubmitting=!1}}}),!0)}addOrUpdateCartItem(t,e,s,n){return m(this,null,function*(){n?yield this.updateCartLineItem(n,e):yield this.submitToCart(t,e,s)})}addItemsToCart(t,e,s,n=null,r=null){return m(this,null,function*(){try{e>0&&(yield this.addOrUpdateCartItem(t,e,!1,n)),s>0&&(yield this.addOrUpdateCartItem(t,s,!0,r)),yield this.openCartDrawer(),yield this.updateButtonText()}catch(i){throw console.error("BuyButtons: Error adding items to cart:",i),i}})}openCartDrawer(){return m(this,null,function*(){var e;yield new Promise(s=>setTimeout(s,100));const t=document.querySelector("cart-drawer");if(t)try{const n=(((e=t.getSectionsToRender)==null?void 0:e.call(t))||[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-icon-bubble",selector:".cart-count-bubble"}]).map(a=>a.id).join(","),r=yield fetch(`${window.location.pathname}?sections=${n}`);if(!r.ok)throw new Error(`Failed to fetch sections: ${r.status}`);const i=yield r.json();if(!i||Object.keys(i).length===0)throw new Error("No sections data received");t.classList.contains("is-empty")&&t.classList.remove("is-empty"),typeof t.renderContents=="function"?t.renderContents({sections:i}):typeof t.open=="function"&&t.open()}catch(s){console.error("BuyButtons: Failed to refresh cart:",s),typeof t.open=="function"&&t.open()}})}updateCartLineItem(t,e){return m(this,null,function*(){var s;try{const i=(yield(yield fetch("/cart.js")).json()).items.find(f=>f.key===t);if(!i)return;const a=i.quantity+e,d=this.getCartElement(),c=d?(s=d.getSectionsToRender)==null?void 0:s.call(d).map(f=>f.id):[],l={id:t,quantity:a};c.length>0&&(l.sections=c.join(","),l.sections_url=window.location.pathname);const h=yield fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!h.ok)throw new Error(`Cart update failed: ${h.status}`);const p=yield h.json();
44yield this.publishCartUpdate(p)}catch(n){throw console.error("BuyButtons: Failed to update line item:",n),n}})}submitToCart(t,e,s){return m(this,null,function*(){var l;const n=s?{Preorder:"true"}:{},r=this.getCartElement(),i=r?(l=r.getSectionsToRender)==null?void 0:l.call(r).map(h=>h.id):[],a=new FormData;a.append("id",t),a.append("quantity",e.toString()),Object.entries(n).forEach(([h,p])=>{a.append(`properties[${h}]`,p)}),i.length>0&&(a.append("sections",i.join(",")),a.append("sections_url",window.location.pathname));const d=yield fetch("/cart/add.js",{method:"POST",headers:{"X-Requested-With":"XMLHttpRequest"},body:a});if(!d.ok)throw new Error(`Failed to add to cart: ${d.status}`);const c=yield d.json();yield this.publishCartUpdate(c,t)})}setupEventListeners(){var s;if(!this.variantIdInput)return;new MutationObserver(n=>{n.forEach(r=>{r.type==="attributes"&&r.attributeName==="value"&&this.updateButtonText()})}).observe(this.variantIdInput,{attributes:!0,attributeFilter:["value"]}),this.variantIdInput.addEventListener("change",()=>this.updateButtonText());const e=(s=this.productForm)==null?void 0:s.querySelector('input[name="quantity"]');e&&(e.addEventListener("change",()=>this.updateButtonText()),e.addEventListener("input",()=>this.updateButtonText())),document.addEventListener("cart:updated",()=>this.updateButtonText())}updateButtonText(){return m(this,null,function*(){if(!this.variantIdInput||!this.submitButton||!this.productForm)return;const t=this.variantIdInput.value,e=this.config.variantData[t];if(!e||(this.updateStoreFinderVisibility(e),e.keep_selling))return;const s=yield this.checkIfNextAdditionIsPreorder(t,e.inventory_data);this.updatePreorderInput(s),this.updateButton(e,s),this.updatePreorderMessageVisibility(e,s)})}checkPreorderStatus(t){const e=this.parseInventoryData(t);return(e==null?void 0:e.status)==="preorder"}updateStoreFinderVisibility(t){var n,r,i,a;const e=(i=(r=(n=this.productForm)==null?void 0:n.parentElement)==null?void 0:r.querySelector("stock-checker"))!=null?i:document.querySelector("stock-checker");if(!e)return;const s=!t.keep_selling&&this.checkPreorderStatus(t.inventory_data);e.style.display=s?"none":"",(a=document.getElementById("preorder-message"))==null||a.classList.toggle("preorder-message--standalone",s)}updatePreorderMessageVisibility(t,e){const s=document.getElementById("preorder-message");if(s){if(!t.available||t.price===0){s.classList.add("disabled");return}else if(e){s.classList.remove("disabled");return}s.classList.add("disabled")}}checkIfNextAdditionIsPreorder(t,e){return m(this,null,function*(){var a;if(this.checkPreorderStatus(e))return!0;const s=this.getAvailableQuantity(e);if(s===0)return!0;const{regularQty:n}=yield this.getVariantQuantityInCart(t),r=(a=this.productForm)==null?void 0:a.querySelector('input[name="quantity"]'),i=r?parseInt(r.value||"1",10):1;return n+i>s})}updatePreorderInput(t){if(!this.productForm)return;const e=this.productForm.querySelector("form");let s=this.productForm.querySelector('input[name="properties[Preorder]"]');t?s||(s=document.createElement("input"),s.type="hidden",s.name="properties[Preorder]",s.value="true",e.appendChild(s)):s&&s.remove()}updateButton(t,e){if(!this.submitButton)return;const s=this.submitButton.querySelector("span");s&&(t.available?t.price===0?(s.textContent=this.config.translations.unavailable,this.submitButton.disabled=!0):e?(s.textContent=this.config.translations.preorder,this.submitButton.disabled=!1):(s.textContent=this.config.translations.add_to_cart,this.submitButton.disabled=!1):(s.textContent=this.config.translations.sold_out,this.submitButton.disabled=!0))}}function D(){const o=document.getElementById("preorder-message");if(!o)return;const t=o.querySelector(".preorder-message__trigger"),e=o.querySelector(".preorder-message__tooltip");if(!t||!e)return;const s=()=>{const i=!(e.getAttribute("aria-hidden")==="false");e.setAttribute("aria-hidden",String(!i)),t.setAttribute("aria-expanded",String(i)),o.classList.toggle("is-open",i)},n=()=>{e.setAttribute("aria-hidden","true"),t.setAttribute("aria-expanded","false"),o.classList.remove("is-open")};t.addEventListener("click",r=>{r.stopPropagation(),s()}),e.addEventListener("click",r=>{r.stopPropagation(),n()}),document.addEventListener("click",r=>{o.contains(r.target)||n()}),t.addEventListener("keydown",r=>{r.key==="Enter"||r.key===" "?(r.preventDefault(),s()):r.key==="Escape"&&n()})}document.addEventListener("DOMContentLoaded",()=>{const o=document.querySelector("script[data-buy-buttons-config]");if(o&&o.textContent)try{const t=JSON.parse(o.textContent);new F(t)}catch(t){console.error("BuyButtons: Failed to parse configuration:",t)}D()});class C{constructor(t){this.variants=[],this.options=[],this.currentSelections=new Map,this.element=t}init(){this.loadProductData(),this.initializeSelections(),this.filterOptions(),this.attachEventListeners()}loadProductData(){const t=this.element.querySelector("script[data-product-variants]");if(t)try{const e=t.textContent||"{}",s=JSON.parse(e);this.variants=s.variants.map(n=>{var i;return{id:((i=n.id)==null?void 0:i.toString())||"",option1:n.option1||null,option2:n.option2||null,option3:n.option3||null,available:n.available||!1}}),this.options=s.options||[]}catch(e){console.error("VariantFilter: Error parsing product data",e)}}initializeSelections(){this.element.querySelectorAll('input[type="radio"]:checked').forEach(e
44=>{const s=e,n=s.name.trim(),r=s.value,i=n.match(/-(\d+)$/);if(i){const a=parseInt(i[1]);this.currentSelections.set(a,r)}})}attachEventListeners(){this.element.addEventListener("change",t=>{const e=t.target;if(e instanceof HTMLInputElement&&e.type==="radio"){const s=e.name.trim(),n=e.value,r=s.match(/-(\d+)$/);if(r){const i=parseInt(r[1]);this.currentSelections.set(i,n),setTimeout(()=>this.filterOptions(),10)}}})}filterOptions(){this.variants.length!==0&&(this.validateAndFixSelections(),this.options.forEach((t,e)=>{const s=t.position;if(s===1){t.values.forEach(n=>{this.findInputsForValue(s,n).forEach(i=>this.showInput(i))});return}t.values.forEach(n=>{const r=this.valueExistsInVariants(s,n);this.findInputsForValue(s,n).forEach(a=>{r?this.showInput(a):this.hideInput(a)})})}))}validateAndFixSelections(){this.options.forEach(t=>{const e=t.position;if(e===1)return;const s=this.currentSelections.get(e);if(!s)return;if(!this.valueExistsInVariants(e,s)){const r=t.values.find(i=>this.valueExistsInVariants(e,i));if(r){const a=this.findInputsForValue(e,r).find(d=>d instanceof HTMLInputElement&&d.type==="radio");a&&(a.click(),this.currentSelections.set(e,r))}}})}valueExistsInVariants(t,e){return this.variants.some(n=>{if(this.getVariantOptionValue(n,t)!==e)return!1;for(const[i,a]of this.currentSelections.entries()){if(i>=t)continue;if(this.getVariantOptionValue(n,i)!==a)return!1}return!0})}getVariantOptionValue(t,e){switch(e){case 1:return t.option1;case 2:return t.option2;case 3:return t.option3;default:return null}}findInputsForValue(t,e){const s=[];return this.element.querySelectorAll('input[type="radio"]').forEach(r=>{const i=r,a=i.name.trim().match(/-(\d+)$/);if(a&&parseInt(a[1])===t&&i.value===e){s.push(i);const d=this.element.querySelector(`label[for="${i.id}"]`);d&&s.push(d)}}),s}hideInput(t){if(t instanceof HTMLInputElement){const e=this.element.querySelector(`label[for="${t.id}"]`);e&&e.style.setProperty("display","none","important"),t.style.setProperty("display","none","important")}else t.tagName,t.style.setProperty("display","none","important")}showInput(t){if(t instanceof HTMLInputElement){const e=this.element.querySelector(`label[for="${t.id}"]`);e&&e.style.removeProperty("display"),t.style.removeProperty("display")}else t.tagName,t.style.removeProperty("display")}}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",x):x();function x(){V();const o=new MutationObserver(e=>{for(const s of e)s.type==="childList"&&s.addedNodes.forEach(n=>{if(n instanceof HTMLElement){n.tagName.toLowerCase()==="variant-selects"&&new C(n).init();const r=n.querySelector("variant-selects");r&&r instanceof HTMLElement&&new C(r).init()}})}),t=document.querySelector("product-info");t?o.observe(t,{childList:!0,subtree:!0}):o.observe(document.body,{childList:!0,subtree:!0})}function V(){const o=document.querySelectorAll("variant-selects");o.length!==0&&o.forEach((t,e)=>{if(t._variantFilter)return;const s=new C(t);t._variantFilter=s,s.init()})}function _(){const o=document.querySelector('script.klaviyo_bis_translations[type="application/json"]');if(!o)return null;const t=o.textContent;if(!t)return null;try{return JSON.parse(t)}catch(e){return console.error("Invalid Klaviyo BIS translations JSON:",e),null}}function N(o){const t={};for(const[e,s]of Object.entries(o))typeof s=="string"&&(t[e]=s);return t}function $(){const o=_();if(!o)return;const d=o,{baseLang:t,targetLang:e}=d,s=k(d,["baseLang","targetLang"]),n=document.documentElement.lang||"en";if(e&&!n.startsWith(e))return;const r=document.querySelector('div[role="dialog"][aria-label="POPUP Form"]');if(!r)return;const i=N(s);function a(c,l){var h;for(const[p,f]of Object.entries(l))c.children.length===0&&((h=c.textContent)==null?void 0:h.trim())===p&&(c.textContent=f),c.children.length===0&&c.textContent&&c.textContent.includes(p)&&(c.textContent=c.textContent.replace(p,f)),c.getAttribute("aria-label")===p&&c.setAttribute("aria-label",f)}r.querySelectorAll("span, h1, label, button, div").forEach(c=>{a(c,i)}),r.querySelectorAll("input, textarea").forEach(c=>{const l=c;l.placeholder&&i[l.placeholder]&&(l.placeholder=i[l.placeholder])})}function J(){const o=_();if(!o)return;const i=o,{baseLang:t,targetLang:e}=i,s=k(i,["baseLang","targetLang"]),n=document.documentElement.lang||"en";if(e&&!n.startsWith(e))return;new MutationObserver(()=>{document.querySelector('div[role="dialog"][aria-label="POPUP Form"]')&&$()}).observe(document.body,{childList:!0,subtree:!0})}function j(){const o=_();if(!o)return;const i=o,{baseLang:t,targetLang:e}=i,s=k(i,["baseLang","targetLang"]),n=document.documentElement.lang||"en";if(e&&!n.startsWith(e))return;const r=new MutationObserver(()=>{var d;const a=document.getElementById("klaviyo-bis-button-container");if(a){const c=a.querySelector("button");if(c){const l=((d=c.textContent)==null?void 0:d.trim())||"";let h=l;(!t||t&&(!c.lang||c.lang.startsWith(t)))&&(h=s[l]||s["Notify me when back in stock"]||l),c.textContent=h,r.disconnect()}}});r.observe(document.body,{childList:!0,subtree:!0}),J()}j();
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.