1class NewsletterForm extends window.BAO.CustomElement(){connectedCallback(){super.connectedCallback(),this.endpoint="https://op-newsletter-form.by-association-only.workers.dev/signup",this.setupCountryCode()}setupListeners(){super.setupListeners(),this.handleSubmit=this.handleSubmit.bind(this),this.handlePhoneInput=this.handlePhoneInput.bind(this),this.els.form?.exists&&this.listeners.add(this.els.form.element,"submit",this.handleSubmit),this.els.phone?.exists&&(this.listeners.add(this.els.phone.element,"countrychange",this.handlePhoneInput),this.listeners.add(this.els.phone.element,"change",this.handlePhoneInput),this.listeners.add(this.els.phone.element,"input",this.handlePhoneInput))}setupCountryCode(){this.els.phone?.exists&&window.intlTelInput&&(this.iti=window.intlTelInput(this.els.phone.element,{utilsScript:"https://cdn.jsdelivr.net/npm/[email protected]/build/js/utils.js",separateDialCode:!0,showFlags:!1,initialCountry:this.dataset.initialCountry||"gb",strictMode:!0}))}async handleSubmit(event){event.preventDefault(),await this.handlePhoneInput();try{const response=await this.submitForm(this.formData);response.success?this.showSuccess():this.showError(response.error||response.message||"Submission failed. Please try again.")}catch(error){console.error("Form submission error:",error),this.showError("An unexpected error occurred. Please try again later.")}}async handlePhoneInput(){this.els.phoneFormatted?.exists&&(this.els.phoneFormatted.element.value=this.iti?.getNumber()||this.els.phone.element.value)}async submitForm(data){try{const response=await fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(data)}),responseData=await response.json();return response.ok||console.error(`API Error: ${response.status}`,responseData),responseData}catch(error){return console.error("Fetch or JSON parsing failed:",error),{success:!1,message:"Network error or invalid response from server."}}}showSuccess(){this.els.form?.element?.reset(),this.innerHTML=` 2 <div 3 class="frm-Form_Validation" 4 tabindex="-1" 5 role="status" 6 > 7 <p class="frm-Form_ValidationText frm-Form_ValidationText-success"> 8 ${this.dataset.successMessage||"You're signed up"} 9 </p> 10 </div> 11 `,this.querySelector(".frm-Form_Validation")?.focus()}showError(message){let errorContainer=this.querySelector(".frm-Form_Validation");errorContainer||(errorContainer=document.createElement("div"),errorContainer.className="frm-Form_Validation",errorContainer.setAttribute("tabindex","-1"),errorContainer.setAttribute("role","alert"),errorContainer.innerHTML=` 12 <p class="frm-Form_ValidationText frm-Form_ValidationText-error"></p> 13 `,this.prepend(errorContainer)),errorContainer.querySelector(".frm-Form_ValidationText").textContent=message,errorContainer.focus()}get smsConsent(){return this.els.gdpr?.exists?this.els.gdpr.element.checked:!1}get phone(){const phone=this.iti?.getNumber()||this.els.phone?.element?.value||"";return this.els.gdpr?.exists?this.smsConsent?phone:"":phone}get formData(){return{firstName:this.els.firstname?.element?.value||"",lastName:this.els.lastname?.element?.value||"",email:this.els.email.element.value,phone:this.phone,sms_consent:this.els.gdpr?.exists?this.smsConsent:!!this.phone,source:this.dataset.source,store:this.dataset.store}}}customElements.get("newsletter-form")||customElements.define("newsletter-form",NewsletterForm); 14//# sourceMappingURL=/cdn/shop/t/1735/assets/newsletter-form.js.map?v=46214140336273890361783441576
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.