1if(!customElements.get("product-form")){let removeElementsByScreenSize2=function(container=document){const mobileLayout=window.matchMedia("(max-width: 990px)").matches,switchingLayout=previousMobileLayout!==void 0&&previousMobileLayout!==mobileLayout,variantStates=new Map;switchingLayout&&document.querySelectorAll(mobileLayout?".hide-mobile":".hide-desktop").forEach(block=>{const picker=block.querySelector("variant-selects, variant-radios");if(!picker)return;const section=picker.dataset.originalSection||picker.dataset.section||picker.dataset.sectionId,selected=Array.from(picker.querySelectorAll("input[type=radio]:checked, select option:checked")).map(input=>input.dataset.optionValueId).filter(Boolean),variantInput=block.querySelector('input[name="id"]'),quantity=block.querySelector('input[name="quantity"]');variantStates.set(section,{selected,variantId:variantInput?.value,quantity:quantity?.value})}),mobileLayout?(document.querySelectorAll(".hide-mobile").forEach(el=>{removedElements.desktop.push({parent:el.parentNode,element:el,nextSibling:el.nextSibling}),el.remove()}),removedElements.mobile.forEach(({parent,element,nextSibling})=>{nextSibling&&nextSibling.parentNode===parent?parent.insertBefore(element,nextSibling):parent.appendChild(element)}),removedElements.mobile=[]):(document.querySelectorAll(".hide-desktop").forEach(el=>{removedElements.mobile.push({parent:el.parentNode,element:el,nextSibling:el.nextSibling}),el.remove()}),removedElements.desktop.forEach(({parent,element,nextSibling})=>{nextSibling&&nextSibling.parentNode===parent?parent.insertBefore(element,nextSibling):parent.appendChild(element)}),removedElements.desktop=[]),previousMobileLayout=mobileLayout,switchingLayout&&document.querySelectorAll(mobileLayout?".hide-desktop":".hide-mobile").forEach(block=>{const picker=block.querySelector("variant-selects, variant-radios");if(!picker)return;const section=picker.dataset.originalSection||picker.dataset.section||picker.dataset.sectionId,state=variantStates.get(section);if(!state||!state.selected.length)return;let changeTarget;picker.querySelectorAll('input[type="radio"][data-option-value-id]').forEach(input=>{input.checked=state.selected.includes(input.dataset.optionValueId),input.checked&&(changeTarget=input)}),picker.querySelectorAll("select").forEach(select=>{const option=Array.from(select.options).find(option2=>state.selected.includes(option2.dataset.optionValueId));option&&(select.value=option.value,changeTarget=select)});const variantInput=block.querySelector('input[name="id"]');variantInput&&state.variantId&&(variantInput.value=state.variantId);const quantity=block.querySelector('input[name="quantity"]');quantity&&state.quantity&&(quantity.value=state.quantity),changeTarget&&(block.querySelectorAll('button[name="add"]').forEach(button=>{button.disabled=!0}),changeTarget.dispatchEvent(new Event("change",{bubbles:!0})))})};var removeElementsByScreenSize=removeElementsByScreenSize2;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.cart=document.querySelector("cart-notification")||document.querySelector("cart-drawer"),this.submitButton=this.querySelector('[type="submit"]'),document.querySelector("cart-drawer")&&this.submitButton.setAttribute("aria-haspopup","dialog")}refreshCartSections(){if(!this.cart)return Promise.resolve();const sectionIds=this.cart.getSectionsToRender().map(s=>s.id).join(","),url=`${window.routes.cart_url}?sections=${sectionIds}§ions_url=${encodeURIComponent(window.location.pathname)}`;return fetch(url,{headers:{"X-Requested-With":"XMLHttpRequest"}}).then(r=>r.json()).then(sections=>{this.cart.renderContents({sections}),publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form"})}).catch(e=>console.error(e))}onSubmitHandler(evt){if(evt.preventDefault(),this.submitButton.getAttribute("aria-disabled")==="true")return;this.handleErrorMessage(),this.submitButton.setAttribute("aria-disabled",!0);const config=fetchConfig("javascript");config.headers["X-Requested-With"]="XMLHttpRequest",delete config.headers["Content-Type"];const formData=new FormData(this.form);this.cart&&(formData.append("sections",this.cart.getSectionsToRender().map(section=>section.id)),formData.append("sections_url",window.location.pathname),this.cart.setActiveElement(document.activeElement)),config.body=formData,fetch(`${routes.cart_add_url}`,config).then(response=>response.json()).then(response=>{if(response.status){this.handleErrorMessage(response.description);const soldOutMessage=this.submitButton.querySelector(".sold-out-message");if(soldOutMessage&&(this.submitButton.setAttribute("aria-disabled",!0),this.submitButton.querySelector("span")?.classList.add("hidden"),soldOutMessage.classList.remove("hidden")),this.error=!0,!this.cart){const cartUrl=window.routes?.cart_url||"/cart";window.location.pathname===cartUrl?window.location.reload():window.location.href=cartUrl;return}if(response.sections)this.cart.renderContents(response),publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form"});else return this.refreshCartSections();return}if(!this.cart){window.location=window.routes.cart_url;return}this.error||publish(PUB_SUB_EVENTS.cartUpdate,{source:"product-form"}),this.error=!1;const quickAddModal=this.closest("quick-add-modal");quickAddModal?(document.body.addEventListener("modalClosed",()=>{setTimeout(()=>{this.cart.renderContents(response)})},{once:!0}),quickAddModal.hide(!0),typeof AOS<"u"&&AOS.init()):(this.cart.renderContents(response),typeof AOS<"u"&&AOS.init())}).catch(e=>{console.error(e)}).finally(()=>{this.submitButton.classList.remove("loading"),this.cart&&this.cart.classList.contains("is-empty")&&this.cart.classList.remove("is-empty"),this.error||this.submitButton.removeAttribute("aria-disabled"),typeof AOS<"u"&&AOS.init()})}handleErrorMessage(errorMessage=!1){if(!this.hideErrors&&(this.errorMessageWrapper=this.errorMessageWrapper||this.querySelector(".product-form__error-message-wrapper"),!!this.errorMessageWrapper&&(this.errorMessage=this.errorMessage||this.errorMessageWrapper.querySelector(".product-form__error-message"),this.errorMessageWrapper.toggleAttribute("hidden",!errorMessage),errorMessage)))if(typeof errorMessage=="object"){const formattedMessage=Object.entries(errorMessage).map(([field,messages])=>`${field}: ${messages.join(", ")}`).join(" | ");this.errorMessage.textContent=formattedMessage}else this.errorMessage.textContent=errorMessage}});let removedElements={mobile:[],desktop:[]},previousMobileLayout;removeElementsByScreenSize2(),window.addEventListener("resize",removeElementsByScreenSize2),window.addEventListener("shopify:section:select",removeElementsByScreenSize2)}class StickyAddToCart extends HTMLElement{constructor(){super(),this._handleResize=this._debounce(this.initStickyAddToCart.bind(this),200)}connectedCallback(){this.initStickyAddToCart(),window.addEventListener("resize",this._handleResize)}disconnectedCallback(){window.removeEventListener("resize",this._handleResize)}initStickyAddToCart(){const img=this.querySelector(".product-content img"),selectField=this.querySelector('select[name="id"]'),addButton=this.querySelector('button[name="add"]'),productForm=d
1ocument.querySelector(".product-form");if(!selectField||!addButton||!productForm)return;const addToCartText=addButton.getAttribute("data-add-to-cart"),soldOutText=addButton.getAttribute("data-sold-out"),checkVisibility=()=>{const formRect=productForm.getBoundingClientRect(),footerRect=document.querySelector("footer")?.getBoundingClientRect(),isOutOfView=formRect.bottom<=0,isFooterVisible=footerRect&&footerRect.top<window.innerHeight;isOutOfView&&!isFooterVisible?(this.classList.add("show"),document.documentElement.style.paddingBottom=`${this.clientHeight}px`):(this.classList.remove("show"),document.documentElement.style.paddingBottom="0")};checkVisibility(),window.addEventListener("scroll",checkVisibility),selectField.addEventListener("change",()=>{const selectedOption=selectField.options[selectField.selectedIndex];selectedOption.dataset.img&&img.setAttribute("src",selectedOption.dataset.img),selectedOption.getAttribute("data-available")==="false"?(addButton.setAttribute("disabled","true"),addButton.querySelector("span").textContent=soldOutText):(addButton.removeAttribute("disabled"),addButton.querySelector("span").textContent=addToCartText)}),document.querySelector('.product-form [name="id"]')?.addEventListener("change",e=>{const value=Number(e.target.value);value&&(selectField.value=value)})}_debounce(func,wait){let timeout;return(...args)=>{clearTimeout(timeout),timeout=setTimeout(()=>func.apply(this,args),wait)}}}customElements.define("sticky-add-to-cart",StickyAddToCart);class IngredientDetails extends HTMLElement{constructor(){super()}connectedCallback(){let content=this.innerHTML;content=content.replace(/<\/?p>/g,""),content=content.replace(/<br\s*\/?>/g,"|||BR|||");let rows=content.split("|||BR|||").map(row=>row.trim()).filter(row=>row.length>0);this.innerHTML="",rows.forEach((row,index)=>{setTimeout(()=>{let isIndented=!1;row.startsWith("-")&&(row=row.substring(1).trim(),isIndented=!0);const useAlternativeFormat=document.querySelector("[data-ingredient-format]").dataset.ingredientFormat==="true";let columns=row.split(useAlternativeFormat?"#":",").map(col=>col.trim()),rowElement=document.createElement("span");rowElement.classList.add("ingredient-details-content"),isIndented&&rowElement.classList.add("indented"),columns.forEach(col=>{let colElement=document.createElement("span");colElement.innerHTML=col,rowElement.appendChild(colElement)}),this.appendChild(rowElement)},index*30)})}}customElements.define("ingredient-details",IngredientDetails); 2//# sourceMappingURL=/cdn/shop/t/20/assets/product-form.js.map?v=157882950554862864801791385452
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.