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