import{ba as q,r as m,bx as z,gf as J,at as K,u as $,w as f,gp as H,gq as _,gr as Q,aA as Y,aB as X,gs as Z,j as e,x,bF as ee,q as r,f as se,bk as n,bB as v,bJ as te,bz as re,bA as ae,aJ as ie,cY as p,c as b,t as oe,h as ne}from"./index-Cox3ZWL0.js";import{u as le}from"./useScreenWithScroll-zcr7TMGO.js";import{D as ce,V as de,E as D,A as ue,S as xe,R as pe,K as me}from"./VllmImageTagField-C0Y_qtIF.js";import{s as t}from"./styles-BKOcRT3k.js";import"./index-DFIJFuHt.js";import{v as ge,f as je,g as fe,h as he,T as Ee,i as Fe,V as ve,j as be,A as De}from"./PythonEnvField-fDU6r1Ny.js";import{d as P,c as Pe}from"./utils-CJCLrWXv.js";import"./form-_K_-Blw_.js";import"./KubernetesProjectEdit-fVArwJ6F.js";import"./index-CvEisYn5.js";import"./SingleSelect-BT2eGsJi.js";import"./getDefaultFormValues-vy9JWs45.js";import"./index-DlTLF62i.js";import"./rcompare-CzTiCFJf.js";const S=({to:a,params:i})=>{const l=q();return m.useEffect(()=>{l(a,i)},[a,i,l]),null},Me=()=>{var F;const[a,i]=m.useState(!1),l=z(),C=le(),c=J(),{project:I}=K(),{dId:d}=$(),[O,y]=f(),[T,V]=f(),[k,A]=f(),[B,{isLoading:g,isSuccess:G}]=H(),{data:s,isFetching:E}=_({projectId:c,id:d},{refetchOnMountOrArgChange:!0}),[w,{isLoading:N,isSuccess:R}]=Q(),u=Y({reValidateMode:"onChange",shouldUnregister:!1,mode:"onChange",resolver:X(ge)}),M=async o=>{ne(u.formState.errors)&&await B({projectId:c,formValues:Pe({apiValues:P(s),formValues:o,project:I})})},{handleDelete:L}=m.useContext(Z),W=async()=>{try{await w({projectId:+c,deploymentId:d}).unwrap(),L(oe(x.project.deployments.overview,x.project.value,{id:c,dId:d}))}catch(o){console.error(o)}},U=()=>l(-1),j=()=>i(o=>!o);return m.useEffect(()=>{u.reset({...P(s),kserve:(s==null?void 0:s.servingTool)==="KSERVE"})},[s]),G?e.jsx(S,{to:x.project.deployments.overview,params:{dId:d}}):R?e.jsx(S,{to:x.project.deployments.list}):e.jsx(ee,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(M),style:t.editForm,children:[e.jsx(r,{sx:t.editFormWrapper,children:e.jsxs(r,{flexDirection:"column",sx:t.fieldsWrapper,children:[e.jsx(se,{title:"Edit deployment",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsxs(r,{sx:t.defaultGap,children:[e.jsx(h,{name:"name",value:s==null?void 0:s.name}),e.jsx(h,{name:"framework",value:s==null?void 0:s.modelFramework}),e.jsx(h,{name:"model server",value:s==null?void 0:s.modelServer})]}),e.jsxs(r,{sx:t.defaultGap,children:[e.jsx(je,{}),e.jsx(fe,{})]}),e.jsx(ce,{})]})}),e.jsx(n,{title:"Environment configuration",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(he,{isFileExplorerOpen:O,toggleFileExplorerPopup:y}),e.jsx(Ee,{isFileExplorerOpen:T,toggleFileExplorerPopup:V}),e.jsx(Fe,{}),e.jsxs(r,{sx:t.defaultGap,alignSelf:"flex-start",children:[e.jsx(ve,{}),e.jsx(de,{})]}),e.jsx(be,{isFileExplorerOpen:k,toggleFileExplorerPopup:A}),e.jsx(D,{name:"predictorEnvVars",label:"Predictor environment variables"}),e.jsx(D,{name:"transformerEnvVars",label:"Transformer environment variables"})]})}),e.jsx(n,{title:"Advanced configuration",children:e.jsxs(r,{flexDirection:"column",sx:t.defaultGap,children:[e.jsx(De,{apiProtocol:s==null?void 0:s.apiProtocol}),e.jsx(ue,{batchingEnabled:(F=s==null?void 0:s.batchingConfiguration)==null?void 0:F.batchingEnabled})]})}),e.jsx(n,{title:"Scaling configuration",children:e.jsx(xe,{})}),e.jsx(n,{title:"Resources per Instance",children:e.jsx(pe,{})}),e.jsx(me,{prefix:[],init:!1}),e.jsxs(n,{title:"Danger zone",mb:"20px",children:[e.jsx(v,{intent:"alert",type:"button",disabled:g||E,onClick:j,children:"Delete deployment"}),e.jsx(te,{title:`Delete ${s==null?void 0:s.name}`,secondaryText:"Once you delete a deployment, there is no going back. Please be certain.",isOpen:a,onClose:j,mainButtonProps:{children:"Delete deployment",isLoading:N,onClick:W},secondaryButtonProps:{children:"Back",onClick:j}})]})]})}),e.jsx(re,{sx:{maxWidth:`var(${ae})`},hasScrollOnScreen:C,mainButton:e.jsx(v,{type:"submit",intent:"primary",disabled:g||E,isLoading:g,children:!s||(s==null?void 0:s.status)===p.CREATING||(s==null?void 0:s.status)===p.CREATED||(s==null?void 0:s.status)===p.STOPPED||(s==null?void 0:s.status)===p.STOPPING?"Save":"Save and restart"}),secondaryButton:e.jsx(ie,{type:"button",intent:"secondary",onClick:U,children:"Back"})})]})})},h=({name:a,value:i})=>e.jsxs(r,{flexDirection:"column",justifyContent:"flex-start",children:[e.jsx(b,{bold:!0,gray:!0,mb:"4px",children:a}),e.jsx(b,{bold:!0,children:i})]});export{Me as Edit,Me as default};
