1import{r as n,j as e}from"./client-DgmbFQwv.js";import{b as A,L as g}from"./index-TryCyB3y.js";import{A as w}from"./AccountSecuritySettings-0xGq89qO.js";import{B as d}from"./button-DSMzvqdJ.js";import{u as C}from"./useUserRoles-BYwtHlZr.js";import{s as f}from"./client-BQyHXIr5.js";import{d as T}from"./tenantProducts-C5vvgVOK.js";import{A as P}from"./arrow-left-BWmggP1l.js";import"./main-CM6kJPpm.js";import"./tooltip-CscMiEuD.js";import"./useAuth-BCBk10aC.js";import"./index-CZuluy6V.js";import"./tslib.es6-CRrOrkzB.js";import"./createLucideIcon-CvMKHw2G.js";function H(){const{tenantId:y,isPlatformAdmin:j}=C(),[m]=A(),[t,l]=n.useState(null),[S,o]=n.useState(!0),[h,i]=n.useState(null),[I,N]=n.useState(0),p=T(m.get("returnTo"))||"/crm2",c=m.get("tenantId"),r=(c&&/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(c)?c:void 0)||(j?void 0:y),x=new URLSearchParams({returnTo:p});r&&x.set("tenantId",r);const b=`/auth?returnTo=${encodeURIComponent(`/account/security?${x}`)}`,v=n.useCallback(()=>N(s=>s+1),[]);return n.useEffect(()=>{let s=!0;o(!0),i(null),f.auth.getUser().then(({data:u,error:a})=>{s&&(l(u.user),a&&a.name!=="AuthSessionMissingError"&&i("Your sign-in could not be checked. Check your connection and try again."),o(!1))}).catch(()=>{s&&(i("Your sign-in could not be checked. Check your connection and try again."),o(!1))});const{data:{subscription:k}}=f.auth.onAuthStateChange((u,a)=>{!s||u==="INITIAL_SESSION"||l((a==null?void 0:a.user)||null)});return()=>{s=!1,k.unsubscribe()}},[I]),e.jsx("main",{className:"min-h-screen bg-background px-4 py-6 text-foreground sm:px-6 sm:py-8",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-5",children:[e.jsx(d,{variant:"ghost",className:"min-h-11 px-2",asChild:!0,children:e.jsxs(g,{to:p,children:[e.jsx(P,{className:"h-4 w-4","aria-hidden":"true"}),"Back to workspace"]})}),e.jsxs("header",{children:[e.jsx("h1",{className:"font-sans text-2xl font-bold",children:"Your account"}),e.jsx("p",{className:"mt-2 max-w-prose break-words text-sm leading-6 text-muted-foreground",children:t!=null&&t.email?`Security settings for ${t.email}`:"Manage sign-in methods and recover access to your account."})]}),S?e.jsx("p",{role:"status",className:"text-sm",children:"Checking your sign-inâ¦"}):h?e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{role:"alert",className:"text-sm text-red-700",children:h}),e.jsx(d,{variant:"outline",className:"min-h-11",onClick:v,children:"Check sign-in again"})]}):t?e.jsx(w,{tenantId:r},`${t.id}:${r||"personal"}`):e.jsxs("div",{className:"space-y-3",children:[e.jsx("p",{className:"text-base leading-7",children:"Sign in with your password or email code to manage your security or use a saved recovery code."}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"If an MFA reset is incomplete, sign in again to finish recovery. Its saved request will appear in your security settings."}),e.jsx(d,{className:"min-h-11",asChild:!0,children:e.jsx(g,{to:b,children:"Sign in to continue"})})]})]})})}export{H 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.