module.exports=[86908,a=>{"use strict";var b=a.i(48333),c=a.i(81235),d=a.i(93465);let e=process.env.NEXT_PUBLIC_API_BASE||"http://localhost:5000";function f(){let a=(0,d.useRouter)(),f=(0,d.useSearchParams)(),[g,h]=(0,c.useState)("admin");(0,c.useEffect)(()=>{let a=f.get("username");a&&h(String(a))},[f]);let[i,j]=(0,c.useState)(""),[k,l]=(0,c.useState)(""),[m,n]=(0,c.useState)(!1),o=async b=>{b.preventDefault(),l(""),n(!0);try{let b=await fetch(`${e}/api/admin/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:g,password:i})});if(!b.ok){let a=await b.json().catch(()=>({}));throw Error(a.message||"Login failed")}let c=await b.json(),d=c?.token||"";if(!d)throw Error("Token missing from server");localStorage.setItem("admin_token_v1",d),localStorage.setItem("admin_session_v1","true"),document.cookie=`admin_token_v1=${encodeURIComponent(d)}; path=/`,document.cookie="admin_session_v1=true; path=/",a.replace("/admin/inbox")}catch(a){l(a?.message||"Login failed")}finally{n(!1)}};return(0,b.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-[#f6f6f6] p-6",children:(0,b.jsxs)("div",{className:"w-full max-w-md bg-white border border-black/10 rounded-2xl shadow-sm p-6",children:[(0,b.jsx)("div",{className:"text-2xl font-bold",children:"Admin Login"}),(0,b.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Social AI Bot"}),(0,b.jsxs)("form",{onSubmit:o,className:"mt-6 space-y-4",children:[(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-semibold mb-1",children:"Username"}),(0,b.jsx)("input",{value:g,onChange:a=>h(a.target.value),className:"w-full px-4 py-3 rounded-lg border border-black/10",placeholder:"username",autoComplete:"username"})]}),(0,b.jsxs)("div",{children:[(0,b.jsx)("div",{className:"text-sm font-semibold mb-1",children:"Password"}),(0,b.jsx)("input",{type:"password",value:i,onChange:a=>j(a.target.value),className:"w-full px-4 py-3 rounded-lg border border-black/10",placeholder:"password",autoComplete:"current-password"})]}),k?(0,b.jsx)("div",{className:"text-sm text-red-600",children:k}):null,(0,b.jsx)("button",{disabled:m,className:"w-full px-4 py-3 rounded-lg border border-black/10 hover:bg-black hover:text-white transition disabled:opacity-60",children:m?"Logging in...":"Login"})]})]})})}a.s(["default",()=>f])}];

//# sourceMappingURL=Downloads_ui-main-fixed_ui-main_app_admin_login_AdminLoginClient_736b08c0.js.map