import{b4 as l,cM as a,j as t,y as S,fO as j,L as I,bs as d,$ as c,ap as m,C as g,bA as b,fP as v,aw as y,ds as D,eL as f,r as u,dv as _,dt as $,du as A}from"./index-Cc-6WbPt.js";import{u as h}from"./useProjectId-hjycL6JQ.js";const E=e=>{const{deployment:{status:s}}=e;return l(s,[a.RUNNING,a.IDLE,a.FAILED,a.STARTING,a.UPDATING])?t.jsx(C,{...e}):t.jsx(L,{...e})},C=({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}})]})},L=({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],T=({projectName:e,deploymentName:s})=>`/grafana/d/kserve/kserve?${f.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${s}-.*`,"var-revision":"All"})}`,w=()=>{const{project:e}=y();return s=>`${D}${T({projectName:(e==null?void 0:e.projectName)??"",deploymentName:s})}`},k=({projectName:e,deploymentName:s})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e}_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 $().request({url:`/elastic/jwt/${r} `,type:A.get});p&&i(p.kibanaUrl)};return u.useEffect(()=>{o(e)},[e]),r=>`${_}${n}security_tenant=private#${k({projectName:(s==null?void 0:s.projectName)??"",deploymentName:r})}`};export{E as D,w as a,B as u};
