import{j as e,i as t}from"./vendor-ui-BUsIib4b.js";import{R as C,r as s,u as k,L as S}from"./vendor-react-C0ZmnAiH.js";import{u as z,l as F,I as g,B as E,c as I,a as N}from"./index-1Tge9Z5s.js";import{u as R}from"./use_metadata-C9OHa5vq.js";import"./vendor-three-DPUqg5ET.js";import"./vendor-query-CD5rVjAu.js";import"./vendor-utils-DwtcRXMR.js";import"./vendor-charts-CcS99Kb5.js";const M=t.div`
min-height: 100vh;
display: flex;
flex-direction: column;
`,P=t.div`
flex: 1;
display: flex;
justify-content: center;
align-items: center;
padding: 40px 16px;
`,T=t.div`
padding: 25px;
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.145),
0px 1px 2px rgba(0, 0, 0, 0.16);
border-radius: 10px;
display: flex;
flex-direction: column;
gap: 20px;
width: 320px;
background: transparent;
`,h=t.label`
margin-bottom: 3px;
font-size: 14px;
color: #e5e5e5;
`,W=t.div`
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
width: 100%;
margin: 20px 0 10px 0;
`,q=t.h1`
color: #fff;
font-size: 24px;
margin-bottom: 0px;
`,B=t(S)`
color: #58a6ff;
text-decoration: none;
&:hover {
text-decoration: underline;
}
`,D=t.img`
cursor: pointer;
max-height: 45px;
width: auto;
`,U=t.div`
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
`,_=t(U)`
justify-content: flex-start;
font-size: 14px;
`,A=t(B)`
margin-left: auto;
order: 2;
font-size: 14px;
color: #ffffff;
text-decoration: none;
border-bottom: 1px dotted transparent;
padding-bottom: 1px;
&:hover {
text-decoration: none;
border-bottom-color: #ffffff;
}
`,G=t.div`
display: flex;
align-items: baseline;
justify-content: space-between;
margin-bottom: 5px;
`,H=t.div`
background-color: #290000;
color: white;
border: 1px solid #630000;
border-radius: 6px;
padding: 10px;
text-align: center;
margin-top: 12px;
font-size: 13px;
`,J=()=>{const[a,b]=s.useState(""),[u,j]=s.useState(""),[n,w]=s.useState("identifier"),o=s.useRef(null),c=s.useRef(null),{sessionToken:x,useLogin:y,loginError:f,isLoading:i}=z(),d=k();R({title:"Login - ModelWorks"}),s.useEffect(()=>{x&&d("/dashboard")},[x,d]),s.useEffect(()=>{n==="identifier"&&o.current&&o.current.focus(),n==="password"&&c.current&&c.current.focus()},[n]);const v=async l=>{if(l.preventDefault(),n==="identifier"){if(!a.trim()){o.current&&o.current.focus();return}w("password");return}const{success:p,token:L}=await y(a,u);!p||!L?o.current&&o.current.focus():d("/dashboard")},m=l=>p=>{l(p.target.value)},r=n==="password";return e.jsxs(M,{children:[e.jsx(P,{children:e.jsxs(T,{children:[e.jsxs(W,{children:[e.jsx(D,{src:F,alt:"ModelWorks Logo",className:"mb-5"}),e.jsx(q,{children:"Log in to ModelWorks!"})]}),e.jsxs("form",{onSubmit:v,children:[e.jsxs("div",{className:"mb-4",children:[e.jsx(G,{children:e.jsx(h,{htmlFor:"username",children:"Username or Email"})}),e.jsx(g,{id:"username",ref:o,type:"text",required:!0,value:a,onChange:m(b),className:"bg-[#010409] border-[#30363d] text-zinc-100",autoComplete:"username"})]}),r&&e.jsxs("div",{className:"mb-4",children:[e.jsxs(_,{children:[e.jsx(h,{htmlFor:"password",children:"Password"}),e.jsx(A,{to:"/forgot_password",tabIndex:-1,children:"Forgot password?"})]}),e.jsx(g,{id:"password",type:"password",required:!0,ref:c,value:u,onChange:m(j),className:"bg-[#010409] border-[#30363d] text-zinc-100",autoComplete:"current-password"})]}),f&&e.jsx(H,{children:f}),e.jsxs(E,{type:"submit",size:"lg",className:"mt-5 w-full flex items-center justify-center",disabled:r&&i,...r&&i?{"aria-busy":!0}:{},children:[r&&i&&e.jsx(I,{size:16,className:"mr-2 animate-spin"}),r?i?"Signing in...":"Sign in":"Continue"]})]})]})}),e.jsx(N,{showCopyright:!0})]})},ee=C.memo(J);export{ee as default};