import{u as j,r as o,j as e,L as y,t as c}from"./index-DEjMkqlI.js";import{s as d}from"./client-DXODAVLv.js";import{B as N}from"./button-CPTgagfA.js";import{L as m,I as l}from"./label-BFhjrfYb.js";function L(){const a=j(),[s,u]=o.useState("signin"),[x,n]=o.useState(!1);o.useEffect(()=>{d.auth.getSession().then(({data:t})=>{t.session&&a({to:"/admin"})})},[a]);async function f(t){t.preventDefault(),n(!0);const r=new FormData(t.currentTarget),i=String(r.get("email")??"").trim(),g=String(r.get("password")??""),b=String(r.get("display_name")??"").trim();if(s==="signup"){const{error:h}=await d.auth.signUp({email:i,password:g,options:{emailRedirectTo:`${window.location.origin}/admin`,data:{display_name:b||i}}});if(n(!1),h){c.error(h.message);return}c.success("Account created. Check your inbox to verify, then sign in."),u("signin");return}const{error:p}=await d.auth.signInWithPassword({email:i,password:g});if(n(!1),p){c.error(p.message);return}a({to:"/admin"})}return e.jsx("div",{className:"min-h-screen flex items-center justify-center px-5 py-10 bg-background bg-spotlight",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs(y,{to:"/",className:"flex items-center justify-center gap-2 mb-10",children:[e.jsx("span",{className:"font-display text-3xl",children:"Luxxen"}),e.jsx("span",{className:"font-display text-3xl text-gradient-gold",children:"Pictures"})]}),e.jsxs("div",{className:"bg-onyx border border-border p-8 md:p-10",children:[e.jsx("h1",{className:"font-display text-3xl text-center",children:s==="signin"?"Admin Sign In":"Create Admin Account"}),e.jsx("p",{className:"text-center text-sm text-muted-foreground mt-2",children:s==="signin"?"Access the Luxxen Pictures dashboard":"First admin? Create your account."}),e.jsxs("form",{onSubmit:f,className:"mt-8 space-y-5",children:[s==="signup"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"text-xs uppercase tracking-widest text-muted-foreground",children:"Display Name"}),e.jsx(l,{name:"display_name",required:!0,maxLength:120,className:"bg-background h-12"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"text-xs uppercase tracking-widest text-muted-foreground",children:"Email"}),e.jsx(l,{name:"email",type:"email",required:!0,className:"bg-background h-12"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(m,{className:"text-xs uppercase tracking-widest text-muted-foreground",children:"Password"}),e.jsx(l,{name:"password",type:"password",required:!0,minLength:6,className:"bg-background h-12"})]}),e.jsx(N,{type:"submit",variant:"hero",size:"lg",disabled:x,className:"w-full",children:x?"...":s==="signin"?"Sign In":"Create Account"})]}),e.jsx("button",{onClick:()=>u(s==="signin"?"signup":"signin"),className:"w-full mt-6 text-sm text-muted-foreground hover:text-gold transition-colors",children:s==="signin"?"No account yet? Create one":"Already have an account? Sign in"})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground mt-6",children:"The first user to sign up should be granted the admin role from the backend dashboard."})]})})}export{L as component};
