import{r as T,ar as v,fa as B,aC as F,aD as S,p as w,bo as G,bc as I,V as K,j as e,b as z,$ as j,b2 as t,aN as p,ao as W,ap as Y,C as A,cD as u,bG as U,b1 as m,bq as q,de as f,br as H,cb as J,cv as i,au as N,fb as M,aE as Q,fc as R,eF as L}from"./index-Cc-6WbPt.js";const X=w(R,L),Z=r=>v().shape({projectName:M("consecutiveUnderlines",Q.notOneOf(r,"This name already exists").label("Name")),namespace:N().max(63).label("Namespace"),description:i.label("Description"),featureStoreTopic:i,memberEmails:J().of(N().email().optional())}),D=({isLoading:r,onSubmit:y,onDelete:d,isEdit:o,initialData:s,projectsNames:x=[],isProgressingSubmit:n,isSuccessSubmit:b,progressElement:h})=>{const _=T.useMemo(()=>Z(x),[x]),{data:C}=B(),{handleSubmit:O,formState:{errors:a},register:c,control:$}=F({mode:"onTouched",defaultValues:{projectName:s==null?void 0:s.projectName,namespace:s==null?void 0:s.namespace,description:s==null?void 0:s.description,membersEmails:[],featureStoreTopic:s==null?void 0:s.featureStoreTopic},resolver:S(_),shouldUnregister:!1}),l=X(a),g=l===0?"":`${l} error${l>1?"s":""}`,E=G(),[k,P]=I({name:["projectName","description"],control:$}),{data:V}=K("kube_skip_namespace_creation");return e.jsxs("form",{onSubmit:O(y),children:[e.jsx(z,{title:o?"Edit a project":"Create a New Project",mb:"100px",children:(n||b)&&h?h:e.jsxs(j,{flexDirection:"column",children:[e.jsxs(j,{children:[e.jsx(t,{label:"Name",readOnly:o,...c("projectName"),placeholder:"project_acme",labelAction:e.jsx(W,{mainText:"Only alphanumeric characters, dash or underscore",position:"right",children:e.jsx(Y,{ml:"5px",size:"xs",icon:A.info_block})}),...p("projectName",a)}),e.jsx(t,{labelProps:{ml:"20px",flex:1},label:"Description",...c("description"),placeholder:"project about....",...p("description",a)})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx(u,{legend:"External topic"}),e.jsx(t,{label:"Topic name",...c("featureStoreTopic"),placeholder:"featurestore_topic"})]}),V&&e.jsxs(e.Fragment,{children:[e.jsx(u,{legend:"Kubernetes"}),e.jsx(t,{labelProps:{flex:1},label:"Namespace",readOnly:o,...c("namespace"),placeholder:"Kubernetes pre-created namespace",...p("namespace",a)})]}),o&&d&&e.jsx(U,{text:"Danger zone",width:"fit-content",mt:0,children:e.jsx(m,{intent:"alert",disabled:r,onClick:d,children:"Delete the project"})})]})}),e.jsx(q,{sx:{maxWidth:`var(${H})`},title:f(k||"",24),firstValue:f(P||"",50),mainButton:e.jsx(m,{type:"submit",isLoading:n,disabled:r||b,intent:"primary",children:o?"Edit Project":"Create New Project"}),secondaryButton:e.jsx(m,{type:"button",disabled:r||n,intent:"secondary",onClick:()=>E(-1),children:"Back"}),hasScrollOnScreen:!1,errorsValue:g})]})},se=T.memo(D);export{se as P};
