1import{C as h,d as a,s as d,u as c}from"./site.4FScMMdi.js";import{s as r,N as n}from"./notification.3iRQkJDw.js";import{f as m}from"./fetchData.E2TeMMfN.js";import"./password-strength.AqUmoxgQ.js";class u{constructor(t,s){this.controller=document.getElementById(t)??null,this.elements=s.map(i=>document.getElementById(i)??null),!(!this.controller||this.elements.some(i=>!i))&&(this.updateVisibility(),this.controller.addEventListener("change",()=>this.updateVisibility()))}unset(){var t;this.controller!==null&&((t=this.controller)==null||t.removeEventListener("change",()=>this.updateVisibility()))}updateVisibility(){const t=this.controller.checked,s=this.elements&&this.elements[0];s&&(s.style.display=t?"none":"block",s.setAttribute("aria-hidden",t?"true":"false"));const i=this.elements&&this.elements[1];i&&(i.style.display=t?"block":"none",i.setAttribute("aria-hidden",t?"false":"true"))}}const o=class o extends h{constructor(){super(...arguments),this.fetchFn=m}isLoading(t){t===!0?this.element.classList.add("waiting-list-modal--loading"):this.element.classList.remove("waiting-list-modal--loading")}showNotification(t){const s=i=>`waiting-list-modal--${r[i]}`;this.isLoading(!1),this.element.classList.add(s(t)),a("notifications:show",t),this.dismissButtonTarget.disabled=!1}resetNotifications(){Object.values(r).forEach(t=>{this.element.classList.remove(`waiting-list-modal--${t}`)}),a("notifications:hideAll"),this.dismissButtonTarget.disabled=!0}connect(){this.boundAddEvent=this.handleAddEvent.bind(this),d("waiting-list-button:addEvent",this.boundAddEvent)}disconnect(){c("waiting-list-button:addEvent",this.boundAddEvent)}initializeToggler(){this.toggler=new u("wl_toggle_tiers",["hideTiers","showTiers"])}async handleAddEvent({eventId:t}){this.resetNotifications(),this.isLoading(!0),this.abortController=new AbortController,this.signal=this.abortController.signal;const s=new FormData;s.append("id",t);try{const i=await this.fetchFn(this.endpointValue,"POST",{body:s,signal:this.signal});if(!i.ok)throw new Error(`Error fetching data: ${i.error.message}`);const e=i.data;if(e.blnReload&&typeof e.strReloadUrl=="string"){window.location.href=e.strReloadUrl;return}this.clear(),this.eventId=t,this.isLoading(!1),this.placeholderTarget.innerHTML=e.html,this.initializeToggler()}catch{this.showNotification(n.Error)}}async submit(t){var i;this.isLoading(!0),t.preventDefault(),t.stopPropagation();const s=new FormData(this.formTarget);s.append("id",t.params.eventId);try{const e=await this.fetchFn(this.formTarget.action,"POST",{body:s,signal:this.signal});if(!e.ok)throw new Error(`Error submitting form: ${e.error.message}`);this.clear(),this.showNotification(n.Success)}catch{this.clear(),this.showNotification(n.Error)}this.eventId=null,(i=this.toggler)==null||i.unset()}abort(){this.abortController&&this.abortController.abort(),this.resetNotifications()}clear(){var s;(s=this.toggler)==null||s.unset();const t=Array.from(this.placeholderTarget.childNodes);t.length!==0&&t.forEach(i=>{i.remove()})}dismiss(){this.clear(),this.resetNotifications()}};o.values={endpoint:String},o.targets=["placeholder","notifications","form","dismissButton"];let l=o;export{l as default}; 2//# sourceMappingURL=waiting_list_controller.C2TFXEn8.js.map
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.