1(()=>{var __webpack_exports__={};customElements.get("product-information")||customElements.define("product-information",class extends HTMLElement{constructor(){super(),this.dataCache=new Map,this.init()}init(){this.cacheDOMElements(),this.bindEventHandlers()}cacheDOMElements(){this.sectionId=this.getAttribute("data-section-id"),this.sectionFetchId=this.getAttribute("data-section-fetch-id"),this.isQuickView=this.dataset.quickView==="true",this.productForm=this.querySelector("product-form"),this.productUrl=this.dataset.url,this.elementsToUpdate=this.querySelectorAll('[data-updates-on-change="true"]'),this.formQuantityInput=this.productForm?.querySelector('[name="quantity"]'),this.stickyContainer=this.classList.contains("product-sticky")?this:null,this.stickyHeader=document.querySelector(".header-section"),this.enableURLUpdate=this.dataset.enableUrlUpdate==="true",this.variantCount=this.getVariantData().length,this.qtyErrorMessage=this.productForm?.querySelector("[data-qty-error-message]"),this.isFeaturedProduct=this.dataset.isFeaturedProduct==="true"}connectedCallback(){this.updateOptions(),this.setStickyOffset(),this.attachEventListeners()}disconnectedCallback(){this.removeEventListeners()}bindEventHandlers(){this.resizeHandler=this.handleResize.bind(this),this.onQuantityChange=this.handleQuantityChange.bind(this),this.onVariantChange=this.handleVariantChange.bind(this)}attachEventListeners(){this.addEventListener("mouseover",this.preFetchAllVariantData.bind(this),{once:!0}),this.addEventListener("touchstart",this.preFetchAllVariantData.bind(this),{once:!0}),window.addEventListener("resize",this.resizeHandler),eventBus.on("qty:change",this.onQuantityChange),eventBus.on("variant:change",this.onVariantChange)}removeEventListeners(){window.removeEventListener("resize",this.resizeHandler),eventBus.off("qty:change",this.onQuantityChange),eventBus.off("variant:change",this.onVariantChange)}preFetchAllVariantData(){if(this.variantCount<=1||this.isFeaturedProduct&&window.Shopify.designMode)return;this.getVariantData().forEach(variant=>{const fetchUrl=`${this.productUrl}?section_id=${this.sectionFetchId}&variant=${variant.id}`;this.dataCache.has(fetchUrl)||fetch(fetchUrl).then(response=>response.text()).then(data=>{this.dataCache.set(fetchUrl,data)}).catch(error=>{console.error("Error pre-fetching data for variant:",error)})})}handleResize(){window.Shopify.designMode&&this.setStickyOffset()}handleQuantityChange(event){if(this.clearErrors(),this.formQuantityInput&&event.value){if(event.sectionId&&event.sectionId!==this.sectionId)return;this.formQuantityInput.value=event.value}}setStickyOffset(){this.stickyContainer&&this.stickyHeader&&(this.stickyContainer.style.top=`${this.stickyHeader.offsetHeight}px`)}updateOptions(){this.options=Array.from(this.querySelectorAll("variant-dropdown, product-swatch")).map(element=>{if(element.tagName==="VARIANT-DROPDOWN")return element.querySelector("[data-dropdown-list]")?.querySelector("[data-dropdown-option].selected")?.getAttribute("data-option-value");if(element.tagName==="PRODUCT-SWATCH")return element.querySelector("input:checked")?.value}).filter(Boolean)}async handleVariantChange(context){if(this.variantCount<=1||context.sectionId&&context.sectionId!==this.sectionId)return;if(this.clearErrors(),this.updateOptions(),context.variant?this.currentVariant=context.variant:this.getCurrentVariant(),!this.currentVariant){this.handleInvalidVariant();return}this.toggleAddButton(this.currentVariant.available);const fetchUrl=`${this.productUrl}?section_id=${this.sectionFetchId}&variant=${this.currentVariant.id}`;this.dataCache.has(fetchUrl)&&!this.isFeaturedProduct&&!window.Shopify.designMode?this.updateFromCache(fetchUrl,context):await this.fetchAndUpdate(fetchUrl,context)}handleInvalidVariant(){this.toggleAddButton(!1);const addButton=this.productForm?.querySelector('[name="add"]');if(!addButton)return;const addButtonSpan=addButton.querySelector("[data-add-to-cart-text]");if(!addButtonSpan)return;addButtonSpan.textContent=addButtonSpan.getAttribute("data-unavailable-text");const priceElement=this.querySelector("[data-product-price]");if(!priceElement)return;const priceElementSpan=priceElement.querySelector("span[data-price-text]");priceElementSpan&&(priceElementSpan.textContent=priceElementSpan.getAttribute("data-unavailable-text"))}async fetchAndUpdate(fetchUrl,context){if(!(!fetchUrl||!this.sectionId))try{this.updateOptions(),this.enableURLUpdate&&this.updateURL();const response=await fetch(fetchUrl);if(!response.ok)throw new Error(`HTTP error! status: ${response.status}`);const responseText=await response.text();this.updateDOMWithFetchedData(responseText,context),this.dataCache.set(fetchUrl,responseText)}catch(error){console.error("Failed to update product information:",error)}}updateFromCache(fetchUrl,context){this.enableURLUpdate&&this.updateURL();const cachedData=this.dataCache.get(fetchUrl);this.updateDOMWithFetchedData(cachedData,context)}updateDOMWithFetchedData(data,context){const html=this.parseHTML(data);if(this.isQuickView){const quickViewContent=html.querySelector("template[data-quick-view-product]")?.content;this.updateDOM(quickViewContent,context)}else this.updateDOM(html,context)}parseHTML(data){return new DOMParser().parseFromString(data,"text/html")}updateDOM(html,context={}){this.replaceElements(html,context),this.formQuantityInput&&(this.formQuantityInput.value=1),!context.fromSlideChange&&eventBus.emit("variant:updated",{variant:this.currentVariant,sectionId:this.sectionId})}toggleAddButton(enable){const addButton=this.productForm?.querySelector('[name="add"]');addButton&&addButton.toggleAttribute("disabled",!enable)}updateURL(){this.currentVariant&&window.history.replaceState({},"",`${this.productUrl}?variant=${this.currentVariant.id}`)}replaceElements(html,context={}
1){if(!html||!this.elementsToUpdate.length)return;const newSection=html.querySelector(`product-information[data-section-id="${this.sectionId}"][data-url="${this.productUrl}"]`);newSection&&this.elementsToUpdate.forEach(updateBlock=>{const blockId=updateBlock.getAttribute("data-block-id"),currentBlock=this.querySelector(`[data-block-id="${blockId}"]`),newBlock=newSection.querySelector(`[data-block-id="${blockId}"]`);!blockId||!currentBlock||!newBlock||currentBlock.querySelectorAll("[data-update-item]").forEach(item=>{const itemId=item.getAttribute("data-update-item"),newItem=newBlock.querySelector(`[data-update-item="${itemId}"]`);!itemId||!newItem||item.replaceWith(newItem)})})}clearErrors(){this.qtyErrorMessage&&this.qtyErrorMessage.classList.add("hidden")}getCurrentVariant(){const variants=this.getVariantData();this.currentVariant=variants.find(variant=>variant.options.every((option,index)=>option===this.options[index]))||null}getVariantData(){if(!this.variantData){const variantContent=this.querySelector('script[type="application/json"]');this.variantData=variantContent?JSON.parse(variantContent.textContent):{}}return this.variantData}})})(); 2//# sourceMappingURL=/cdn/shop/t/31/assets/component-product-information.js.map?v=11582580954040738751732862340
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.