1import{u as b,b as y,k as _,d as N,j as i,L as S}from"./index-DTo46tGQ.js";import{f as C,b as P}from"./react-vendor-CfoRXicY.js";import{supabase as h}from"./supabase-CNbjEO5G.js";import{CONNECT_SESSION_KEY as l}from"./AuthConnect-DDXaqOc2.js";import"./supabase-DHizuabt.js";import"./types-DHgsoueE.js";function E(r){if(!r||!r.startsWith("/")||r.startsWith("//"))return"/dashboard";try{const a=new URL(r,window.location.origin);return a.origin!==window.location.origin?"/dashboard":`${a.pathname}${a.search}${a.hash}`||"/dashboard"}catch{return"/dashboard"}}const U=()=>{const{session:r,loading:a}=b(),e=C();return y({title:"Finishing sign-in",description:"Completing your AgentWeb sign-in and sending you back to where you started."}),P.useEffect(()=>{const s=new URLSearchParams(window.location.hash.replace(/^#/,"")),c=new URLSearchParams(window.location.search).get("next"),g=s.get("type"),n=s.get("error_code"),f=s.get("error_description"),o=c==="company-brain-reset"||g==="recovery"||n==="otp_expired";if(n){if(o){const t=new URLSearchParams({error:n,message:f||"Email link is invalid or has expired."});e(`/company-brain/reset-password?${t.toString()}`,{replace:!0});return}e("/login?error=auth_failed",{replace:!0});return}if(a)return;if(!r){const t=setTimeout(()=>{r||e(o?"/company-brain/reset-password?error=no_session&message=Open%20a%20fresh%20password%20setup%20link.":"/login?error=auth_failed",{replace:!0})},2500);return()=>clearTimeout(t)}if(o){e("/company-brain/reset-password",{replace:!0});return}const p=sessionStorage.getItem(l);if(p){sessionStorage.removeItem(l),e(`/auth/connect?session=${encodeURIComponent(p)}`,{replace:!0});return}const u=_()||"signup";if(u==="company_brain"){e("/company-brain",{replace:!0});return}(async()=>{const{data:t,error:m}=await h.from("profiles_safe").select("created_at").single(),w=Date.now(),d=t!=null&&t.created_at?new Date(t.created_at).getTime():null,x=!m&&d!==null&&w-d<6e4;if(u==="signin"&&x){await h.auth.signOut(),e("/signup?no_account=1",{replace:!0});return}e(E(c??N()),{replace:!0})})()},[r,a,e]),i.jsxs("div",{className:"flex min-h-screen flex-col items-center justify-center gap-5 bg-aw-bg",role:"status",children:[i.jsx(S,{className:"h-5 w-5 animate-spin text-white/45","aria-hidden":!0}),i.jsx("p",{className:"aw-mono text-[11px] uppercase tracking-[0.24em] text-white/40",children:"Finishing sign-inâ¦"})]})};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.