1import{u as E,j as e,S as w}from"./index--siChAZm.js";import{u as A,r as n,N as B}from"./react-vendor-B-clOVnp.js";import{k as g,M as R,aj as T,E as W,c as D,aw as I,a as F}from"./icons-BCLA8W0j.js";const N={minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"linear-gradient(135deg, #031D44 0%, #0f2d60 60%, #1a4080 100%)",padding:16},P={background:"#fff",borderRadius:18,padding:"40px 36px",width:"100%",maxWidth:420,boxShadow:"0 20px 60px rgba(0,0,0,0.35)"},x={position:"relative",marginBottom:16},u={position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",color:"#94a3b8",pointerEvents:"none"},f={width:"100%",boxSizing:"border-box",padding:"12px 12px 12px 40px",border:"1.5px solid #e2e8f0",borderRadius:9,fontSize:"0.95rem",background:"#f8fafc",color:"#1e293b",outline:"none"},L={width:"100%",padding:"13px 0",background:"#031D44",color:"#fff",border:"none",borderRadius:9,fontWeight:700,fontSize:"1rem",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:7,marginTop:4,transition:"opacity .15s"};function M(){const{loginComJWT:h,usuario:y,carregando:b}=E(),j=A(),[l,S]=n.useState("login"),[r,v]=n.useState(""),[s,z]=n.useState(""),[d,k]=n.useState(!1),[o,c]=n.useState(!1),[p,a]=n.useState("");if(!b&&y?.perfil==="admin")return e.jsx(B,{to:"/admin/home",replace:!0});async function C(t){if(t.preventDefault(),a(""),!r.trim()||!s){a("Preencha e-mail e senha.");return}c(!0);try{const m=await fetch("/api/auth/admin-login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:r.trim(),senha:s})}),i=await m.json();if(!m.ok){a(i.erro||"Erro ao autenticar.");return}h(i.token,i.usuario,i.version),S("ok"),setTimeout(()=>j("/admin/home",{replace:!0}),1200)}catch{a("Erro de conexão. Tente novamente.")}finally{c(!1)}}return e.jsx("div",{style:N,children:e.jsxs("div",{style:P,children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:28},children:[e.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:56,height:56,borderRadius:16,background:"#031D44",marginBottom:14},children:e.jsx(g,{size:28,color:"#fff"})}),e.jsx("h1",{style:{fontSize:"1.35rem",fontWeight:800,color:"#031D44",margin:"0 0 4px"},children:"Painel Administrativo"}),e.jsx("p",{style:{fontSize:13,color:"#94a3b8",margin:0},children:"Acesso restrito a administradores"})]}),l==="login"&&e.jsxs("form",{onSubmit:C,children:[e.jsx("label",{style:{fontSize:12,fontWeight:600,color:"#374151",display:"block",marginBottom:4},children:"E-mail"}),e.jsxs("div",{style:x,children:[e.jsx(R,{size:16,style:u}),e.jsx("input",{type:"email",placeholder:"[email protected]",value:r,onChange:t=>v(t.target.value),disabled:o,autoComplete:"email",style:f})]}),e.jsx("label",{style:{fontSize:12,fontWeight:600,color:"#374151",display:"block",marginBottom:4},children:"Senha"}),e.jsxs("div",{style:{...x,marginBottom:20},children:[e.jsx(T,{size:16,style:u}),e.jsx("input",{type:d?"text":"password",placeholder:"Senha",value:s,onChange:t=>z(t.target.value),disabled:o,autoComplete:"current-password",style:{...f,paddingRight:42}}),e.jsx("button",{type:"button",onClick:()=>k(t=>!t),style:{position:"absolute",right:12,top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",color:"#94a3b8",padding:0},tabIndex:-1,children:d?e.jsx(W,{size:16}):e.jsx(D,{size:16})})]}),p&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,background:"#fef2f2",border:"1px solid #fecaca",borderRadius:8,padding:"10px 12px",marginBottom:14,color:"#dc2626",fontSize:13},children:[e.jsx(I,{size:15,style:{flexShrink:0}})," ",p]}),e.jsx("button",{type:"submit",style:{...L,opacity:o?.7:1},disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(w,{size:16})," Entrandoâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(g,{size:16})," Entrar"]})})]}),l==="ok"&&e.jsxs("div",{style:{textAlign:"center",padding:"12px 0 8px"},children:[e.jsx(F,{size:56,color:"#16a34a",style:{marginBottom:14}}),e.jsx("h2",{style:{color:"#16a34a",fontSize:"1.2rem",margin:"0 0 8px"},children:"Acesso autorizado"}),e.jsx("p",{style:{color:"#64748b",fontSize:14,margin:0},children:"Redirecionando para o painelâ¦"})]}),e.jsxs("p",{style:{textAlign:"center",fontSize:11,color:"#cbd5e1",marginTop:24,marginBottom:0},children:["FreelaCerto · Ãrea restrita · ",new Date().getFullYear()]})]})})}export{M as default};
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.