import{aO as l,cY as a,j as t,w as S,gH as j,gf as d,F as I,bB as m,q as c,ao as g,v as y,bJ as v,gI as D,at as h,dN as b,eK as _,r as u,dQ as N,dO as T,dP as f}from"./index-DNBEEyYo.js";const w=e=>{const{deployment:{status:s}}=e;return l(s,[a.RUNNING,a.IDLE,a.FAILED,a.STARTING,a.UPDATING])?t.jsx(k,{...e}):t.jsx(A,{...e})},k=({deployment:e})=>{const[s,n]=S(),[i,{isLoading:o}]=j(),r=d();return t.jsxs(I,{children:[t.jsx(m,{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(g,{icon:y.stop,color:"labels.red",size:"sm"})}),t.jsx("span",{children:"Stop"})]})}),t.jsx(v,{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}})]})},A=({title:e,deployment:s})=>{const[n,{isLoading:i}]=D(),o=d();return t.jsx(m,{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(g,{icon:y.play,color:"primary",size:"sm"})}),t.jsx("span",{children:e??"Run"})]})})},x=[a.STOPPING],C=({projectName:e,deploymentName:s})=>`/grafana/d/kserve/kserve?${_.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${s}-.*`,"var-revision":"All"})}`,L=()=>{const{project:e}=h();return s=>`${b}${C({projectName:(e==null?void 0:e.projectName)??"",deploymentName:s})}`},P=({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))`,E=()=>{const{id:e,project:s}=h(),[n,i]=u.useState(),o=async r=>{const{data:p}=await new T().request({url:`/elastic/jwt/${r} `,type:f.get});p&&i(p.kibanaUrl)};return u.useEffect(()=>{o(e)},[e]),r=>`${N}${n}security_tenant=private#${P({projectName:(s==null?void 0:s.projectName)??"",deploymentName:r})}`};export{w as D,L as a,E as u};
