import{b4 as l,cL as a,j as t,y as S,fL as j,L as I,br as d,$ as c,ap as m,C as g,bz as b,fM as v,aw as y,dr as D,eJ as L,r as u,du as f,ds as C,dt as _}from"./index-46ma1THH.js";import{u as h}from"./useProjectId-0fA9rNnF.js";const w=e=>{const{deployment:{status:s}}=e;return l(s,[a.RUNNING,a.IDLE,a.FAILED,a.STARTING,a.UPDATING])?t.jsx($,{...e}):t.jsx(T,{...e})},$=({deployment:e})=>{const[s,n]=S(),[i,{isLoading:o}]=j(),r=h();return t.jsxs(I,{children:[t.jsx(d,{variant:"secondary",color:"labels.red",disabled:l(e.status,x),onClick:n,height:"32px",minWidth:"88px",children:t.jsxs(c,{alignItems:"center",children:[t.jsx(c,{mr:"10px",children:t.jsx(m,{icon:g.stop,color:"labels.red",size:"sm"})}),t.jsx("span",{children:"Stop"})]})}),t.jsx(b,{title:`Stop the deployment ${e.name}`,secondaryText:`You are about to stop the deployment ${e.name}. Please be certain.`,isOpen:s,onClose:n,mainButtonProps:{children:"Stop deployment",isLoading:o,onClick:async()=>{await i({projectId:r,servingId:e.id}),n()}},secondaryButtonProps:{children:"Back",onClick:n}})]})},T=({title:e,deployment:s})=>{const[n,{isLoading:i}]=v(),o=h();return t.jsx(d,{variant:"secondary",color:"labels.green",disabled:l(s.status,x),onClick:()=>n({projectId:o,servingId:s.id}),height:"32px",minWidth:"88px",children:t.jsxs(c,{alignItems:"center",children:[t.jsx(c,{mr:"10px",children:t.jsx(m,{icon:g.play,color:"primary",size:"sm"})}),t.jsx("span",{children:e??"Run"})]})})},x=[a.STOPPING],k=({projectName:e,deploymentName:s})=>`/grafana/d/kserve/kserve?${L.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${s}-.*`,"var-revision":"All"})}`,E=()=>{const{project:e}=y();return s=>`${D}${k({projectName:(e==null?void 0:e.projectName)??"",deploymentName:s})}`},A=({projectName:e,deploymentName:s})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e.toLowerCase()}_serving-*',interval:auto,query:(language:lucene,query:'serving_name:${s}'),sort:!('@timestamp',desc))`,B=()=>{const{id:e,project:s}=y(),[n,i]=u.useState(),o=async r=>{const{data:p}=await new C().request({url:`/elastic/jwt/${r} `,type:_.get});p&&i(p.kibanaUrl)};return u.useEffect(()=>{o(e)},[e]),r=>`${f}${n}security_tenant=private#${A({projectName:(s==null?void 0:s.projectName)??"",deploymentName:r})}`};export{w as D,E as a,B as u};
