import{a as l,j as e}from"./vendor-query-Brcc40-Y.js";import{b as f,u as h}from"./vendor-react-DP6BW_9B.js";import{f as p,S as x,s as d,g as j}from"./index-tN-ddyeb.js";import{u as S}from"./users.service-CoC1p39-.js";import"./vendor-utils-ui5PHgZB.js";import"./vendor-zustand-CVDiRiMG.js";import"./vendor-form-BQNAly2Z.js";function P(){const[a]=f(),i=h(),n=p(t=>t.setAuth),[o,c]=l.useState(null);return l.useEffect(()=>{const t=a.get("token");if(!t){c("Missing authentication token");return}let r=!1;async function m(){try{d(t);const u=await S.getMe();if(r)return;n(u,t);const s=sessionStorage.getItem("postAuthRedirect");sessionStorage.removeItem("postAuthRedirect");const g=s!=null&&s.startsWith("/")&&!s.startsWith("//")?s:"/";i(g,{replace:!0})}catch{r||(c("Google sign-in failed. Please try again."),j())}}return m(),()=>{r=!0}},[a,i,n]),o?e.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-4 bg-bg-base px-4",children:[e.jsx("p",{className:"text-sm text-danger",children:o}),e.jsx("a",{href:"/login",className:"text-sm text-primary hover:text-primary",children:"Back to login"})]}):e.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-3 bg-bg-base",children:[e.jsx(x,{size:"lg"}),e.jsx("p",{className:"text-sm text-ink-muted",children:"Signing you in with Google…"})]})}export{P as default};
