module.exports=[83694,a=>{"use strict";var b=a.i(87924),c=a.i(72131);a.s(["default",0,function(){let[a,d]=(0,c.useState)(""),[e,f]=(0,c.useState)(""),[g,h]=(0,c.useState)(""),[i,j]=(0,c.useState)(!1),[k,l]=(0,c.useState)(!0);(0,c.useEffect)(()=>{let a=!1;return fetch("/api/auth",{cache:"no-store"}).then(a=>a.json()).then(b=>{a||(b.user&&b.landing?window.location.replace(b.landing):l(!1))}).catch(()=>!a&&l(!1)),()=>{a=!0}},[]);let m=async b=>{b.preventDefault(),j(!0),h("");try{let b=await fetch("/api/auth",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:"login",email:a,password:e})}),c=await b.json();if(!b.ok)throw Error(c.error||"Unable to sign in");window.location.replace(c.landing||"/")}catch(a){h(a instanceof Error?a.message:"Unable to sign in"),j(!1)}};return k?(0,b.jsx)("div",{className:"login-shell",children:(0,b.jsx)("div",{className:"login-card",children:(0,b.jsx)("p",{className:"login-checking",children:"Checking your session..."})})}):(0,b.jsx)("div",{className:"login-shell",children:(0,b.jsxs)("div",{className:"login-card",children:[(0,b.jsxs)("div",{className:"login-brand",children:[(0,b.jsx)("span",{className:"brand-mark",children:"HO"}),(0,b.jsxs)("div",{children:[(0,b.jsx)("strong",{children:"Hostel Operations"}),(0,b.jsx)("small",{children:"Internal management system"})]})]}),(0,b.jsx)("h1",{children:"Sign in"}),(0,b.jsx)("p",{className:"login-intro",children:"Staff accounts open the management system. Student accounts open the resident portal."}),g&&(0,b.jsx)("div",{className:"login-error",children:g}),(0,b.jsxs)("form",{onSubmit:m,children:[(0,b.jsxs)("label",{children:["Email",(0,b.jsx)("input",{type:"email",value:a,onChange:a=>d(a.target.value),autoComplete:"username",required:!0,autoFocus:!0})]}),(0,b.jsxs)("label",{children:["Password",(0,b.jsx)("input",{type:"password",value:e,onChange:a=>f(a.target.value),autoComplete:"current-password",required:!0})]}),(0,b.jsx)("button",{className:"primary",disabled:i,children:i?"Signing in...":"Sign in"})]}),(0,b.jsx)("p",{className:"login-foot",children:"Forgot your password? Ask an administrator to set a new one for you."})]})})}])}];

//# sourceMappingURL=app_login_page_tsx_0z71ad3._.js.map