1if(!customElements.get("newsletter-form")){class NewsletterForm extends HTMLElement{static formAssociated=!0;static observedAttributes=["email","message"];constructor(){super(),this.elForm=this.querySelector("form"),this.elInput=this.querySelector("input"),this.elMessage=this.querySelector("[data-message]"),this.email=this.getAttribute("email"),this.listId=this.getAttribute("list-id"),this.source=this.getAttribute("source"),this.url=this.elForm.getAttribute("action"),this.elForm.addEventListener("submit",this.validate.bind(this)),this.elInput.addEventListener("input",this.setEmail.bind(this)),this.elInput.addEventListener("focus",this.reset.bind(this)),this.elInput.addEventListener("focusout",()=>{!this.email&&this.classList.remove("focussed")})}setEmail(ev){this.setAttribute("email",ev.currentTarget.value)}reset(){this.elInput.setAttribute("aria-invalid",!1),this.classList.remove("error"),this.classList.add("focussed"),this.setAttribute("message","")}validate(ev){ev.preventDefault(),/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(this.email)?(this.classList.add("submitting"),this.subscribe().then(response=>{if(this.classList.remove("submitting"),response.ok)this.classList.add("success"),this.setAttribute("message","Thank you for signing up!");else{let message="Oops! Please try again later";this.classList.add("error"),this.setAttribute("message",message)}}).catch(err=>{console.log(err),this.classList.remove("submitting"),this.classList.add("error")})):(this.setAttribute("message","Invalid Email"),this.elInput.setAttribute("aria-invalid",!0),this.classList.remove("error"))}async subscribe(){const options={method:"POST",headers:{revision:"2024-05-15","content-type":"application/json"},body:JSON.stringify({data:{type:"subscription",attributes:{custom_source:this.source,profile:{data:{type:"profile",attributes:{email:this.email}}}},relationships:{list:{data:{type:"list",id:this.listId}}}}})};return fetch(this.url,options).then(response=>response).catch(err=>err)}attributeChangedCallback(name,oldValue,newValue){switch(name){case"email":this.email=newValue;break;case"message":this.elMessage.innerHTML=newValue;break}}}customElements.define("newsletter-form",NewsletterForm)} 2//# sourceMappingURL=/cdn/shop/t/3480/assets/newsletter-form.js.map?v=27164494811512646591790785188
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.