import{r as y,ar as F,f8 as P,aC as S,aD as w,p as v,bo as K,bc as z,V as I,j as e,b as Y,$ as h,b2 as t,aN as p,ao as G,ap as U,C as q,cC as u,bF as A,b1 as m,bq as J,dd as f,ca as M,cu as i,au as N,f9 as Q,aE as R,fa as W,eD as H}from"./index-46ma1THH.js";const L=v(W,H),X=r=>F().shape({projectName:Q("consecutiveUnderlines",R.notOneOf(r,"This name already exists").label("Name")),namespace:N().max(63).label("Namespace"),description:i.label("Description"),featureStoreTopic:i,memberEmails:M().of(N().email().optional())}),Z=({isLoading:r,onSubmit:T,onDelete:d,isEdit:o,initialData:s,projectsNames:x=[],isProgressingSubmit:n,isSuccessSubmit:j,progressElement:b})=>{const C=y.useMemo(()=>X(x),[x]),{data:_}=P(),{handleSubmit:g,formState:{errors:a},register:c,control:O}=S({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:w(C),shouldUnregister:!1}),l=L(a),$=l===0?"":`${l} error${l>1?"s":""}`,k=K(),[V,B]=z({name:["projectName","description"],control:O}),{data:E}=I("kube_skip_namespace_creation");return e.jsxs("form",{onSubmit:g(T),children:[e.jsx(Y,{title:o?"Edit a project":"Create a New Project",mb:"100px",children:(n||j)&&b?b:e.jsxs(h,{flexDirection:"column",children:[e.jsxs(h,{children:[e.jsx(t,{label:"Name",readOnly:o,...c("projectName"),placeholder:"project_acme",labelAction:e.jsx(G,{mainText:"Only alphanumeric characters, dash or underscore",position:"right",children:e.jsx(U,{ml:"5px",size:"xs",icon:q.info_block})}),...p("projectName",a)}),e.jsx(t,{labelProps:{ml:"20px",flex:1},label:"Description",...c("description"),placeholder:"project about....",...p("description",a)})]}),_&&e.jsxs(e.Fragment,{children:[e.jsx(u,{legend:"External topic"}),e.jsx(t,{label:"Topic name",...c("featureStoreTopic"),placeholder:"featurestore_topic"})]}),E&&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(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,{title:f(V||"",24),firstValue:f(B||"",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:()=>k(-1),children:"Back"}),hasScrollOnScreen:!1,errorsValue:$})]})},ee=y.memo(Z);export{ee as P};
