1import{r as i,x as D,v as q,n as e,L as I,D as n}from"./vendor-react-CXHG0QNZ.js";import{F as s,P as z,C as H,aD as O,O as y,aj as B,S as G,R as U,ao as W,a as S,t as $,a6 as J}from"./vendor-fa-C4xqBMvT.js";import{u as Q,d as V,c as X}from"./index-DPeCy0PN.js";import{u as Y}from"./useRateLimit-DS_jj5T4.js";import"./vendor-supabase-DTKgmkps.js";function le(){const[m,L]=i.useState(!1),[x,u]=i.useState(!1),[c,o]=i.useState("login"),[l,b]=i.useState(""),[h,p]=i.useState(!1),{signIn:E,signOut:C,user:A,role:F}=Q(),f=D(),{get:g}=V(),j=g("site_name"),w=g("logo_url"),{isBlocked:r,countdownLabel:P,record:R}=Y("admin_login_fail",{max:5,windowMs:15*60*1e3}),{register:N,handleSubmit:M,formState:{errors:d}}=q();if(A&&F==="admin")return f("/admin"),null;const K=async({email:a,password:t})=>{if(!r){u(!0);try{if((await E(a,t)).role!=="admin")throw await C(),new Error("not_admin");n.success("Login berhasil! Selamat datang di panel admin."),f("/admin")}catch{R()?n.error("Email atau password salah."):n.error("Terlalu banyak percobaan gagal. Akses dikunci sementara.")}finally{u(!1)}}},T=async a=>{if(a.preventDefault(),!l||!/\S+@\S+\.\S+/.test(l)){n.error("Masukkan email yang valid");return}p(!0);try{const{error:t}=await X.auth.resetPasswordForEmail(l,{redirectTo:`${window.location.origin}/admin/reset-password`});if(t)throw t;o("sent")}catch(t){n.error("Gagal mengirim email reset: "+t.message)}finally{p(!1)}},k="w-full pl-11 pr-4 py-3 rounded-xl border border-slate-200 text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-400 transition-all",v=({subtitle:a})=>e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-blue-600 to-blue-800 rounded-2xl flex items-center justify-center text-white mx-auto mb-4 shadow-lg shadow-blue-500/30 overflow-hidden",children:w?e.jsx("img",{src:w,alt:j,className:"w-full h-full object-contain p-1"}):e.jsx(s,{icon:J,className:"text-2xl"})}),e.jsxs("h1",{className:"text-2xl font-extrabold text-slate-900",children:[j," Admin"]}),e.jsx("p",{className:"text-slate-500 text-sm mt-1",children:a})]});return e.jsxs("div",{className:"min-h-screen bg-gradient-to-br from-slate-900 via-blue-950 to-slate-900 flex items-center justify-center px-4",children:[e.jsx("div",{className:"absolute inset-0 opacity-5",style:{backgroundImage:"radial-gradient(circle at 2px 2px, white 1px, transparent 0)",backgroundSize:"40px 40px"}}),e.jsx("div",{className:"relative w-full max-w-md",children:e.jsxs("div",{className:"bg-white rounded-3xl shadow-2xl p-8 sm:p-10",children:[c==="login"&&e.jsxs(e.Fragment,{children:[e.jsx(v,{subtitle:"Masuk ke panel administrasi"}),r?e.jsxs("div",{className:"flex items-start gap-3 bg-red-50 border border-red-200 rounded-xl px-4 py-3 mb-6",children:[e.jsx(s,{icon:z,className:"text-red-500 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-red-700 text-sm font-semibold",children:"Akses dikunci sementara"}),e.jsxs("p",{className:"text-red-600 text-xs mt-0.5",children:["Terlalu banyak percobaan gagal. Coba lagi dalam"," ",e.jsxs("span",{className:"font-bold inline-flex items-center gap-1",children:[e.jsx(s,{icon:H}),P]})]})]})]}):e.jsxs("div",{className:"flex items-center gap-2 bg-blue-50 border border-blue-100 rounded-xl px-4 py-3 mb-6",children:[e.jsx(s,{icon:O,className:"text-blue-600 flex-shrink-0"}),e.jsx("p",{className:"text-blue-700 text-xs font-medium",children:"Akses ini dilindungi dengan enkripsi end-to-e
1nd"})]}),e.jsxs("form",{onSubmit:M(K),className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Email Admin"}),e.jsxs("div",{className:"relative",children:[e.jsx(s,{icon:y,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{...N("email",{required:"Email wajib diisi",pattern:{value:/\S+@\S+\.\S+/,message:"Email tidak valid"}}),type:"email",className:k,placeholder:"[email protected]",autoComplete:"email",disabled:r})]}),d.email&&e.jsx("p",{className:"text-red-500 text-xs mt-1",children:d.email.message})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700",children:"Password"}),e.jsx("button",{type:"button",onClick:()=>o("forgot"),className:"text-xs text-blue-600 hover:underline font-medium",children:"Lupa password?"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(s,{icon:B,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{...N("password",{required:"Password wajib diisi",minLength:{value:6,message:"Password minimal 6 karakter"}}),type:m?"text":"password",className:"w-full pl-11 pr-12 py-3 rounded-xl border border-slate-200 text-slate-800 placeholder-slate-400 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-400 transition-all",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",autoComplete:"current-password",disabled:r}),e.jsx("button",{type:"button",onClick:()=>L(!m),className:"absolute right-4 top-1/2 -translate-y-1/2 text-slate-400 hover:text-slate-600 transition-colors",children:e.jsx(s,{icon:m?G:U})})]}),d.password&&e.jsx("p",{className:"text-red-500 text-xs mt-1",children:d.password.message})]}),e.jsx("button",{type:"submit",disabled:x||r,className:"w-full bg-gradient-to-r from-blue-600 to-blue-700 text-white py-3.5 rounded-xl font-bold text-base hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 transition-all disabled:opacity-50 disabled:transform-none flex items-center justify-center gap-2",children:x?e.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent rounded-full animate-spin"}):"Masuk ke Dashboard"})]}),e.jsx("p",{className:"text-center text-sm text-slate-500 mt-6",children:e.jsx(I,{to:"/",className:"text-blue-600 hover:underline",children:"â Kembali ke Website"})})]}),c==="forgot"&&e.jsxs(e.Fragment,{children:[e.jsx(v,{subtitle:"Reset password admin"}),e.jsx("div",{className:"bg-amber-50 border border-amber-200 rounded-xl px-4 py-3 mb-6 text-sm text-amber-800",children:"Masukkan email admin Anda. Kami akan mengirim link reset password ke email tersebut."}),e.jsxs("form",{onSubmit:T,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-slate-700 mb-2",children:"Email Admin"}),e.jsxs("div",{className:"relative",children:[e.jsx(s,{icon:y,className:"absolute left-4 top-1/2 -translate-y-1/2 text-slate-400"}),e.jsx("input",{type:"email",value:l,onChange:a=>b(a.target.value),className:k,placeholder:"[email protected]",autoComplete:"email",required:!0})]})]}),e.jsx("button",{type:"submit",disabled:h,className:"w-full bg-gradient-to-r from-blue-600 to-blue-700 text-white py-3.5 rounded-xl font-bold text-base hover:-translate-y-0.5 hover:shadow-lg hover:shadow-blue-500/30 transition-all disabled:opacity-70 disabled:transform-none flex items-center justify-center gap-2",children:h?e.jsx("div",{className:"w-5 h-5 border-2 border-white border-t-transparent rounded-full animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(s,{icon:W})," Kirim Link Reset"]})})]}),e.jsxs("button",{onClick:()=>o("login"),className:"flex items-center gap-2 text-sm text-slate-500 hover:text-slate-700 mt-6 mx-auto",children:[e.jsx(s,{icon:S}),"Kembali ke halaman login"]})]}),c==="sent"&&e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-20 h-20 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-6",children:e.jsx(s,{icon:$,className:"text-4xl text-green-500"})}),e.jsx("h2",{className:"text-xl font-bold text-slate-900 mb-2",children:"Email Terkirim!"}),e.jsx("p",{className:"text-slate-500 text-sm mb-2",children:"Link reset password telah dikirim ke:"}),e.jsx("p",{className:"font-semibold text-blue-600 mb-4",children:l}),e.jsx("p",{className:"text-slate-400 text-xs mb-8",children:"Cek inbox (dan folder spam) Anda. Link berlaku selama 1 jam."}),e.jsxs("button",{onClick:()=>{o("login"),b("")},className:"flex items-center gap-2 text-sm text-blue-600 hover:underline mx-auto",children:[e.jsx(s,{icon:S}),"Kembali ke halaman login"]})]})]})})]})}export{le 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.