import{K as e,Nt as t,Ut as n,Zt as r,nn as i}from"./branding-B7dW-jsD.js";import{t as a}from"./checkbox-C_4HWmk5.js";import{k as o,n as s,r as c}from"./index-B6j-NK0t.js";import{t as l}from"./HeaderApp-Aqs89_qS.js";import{t as u}from"./use-document-meta-Ds8yu_o4.js";import{t as d}from"./api-toast-D3el9g6G.js";import{t as f}from"./actions-bXnNyRN5.js";var p=i(r(),1),m=t(),h=3,g=8;function _(){let t=n(),[r,i]=(0,p.useState)(``),[_,v]=(0,p.useState)(``),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(!1),[C,w]=(0,p.useState)(!1);u({title:`New User`,description:`Create a new user account.`});function T(){w(!0),d(f({email:r.trim(),username:_.trim(),password:y,is_admin:x}),{loading:`Creating user...`,success:`User created`,error:`Failed to create user`}).then(()=>t(`/users`)).catch(()=>{}).finally(()=>w(!1))}let E=r.trim().length>0&&_.trim().length>=h&&y.length>=g&&!C;return(0,m.jsx)(l,{title:`New User`,description:`Create a new user account.`,children:(0,m.jsx)(`div`,{className:`max-w-lg`,children:(0,m.jsx)(s,{children:(0,m.jsx)(c,{className:`p-6`,children:(0,m.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),E&&T()},className:`space-y-4`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`user-email`,className:`text-sm font-medium`,children:`Email`}),(0,m.jsx)(o,{id:`user-email`,type:`email`,placeholder:`user@example.com`,value:r,onChange:e=>i(e.target.value),className:`mt-1`,autoComplete:`email`,"aria-required":`true`})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`user-username`,className:`text-sm font-medium`,children:`Username`}),(0,m.jsx)(o,{id:`user-username`,placeholder:`johndoe`,value:_,onChange:e=>v(e.target.value),className:`mt-1`,autoComplete:`username`,"aria-required":`true`,"aria-describedby":`username-hint`}),(0,m.jsxs)(`p`,{id:`username-hint`,className:`text-xs text-muted-foreground mt-1`,children:[`At least `,h,` characters`]})]}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`user-password`,className:`text-sm font-medium`,children:`Password`}),(0,m.jsx)(o,{id:`user-password`,type:`password`,placeholder:``,value:y,onChange:e=>b(e.target.value),className:`mt-1`,autoComplete:`new-password`,"aria-required":`true`,"aria-describedby":`password-hint`}),(0,m.jsxs)(`p`,{id:`password-hint`,className:`text-xs text-muted-foreground mt-1`,children:[`At least `,g,` characters`]})]}),(0,m.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,m.jsx)(a,{id:`user-is-admin`,checked:x,onCheckedChange:e=>S(e===!0),"aria-describedby":`admin-desc`,className:`mt-0.5`}),(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`user-is-admin`,className:`text-sm font-medium cursor-pointer`,children:`Admin privileges`}),(0,m.jsx)(`p`,{id:`admin-desc`,className:`text-xs text-muted-foreground mt-0.5`,children:`Grants full access to all workflows, runs, and user management.`})]})]}),(0,m.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,m.jsx)(e,{type:`button`,variant:`outline`,onClick:()=>{window.history.length>1?t(-1):t(`/users`)},children:`Cancel`}),(0,m.jsx)(e,{type:`submit`,disabled:!E,children:C?`Creating...`:`Create User`})]})]})})})})})}export{_ as Component};