import{p as b,k as a,s as d,j as e,L as y}from"./index-D0iJORaS.js";import{C as w,I as m,B as S,L as C}from"./input-CcQzS21A.js";import{L as u}from"./label-gVuAupIv.js";import{C as L}from"./circle-check-CfUyk-e8.js";import{L as k}from"./lock-DL7_GkL6.js";function P(){const x=b(),[t,h]=a.useState(""),[n,p]=a.useState(""),[i,r]=a.useState(null),[f,j]=a.useState(!1),[o,l]=a.useState(!1),[g,v]=a.useState(!1);a.useEffect(()=>{d.auth.getSession().then(({data:s})=>{v(!!s.session)})},[]);const N=async s=>{if(s.preventDefault(),r(null),t.length<6)return r("Senha mínima de 6 caracteres.");if(t!==n)return r("As senhas não coincidem.");l(!0);const{error:c}=await d.auth.updateUser({password:t});l(!1),c?r(c.message):(j(!0),setTimeout(()=>x({to:"/login"}),2e3))};return e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-muted/40 via-background to-accent/30 px-4 py-10",children:e.jsxs("div",{className:"w-full max-w-md",children:[e.jsxs("div",{className:"mb-6 flex flex-col items-center",children:[e.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-xl bg-gradient-to-br from-primary to-primary-glow shadow-lg shadow-primary/20",children:e.jsx(w,{className:"h-6 w-6 text-primary-foreground"})}),e.jsx("h1",{className:"mt-3 text-xl font-bold tracking-tight",children:"365-BI"})]}),e.jsx("div",{className:"rounded-2xl border bg-card p-6 shadow-xl sm:p-8",children:f?e.jsxs("div",{className:"space-y-4 text-center",children:[e.jsx(L,{className:"mx-auto h-10 w-10 text-emerald-500"}),e.jsx("p",{className:"text-sm",children:"Senha atualizada. Redirecionando para o login…"})]}):g?e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Definir nova senha"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Crie uma senha de pelo menos 6 caracteres."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Nova senha"}),e.jsxs("div",{className:"relative",children:[e.jsx(k,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(m,{type:"password",value:t,onChange:s=>h(s.target.value),className:"pl-9 h-11"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(u,{children:"Confirmar senha"}),e.jsx(m,{type:"password",value:n,onChange:s=>p(s.target.value),className:"h-11"})]}),i&&e.jsx("div",{className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:i}),e.jsx(S,{type:"submit",disabled:o,className:"w-full h-11",children:o?e.jsx(C,{className:"h-4 w-4 animate-spin"}):"Salvar nova senha"})]}):e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Link inválido ou expirado."," ",e.jsx(y,{to:"/recuperar-senha",className:"text-primary underline",children:"Solicitar novo"})]})})]})})}export{P as component};
