import{g2 as s,bc as l,j as n,P as I,g8 as j,o as T,aU as p,Q as i,ag as m,z as g,b0 as y,g9 as D,be as N,r as d,dl as P,dm as b}from"./index-ea7817a2.js";import{u as x}from"./useProjectId-fe5627bf.js";import{u as S}from"./useCurrentProject-0132f110.js";const _=e=>{const{deployment:{status:t}}=e;return l(t,[s.RUNNING,s.IDLE,s.FAILED])?n.jsx(v,{...e}):n.jsx(f,{...e})},v=({deployment:e})=>{const[t,a]=I(),[c,{isLoading:r}]=j(),o=x();return n.jsxs(T,{children:[n.jsx(p,{variant:"secondary",color:"labels.red",disabled:l(e.status,h),onClick:a,height:"32px",minWidth:"88px",children:n.jsxs(i,{alignItems:"center",children:[n.jsx(i,{mr:"10px",children:n.jsx(m,{icon:g.stop,color:"labels.red",size:"sm"})}),n.jsx("span",{children:"Stop"})]})}),n.jsx(y,{title:`Stop the deployment ${e.name}`,secondaryText:`You are about to stop the deployment ${e.name}. Please be certain.`,isOpen:t,onClose:a,mainButtonProps:{children:"Stop deployment",isLoading:r,onClick:async()=>{await c({projectId:o,servingId:e.id}),a()}},secondaryButtonProps:{children:"Back",onClick:a}})]})},f=({title:e,deployment:t})=>{const[a,{isLoading:c}]=D(),r=x();return n.jsx(p,{variant:"secondary",color:"labels.green",disabled:l(t.status,h),onClick:()=>a({projectId:r,servingId:t.id}),height:"32px",minWidth:"88px",children:n.jsxs(i,{alignItems:"center",children:[n.jsx(i,{mr:"10px",children:n.jsx(m,{icon:g.play,color:"primary",size:"sm"})}),n.jsx("span",{children:e??"Run"})]})})},h=[s.STARTING,s.STOPPING,s.UPDATING],w=({status:e,...t})=>n.jsx(i,{...t,sx:{gap:"10px"},children:n.jsx(N,{variant:A(e),mode:E(e),loading:!G(e),value:e.toLocaleLowerCase()})}),A=e=>{switch(e){case s.CREATING:return"light";case s.CREATED:return"light";case s.RUNNING:case s.STARTING:case s.IDLE:return"success";case s.UPDATING:return"notice";case s.FAILED:return"fail";case s.STOPPING:case s.STOPPED:return"label";default:return"default"}},E=e=>e===s.IDLE?"bordered":"default",G=e=>e!==s.CREATING&&e!==s.STARTING&&e!==s.UPDATING&&e!==s.STOPPING,C=({projectName:e,deploymentName:t})=>`/grafana/d/kserve/kserve?orgId=1&var-namespace=${e.replaceAll("_","-")}&var-configuration=${t}-predictor-default&var-revision=All&refresh=10s`,U=()=>{const{project:e}=S();return t=>`/hopsworks-api${C({projectName:(e==null?void 0:e.projectName)??"",deploymentName:t})}`},L=({projectName:e,deploymentName:t})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e}_serving-*',interval:auto,query:(language:lucene,query:'serving_name:${t}'),sort:!('@timestamp',desc))`,O=()=>{const{id:e,project:t}=S(),[a,c]=d.useState(),r=async o=>{const{data:u}=await new P().request({url:`/elastic/jwt/${o} `,type:b.get});u&&c(u.kibanaUrl)};return d.useEffect(()=>{r(e)},[e]),o=>`${a}security_tenant=private#${L({projectName:(t==null?void 0:t.projectName)??"",deploymentName:o})}`};export{_ as D,w as S,U as a,O as u};
