import{j as t,q as h,c as A,bl as v,bx as I,bI as N,b as O,cF as y,T as b,r as i,t as d,x as u,bG as F,bH as G,cG as w,cH as S}from"./index-C6OVXshM.js";import{P as L}from"./ProjectForm-7N7-c0a9.js";const M=({children:s})=>t.jsxs(h,{width:"100%",flexDirection:"column",alignItems:"center",children:[t.jsx(A,{bold:!0,color:"gray",fontSize:"18px",mb:"8px",children:"Building new project"}),t.jsx(v,{mb:"20px",children:"Project creation"}),s]}),U=()=>{const s=I(),l=N(),{currentData:n,isLoading:f}=O(),[p]=y(),{data:j}=b("trino_enabled"),{data:g}=b("superset_enabled"),[x,c]=i.useState({isProgressing:!1,isSuccess:!1,isError:!1}),m=i.useCallback(e=>{s(d(u.project.prj.view,u.project.value,{id:e}))},[s]),P=i.useCallback(async e=>{c(a=>({...a,isProgressing:!1,isSuccess:!0})),setTimeout(()=>{e?m(e):s(d(u.project.list))},1e3)},[s,m]),T=i.useCallback(async e=>{var a;try{c(o=>({...o,isProgressing:!0,isError:!1}));const r=await p({services:["JOBS","JUPYTER","HIVE","KAFKA","FEATURESTORE","SERVING","AIRFLOW",...j?["TRINO"]:[],...g?["SUPERSET"]:[]],projectName:e.projectName,namespace:e.namespace,description:e.description,featureStoreTopic:e.featureStoreTopic}).unwrap();P(r.data)}catch(r){c(R=>({...R,isProgressing:!1,isError:!0}));const o=(a=r==null?void 0:r.response)==null?void 0:a.data;l.error({title:"Error",content:`${o.errorMsg||""} ${o.usrMsg||""}`})}},[p,P,l,j,g]),{isProgressing:E,isSuccess:C}=x;return F(G.createProject),t.jsx(L,{projectsNames:n==null?void 0:n.map(({projectName:e})=>e),isLoading:f,onSubmit:T,isProgressingSubmit:E,isSuccessSubmit:C,progressElement:t.jsx(M,{children:t.jsx(w,{isAnimating:E,animationDuration:S/100,incrementDuration:S/25})})})};export{U as default};
