import{j as e,r as n,h as x,N as h}from"./vendor-tanstack-BpuysabX.js";import{l as g,C as j,m as v,n as L,o as C,p as w,q as b,R as N,r as R,P as S}from"./index-CREafGO4.js";import"./vendor-radix-DIu41Ss_.js";import"./vendor-recharts-C2XeLr4O.js";import"./vendor-forms-Buh7U8Ay.js";import"./vendor-date-C1t37jsh.js";function P({className:r="size-11"}){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 76 76",className:r,"aria-label":"Prefect Logo",children:[e.jsx("title",{children:"Prefect Logo"}),e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M15.89 15.07 38 26.543v22.935l22.104-11.47.007.004V15.068l-.003.001L38 3.598z",clipRule:"evenodd"}),e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M15.89 15.07 38 26.543v22.935l22.104-11.47.007.004V15.068l-.003.001L38 3.598z",clipRule:"evenodd"}),e.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M37.987 49.464 15.89 38v22.944l.013-.006L38 72.402V49.457z",clipRule:"evenodd"})]})}function u({redirectTo:r="/dashboard"}){const[t,s]=n.useState(""),[i,l]=n.useState(""),[o,c]=n.useState(!1),{login:f}=g(),m=x(),p=a=>{a.preventDefault(),!(o||!t.trim())&&(c(!0),l(""),f(t).then(d=>{d.success?m({to:r}):(l(d.error??"Authentication failed"),c(!1))}))};return e.jsx("div",{className:"flex items-center justify-center min-h-screen",children:e.jsxs(j,{className:"w-full max-w-[400px]",children:[e.jsxs(v,{className:"flex flex-col items-center gap-4",children:[e.jsx(P,{className:"size-16"}),e.jsx(L,{children:"Login"})]}),e.jsx(C,{children:e.jsxs("form",{onSubmit:p,className:"flex flex-col gap-4",children:[e.jsx(w,{type:"password",placeholder:"admin:pass",value:t,onChange:a=>s(a.target.value),autoFocus:!0,disabled:o}),i&&e.jsx("p",{className:"text-sm text-destructive",children:i}),e.jsx(b,{type:"submit",disabled:o,className:"w-full",children:o?"Logging in...":"Login"})]})})]})})}const B=function(){const{redirectTo:t}=N.useSearch(),s=R();return s?s.isLoading?e.jsx(S,{}):s.isAuthenticated?e.jsx(h,{to:t??"/dashboard",replace:!0}):e.jsx(u,{redirectTo:t}):e.jsx(u,{redirectTo:t})};export{B as component};
//# sourceMappingURL=login-CgYNDRJv.js.map
