1import{a as c,j as e}from"./vendor-framer-motion-DgxRQIHL.js";import{bc as k,aj as R,ba as z,ak as C,L as b,a4 as g,aE as A,m as E,z as j}from"./index-9GEQNrq5.js";import{l as L}from"./vendor-firebase-U95O8hiF.js";import{C as B}from"./circle-x-DrzOSU8n.js";import"./vendor-editor-D77TyNkE.js";import"./vendor-pdf-DqDRg8pW.js";import"./vendor-charts-IsSz2KDH.js";function T(s){return!s||typeof s!="string"?"":s.split("?")[0].trim().replace(/\.(mo|com|io|org)$/i,"")}const U=()=>{const{token:s}=k(),n=R(),{user:l,loading:m}=z(),{organization:d,userOrganizations:p,isLoading:u,refreshOrganization:y}=C(),[x,o]=c.useState("idle"),[N,f]=c.useState(null),v=c.useRef(!1);return c.useEffect(()=>{if(m)return;const h=T(s);if(!h){o("error"),f("Link de convite inválido.");return}if(!l){n(`/login?redirect=${encodeURIComponent(`/beta/${s??""}`)}`,{replace:!0});return}if(!u&&p.length===0){n(`/onboarding?redirect=${encodeURIComponent(`/beta/${s??""}`)}`,{replace:!0});return}if(!d?.id||v.current)return;(async()=>{v.current=!0,o("applying"),f(null);try{const t=L(E,"applyBetaInvite"),{data:i}=await t({token:h,orgId:d.id});if(i?.success&&i?.betaAccess){o("success"),await y();const r=i.betaAccess.expiresAt,a=r?.toDate?r.toDate():r?.seconds?new Date(r.seconds*1e3):null,w=a?a.toLocaleDateString("pt-BR"):"";j.success(`Acesso beta ativado até ${w}.`),setTimeout(()=>n("/dashboard",{replace:!0}),1500)}else throw new Error("Resposta inválida.")}catch(t){o("error");const i=t&&typeof t=="object"&&"code"in t?t.code:"",r=t&&typeof t=="object"&&"message"in t?String(t.message):"";let a="Não foi possÃvel ativar o acesso beta. Tente novamente.";i==="not-found"?a="Este link de convite não existe ou já expirou.":i==="failed-precondition"?a=r||"Este convite foi revogado ou já atingiu o limite de uso.":i==="permission-denied"?a="Você não tem permissão para ativar este convite nesta organização.":r&&(a=r),f(a),j.error(a)}})()},[l,m,u,d?.id,p.length,s,n]),m||!l?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[var(--app-bg,#09090b)] p-6",children:[e.jsx(b,{className:"w-12 h-12 animate-spin text-[var(--brand-primary,#08b6d5)] mb-4"}),e.jsx("p",{className:"text-[var(--text-muted,#71717a)]",children:"Redirecionando..."})]}):!u&&p.length===0?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[var(--app-bg,#09090b)] p-6",children:[e.jsx(b,{className:"w-12 h-12 animate-spin text-[var(--brand-primary,#08b6d5)] mb-4"}),e.jsx("p",{className:"text-[var(--text-muted,#71717a)]",children:"Redirecionando para configuração..."})]}):x==="applying"||x==="idle"?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[var(--app-bg,#09090b)] p-6",children:[e.jsx(g,{theme:"dark",showText:!0,className:"mb-8"}),e.jsx(b,{className:"w-12 h-12 animate-spin text-[var(--brand-primary,#08b6d5)] mb-4"}),e.jsx("p",{className:"text-[var(--text-muted,#71717a)]",children:"Ativando seu acesso beta..."})]}):x==="success"?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[var(--app-bg,#09090b)] p-6",children:[e.jsx(g,{theme:"dark",showText:!0,className:"mb-8"}),e.jsx(A,{className:"w-16 h-16 text-emerald-500 mb-4"}),e.jsx("p",{className:"text-[var(--text-primary,#fafafa)] font-semibold text-center",children:"Acesso beta ativado!"}),e.jsx("p",{className:"text-[var(--text-muted,#71717a)] text-sm mt-1 text-center",children:"Redirecionando para o painel..."})]}):e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-[var(--app-bg,#09090b)] p-6",children:[e.jsx(g,{theme:"dark",showText:!0,className:"mb-8"}),e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-xl p-6 max-w-md text-center",children:[e.jsx(B,{className:"w-12 h-12 text-red-400 mx-auto mb-3"}),e.jsx("p",{className:"text-[var(--text-primary,#fafafa)] font-semibold mb-1",children:"Não foi possÃvel ativar o beta"}),e.jsx("p",{className:"text-[var(--text-muted,#71717a)] text-sm",children:N}),e.jsx("button",{type:"button",onClick:()=>n("/dashboard",{replace:!0}),className:"mt-4 px-4 py-2 rounded-lg bg-[var(--surface,#27272a)] border border-[var(--subtle,#3f3f46)] text-[var(--text-primary,#fafafa)] text-sm font-medium hover:opacity-90 transition-opacity",children:"Ir para o painel"})]})]})};export{U 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.