1import{u as f,r as s,E as u,j as e,c as h}from"./index-DSZpxYnS.js";import{b as y}from"./admin.functions-CF2H0Crg.js";import{L as j}from"./loader-circle-5FguiGAv.js";function k(){const n=f(),[r,x]=s.useState("login"),[i,p]=s.useState("[email protected]"),[o,g]=s.useState(""),[l,d]=s.useState(!1),[c,m]=s.useState(null);s.useEffect(()=>{u.auth.getSession().then(({data:t})=>{t.session&&n({to:"/admin"})})},[n]);async function b(t){t.preventDefault(),m(null),d(!0);try{r==="bootstrap"&&await y({data:{email:i,password:o}});const{error:a}=await u.auth.signInWithPassword({email:i,password:o});if(a)throw a;n({to:"/admin"})}catch(a){m(a?.message??"Login failed")}finally{d(!1)}}return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-muted/30 p-4",children:e.jsxs("div",{className:"w-full max-w-md rounded-2xl border border-border bg-card p-8 shadow-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[e.jsx(h,{className:"h-5 w-5"}),e.jsx("span",{className:"text-xs font-semibold uppercase tracking-[0.18em]",children:"Admin Access"})]}),e.jsx("h1",{className:"mt-3 font-display text-3xl font-bold text-ink",children:r==="login"?"Sign in":"Create admin account"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Authorized personnel only."}),e.jsxs("form",{onSubmit:b,className:"mt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1.5",children:"Email"}),e.jsx("input",{required:!0,type:"email",value:i,onChange:t=>p(t.target.value),className:"w-full rounded-lg border border-input bg-background px-3 py-2.5 text-sm focus:border-primary focus:ring-2 focus:ring-primary/20 outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-1.5",children:"Password"}),e.jsx("input",{required:!0,type:"password",value:o,onChange:t=>g(t.target.value),className:"w-full rounded-lg border border-input bg-background px-3 py-2.5 text-sm focus:border-primary focus:ring-2 focus:ring-primary/20 outline-none"})]}),c&&e.jsx("div",{className:"rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:c}),e.jsxs("button",{disabled:l,className:"w-full inline-flex items-center justify-center gap-2 rounded-lg bg-primary text-primary-foreground px-4 py-2.5 text-sm font-semibold hover:bg-primary/90 disabled:opacity-60",children:[l&&e.jsx(j,{className:"h-4 w-4 animate-spin"}),r==="login"?"Sign in":"Create admin & sign in"]})]}),e.jsx("button",{type:"button",onClick:()=>x(r==="login"?"bootstrap":"login"),className:"mt-4 w-full text-center text-xs text-muted-foreground hover:text-primary",children:r==="login"?"First time? Create the admin account â":"â Back to sign in"})]})})}export{k as component};
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.