1const KLAVIYO_ENDPOINT="https://a.klaviyo.com/client/back-in-stock-subscriptions/",KLAVIYO_REVISION="2024-02-15";function clearDialogAnimationLeftovers(dialog){dialog.style.removeProperty("opacity"),dialog.shadowRoot?.querySelectorAll('[part~="content"], [part~="overlay"]').forEach(part=>{part.style.removeProperty("transform"),part.style.removeProperty("opacity")})}customElements.get("variant-selection")||customElements.define("variant-selection",class extends HTMLElement{connectedCallback(){if(this.picker=this.closest("variant-picker"),!this.picker)return;new URL(window.location.href).searchParams.has("variant")&&this.picker.removeAttribute("data-unselected"),this.abortController=new AbortController;const{signal}=this.abortController;document.addEventListener("submit",this.onSubmit.bind(this),{capture:!0,signal}),document.addEventListener("click",this.onDocumentClick.bind(this),{capture:!0,signal}),this.picker.addEventListener("change",this.clearErrors.bind(this),{signal}),this.watchPopovers(),window.matchMedia("(min-width: 1000px)").addEventListener("change",this.closeDropdowns.bind(this),{signal})}watchPopovers(){document.querySelectorAll(".variant-picker__popover").forEach(popover=>{popover.dataset.homeWatch!=="true"&&(popover.dataset.homeWatch="true",popover.addEventListener("dialog:after-hide",()=>this.sendPopoverHome(popover)),popover.addEventListener("dialog:before-show",()=>clearDialogAnimationLeftovers(popover))),popover.parentElement===document.body&&(popover.hasAttribute("open")?popover.hide():this.sendPopoverHome(popover))})}sendPopoverHome(popover){if(popover.parentElement!==document.body)return;const home=document.querySelector(`[aria-controls="${CSS.escape(popover.id)}"]`)?.parentElement;if(!home||home.querySelector(`:scope > #${CSS.escape(popover.id)}`)){popover.remove();return}home.appendChild(popover)}closeDropdowns(){document.querySelectorAll(".variant-picker__popover[open]").forEach(popover=>{typeof popover.hide=="function"&&(popover.addEventListener("dialog:after-hide",()=>{document.querySelector("x-popover[open], x-modal[open], x-drawer[open]")||document.documentElement.classList.remove("lock")},{once:!0}),popover.hide())})}disconnectedCallback(){this.abortController?.abort()}get isUnselected(){return this.picker.hasAttribute("data-unselected")}get formId(){return this.getAttribute("form-id")}onSubmit(event){event.target.getAttribute("id")===this.formId&&this.isUnselected&&this.reportMissingSelection()&&(event.preventDefault(),event.stopImmediatePropagation())}onDocumentClick(event){if(!this.isUnselected||!event.target.closest(`#${CSS.escape(this.formId)}`))return;const isCheckoutButton=!!event.target.closest(".shopify-payment-button"),isSubmitButton=!!event.target.closest('[type="submit"]');!isCheckoutButton&&!isSubmitButton||this.reportMissingSelection()&&(event.preventDefault(),event.stopImmediatePropagation())}reportMissingSelection(){const option=Array.from(this.picker.querySelectorAll(".variant-picker__option")).find(element=>!element.querySelector("input[data-option-position]:checked"));if(!option)return!1;const error=option.querySelector(".variant-picker__error"),trigger=option.querySelector("button.select[aria-controls]");return error&&(error.hidden=!1),trigger&&(trigger.focus(),trigger.getAttribute("aria-expanded")==="false"&&trigger.click()),!0}clearErrors(){this.picker.querySelectorAll(".variant-picker__error:not([hidden])").forEach(error=>error.hidden=!0)}}),customElements.get("notify-me")||customElements.define("notify-me",class extends HTMLElement{connectedCallback(){this.variants=this.parseVariants(),this.form=this.querySelector("[data-notify-form]"),this.titleElement=this.querySelector("[data-notify-variant-title]"),this.dateElement=this.querySelector("[data-notify-date]"),this.dateValueElement=this.querySelector("[data-notify-date-value]"),this.messageElement=this.querySelector("[data-notify-message]"),this.selectToggle=this.querySelector("[data-notify-select-toggle]"),this.selectList=this.querySelector("[data-notify-select-list]"),this.modal=this.querySelector("x-modal"),this.abortController=new AbortController;const{signal}=this.abortController;document.addEventListener("click",this.onNotifyClick.bind(this),{signal}),this.form?.addEventListener("submit",this.onSubmit.bind(this),{signal}),this.selectToggle?.addEventListener("click",this.toggleSelect.bind(this),{signal}),this.selectList?.addEventListener("click",this.onSelectChoice.bind(this),{signal}),this.modal?.addEventListener("dialog:before-show",()=>clearDialogAnimationLeftovers(this.modal),{signal})}disconnectedCallback(){this.abortController?.abort()}parseVariants(){try{return JSON.parse(this.querySelector("[data-notify-variants]")?.textContent||"{}")}catch{return{}}}get isNotRestocking(){return this.hasAttribute("not-restocking")}onNotifyClick(event){const trigger=event.target.closest(`[aria-controls="${CSS.escape(this.getAttribute("modal-id"))}"]`);if(!trigger)return;const variantId=trigger.getAttribute("data-notify-variant");if(variantId){this.setVariant(variantId);const popover=trigger.closest("x-popover");typeof popover?.hide=="function"&&popover.hide()}else this.variantId||this.setVariant(Object.keys(this.variants)[0]);this.closeSelect()}toggleSelect(){this.selectToggle.getAttribute("aria-expanded")==="true"?this.closeSelect():(this.selectToggle.setAttribute("aria-expanded","true"),this.selectList.hidden=!1)}closeSelect(){this.selectToggle?.setAttribute("aria-expanded","fal
1se"),this.selectList&&(this.selectList.hidden=!0)}onSelectChoice(event){const option=event.target.closest("[data-notify-choose]");option&&(this.setVariant(option.getAttribute("data-notify-choose")),this.closeSelect(),this.selectToggle.focus())}setVariant(variantId){this.variantId=variantId;const variant=this.variants[variantId]||{};if(this.titleElement&&(this.titleElement.textContent=variant.title||""),this.selectList?.querySelectorAll("[data-notify-choose]").forEach(option=>{option.setAttribute("aria-selected",String(option.getAttribute("data-notify-choose")===variantId))}),this.dateElement){const hasDate=!!variant.date;this.dateValueElement&&(this.dateValueElement.textContent=variant.date||""),this.dateElement.hidden=!hasDate}this.setMessage("")}setMessage(text,state){this.messageElement&&(this.messageElement.textContent=text,this.messageElement.hidden=!text,this.messageElement.classList.toggle("notify-me__message--error",state==="error"),this.messageElement.classList.toggle("notify-me__message--success",state==="success"))}async onSubmit(event){event.preventDefault();const companyId=this.getAttribute("company-id"),emailField=this.form.elements.email;if(!this.form.reportValidity())return;if(!companyId||!this.variantId){this.setMessage(this.dataset.errorMessage,"error");return}const submitButton=this.form.querySelector('[type="submit"]');submitButton?.setAttribute("aria-busy","true");try{(await fetch(`${KLAVIYO_ENDPOINT}?company_id=${encodeURIComponent(companyId)}`,{method:"POST",headers:{"Content-Type":"application/json",revision:KLAVIYO_REVISION},signal:this.abortController.signal,body:JSON.stringify({data:{type:"back-in-stock-subscription",attributes:{profile:{data:{type:"profile",attributes:{email:emailField.value.trim()}}},channels:["EMAIL"]},relationships:{variant:{data:{type:"catalog-variant",id:`$shopify:::$default:::${this.variantId}`}}}}})})).status===202?(this.setMessage(this.dataset.successMessage,"success"),this.form.reset()):this.setMessage(this.dataset.errorMessage,"error")}catch(error){error.name!=="AbortError"&&this.setMessage(this.dataset.errorMessage,"error")}finally{submitButton?.removeAttribute("aria-busy")}}}); 2//# sourceMappingURL=/cdn/shop/t/270/assets/notify-me.js.map?v=154105015074023670491789988830
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.