import{i as e,n as t,t as n}from"./jsx-runtime-bzQ4Vb5N.js";import{T as r,i,x as a}from"./index-t_-MMk0R.js";import{i as o,n as s,r as c,t as l}from"./card-2XLQ4Sqm.js";import{t as u}from"./button-CpC4WAFQ.js";import{t as d}from"./input-ybUNh9ew.js";import{t as f}from"./train-front-D3o-kwRh.js";import{i as p,n as m,r as h,t as g}from"./tabs-DFilYnmT.js";import{t as _}from"./label-KRr-9qDf.js";var v=e(t()),y=n();function b(){let e=r(),[t,n]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``),[w,T]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{a.auth.getSession().then(({data:t})=>{t.session&&e({to:`/dashboard`,replace:!0})})},[e]),(0,y.jsxs)(`div`,{className:`min-h-screen grid lg:grid-cols-2 bg-background`,children:[(0,y.jsxs)(`div`,{className:`hidden lg:flex flex-col justify-between p-12 bg-sidebar text-sidebar-foreground`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,y.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-md bg-sidebar-primary text-sidebar-primary-foreground`,children:(0,y.jsx)(f,{className:`h-6 w-6`})}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`div`,{className:`text-lg font-semibold`,children:`ER-SPRMS`}),(0,y.jsx)(`div`,{className:`text-xs opacity-80`,children:`Eastern Railway`})]})]}),(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`h1`,{className:`text-3xl font-semibold leading-tight`,children:[`Safety Performance &`,(0,y.jsx)(`br`,{}),`Risk Monitoring System`]}),(0,y.jsx)(`p`,{className:`mt-4 max-w-md text-sm opacity-80`,children:`Division-wise, AEN-wise, and SSE-wise progress of track maintenance across SDAH, ASN, HWH and MLDT — with automated compliance, risk scoring, and rankings.`})]}),(0,y.jsx)(`p`,{className:`text-xs opacity-60`,children:`© Eastern Railway HQ`})]}),(0,y.jsx)(`div`,{className:`flex items-center justify-center p-6`,children:(0,y.jsxs)(l,{className:`w-full max-w-md`,children:[(0,y.jsxs)(c,{children:[(0,y.jsx)(o,{className:`text-2xl`,children:`Welcome`}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Sign in to the ER-SPRMS dashboard.`})]}),(0,y.jsx)(s,{children:(0,y.jsxs)(g,{defaultValue:`signin`,children:[(0,y.jsxs)(h,{className:`grid w-full grid-cols-2`,children:[(0,y.jsx)(p,{value:`signin`,children:`Sign in`}),(0,y.jsx)(p,{value:`signup`,children:`Sign up`})]}),(0,y.jsx)(m,{value:`signin`,children:(0,y.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),T(!0);let{error:r}=await a.auth.signInWithPassword({email:t,password:b});if(T(!1),r)return i.error(r.message);i.success(`Signed in`),e({to:`/dashboard`,replace:!0})},className:`space-y-4 pt-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(_,{htmlFor:`e1`,children:`Email`}),(0,y.jsx)(d,{id:`e1`,type:`email`,value:t,onChange:e=>n(e.target.value),required:!0})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(_,{htmlFor:`p1`,children:`Password`}),(0,y.jsx)(d,{id:`p1`,type:`password`,value:b,onChange:e=>x(e.target.value),required:!0})]}),(0,y.jsx)(u,{type:`submit`,className:`w-full`,disabled:w,children:w?`Signing in…`:`Sign in`})]})}),(0,y.jsx)(m,{value:`signup`,children:(0,y.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),T(!0);let{error:r}=await a.auth.signUp({email:t,password:b,options:{emailRedirectTo:window.location.origin,data:{display_name:S}}});if(T(!1),r)return i.error(r.message);i.success(`Account created — signing you in…`);let{data:o}=await a.auth.getSession();o.session&&e({to:`/dashboard`,replace:!0})},className:`space-y-4 pt-4`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(_,{htmlFor:`n2`,children:`Full name`}),(0,y.jsx)(d,{id:`n2`,value:S,onChange:e=>C(e.target.value),required:!0})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(_,{htmlFor:`e2`,children:`Email`}),(0,y.jsx)(d,{id:`e2`,type:`email`,value:t,onChange:e=>n(e.target.value),required:!0})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(_,{htmlFor:`p2`,children:`Password`}),(0,y.jsx)(d,{id:`p2`,type:`password`,minLength:6,value:b,onChange:e=>x(e.target.value),required:!0})]}),(0,y.jsx)(u,{type:`submit`,className:`w-full`,disabled:w,children:w?`Creating…`:`Create account`}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`The first user to register automatically becomes HQ Admin.`})]})})]})})]})})]})}export{b as component};