1"use strict";(self.webpackChunkpolitico_theme=self.webpackChunkpolitico_theme||[]).push([[7073],{4494:function(t,e,s){var i=s(6045),r=s(3824);e.default=()=>new i.A({formEl:r.d3})},6045:function(t,e,s){s.d(e,{A:function(){return i}});class i{constructor(t){this.settings={customEventErrorName:"formError",isFieldmanagerForm:!1,...t},this.formEl=this.settings.formEl,"string"===typeof this.formEl&&(this.formEl=document.querySelector(this.settings.formEl)),this.formEl&&(this.setup(),this.onFocus=this.onFocus.bind(this))}setup(){this.formEl.addEventListener("submit",(t=>{const e=this.formEl.querySelectorAll("[required]"),s=[];let i=!1;if(e.forEach((t=>{let e=t.parentNode;if(this.settings.isFieldmanagerForm){const s=t.closest(".form__fields--field");s&&(e=s)}const r=e.querySelector(".form__fields--error-message");let o=""===t.value;"email"===t.type&&(o=!this.validateEmail(t.value)),o?(e.classList.add("form__fields--empty"),t.addEventListener("focus",this.onFocus),r&&s.push(r.textContent),i=!0):(e.classList.remove("form__fields--empty"),t.removeEventListener("focus",this.onFocus)),r&&r.setAttribute("aria-hidden",!o)})),i){t.preventDefault(),this.formEl.scrollIntoView();const e=new CustomEvent(this.settings.customEventErrorName,{detail:s.toString()});return this.formEl.dispatchEvent(e),!1}if(this.settings.trackSubmitEmail&&this.settings.trackEventId&&this.settings.emailField){const t=this.formEl.querySelector(this.settings.emailField);t&&this.settings.trackSubmitEmail(t.value,this.settings.trackEventId)}return!0}))}onFocus({target:t}){const e=t.parentNode,s=e.querySelector(".form__fields--error-message");e.classList.remove("form__fields--empty"),s.setAttribute("aria-hidden",!0)}validateEmail(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}}}}]);
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.