import{Ft as e,K as t,Nt as n,Pt as r,Ut as i,Zt as a,n as o,nn as s}from"./branding-B7dW-jsD.js";import{a as c,i as l,n as u,r as d,t as f}from"./input-group-B0YeBn48.js";import{L as p,T as m,z as h}from"./index-B6j-NK0t.js";import{t as g}from"./use-document-meta-Ds8yu_o4.js";import{t as _}from"./api-toast-D3el9g6G.js";var v=s(a(),1),y=n();function b(){let[n,a]=(0,v.useState)(``),[s,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)({status:`idle`}),T=i(),E=p(),D=o();g({title:`Sign in`,description:`Sign in to your ${D.name} account.`});let O=e=>{e.preventDefault(),w({status:`submitting`}),_(r.post(`/auth/sign-in`,{email:n,password:s}).then(()=>E(h())),{loading:`Signing in...`,success:`Signed in!`,error:`Sign in failed`}).then(()=>T(`/`)).catch(e=>{w({status:`error`,message:e instanceof Error?e.message:`Sign in failed. Please try again.`})}).finally(()=>{w(e=>e.status===`submitting`?{status:`idle`}:e)})},k=C.status===`submitting`;return(0,y.jsxs)(`div`,{className:`grid min-h-screen lg:grid-cols-2`,children:[(0,y.jsxs)(`div`,{className:`relative hidden lg:flex flex-col justify-between bg-sidebar border-r border-sidebar-border p-10 overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`relative flex items-center gap-3`,children:[(0,y.jsx)(`img`,{src:D.logoUrl,alt:D.name,className:`size-9 rounded-[var(--radius-sm)]`,width:36,height:36,fetchPriority:`high`}),(0,y.jsx)(`span`,{className:`text-xl font-semibold tracking-tight text-sidebar-foreground`,children:D.name})]}),(0,y.jsxs)(`div`,{className:`relative space-y-3`,children:[(0,y.jsx)(`p`,{className:`text-sm text-sidebar-foreground/60 leading-relaxed max-w-xs`,children:`Orchestrate workflows, automate operations, and monitor executions from a single control plane.`}),(0,y.jsx)(`span`,{className:`inline-block font-mono text-xs text-muted-foreground border border-border rounded-[var(--radius-sm)] px-2 py-0.5`,children:D.name})]}),(0,y.jsxs)(`p`,{className:`relative text-xs text-muted-foreground`,children:[`© `,new Date().getFullYear(),` `,D.copyright]})]}),(0,y.jsxs)(`div`,{className:`relative flex flex-col p-6 sm:p-10 overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`relative flex items-center gap-3 lg:hidden mb-auto`,children:[(0,y.jsx)(`img`,{src:D.logoUrl,alt:D.name,className:`size-9 rounded-[var(--radius-sm)]`,width:36,height:36,fetchPriority:`high`}),(0,y.jsx)(`span`,{className:`text-xl font-semibold tracking-tight`,children:D.name})]}),(0,y.jsx)(`div`,{className:`relative flex flex-1 flex-col items-center justify-center`,children:(0,y.jsxs)(`div`,{className:`w-full max-w-sm space-y-8`,children:[(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`span`,{className:`block text-xs font-mono uppercase tracking-widest text-primary mb-2`,children:D.name}),(0,y.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Welcome back`}),(0,y.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Sign in to your account to continue`})]}),(0,y.jsxs)(`form`,{onSubmit:O,className:`space-y-4`,"aria-busy":k,children:[(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(`label`,{htmlFor:`email`,className:`text-sm font-medium`,children:`Email`}),(0,y.jsx)(f,{children:(0,y.jsx)(d,{id:`email`,type:`email`,placeholder:`you@example.com`,value:n,onChange:e=>a(e.target.value),required:!0,autoComplete:`email`})})]}),(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(`label`,{htmlFor:`password`,className:`text-sm font-medium`,children:`Password`}),(0,y.jsxs)(f,{children:[(0,y.jsx)(d,{id:`password`,type:x?`text`:`password`,placeholder:``,value:s,onChange:e=>b(e.target.value),required:!0,autoComplete:`current-password`}),(0,y.jsx)(u,{size:`icon-sm`,type:`button`,"aria-label":x?`Hide password`:`Show password`,onClick:()=>S(e=>!e),children:x?(0,y.jsx)(c,{className:`size-4`,"aria-hidden":`true`}):(0,y.jsx)(l,{className:`size-4`,"aria-hidden":`true`})})]}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Contact your admin to reset your password.`})]}),(0,y.jsxs)(t,{type:`submit`,className:`w-full`,size:`lg`,disabled:k,children:[k&&(0,y.jsx)(m,{className:`size-4 animate-spin`,"aria-hidden":`true`}),k?`Signing in...`:`Sign in`]}),C.status===`error`&&(0,y.jsx)(`p`,{className:`text-sm text-destructive mt-2`,role:`alert`,children:C.message})]}),(0,y.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[`Don't have an account?`,` `,(0,y.jsx)(e,{to:`/sign-up`,className:`font-medium text-foreground underline underline-offset-2 hover:text-primary`,children:`Sign up`})]})]})})]})]})}export{b as Component};