1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/events-DSk_YYbR.js","assets/api-3zWh6Ndi.js","assets/index-BNlvsJKT.js","assets/vendor-mantine-DQvSv3QS.js","assets/vendor-charts-BYZ8jVF7.js","assets/vendor-mantine-DGq0HqbN.css","assets/vendor-firebase-DFbLPQpn.js"])))=>i.map(i=>d[i]); 2import{r as N,a as he,u as fe,c as pe,_ as F,L as V,t as ve,f as xe}from"./index-BNlvsJKT.js";import{j as e,B as k,c as W,v as G,S,m as D,l as Z,L as ye,T as b,G as q,b as C,C as Y,t as K,f as be}from"./vendor-mantine-DQvSv3QS.js";import{r as c}from"./vendor-charts-BYZ8jVF7.js";import{a as we}from"./orgs-TXp-zw39.js";import{fetchEventsByOrg as Ee}from"./events-DSk_YYbR.js";import{A as je,n as U}from"./registration-completeness-Cxtc1eqh.js";import{r as J,d as Q,c as Se}from"./vendor-firebase-DFbLPQpn.js";import{a as _e}from"./api-3zWh6Ndi.js";import{B as X}from"./BrandedFooter-DwGdCrXy.js";import{U as Ie}from"./UserSession-CAdx0c0G.js";import{I as Ae}from"./IconPencil-9U1yj81q.js";import"./form-catalogs-B46xrs_A.js";import"./form-values-_7Pl0sE8.js";import"./IconUserPlus-jzJoG5xm.js";import"./createReactComponent-DiLeKDoc.js";import"./org-attendees-CIjkNOOP.js";function ee({config:t}){if(!t?.enabled)return null;const{backgroundImageUrl:n,backgroundImageMobileUrl:i}=t;if(!n&&!i)return null;const f=i||n,d=n||f,_=300,o=500,[w,E]=c.useState(null),[p,I]=c.useState(null),x=c.useCallback(v=>{const m=v.currentTarget;m.naturalWidth&&m.naturalHeight&&E(m.naturalWidth/m.naturalHeight)},[]),y=c.useCallback(v=>{const m=v.currentTarget;m.naturalWidth&&m.naturalHeight&&I(m.naturalWidth/m.naturalHeight)},[]);return e.jsxs(e.Fragment,{children:[e.jsx(k,{hiddenFrom:"sm",style:{width:"100%",position:"relative"},children:e.jsx("img",{src:f,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",draggable:!1,onLoad:x,style:{display:"block",width:"100%",height:w?"auto":`${_}px`,aspectRatio:w?`${w} / 1`:void 0,objectFit:"contain",objectPosition:"center",userSelect:"none"}})}),e.jsx(k,{visibleFrom:"sm",style:{width:"100%",position:"relative"},children:e.jsx("img",{src:d,alt:"","aria-hidden":"true",loading:"lazy",decoding:"async",draggable:!1,onLoad:y,style:{display:"block",width:"100%",height:p?"auto":`${o}px`,aspectRatio:p?`${p} / 1`:void 0,objectFit:"contain",objectPosition:"center",userSelect:"none"}})})]})}function De(t){const[n,i]=c.useState(null),[f,d]=c.useState("upcoming"),[_,o]=c.useState(0),[w,E]=c.useState(!0);return c.useEffect(()=>{if(!t){E(!1);return}let p=!1;const I=[];return(async()=>{try{E(!0);const{data:x}=await _e.get(`/public/events/${t}`);if(p)return;i(x);const y=x.eventId,v=J(N,`/events/${y}/status`),m=J(N,`/events/${y}/nowCount`),A=Q(v,h=>{p||d(String(h.val()??"upcoming"))}),L=Q(m,h=>{p||o(Number(h.val()??0))});I.push(A,L),E(!1)}catch(x){console.error("Error loading event data:",x),p||E(!1)}})(),()=>{p=!0,I.forEach(x=>{try{x()}catch{}})}},[t]),c.useMemo(()=>({resolved:n,status:f,nowCount:_,loading:w}),[n,f,_,w])}const R={primary:"#228BE6",secondary:"#7C3AED",accent:"#14B8A6",background:"#F8FAFC",text:"#0F172A"};function te(t){const n=t||{};return{primary:n.primary||R.primary,secondary:n.secondary||R.secondary,accent:n.accent||R.accent,background:n.background||R.background,text:n.text||R.text}}function re(t){const n=i=>new Array(10).fill(i);return{colors:{brand:n(t.primary),accent:n(t.accent)},primaryColor:"brand",fontFamily:'Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji"',headings:{fontWeight:"800"},defaultRadius:"md",components:{Card:{styles:{root:{border:"1px solid var(--mantine-color-gray-3)",boxShadow:"0 10px 24px rgba(2,6,23,0.06)"}}},Button:{defaultProps:{radius:"md",color:"brand"}}}}}function ae(t){return{"--primary-color":t.primary,"--secondary-color":t.secondary,"--accent-color":t.accent,"--bg-color":t.background,"--text-color":t.text}}function ne(t){return{background:`radial-gradient(1200px 600px at 10% 0%, ${t.primary}14, transparent 60%),radial-gradient(900px 500px at 90% 10%, ${t.secondary}14, transparent 55%),radial-gradient(900px 500px at 50% 100%, ${t.accent}10, transparent 60%),var(--bg-color)`}}function Ge(){const{slug:t,eventSlug:n}=he(),{user:i}=fe(),f=pe(),[d,_]=c.useState(null),[o,w]=c.useState(null),[E,p]=c.useState(!0),[I,x]=c.useState(null),[y,v]=c.useState(null),m=o?.branding||d?.branding,A=te(m?.colors),L=c.useMemo(()=>re(A),[A]),[h,$]=c.useState(null),ie=n||"",{resolved:T,status:u,loading:z}=De(ie),oe=i&&d&&d.ownerUid===i.uid,se=async()=>
2{if(!(!t||!n))try{p(!0),x(null);const r=await we(t);_(r);const l=(await Ee(r._id)).find(s=>s.slug===n||s._id===n)||null;w(l)}catch(r){console.error("Error loading data:",r),x("No se pudo cargar la información del evento")}finally{p(!1)}};c.useEffect(()=>{(async()=>{if(!i||!o?._id||!d?._id){$(null);return}let a=i.email||null;if(!a&&i.uid&&(a=localStorage.getItem(`uid-${i.uid}-email`)||localStorage.getItem("user-email")),!a){$(null);return}try{const{checkIfRegistered:l}=await F(async()=>{const{checkIfRegistered:g}=await import("./events-DSk_YYbR.js");return{checkIfRegistered:g}},__vite__mapDeps([0,1,2,3,4,5,6])),s=await l(o._id,a);console.log("ð Prefetch registration state:",{email:a,eventId:o._id,isRegistered:s.isRegistered}),$(!!s.isRegistered)}catch(l){console.error("â Error prefetching registration state:",l),$(null)}})()},[i?.uid,o?._id,d?._id]);const le=async()=>{if(ve("event_cta_click",{content_type:"event_main_cta",item_id:o?._id,event_slug:n,org_slug:t,event_status:u,is_registered:!!h,cta_label:O(u,!!h)}),!i){if(!t){console.error("No slug found when trying to go to access");return}const a=`/org/${t}/access`,l=n?`${a}?eventSlug=${n}`:a;console.log("ðï¸ EventLanding: No session, going to access:",l),f(l);return}if(h&&t&&n){const a=d?.registrationForm?.fields??[];if(a.length>0){const{checkIfRegistered:l}=await F(async()=>{const{checkIfRegistered:g}=await import("./events-DSk_YYbR.js");return{checkIfRegistered:g}},__vite__mapDeps([0,1,2,3,4,5,6]));let s=i?.email||null;if(!s&&i?.uid&&(s=localStorage.getItem(`uid-${i.uid}-email`)||localStorage.getItem("user-email")),s&&o?._id){const g=await l(o._id,s);if(g.orgAttendee&&U(a,g.orgAttendee.registrationData)){v({attendeeId:g.orgAttendee._id,registrationData:g.orgAttendee.registrationData??{},isAlreadyRegistered:!0});return}}}console.log("â
User already registered (prefetched), redirecting to /attend"),f(`/org/${t}/event/${n}/attend`);return}let r=i.email||void 0;if(!r&&i.uid&&(r=localStorage.getItem(`uid-${i.uid}-email`)||localStorage.getItem("user-email")||void 0),r&&i.uid&&o?._id&&d?._id){console.log("ð EventLanding: Validating existing session before redirecting",{userEmail:r,eventId:o._id,orgId:d._id,hasUID:!!i.uid});try{const{checkIfRegistered:a,registerToEventWithFirebase:l}=await F(async()=>{const{checkIfRegistered:j,registerToEventWithFirebase:me}=await import("./events-DSk_YYbR.js");return{checkIfRegistered:j,registerToEventWithFirebase:me}},__vite__mapDeps([0,1,2,3,4,5,6])),s=await a(o._id,r),g=d?.registrationForm?.fields??[];if(s.isRegistered){if(s.orgAttendee&&U(g,s.orgAttendee.registrationData)){v({attendeeId:s.orgAttendee._id,registrationData:s.orgAttendee.registrationData??{},isAlreadyRegistered:!0});return}console.log("â
EventLanding: User already registered, redirecting to /attend"),f(`/org/${t}/event/${n}/attend`);return}if(s.orgAttendee){if(U(g,s.orgAttendee.registrationData)){v({attendeeId:s.orgAttendee._id,registrationData:s.orgAttendee.registrationData??{},isAlreadyRegistered:!1});return}console.log("ð¯ EventLanding: User has OrgAttendee, auto-registering to event"),await l(o._id,{email:r,name:s.orgAttendee.name,formData:s.orgAttendee.registrationData,firebaseUID:i.uid}),console.log("â
EventLanding: Auto-registration successful, redirecting to /attend"),f(`/org/${t}/event/${n}/attend`);return}console.log("â ï¸ EventLanding: User has session but no OrgAttendee for this org")}catch(a){console.error("â EventLanding: Error in auto-registration flow:",a)}}console.log("EventLanding: Logged user but no OrgAttendee/EventUser â forcing logout");try{await Se(xe),localStorage.removeItem("user-email"),i?.uid&&localStorage.removeItem(`uid-${i.uid}-email`),Object.keys(localStorage).filter(a=>a.startsWith("uid-")||a.includes("email")).forEach(a=>localStorage.removeItem(a)),console.log("â
EventLanding: Session cleaned, user must go through /access again")}catch(a){console.error("â EventLanding: Error cleaning session:",a)}},ce=c.useCallback(async()=>{if(!y||!t||!n){v(null);return}if(!y.isAlreadyRegistered&&o?._id&&i?.uid)try{let r=i.email||null;if(r||(r=localStorage.getItem(`uid-${i.uid}-email`)||localStorage.getItem("user-email")),r){const{checkIfRegistered:a,registerToEventWithFirebase:l}=await F(async()=>{const{checkIfRegistered:g,registerToEventWithFirebase:j}=await import("./events-DSk_YYbR.js");return{checkIfRegistered:g,registerToEventWithFirebase:j}},__vite__mapDeps([0,1,2,3,4,5,6])),s=await a(o._id,r);
2s.orgAttendee&&!s.isRegistered&&await l(o._id,{email:r,name:s.orgAttendee.name,formData:s.orgAttendee.registrationData,firebaseUID:i.uid})}}catch(r){console.error("Error registering to event after profile update:",r)}v(null),f(`/org/${t}/event/${n}/attend`)},[y,o,i,t,n,f]);c.useEffect(()=>{se()},[t,n]);const de=E||z,B=I||(!T&&!z?"Evento no encontrado":null);if(y&&d&&o){const r=o?.branding||d?.branding,a=te(r?.colors),l=re(a);return e.jsx(W,{theme:l,withCssVariables:!0,children:e.jsxs(k,{style:{...ae(a),...ne(a),minHeight:"100vh"},c:"var(--text-color)",children:[e.jsx(ee,{config:r?.header}),e.jsx(G,{size:"sm",py:"xl",children:e.jsxs(S,{gap:"md",children:[e.jsx(D,{color:"yellow",title:"Completa tu perfil para continuar",children:"Antes de ingresar al evento necesitamos que actualices algunos datos de tu registro."}),e.jsx(je,{orgSlug:d.domainSlug,orgId:d._id,eventId:o._id,registrationScope:"org-only",existingData:{attendeeId:y.attendeeId,registrationData:y.registrationData},mode:"page",onSuccess:ce,onCancel:()=>v(null)})]})}),e.jsx(X,{config:r?.footer})]})})}if(de)return e.jsx(Z,{h:"100vh",children:e.jsxs(S,{align:"center",gap:"lg",children:[e.jsx(ye,{size:"lg"}),e.jsx(b,{children:"Cargando información del evento..."})]})});if(B||!d||!T)return e.jsx(Z,{h:"100vh",children:e.jsxs(S,{align:"center",gap:"md",children:[e.jsx(b,{c:"red",size:"xl",fw:600,children:B||"Evento no encontrado"}),e.jsx(b,{c:"dimmed",ta:"center",children:"Lo sentimos, no pudimos cargar la información del evento solicitado."})]})});const P=r=>{switch(r){case"live":return"green";case"upcoming":return"blue";case"ended":return"gray";case"replay":return"orange";default:return"gray"}},ge=r=>{switch(r){case"live":return"En vivo ahora";case"upcoming":return"Próximamente";case"ended":return"Finalizado";case"replay":return"Repetición disponible";default:return"Estado desconocido"}},O=(r,a)=>{if(a)switch(r){case"live":return"Ingresar al evento en vivo";case"replay":return"Ingresar a la repetición";case"ended":return"Ingresar al contenido del evento";case"upcoming":default:return"Ingresar al evento"}switch(r){case"live":return"Registrarme para ingresar en vivo";case"replay":return"Registrarme para ver la repetición";case"ended":return"Registrarme para ver la información";case"upcoming":default:return"Check in al evento"}},H=Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC",ue=r=>{if(!r)return null;const a=new Date(r);return Number.isNaN(a.getTime())?null:new Intl.DateTimeFormat("es-ES",{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit",timeZone:H}).format(a)},M=(()=>{if(u!=="upcoming"||!o?.startDate)return null;const r=new Date,l=new Date(o.startDate||o.schedule?.startsAt||"").getTime()-r.getTime();if(l<=0)return null;const s=Math.floor(l/(1e3*60*60*24)),g=Math.floor(l%(1e3*60*60*24)/(1e3*60*60)),j=Math.floor(l%(1e3*60*60)/(1e3*60));return s>0?`${s} dÃa${s>1?"s":""}, ${g} hora${g>1?"s":""}`:g>0?`${g} hora${g>1?"s":""}, ${j} minuto${j>1?"s":""}`:`${j} minuto${j>1?"s":""}`})();return e.jsxs(W,{theme:L,withCssVariables:!0,children:[e.jsxs(k,{style:{...ae(A),...ne(A),minHeight:"100vh"},c:"var(--text-color)",children:[e.jsx(ee,{config:m?.header}),e.jsxs(G,{size:"md",py:{base:"lg",sm:"xl"},children:[e.jsxs(q,{justify:"space-between",align:"center",mb:{base:"md",sm:"xl"},wrap:"nowrap",gap:"xs",children:[e.jsx(C,{component:V,to:`/org/${t}`,variant:"subtle",color:"gray",size:"sm",radius:"xl",leftSection:e.jsx(Ae,{size:16}),style:{flexShrink:0},children:"Volver"}),e.jsx(k,{style:{flexShrink:0},children:e.jsx(Ie,{eventId:o?._id,orgId:d?._id})})]}),e.jsxs(S,{gap:"lg",align:"center",children:[e.jsx(Y,{withBorder:!0,radius:"2xl",shadow:"xl",p:{base:"lg",sm:"xl"},w:"100%",maw:860,children:e.jsxs(S,{gap:"lg",align:"center",children:[e.jsxs(q,{justify:"center",gap:"sm",wrap:"wrap",children:[e.jsxs(K,{color:P(u),size:"xl",radius:"xl",variant:u==="live"?"filled":"light",styles:{root:{paddingInline:14,paddingBlock:10}},children:[u==="live"&&"ð´ ",ge(u)]}),M&&u==="upcoming"&&e.jsxs(K,{color:"gray",variant:"light",size:"xl",radius:"xl",children:["â° Faltan ",M]})]}),e.jsxs(S,{gap:6,ta:"center",children:[e.jsx(be,{order:1,fw:900,style:{fontSize:"clamp(1.7rem, 4vw, 2.7rem)",lineHeight:1.1,letterSpacing:-.4},children:T.title}),e.jsx(b,{c:"dimmed",size:"sm",children:h?"â
Ya estás identificado":"ð« Check-in rápido para ingresar"})]}),(o?.startDate||o?.schedule?.startsAt)&&e.jsx(Y,{withBorder:!0,radius:"xl",p:"md",w:"100%",styles:{root:{background:"rgba(255,255,255,.55)",borderColor:"rgba(0,0,0,.08)"}},children:e.jsxs(S,{gap:6,align:"center",children:[e.jsxs(b,{fw:800,ta:"center",style:{fontSize:"clamp(1rem, 2.2vw, 1.2rem)"},children:["ð
"," ",ue(o.startDate||o.schedule?.startsAt||null)]}),e.jsxs(b,{size:"xs",c:"dimmed",ta:"center",children:["Hora mostrada según tu zona horaria (",H,")"]})]})}
2),e.jsx(C,{onClick:le,size:"xl",radius:"xl",leftSection:"ðï¸",variant:u==="live"?"gradient":"filled",gradient:u==="live"?{from:"red",to:"pink",deg:90}:void 0,color:u==="live"?void 0:m?.colors?.primary?"brand":P(u),w:"100%",maw:480,styles:{root:{boxShadow:"0 18px 40px rgba(0,0,0,.12)",height:"auto",paddingTop:14,paddingBottom:14,whiteSpace:"normal"},label:{whiteSpace:"normal",textAlign:"center",lineHeight:1.15},inner:{alignItems:"center"}},children:O(u,!!h)}),u==="live"&&e.jsx(D,{color:"red",variant:"light",radius:"xl",w:"100%",children:e.jsxs(b,{size:"sm",ta:"center",children:["ð¥ El evento está en vivo ahora."," ",h?"Ingresa para ver la transmisión.":"RegÃstrate para unirte."]})}),u==="upcoming"&&e.jsx(D,{color:"blue",variant:"light",radius:"xl",w:"100%",children:e.jsxs(b,{size:"sm",ta:"center",children:["ð"," ",h?"Ya estás registrado, presiona ingresar cuando quieras.":"RegÃstrate ahora para reservar tu lugar."]})}),u==="ended"&&e.jsx(D,{color:"gray",variant:"light",radius:"xl",w:"100%",children:e.jsxs(b,{size:"sm",ta:"center",children:["ð El evento ha finalizado."," ",h?"Ingresa para ver la información disponible.":"Puedes registrarte si el organizador habilitó contenido."]})}),u==="replay"&&e.jsx(D,{color:"orange",variant:"light",radius:"xl",w:"100%",children:e.jsxs(b,{size:"sm",ta:"center",children:["â¶ï¸ La repetición está disponible."," ",h?"Ingresa para ver el contenido grabado.":"RegÃstrate o ingresa para acceder."]})})]})}),oe&&e.jsx(C,{component:V,to:`/org/${t}/event/${n}/admin`,variant:"light",radius:"xl",leftSection:"ðï¸",children:"Panel de administración"})]})]})]}),e.jsx(X,{config:m?.footer})]})}export{Ge as default};
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.