import{e as y,d as i,i as h,r as o,z as P,A as S,j as e,B as x,K as b,q as g}from"./index-3c1b2661.js";import{c as C,a as R,u as E}from"./index.esm-7989c879.js";import{S as N,u as k}from"./updateMaxHeight-4e644a5f.js";import{P as q,a as D,c as L,i as B,d as F,n as $,p as w,b as z,r as A}from"./ProjectForm-420f46d7.js";import"./FormMenuItem-c982b037.js";import"./formFields-e7157cb4.js";import"./instanceConfigInheritance-8da60590.js";import"./ConfigurationTable-5663621c.js";import"./ConfigFieldDescription-f8ae8325.js";import"./AutoExpandingTextArea-38ef4775.js";import"./DiskSizeSelector-f5c6feab.js";const _=()=>{var m;const r=y(),a=i.useNotify(),l=h(),d=o.useState(null),[c,u]=o.useState(q),p=C().shape({name:R().test("deduplicate","A project with this name already exists",t=>P(t,"",d,"projects")).required()}),n=()=>{k("form-contents","p-bottom-controls")};o.useEffect(n,[(m=a.notification)==null?void 0:m.message,c]),S("resize",n);const s=E({initialValues:{name:"",restricted:!1,readOnly:!1,type:"project"},validationSchema:p,onSubmit:t=>{const j=t.restricted?{...L(t),...B(t),...F(t),...$(t)}:{};b(JSON.stringify({...w(t),config:{...z(t),...A(t),...j}})).then(()=>{r(`/ui/project/${t.name}/instances`,a.queue(a.success(`Project ${t.name} created.`)))}).catch(f=>{s.setSubmitting(!1),a.failure("Project creation failed",f)}).finally(()=>{l.invalidateQueries({queryKey:[g.projects]})})}});return e.jsxs(x,{title:"Create a project",contentClassName:"create-project",children:[e.jsx(D,{formik:s,section:c,updateSection:u,isEdit:!1}),e.jsxs("div",{className:"p-bottom-controls",id:"form-footer",children:[e.jsx("hr",{}),e.jsx(i.Row,{className:"u-align--right",children:e.jsxs(i.Col,{size:12,children:[e.jsx(i.Button,{appearance:"base",onClick:()=>r(-1),children:"Cancel"}),e.jsx(N,{isSubmitting:s.isSubmitting,isDisabled:!s.isValid||!s.values.name,buttonLabel:"Create",onClick:()=>void s.submitForm()})]})})]})]})};export{_ as default};
