import{f3 as t,bq as l,j as a,w as I,f7 as j,c as T,d as i,an as d,T as m,be as y,f8 as D,aN as N,dV as f,r as p,cC as v,cD as b}from"./index-CK33qGU_.js";import{u as g}from"./useProjectId-CsRVHJQA.js";import{B as h}from"./ButtonWithRole-NHXEosto.js";import{u as S}from"./useDownload-hrjXceJg.js";const U=e=>{const{deployment:{status:s}}=e;return l(s,[t.RUNNING,t.IDLE,t.FAILED,t.STARTING,t.UPDATING])?a.jsx(A,{...e}):a.jsx(P,{...e})},A=({deployment:e})=>{const[s,n]=I(),[c,{isLoading:r}]=j(),o=g();return a.jsxs(T,{children:[a.jsx(h,{variant:"secondary",color:"labels.red",disabled:l(e.status,x),onClick:n,height:"32px",minWidth:"88px",children:a.jsxs(i,{alignItems:"center",children:[a.jsx(i,{mr:"10px",children:a.jsx(d,{icon:m.stop,color:"labels.red",size:"sm"})}),a.jsx("span",{children:"Stop"})]})}),a.jsx(y,{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:r,onClick:async()=>{await c({projectId:o,servingId:e.id}),n()}},secondaryButtonProps:{children:"Back",onClick:n}})]})},P=({title:e,deployment:s})=>{const[n,{isLoading:c}]=D(),r=g();return a.jsx(h,{variant:"secondary",color:"labels.green",disabled:l(s.status,x),onClick:()=>n({projectId:r,servingId:s.id}),height:"32px",minWidth:"88px",children:a.jsxs(i,{alignItems:"center",children:[a.jsx(i,{mr:"10px",children:a.jsx(d,{icon:m.play,color:"primary",size:"sm"})}),a.jsx("span",{children:e??"Run"})]})})},x=[t.STOPPING],B=({status:e,...s})=>a.jsx(i,{...s,sx:{gap:"10px"},children:a.jsx(N,{variant:C(e),mode:E(e),loading:!G(e),value:e.toLocaleLowerCase()})}),C=e=>{switch(e){case t.CREATING:return"light";case t.CREATED:return"light";case t.RUNNING:case t.STARTING:case t.IDLE:return"success";case t.UPDATING:return"notice";case t.FAILED:return"fail";case t.STOPPING:case t.STOPPED:return"label";default:return"default"}},E=e=>e===t.IDLE?"bordered":"default",G=e=>e!==t.CREATING&&e!==t.STARTING&&e!==t.UPDATING&&e!==t.STOPPING,L=({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"})}`,O=()=>{const{project:e}=S();return s=>`https://localhost:8181/hopsworks-api${L({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))`,q=()=>{const{id:e,project:s}=S(),[n,c]=p.useState(),r=async o=>{const{data:u}=await new v().request({url:`/elastic/jwt/${o} `,type:b.get});u&&c(u.kibanaUrl)};return p.useEffect(()=>{r(e)},[e]),o=>`https://localhost:8181${n}security_tenant=private#${k({projectName:(s==null?void 0:s.projectName)??"",deploymentName:o})}`};export{U as D,B as S,O as a,q as u};
