import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{t}from"./posthogErrorCapture-CLTfRKFa.js";import{t as n}from"./SetupLayout-Dq49Pl6e.js";import{Cv as r,Gy as i,Hy as a,In as o,Sv as s,bv as c,dg as l,kp as u,lh as d,mv as f,oh as p,op as m,ph as h,wv as g,xv as _}from"./index-DDwwBb9e.js";var v=e(i());function y(e){window.location.href=e}var b=new Set;function x({inviteCode:e,enabled:n}){let r=d.organization.acceptInvite.useMutation({onSuccess:e=>{h.create({title:`Invite Accepted`,description:`You have successfully accepted the invite for ${e.invite.organization.name}.`,type:`success`,meta:{closable:!0},duration:5e3}),y(e.project?.slug?`/${e.project.slug}`:`/`)},onError:e=>{if(e.message===`Invite was already accepted`){y(`/`);return}t(e,{tags:{source:`useAcceptInviteOnce`}})}}),{mutate:i}=r,a=n&&typeof e==`string`;return(0,v.useEffect)(()=>{a&&typeof e==`string`&&(b.has(e)||(b.add(e),i({inviteCode:e})))},[a,e,i]),{status:S(r,a),errorMessage:r.error?.message??null}}function S(e,t){return t?e.isSuccess?`success`:e.isError?e.error?.message===`Invite was already accepted`?`already-accepted`:`error`:`loading`:`idle`}var C=a();function w(){let{inviteCode:e}=u().query,{data:t}=m(),{status:i,errorMessage:a}=x({inviteCode:typeof e==`string`?e:void 0,enabled:!!t});return i===`idle`||i===`loading`||i===`success`||i===`already-accepted`?(0,C.jsx)(o,{}):(0,C.jsx)(n,{children:(0,C.jsxs)(l,{gap:4,children:[(0,C.jsxs)(r,{status:`error`,children:[(0,C.jsx)(s,{}),(0,C.jsxs)(c,{children:[(0,C.jsx)(g,{children:`An error occurred while accepting the invite.`}),(0,C.jsx)(_,{children:a})]})]}),(0,C.jsx)(f,{colorPalette:`orange`,onClick:()=>void p(),children:`Log Out and Try Again`})]})})}export{w as default};
//# sourceMappingURL=accept-Bypj9yX7.js.map