1import{aD as Q,l as I,bd as W,bt as G,g as H,i as K,am as X,w as Z,n as k,p as ee,v as a,be as J,e as d,bz as te,o,c as l,a as c,_ as ne,Q as f,N as m,b as x,M as ae,O as oe,d as C,b8 as se}from"./CmiQwY5M.js";import ie from"./BebDzOn_.js";import le from"./DO1R9hrh.js";import{u as ce}from"./DlPk8MK3.js";import{u as re}from"./BZo89lLc.js";function Ce(i){try{const _=i.trim();return Q().email().safeParse(_).success?_:null}catch{return null}}function O(i){return btoa(i)}const ue={key:0,class:"text-center py-6"},de={class:"flex justify-center mb-4"},me={class:"text-xl font-semibold mb-2"},ve={class:"text-dimmed mb-6"},fe={key:0,class:"mb-6"},pe={key:1,class:"text-center py-6"},ge={class:"flex justify-center mb-4"},_e={class:"text-dimmed mb-6"},ye={class:"font-medium text-default"},be={class:"space-y-3"},he=I({__name:"EventRegistrationModal",props:J({event:{},autoJoinAfterRegistration:{type:Boolean}},{open:{type:Boolean,required:!0},openModifiers:{}}),emits:J(["success","registered"],["update:open"]),setup(i,{emit:_}){const v=i,R=W(i,"open"),$=G(),y=H(),r=K(),S=_,{fetchEventMeetingUrl:q}=ce(),{registerForEvent:z,isEventStarted:A}=re(),b=X(),h=d(!1),u=d(!1),p=d(!1),t=d(null),w=d(null),g=d(!1),E=d(!1),D=C(()=>!!r.value?.email),j=C(()=>{if(!(!w.value||typeof window>"u"))return O(w.value)}),U=C(()=>v.autoJoinAfterRegistration&&A(v.event.start_at));Z(R,n=>{n?n&&U.value&&(t.value=window.open("about:blank","_blank"),t.value||b.add({title:"Popup blocked",description:"Please allow popups to auto-join the event",color:"warning",icon:"i-lucide-alert-circle"})):(h.value=!1,u.value=!1,p.value=!1,g.value=!1,E.value=!1,w.value=null,t.value&&!t.value.closed&&t.value.close(),t.value=null)});async function N(){if(r.value?.email){g.value=!0;try{const n=await z(v.event.id,{event_id:v.event.id,email:r.value.email,name:r.value.user_metadata?.full_name||r.value.email});if(n.success)await M(r.value.email);else{const e=(n.error.message||"").toLowerCase();n.error.status===400&&e.includes("already registered")?await M(r.value.email):b.add({title:"Registration failed",description:n.error.message||"Unable to complete registration",color:"error",icon:"i-lucide-alert-circle"})}}finally{g.value=!1}}}async function T(n){await M(n)}async function M(n){h.value=!0,w.value=n,S("success"),S("registered",n);const e=O(n),s={...y.query,e};y.query.calendar&&(s.calendar=y.query.calendar),$.push({path:y.path,query:s}),U.value&&t.value&&!t.value.closed&&await P(n)}async function P(n){u.value=!0;try{const e=btoa(n),s=await q(v.event.slug,{encodedEmail:e});s.success&&t.value&&!t.value.closed?(t.value.location.href=s.data.meeting_url,p.value=!0,b.add({title:`Welcome, ${s.data.attendee_name}!`,description:"Meeting opened in new tab",color:"success",icon:"i-lucide-check-circle"})):(t.value&&!t.value.closed&&t.value.close(),b.add({title:"Could not auto-join",description:"You can join manually from the event page",color:"warning",icon:"i-lucide-alert-circle"}))}catch(e){t.value&&!t.value.closed&&t.value.close(),console.error("Auto-join failed:",e)}finally{u.value=!1}}return(n,e)=>{const s=ne,V=ie,B=se,Y=le,L=te;return o(),k(L,{open:R.value,"onUpdate:open":e[1]||(e[1]=F=>R.value=F),title:a(h)?"Registration Successful!":`Register for ${i.event.title}`,"close-icon":"i-lucide-x",ui:{content:"max-w-2xl",body:"p-6"}},{body:ee(()=>[a(h)?(o(),l("div",ue,[c("div",de,[a(u)?(o(),k(s,{key:1,name:"i-lucide-loader-2",class:"w-16 h-16 text-primary animate-spin"})):(o(),k(s,{key:0,name:"i-lucide-check-circle",class:"w-16 h-16 text-primary"}))]),c("h4",me,[a(u)?(o(),l(f,{key:0},[m(" Opening meeting... ")],64)):a(p)?(o(),l(f,{key:1},[m(" You're in! ")],64)):(o(),l(f,{key:2},[m(" Congratulations! You're registered! ")],64))]),c("p",ve,[a(u)?(o(),l(f,{key:0},[m(" Redirecting you to the meeting... ")],64)):a(p)?(o(),l(f,{key:1},[m(" Meeting opened in new tab. You can close this window. ")],64)):(o(),l(f,{key:2},[m(" Check your email for event confirmation and details. ")],64))]),!a(u)&&!a(p)&&a(j)?(o(),l("div",fe,[x(V,{"event-slug":i.event.slug,"encoded-email":a(j)},null,8,["event-slug","encoded-email"])])):ae("",!0)])):a(D)&&!a(E)?(o(),l("div",pe,[c("div",ge,[x(s,{name:"i-lucide-user-check",class:"w-12 h-12 text-primary"})]),e[4]||(e[4]=c("h4",{class:"text-xl font-semibold mb-2"}," Quick Registration ",-1)),c("p",_e,[e[2]||(e[2]=m(" Register with your account email:",-1)),e[3]||(e[3]=c("br",null,null,-1)),c("span",ye,oe(a(r)?.email),1)]),c("div",be,[x(B,{label:"Register & Join",icon:"i-lucide-zap",size:"lg",block:"",loading:a(g),disabled:a(g),onClick:N},null,8,["loading","disabled"]),x(B,{label:"Use a different email",variant:"ghost",size:"sm",onClick:e[0]||(e[0]=F=>E.value=!0)})])])):(o(),k(Y,{key:2,event:i.event,onSuccess:T},null,8,["event"]))]),_:1},8,["open","title"])}}}),we=Object.assign(he,{__name:"EventRegistrationModal"}),Se=Object.freeze(Object.defineProperty({__proto__:null,default:we},Symbol.toStringTag,{value:"Module"}));
1export{Se as E,we as _,O as e,Ce as v};
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.