1import{z as y,u as v,r as d,j as e,A as s}from"./index-CrUtuemb.js";import{B as p,L as b,I as E}from"./label-CnhVL9Dm.js";import{A as O}from"./AdminBranding-Bt7JkClo.js";import{L as T}from"./Icons-BGiXV7C8.js";import"./utils-BJMx_d8c.js";async function N(l,m){const r=async t=>{try{return await fetch(t,m)}catch{return null}};let n=await r(`/api/auth/${l}`);if(!n){const t=`${window.location.protocol}//${window.location.hostname}:3001/api/auth/${l}`;n=await r(t)}return n}function C(){const[l]=y(),m=v(),r=l.get("token")||"",[n,t]=d.useState(null),[i,g]=d.useState(""),[u,j]=d.useState(""),[f,o]=d.useState(""),[x,S]=d.useState(!1),[h,R]=d.useState(!1);d.useEffect(()=>{if(!r){t(!1);return}N(`validate-reset-token?token=${encodeURIComponent(r)}`).then(async a=>{if(!a){t(!1);return}const c=await a.json();t(!!c.valid)}).catch(()=>t(!1))},[r]);const w=async a=>{if(a.preventDefault(),o(""),i.length<8){o(s.RESET_PASSWORD_ERROR_MIN);return}if(i!==u){o(s.RESET_PASSWORD_ERROR_MISMATCH);return}S(!0);try{const c=await N("reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r,newPassword:i})});if(!c||!c.ok){const _=c?await c.json():{};o(_.error||"No se pudo actualizar la contraseña.");return}R(!0),setTimeout(()=>m("/admin"),3e3)}catch{o("Error de conexión. Inténtalo de nuevo.")}finally{S(!1)}};return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-gradient-to-br from-gray-900/50 to-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white rounded-xl shadow-2xl w-full max-w-md mx-4 overflow-hidden",children:[e.jsx("div",{className:"bg-gradient-to-r from-[#138a8a] to-[#0f6f6f] px-8 py-12 text-center",children:e.jsx(O,{logoSize:"medium"})}),e.jsxs("div",{className:"p-8",children:[e.jsx("div",{className:"flex items-center justify-center mb-6",children:e.jsx("div",{className:"bg-teal-50 rounded-full p-3",children:e.jsx(T,{className:"w-5 h-5 text-[#138a8a]"})})}),n===null&&e.jsx("p",{className:"text-center text-gray-500 text-sm",children:"Verificando enlaceâ¦"}),n===!1&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-md",children:e.jsx("p",{className:"text-red-600 text-sm text-center font-medium",children:s.RESET_PASSWORD_INVALID_TOKEN})}),e.jsx(p,{onClick:()=>m("/admin"),className:"w-full bg-[#138a8a] hover:bg-[#0f6f6f] text-white",children:s.RESET_PASSWORD_GO_LOGIN})]}),n===!0&&!h&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-900 text-center mb-2",children:s.RESET_PASSWORD_TITLE}),e.jsx("p",{className:"text-gray-600 text-center text-sm mb-6",children:s.RESET_PASSWORD_DESCRIPTION}),e.jsxs("form",{onSubmit:w,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx(b,{htmlFor:"new-password",className:"text-sm font-medium text-gray-700 block mb-2",children:s.RESET_PASSWORD_NEW_LABEL}),e.jsx(E,{id:"new-password",type:"password",value:i,onChange:a=>{g(a.target.value),o("")},placeholder:s.RESET_PASSWORD_PLACEHOLDER,autoFocus:!0,disabled:x,className:"border-gray-300 focus:border-[#138a8a] focus:ring-[#138a8a]"})]}),e.jsxs("div",{children:[e.jsx(b,{htmlFor:"confirm-password",className:"text-sm font-medium text-gray-700 block mb-2",children:s.RESET_PASSWORD_CONFIRM_LABEL}),e.jsx(E,{id:"confirm-password",type:"password",value:u,onChange:a=>{j(a.target.value),o("")},placeholder:s.RESET_PASSWORD_PLACEHOLDER,disabled:x,className:"border-gray-300 focus:border-[#138a8a] focus:ring-[#138a8a]"})]}),f&&e.jsx("div",{className:"p-3 bg-red-50 border border-red-200 rounded-md",children:e.jsx("p",{className:"text-red-600 text-sm font-medium text-center",children:f})}),e.jsx(p,{type:"submit",disabled:x||!i||!u,className:"w-full bg-[#138a8a] hover:bg-[#0f6f6f] text-white font-medium py-2 rounded-lg",children:x?e.jsxs("span",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),s.RESET_PASSWORD_SAVING]}):s.RESET_PASSWORD_BUTTON})]})]}),h&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"p-4 bg-teal-50 border border-teal-200 rounded-md",children:e.jsx("p",{className:"text-teal-700 text-sm text-center font-medium",children:s.RESET_PASSWORD_SUCCESS})}),e.jsx("p",{className:"text-center text-xs text-gray-500",children:"Redirigiendo al panelâ¦"})]})]})]})})}export{C as ResetPasswordPage};
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.