import{Z as w,$ as C,G as r,w as e,N as k}from"./index-DDBPimHe.js";import{W as S,L as E}from"./wrench-ep8n-Rsp.js";function z(){const{signIn:a,signUp:o,session:b,loading:f}=w(),h=C(),[t,c]=r.useState("login"),[i,j]=r.useState(""),[d,N]=r.useState(""),[u,v]=r.useState(""),[m,n]=r.useState(null),[x,p]=r.useState(!1);if(!f&&b)return e.jsx(k,{to:"/"});async function y(s){s.preventDefault(),n(null),p(!0);const g=t==="login"?await a(i,d):await o(i,d,u);if(p(!1),g.error){n(g.error);return}if(t==="signup"){c("login"),n("Cuenta creada. Iniciá sesión.");return}h({to:"/"})}return e.jsx("div",{className:"min-h-screen grid place-items-center bg-background px-4",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"flex items-center gap-3 justify-center mb-8",children:[e.jsx("div",{className:"size-12 rounded-lg gradient-primary grid place-items-center shadow-elevated",children:e.jsx(S,{className:"size-6 text-primary-foreground",strokeWidth:2.5})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-display font-bold text-2xl leading-none",children:"Basurto"}),e.jsx("div",{className:"text-[11px] text-muted-foreground mt-1 uppercase tracking-widest",children:"No Te Calentés"})]})]}),e.jsxs("div",{className:"bg-card border border-border rounded-xl shadow-card p-6",children:[e.jsx("div",{className:"flex gap-1 p-1 bg-muted rounded-md mb-5",children:["login","signup"].map(s=>e.jsx("button",{type:"button",onClick:()=>{c(s),n(null)},className:`flex-1 py-1.5 text-sm rounded font-medium transition ${t===s?"bg-card shadow-sm":"text-muted-foreground"}`,children:s==="login"?"Iniciar sesión":"Crear cuenta"},s))}),e.jsxs("form",{onSubmit:y,className:"space-y-3",children:[t==="signup"&&e.jsx(l,{label:"Nombre completo",children:e.jsx("input",{required:!0,value:u,onChange:s=>v(s.target.value),className:"w-full px-3 py-2 bg-background border border-border rounded-md text-sm outline-none focus:border-ring"})}),e.jsx(l,{label:"Email",children:e.jsx("input",{required:!0,type:"email",value:i,onChange:s=>j(s.target.value),className:"w-full px-3 py-2 bg-background border border-border rounded-md text-sm outline-none focus:border-ring"})}),e.jsx(l,{label:"Contraseña",children:e.jsx("input",{required:!0,minLength:6,type:"password",value:d,onChange:s=>N(s.target.value),className:"w-full px-3 py-2 bg-background border border-border rounded-md text-sm outline-none focus:border-ring"})}),m&&e.jsx("div",{className:"text-xs text-destructive bg-destructive/10 px-3 py-2 rounded",children:m}),e.jsxs("button",{disabled:x,type:"submit",className:"w-full inline-flex items-center justify-center gap-2 px-4 py-2.5 rounded-md gradient-primary text-primary-foreground font-medium text-sm shadow-elevated disabled:opacity-60",children:[x&&e.jsx(E,{className:"size-4 animate-spin"}),t==="login"?"Entrar":"Crear cuenta"]})]})]}),e.jsxs("p",{className:"text-center text-xs text-muted-foreground mt-4",children:["Las cuentas nuevas se crean como ",e.jsx("span",{className:"font-mono",children:"técnico"}),". Un admin puede promoverlas luego."]})]})})}function l({label:a,children:o}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:a}),e.jsx("div",{className:"mt-1",children:o})]})}export{z as component};
