1const E=window.membershipI18n.loading;class A{constructor(e){this.el=e,this.stepIndicators=[...this.select(".form-module__steps").children],this.stepForms=this.selectAll(".form-module__partial"),this.formIndicator=this.select(".form-module__indicator"),this.hiddenPhone=this.select("input[type=hidden][name=phone]"),this.hiddenCode=this.select("input[type=hidden][name=code]"),this.hiddenToken=this.select("input[type=hidden][name=token]"),this._loading=!1}select=e=>this.el.querySelector(e);selectAll=e=>[...this.el.querySelectorAll(e)];indicator(e=null){if(e===null)return this.formIndicator.textContent;this.formIndicator.textContent=e}loading(e=null){return e!==null&&(this._loading=e,e?(this.el.classList.add("form-module--loading"),this.indicator(E)):(this.el.classList.remove("form-module--loading"),this.indicator()===E&&this.indicator(""))),this._loading}setError(e,o,a){const c=this.select(".form-module__error");if(c.innerHTML="",e===null)return;const l=document.createElement("p");if(l.innerText=e,c.appendChild(l),o){const d=document.createElement("a");d.target="_blank",d.href=o,d.innerText=a,c.appendChild(d)}}}const P=i=>{const e={};return[...i.querySelectorAll("input, select")].forEach(o=>{e[o.name]=o.type==="checkbox"?o.checked:o.value}),e},N=i=>{const e=new A(i),o=async(t,r)=>{const n={...r,...window.membershipMeta};try{const s=await fetch(`/api/membership/${t}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),m=await s.json();if(s.status>=400||m.error)throw m;return m}catch(s){throw e.setError(s.message??window.membershipI18n.genericError,s.url,s.urlText),s}};let a=0;Array.from(e.selectAll("form")).forEach(t=>{t.addEventListener("submit",r=>{r.preventDefault(),!e.loading()&&c(a+1)})});const c=async t=>{e.loading(!0);try{const r=await l(a);typeof r=="number"&&(t=r),a===0&&t===1?e.indicator(window.membershipI18n.codeSent):a===1&&e.indicator(window.membershipI18n.codeValid),e.stepIndicators[a%3].ariaCurrent=null,e.stepForms[a].hidden=!0;const n=a;a=t,typeof e.stepForms[a]<"u"&&(e.stepIndicators[a%3].ariaCurrent="step",e.stepForms[a].hidden=!1),d(a,n)}catch{}e.loading(!1)},l=t=>t===0?g():t===1?T():t===2?y():t===3?p():t===4?v():t===5?w():new Promise(r=>r(null)),d=(t,r)=>{t===1?h.focus():t===2?e.select("#member-first-name").focus():t===4?b():t===6&&C(r)},_=[...e.select(".phone-group__items").children].map(t=>t.querySelector("select, input")),u=()=>_.map(t=>t.value.replace(/ /g,"")).join(" "),g=async()=>{const t=u();e.setError(null),e.indicator("Sender kode på SMS."),e.loading(!0);const r=await o("code/send",{phone:t});if(e.indicator(r.message),e.hiddenPhone.value=t,e.loading(!1),r.registerParkingLoop)return 3},h=e.select("[data-validation-code]"),S=()=>e.select("[data-validation-code]").value,T=async()=>{const t=S(),r=u();try{const n=await o("code/verify",{code:t,phone:r});e.setError(null),e.indicator(n.message),e.hiddenCode.value=t,e.hiddenToken.value=n.token}catch(n){throw e.indicator(n.message),h.value="",h.focus(),n}};e.select("[data-resend-code]").addEventListener("click",async()=>{e.loading()||await g()}),e.selectAll("[data-member-car-checkbox]").forEach(t=>t.addEventListener("change",r=>{const n=r.target.closest(".form-module__group");n.querySelector("[data-member-car]").hidden=!r.target.checked,n.querySelector("#member-car-reg").required=r.target.checked})),e.select('input[name="acceptConditions"]').addEventListener("change",t=>{e.select("[data-submit-registration]").disabled=!t.target.checked});const y=async()=>{const t=P(e.select("[data-form-registration]"));try{const r=await o("register",t);return e.setError(null),e.indicator(r.message),6}catch(r){throw e.indicator(r.message),r}},C=t=>{const r=t===5?"[data-parking-registration-completed]":"[data-registration-completed]";i.parentElement.removeChild(i),document.querySelector("#main-content").hidden=!0,document.querySelector(r).hidden=!1};e.select("[data-register-parking-yes]")?.addEventListener("click",async()=>{await c(4)}),e.select("[data-resend-parking-code]").addEventListener("click",async()=>{e.loading()||await p()});const p=async()=>{const t=u();e.setError(null),e.indicator("Sender kode på SMS."),e.loading(!0);const r=await o("parking/code",{phone:t});e.indicator(r.message),e.hiddenPhone.value=t,e.loading(!1)},f=e.select("[data-parking-validation-code]"),k=()=>e.select("[data-parking-validation-code]").value,v=async()=>{const t=k(),r=u();try{const n=await o("parking/verifyCode",{code:t,phone:r});e.setError(null),e.indicator(n.message),e.hiddenCode.value=t,e.hiddenToken.value=n.token}catch(n){throw e.indicator(n.message),f.value="",f.focus(),n}},b=()=>{const t=e.select("[data-free-parking-group]"),r=e.select("[data-form-parking-registration]");t.parentElement.removeChild(t),r.prepend(t)},w=async()=>{const t=P(e.select("[data-form-parking-registration]"));t.phone=e.hiddenPhone.value,t.token=e.hiddenToken.value;try{const r=await o("parking/register",t);return e.setError(null),e.indicator(r.message),6}catch(r){throw e.indicator(r.message),r}}};Array.from(document.querySelectorAll("[data-member-form]")).forEac
1h(i=>N(i));
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.