1import{o as y,D as A,E,r as i,aF as d,j as e,C,aB as I,n as m,A as k}from"./index-D9gYj5Lf.js";import{L as p}from"./loader-CvQIZ5gl.js";import{C as S}from"./circle-alert-gXVSRhlI.js";function R(){const{token:r}=y();A();const{user:l,loading:b}=E(),[t,f]=i.useState(null),[j,x]=i.useState(!0),[s,c]=i.useState(""),[h,u]=i.useState(!1),[o,w]=i.useState(!1),[n,g]=i.useState(!1);i.useEffect(()=>{if(!r){c("No invite token provided"),x(!1);return}d.getInviteInfo(r).then(a=>f(a)).catch(a=>c(a.message||"Invalid or expired invite")).finally(()=>x(!1))},[r]),i.useEffect(()=>{!s||t||!l||n||/already been accepted/i.test(s)&&(async()=>{const{workspaces:a}=await d.getWorkspaces().catch(()=>({workspaces:[]}));a.some(N=>!N.isOwn)&&(g(!0),c(""))})()},[s,t,l,n]),i.useEffect(()=>{if(!n)return;const a=setTimeout(()=>{window.location.href="/app/dashboard"},2e3);return()=>clearTimeout(a)},[n]);const v=async()=>{u(!0),c("");try{await d.acceptInvite(r),w(!0),setTimeout(()=>{window.location.href="/app/dashboard"},2e3)}catch(a){c(a.message||"Failed to accept invite")}finally{u(!1)}};return b||j?e.jsx("div",{className:"landing-light min-h-screen flex items-center justify-center bg-[var(--bg-primary)]",children:e.jsx(p,{className:"w-6 h-6 text-[#2E7A9C] animate-spin"})}):e.jsxs("div",{className:"landing-light min-h-screen flex items-center justify-center px-5 bg-[var(--bg-primary)] relative overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-white via-[#FAFAF7] to-white pointer-events-none"}),e.jsx("div",{className:"absolute left-1/2 top-1/2 h-[480px] w-[min(760px,90vw)] -translate-x-1/2 -translate-y-1/2 rounded-full bg-[#3E9BC3]/[0.10] blur-3xl pointer-events-none"}),e.jsx("div",{className:"w-full max-w-md relative z-10",children:e.jsxs("div",{className:"rounded-[28px] border border-black/[0.08] bg-white p-8",style:{boxShadow:"0 30px 80px -48px rgba(10,10,10,0.34)"},children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-16 h-16 rounded-2xl flex items-center justify-center ${o||n?"bg-[#3E9BC3]/[0.12]":s&&!t?"bg-red-500/[0.10]":"bg-[#3E9BC3]/[0.12]"}`,children:o||n?e.jsx(C,{className:"w-8 h-8 text-[#2E7A9C]"}):s&&!t?e.jsx(S,{className:"w-8 h-8 text-red-400"}):e.jsx(I,{className:"w-8 h-8 text-[#2E7A9C]"})})}),n&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-white mb-2",children:"You're already on the team"}),e.jsx("p",{className:"text-sm text-white/50 mb-6",children:"You joined when you signed in. Redirecting to dashboard..."}),e.jsx(m,{to:"/app/dashboard",className:"text-sm text-[#2E7A9C] font-semibold hover:underline",children:"Go to dashboard"})]}),s&&!t&&!n&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-white mb-2",children:"Invalid Invite"}),e.jsx("p",{className:"text-sm text-white/50 mb-6",children:s}),e.jsx(m,{to:"/",className:"text-sm text-[#2E7A9C] font-semibold hover:underline",children:"Go to homepage"})]}),o&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-white mb-2",children:"You're In!"}),e.jsxs("p",{className:"text-sm text-white/50 mb-2",children:["You've joined ",t?.ownerName||t?.ownerEmail,"'s team."]}),e.jsx("p",{className:"text-xs text-white/30",children:"Redirecting to dashboard..."})]}),t&&!o&&e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-xl font-semibold text-white mb-2",children:"Team Invite"}),e.jsxs("p",{className:"text-sm text-white/50 mb-6",children:[e.jsx("span",{className:"text-white font-medium",children:t.ownerName||t.ownerEmail})," ","invited you to join their team as a ",e.jsx("span",{className:"text-[#2E7A9C] font-medium",children:t.role}),"."]}),!l&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{className:"text-xs text-white/40 mb-4",children:["Sign in with Google using ",e.jsx("span",{className:"text-white/70",children:t.email})," to accept."]}),e.jsx(m,{to:`/login?redirect=/invite/${r}`,className:"btn-blue-primary block w-full py-3 text-center rounded-xl font-semibold",children:"Sign in to accept"})]}),l&&e.jsxs(e.Fragment,{children:[s&&e.jsx("div",{className:"mb-4 rounded-lg p-3 bg-red-500/10 border border-red-500/20 text-sm text-red-300 text-left",children:s}),e.jsxs("p",{className:"text-xs text-white/40 mb-4",children:["Logged in as ",e.jsx("span",{className:"text-white/70",children:l.email})]}),e.jsx("button",{onClick:v,disabled:h,className:"btn-blue-primary w-full flex items-center justify-center gap-2 py-3 rounded-xl font-semibold disabled:opacity-50",children:h?e.jsx(p,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:["Accept Invite ",e.jsx(k,{className:"w-4 h-4"})]})})]})]})]})})]})}export{R 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.