1customElements.get("product-form")||customElements.define("product-form",class extends HTMLElement{constructor(){super(),this.form=this.querySelector("form"),this.form.querySelector("[name=id]").disabled=!1,this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cartNotification=document.querySelector("cart-notification"),this.buttonStickyComponent=document.querySelector("button-sticky-component"),this.upsellComponent=document.querySelector("upsell-component"),this.upsellComponent!==null&&this.upsellComponent!==void 0&&this.upsellComponent.querySelector('[type="button"]').addEventListener("click",this.onSubmitBundle.bind(this))}onSubmitHandler(evt){evt.preventDefault();const submitButton=this.querySelector('[type="submit"]');if(submitButton.classList.contains("loading"))return;if(this.handleErrorMessage(),this.cartNotification.setActiveElement(document.activeElement),submitButton.setAttribute("aria-disabled",!0),submitButton.classList.add("loading"),this.querySelector(".loading-overlay__spinner").classList.remove("hidden"),this.buttonStickyComponent!==null&&this.buttonStickyComponent!==void 0){const submitStickyButton=this.buttonStickyComponent.querySelector('[type="submit"]');if(submitStickyButton.classList.contains("loading"))return;submitStickyButton.setAttribute("aria-disabled",!0),submitStickyButton.classList.add("loading"),this.buttonStickyComponent.querySelector(".loading-overlay__spinner").classList.remove("hidden")}const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form);formData.append("sections",this.cartNotification.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),config.body=formData,fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){this.handleErrorMessage(response.description);return}this.cartNotification.renderContents(response)}).catch(e=>{console.error(e)}).finally(()=>{submitButton.classList.remove("loading"),submitButton.removeAttribute("aria-disabled"),this.querySelector(".loading-overlay__spinner").classList.add("hidden"),this.buttonStickyComponent!==null&&this.buttonStickyComponent!==void 0&&(this.buttonStickyComponent.querySelector('[type="submit"]').classList.remove("loading"),this.buttonStickyComponent.querySelector('[type="submit"]').removeAttribute("aria-disabled"),this.buttonStickyComponent.querySelector(".loading-overlay__spinner").classList.add("hidden"))})}onSubmitBundle(evt){evt.preventDefault();const submitButton=this.upsellComponent.querySelector('[type="button"]');if(submitButton.classList.contains("loading"))return;this.handleErrorUpsellMessage(),this.cartNotification.setActiveElement(document.activeElement),submitButton.setAttribute("aria-disabled",!0),submitButton.classList.add("loading"),this.upsellComponent.querySelector(".loading-overlay__spinner").classList.remove("hidden");const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",this.formData={items:[JSON.parse(serializeForm(this.form))]};const listCheckbox=this.upsellComponent.querySelectorAll("[data-upsell-checkbox]:checked");Array.from(listCheckbox).find((checkbox,index)=>{this.formData.items[index+1]={id:checkbox.value,quantity:1}}),config.body=JSON.stringify({...this.formData,sections:this.cartNotification.getSectionsToRender().map(section=>section.id),sections_url:window.location.pathname}),fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){this.handleErrorUpsellMessage(response.description);return}this.cartNotification.renderUpsellContents(response)}).catch(e=>{console.error(e)}).finally(()=>{submitButton.classList.remove("loading"),submitButton.removeAttribute("aria-disabled"),this.upsellComponent.querySelector(".loading-overlay__spinner").classList.add("hidden")})}handleErrorMessage(errorMessage=!1){this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorMessage.textContent=errorMessage)}handleErrorUpsellMessage(errorMessage=!1){this.errorUpsellMessageWrapper=this.errorUpsellMessageWrapper||this.upsellComponent.querySelector(".product-upsell__error-message-wrapper"),this.errorUpsellMessage=this.errorUpsellMessage||this.errorUpsellMessageWrapper.querySelector(".product-upsell__error-message"),this.errorUpsellMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage&&(this.errorUpsellMessage.textContent=errorMessage)}}); 2//# sourceMappingURL=/cdn/shop/t/32/assets/product-form.js.map?v=58591186242365199751754053374
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.