1async function _removeExpeditedShipping(){try{const expeditedCheckbox=document.querySelector("#expedited-shipping-checkbox-");expeditedCheckbox&&(expeditedCheckbox.checked=!1),await Shopify.Cart.GiftWrap.processGiftWrappingForCartItem(null,!0,null,!0)}catch(e){console.error("Error forcing expedited shipping off",e)}}async function _removeDiscreetPackaging(){try{const discreetCheckbox=document.querySelectorAll("#gift-wrapping-checkbox-");console.log("running"),discreetCheckbox&&discreetCheckbox.forEach(item=>item.checked=!1),await Shopify.Cart.GiftWrap.processGiftWrappingForCartItem(null,!0,null,!0)}catch(e){console.error("Error forcing discreet packaging off",e)}}function showCombinedModal(){return new Promise(resolve=>{const modal=document.querySelector("[data-es-dp-conflict-modal]");if(console.log(modal,"mooodal"),!modal){resolve(!0);return}const btnContinue=modal.querySelector("[data-es-dp-continue]"),btnCancel=modal.querySelector("[data-es-dp-cancel]"),backdrop=modal.querySelector(".modal-backdrop, .modal-dialog");function cleanup(){modal.classList.remove("open");try{siteOverlay.prototype.hideOverlay()}catch{}btnContinue&&btnContinue.removeEventListener("click",onContinue),btnCancel&&btnCancel.removeEventListener("click",onCancel),document.removeEventListener("keydown",onKeydown)}function onContinue(){btnContinue.classList.add("loading"),resolve(!0)}function onCancel(){cleanup(),resolve(!1)}function onKeydown(e){e.key==="Escape"&&onCancel()}btnContinue&&btnContinue.addEventListener("click",onContinue),btnCancel&&btnCancel.addEventListener("click",onCancel),document.addEventListener("keydown",onKeydown),modal.classList.add("open");try{siteOverlay.prototype.showOverlay()}catch{}})}async function combinedCheckAndMaybeRemoveFromCart(){const esConfig=window.EXPEDITED_SHIPPING_PRODUCT,gwConfig=window.GIFT_WRAPPING_PRODUCT;if(!esConfig||!gwConfig)return!0;const cart=await(await fetch("/cart.js")).json(),hasExpedited=cart.items.some(item=>item.product_id===esConfig.productId||item.id===esConfig.variantId),hasDiscreet=cart.items.some(item=>item.product_id===gwConfig.productId||item.id===gwConfig.variantId);if(hasExpedited&&hasDiscreet){if(!await showCombinedModal())return!1;typeof _removeExpeditedShipping=="function"&&await _removeExpeditedShipping(),typeof _removeDiscreetPackaging=="function"&&await _removeDiscreetPackaging()}return!0}function showExpeditedModal(){return new Promise(resolve=>{const modal=document.getElementById("expedited-modal");if(!modal){resolve(!0);return}const btnContinue=modal.querySelector("[data-expedited-continue]"),btnCancel=modal.querySelector("[data-expedited-cancel]"),backdrop=modal.querySelector(".expedited-modal__backdrop");function cleanup(){modal.classList.remove("open");try{siteOverlay.prototype.hideOverlay()}catch{}btnContinue&&btnContinue.removeEventListener("click",onContinue),btnCancel&&btnCancel.removeEventListener("click",onCancel),backdrop&&backdrop.removeEventListener("click",onCancel),document.removeEventListener("keydown",onKeydown)}function onContinue(){btnContinue.classList.add("loading"),resolve(!0)}function onCancel(){cleanup(),resolve(!1)}function onKeydown(e){e.key==="Escape"&&onCancel()}btnContinue&&btnContinue.addEventListener("click",onContinue),btnCancel&&btnCancel.addEventListener("click",onCancel),backdrop&&backdrop.addEventListener("click",onCancel),document.addEventListener("keydown",onKeydown),modal.classList.add("open");try{siteOverlay.prototype.showOverlay()}catch{}})}async function expeditedCheckAndMaybeRemoveFromCart(){const config=window.EXPEDITED_SHIPPING_PRODUCT;if(!config)return!0;const{productId:esProductId,variantId:esVariantId}=config;if(!(await(await fetch("/cart.js")).json()).items.some(item=>item.product_id===esProductId||item.id===esVariantId))return!0;if(!await showExpeditedModal())return!1;if(typeof _removeExpeditedShipping=="function")await _removeExpeditedShipping();else try{await Shopify.Cart.GiftWrap.processGiftWrappingForCartItem(null,!0,null,!0)}catch(e){console.error("Expedited removal fallback failed",e)}return!0}function showDiscreetModal(){return new Promise(resolve=>{const modal=document.querySelector("[data-discreet-conflict-modal]");if(!modal){resolve(!0);return}const btnContinue=modal.querySelector("[data-discreet-continue]"),cancelButtons=modal.querySelectorAll("[data-discreet-cancel]"),backdrop=modal.querySelector(".modal-backdrop, .expedited-modal__backdrop");function cleanup(){modal.classList.remove("open");
1try{siteOverlay.prototype.hideOverlay()}catch{}btnContinue&&btnContinue.removeEventListener("click",onContinue),cancelButtons.forEach(btn=>btn.removeEventListener("click",onCancel)),backdrop&&backdrop.removeEventListener("click",onCancel),document.removeEventListener("keydown",onKeydown)}function onContinue(){btnContinue.classList.add("loading"),resolve(!0)}function onCancel(){cleanup(),resolve(!1)}function onKeydown(e){e.key==="Escape"&&onCancel()}btnContinue&&btnContinue.addEventListener("click",onContinue),cancelButtons.forEach(btn=>btn.addEventListener("click",onCancel)),backdrop&&backdrop.addEventListener("click",onCancel),document.addEventListener("keydown",onKeydown),modal.classList.add("open");try{siteOverlay.prototype.showOverlay()}catch{}})}async function discreetCheckAndMaybeRemoveFromCart(){const config=window.GIFT_WRAPPING_PRODUCT;if(!config)return!0;const{productId:giftProductId,variantId:giftVariantId}=config;if(!(await(await fetch("/cart.js")).json()).items.some(item=>item.product_id===giftProductId||item.id===giftVariantId))return!0;if(!await showDiscreetModal())return!1;if(typeof _removeDiscreetPackaging=="function")await _removeDiscreetPackaging();else try{await Shopify.Cart.GiftWrap.processGiftWrappingForCartItem(null,!0,null,!0)}catch(e){console.error("Discreet packaging fallback removal failed",e)}return!0}class ProductForm extends HTMLElement{constructor(){super(),this.form=this.querySelector("form"),this.form&&(this.form.addEventListener("submit",this.onSubmitHandler.bind(this)),this.cartElement=document.querySelector("ajax-cart"),this.sparePartsCheck(),this.qtyBtns=this.querySelectorAll("[data-qty-btn]"),this.qtyBtns.forEach(qtyBtn=>qtyBtn.addEventListener("click",this.manageQtyBtn.bind(this))))}sparePartsCheck(){const sparePartsContainer=this.closest(".js-spareParts");if(sparePartsContainer){let addEl=sparePartsContainer.querySelectorAll(".js-spareAdd");sparePartsContainer.querySelectorAll(".js-spareInput").forEach(spareParts=>{spareParts.addEventListener("change",()=>{sparePartsContainer.querySelectorAll('.js-spareInput[type="checkbox"]:checked').length>0?addEl.forEach(add=>add.removeAttribute("disabled")):addEl.forEach(add=>add.setAttribute("disabled",!0))})})}}_pixelsEvent(addedItems){try{addedItems.map(addedItem=>{const props=addedItem.properties,qtyAdded=parseFloat(addedItem.quantity);props.product_handle!==void 0&&fetch(`${window.location.origin}/products/${props.product_handle}.json`).then(res=>res.clone().json().then(r=>{if(r.product){const product=r.product,variant=product.variants.find(v=>v.id===parseInt(props.product_id));let variantTitle="";product.variants.length>1&&(variant.option1&&(variantTitle+=" - "+variant.option1),variant.option2&&(variantTitle+=" - "+variant.option2),variant.option3&&(variantTitle+=" - "+variant.option3));let atcEventData={name:`${product.title}${variantTitle}`,productID:variant.id,url:`${window.location.origin}/products/${addedItem.properties.product_handle}?variant=${variant.id}`,imageURL:product.image?product.image.src:"",price:`$${variant.price}`,compareAtPrice:`${variant.compare_at_price?`$${variant.compare_at_price}`:""}`,brand:product.vendor,categories:product.product_type};window.klaviyo.push(["track","Added to Cart",atcEventData]);const bingEventData={ecomm_prodid:[atcEventData.productID],ecomm_pagetype:"product",currency:"USD",event_category:atcEventData.categories,event_label:atcEventData.name,event_value:parseFloat(variant.price),items:[{id:atcEventData.productID,quantity:qtyAdded,price:parseFloat(variant.price)}]};window.uetq=window.uetq||[],window.uetq.push("event","add_to_cart",bingEventData)}}))})}catch{}}async onSubmitHandler(evt){evt.preventDefault();const addItems=[],addOnItems=[],submitButton=this.querySelector('[type="submit"]'),submitSubscription=this.querySelector(".js-subscribe"),subscribe=evt.submitter.classList.contains("js-subscribe"),qtyInput=this.querySelector("[data-qty-input]"),pdpContainer=this.closest(".product-details-wrapper"),sparePartsContainer=this.closest(".js-spareParts"),directCheckout=submitButton.dataset.directCheckout==="true";let replacementNote,cartNote=window.globalVariables.cart.note,replacementButtons;if(!await combinedCheckAndMaybeRemoveFromCart()||!await expeditedCheckAndMaybeRemoveFromCart()||!await discreetCheckAndMaybeRemoveFromCart())return;try{let verifyEmail=this.querySelector("#rc_gift_recipient_email_confirm"),email=this.querySelector("#rc_gift_recipient_email");if(verifyEmail.value!==email.value){verifyEmail.classList.add("error-border");return}}catch{}if(subscribe?(submitSubscription.setAttribute("disabled",!0),submitSubscription.classList.add("loading")):(submitButton.setAttribute("disabled",!0),submitButton.classList.add("loading")),sparePartsContainer||(subscribe?addItems.push(JSON.parse(serializeForm(this.form))):addItems.push(JSON.parse(serializeForm(this.form,"selling_plan")))),pdpContainer&&pdpContainer.querySelectorAll("[data-addon-selection]:checked").forEach(addOn=>
1{if(addOn.disabled==!1){let addOnParent=addOn.closest("addons-form"),addOnJSON={id:addOnParent.querySelector(".variant--id").value,quantity:addOnParent.querySelector(".product-quantity").value};addItems.push(addOnJSON)}}),sparePartsContainer){let spareParts=sparePartsContainer.querySelectorAll("[data-spare-parts]:checked"),spareTitle=sparePartsContainer.querySelector("form").getAttribute("data-title");replacementButtons=document.querySelectorAll(".js-spareAdd"),replacementNote=document.querySelector("#replacement").value||"",spareParts.forEach(sparePart=>{if(sparePart.disabled==!1){let addOnJSON={id:sparePart.value,quantity:"1",properties:{_replacement_parts:spareTitle}};addItems.push(addOnJSON)}})}window.globalVariables.cart.note?.includes(replacementNote)||(cartNote=replacementNote);const body=JSON.stringify({items:addItems,note:cartNote});fetch(`${routes.cart_add_url}`,{...fetchConfig(),body}).then(response=>response.json()).then(parsedState=>{this._pixelsEvent(addItems),directCheckout?window.location.href="/checkout":this.cartElement.getCartData("open_drawer"),qtyInput&&(qtyInput.value=1)}).catch(e=>{console.error(e)}).finally(()=>{subscribe?(submitSubscription.removeAttribute("disabled"),submitSubscription.classList.remove("loading")):(submitButton.removeAttribute("disabled"),submitButton.classList.remove("loading"));try{replacementButtons.forEach(button=>{button.classList.remove("loading")})}catch{}try{document.querySelectorAll(".modal.open").forEach(ele=>{ele.classList.remove("open")})}catch{}})}manageQtyBtn(event){event.preventDefault();let currentTarget=event.currentTarget,action=currentTarget.dataset.for||"increase",qtyContainer=currentTarget.closest("[data-qty-container]"),qtyInput=qtyContainer.querySelector("[data-qty-input]"),currentQty=parseInt(qtyInput.value)||1,finalQty=currentQty;if(action=="decrease"){if(currentQty<=1)return!1;finalQty=currentQty-1}else action=="increase"&&(finalQty=currentQty+1);qtyInput.value=finalQty,this.updateDecreaseButtonState(qtyContainer,finalQty)}updateDecreaseButtonState(qtyContainer,quantity){const decreaseBtn=qtyContainer.querySelector('[data-for="decrease"]');quantity<=1?decreaseBtn.classList.add("disabled"):decreaseBtn.classList.remove("disabled")}}customElements.define("product-form",ProductForm);class VariantSelects extends HTMLElement{constructor(){super(),this.form=this.closest("form")||this.closest(".form-element"),this.formType=this.form.dataset.format,this.addBtn=this.form.querySelector('[name="add"]'),this.notify_me=this.form.querySelector(".notify-me-btn"),this.variant_json=this.form.querySelector("[data-variantJSON]"),this.variantPicker=this.dataset.type,this.formType=="product-page"&&this.onVariantChange("load"),this.addEventListener("change",this.onVariantChange.bind(this))}onVariantChange(event){if(this.setCurrentVariant(),this.formType==="product-page"){window.globalVariables.product.currentVariant=this.currentVariant;const productSKU=document.querySelector('[name="product_sku"]');console.log("variant has changed"),productSKU&&(productSKU.value=this.currentVariant.sku)}if(!this.currentVariant)this.toggleAddButton("disable"),this.form.querySelectorAll("[data-optionindex]").forEach(option=>{let lableID="option"+option.dataset.optionindex;const selectedValue=option.querySelector('input[type="radio"]:checked'),lable=option.querySelector(".selected-option");!lable||!lableID||!selectedValue||(lable.innerHTML=selectedValue.value)});else{if(this.formType=="grid"){const productGrid=this.closest("[data-product-grid]");this.renderProductInfo(this.currentVariant,productGrid),this._updateLinks(productGrid)}else{const productPage=this.closest("[data-product-container]");this.renderProductInfo(this.currentVariant,productPage)}this.updateURLandID(this.currentVariant),this.toggleAddButton("enable")}}_updateLinks(productGrid){if(!this.currentVariant||!productGrid)return;const variantURL="?variant="+this.currentVariant.id;productGrid.querySelectorAll(".product-link").forEach(link=>{let href=link.href.split("?")[0];link.href=href+variantURL})}_getOptionsFromSelect(){let options=[];return this.querySelectorAll(".variant_selector").forEach(selector=>{options.push(selector.value)}),options}_getOptionsFromRadio(){return Array.from(this.querySelectorAll("fieldset:not(.addon-fieldset)")).map(fieldset=>Array.from(fieldset.querySelectorAll("input:not(.addon-swatch)")).find(radio=>radio.checked).value)}setCurrentVariant(){this.currentVariant=!1;let options=this.variantPicker=="variant-select"?this._getOptionsFromSelect():this._getOptionsFromRadio();this._getVariantData().find(variant=>{if(!variant.options.map((option,index)=>options[index]===option).includes(!1)){this.currentVariant=variant;return}})}updateURLandID(currentVariant){if(!currentVariant)return;if(this.formType==="product-page"){const url=new URL(window.location.href);
1url.searchParams.set("variant",currentVariant.id),this.dataset?.url&&(url.pathname=new URL(this.dataset.url,url.origin).pathname),window.history.replaceState({},"",url.toString())}const input=this.form.querySelector('input[name="id"]');input.value=currentVariant.id;let sku=this.form.querySelector('input[name="product_sku"]');sku&&(sku.value=currentVariant.sku);let currentVariantID=this.form.querySelector('input[name="_product_id"]');currentVariantID&&(currentVariantID.value=currentVariant.id);let product_sku=this.form.querySelector('input[name="properties[product_sku]"]');product_sku&&(product_sku.value=currentVariant.sku);let product_id=this.form.querySelector('input[name="properties[_product_id]"]');product_id&&(product_id.value=currentVariant.id)}renderProductInfo(currentVariant,container){if(!currentVariant||!container)return;let price=Shopify.formatMoney(currentVariant.price,window.globalVariables.money_format),compare_price=Shopify.formatMoney(currentVariant.compare_at_price,window.globalVariables.money_format),priceElement=container.querySelector("[data-currentPrice]"),comparePriceElement=container.querySelector("[data-comparePrice]");if(priceElement&&(priceElement.innerHTML=price),comparePriceElement&&(comparePriceElement.innerHTML=compare_price,currentVariant.compare_at_price<=0?comparePriceElement.style.display="none":comparePriceElement.style.display="block"),this.form.querySelectorAll("[data-optionindex]").forEach(option=>{let lableID="option"+option.dataset.optionindex;const lable=option.querySelector(".selected-option");!lable||!lableID||(lable.innerHTML=currentVariant[lableID])}),this.formType=="grid"){if(!currentVariant.featured_image)return;const featuredImage=container.querySelector("[data-feauredImage]");let updatedSrc=currentVariant.featured_image.src;updatedSrc&&(featuredImage.src=updatedSrc,featuredImage.srcset=updatedSrc)}else{if(!currentVariant.featured_image)return;let imageID=currentVariant.featured_media.id,imageSlide=document.querySelector(`.product--media[data-mediaID="${imageID}"]`);if(!imageSlide)return;let slideIndex=Array.from(imageSlide.parentNode.children).indexOf(imageSlide);productSlider&&productSlider.slideTo(slideIndex,2e3,!0)}}toggleAddButton(status){this.addBtn&&(status=="disable"?(this.addBtn.setAttribute("disabled",!0),this.addBtn.querySelector(".add-text")&&(this.addBtn.querySelector(".add-text").textContent=window.variantStrings.unavailable),this.notify_me&&(this.addBtn.classList.remove("d-none"),this.notify_me.classList.add("d-none"))):this.currentVariant&&!this.currentVariant.available?(this.addBtn.setAttribute("disabled",!0),this.addBtn.querySelector(".add-text"),this.addBtn.querySelector(".add-text").textContent=window.variantStrings.soldOut,this.notify_me&&(this.addBtn.classList.add("d-none"),this.notify_me.classList.remove("d-none"))):(this.addBtn.removeAttribute("disabled"),this.addBtn.querySelector(".add-text").textContent=window.variantStrings.addToCart,this.notify_me&&(this.addBtn.classList.remove("d-none"),this.notify_me.classList.add("d-none"))))}_getVariantData(){return this.variantData=this.variantData||JSON.parse(this.variant_json.textContent),this.variantData}}customElements.define("variant-selects",VariantSelects);class VariantRadios extends VariantSelects{constructor(){super(),this.form=this.closest("form")||this.querySelector(".form-element"),this.formType=this.form.dataset.format;const colorSwatchContainer=this.querySelector(".color-swatch");colorSwatchContainer&&colorSwatchContainer.querySelectorAll(".swatch").forEach(swatch=>{let colorHandle=swatch.querySelector('input[type="radio"]').dataset.handle,swatchStyle=Utility.getSwatchStyle(colorHandle);swatch.querySelector(".swatch-label").setAttribute("style",swatchStyle)})}}customElements.define("variant-radios",VariantRadios); 2//# sourceMappingURL=/cdn/shop/t/704/assets/component-product-form.js.map?v=158202764024738821131766007237
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.