import{j as n,r as m}from"./vendor-react-wBh_31cN.js";import{C as y}from"./confirmation-dialog-DFt7ZgUQ.js";import{B as v}from"./ButtonWithRole-BINnbeGr.js";import{u as I}from"./useProjectId-Ck57b-tn.js";import{c as i,A as h,B as C}from"./index-B5BaAmTQ.js";import{i as p}from"./includes-D04d5Ytc.js";import{a as D,ag as _}from"./vendor-icons-BUUmD6ht.js";import{a5 as b,ce as A,A as L,cB as x,cV as T,r as w}from"./index-BKr2rJhV.js";import{u as N}from"./useCurrentProject-C6qZaZgv.js";import{u as P}from"./useProjectNavigate-5znX7Ojg.js";import{n as S}from"./notifications-x-pTFTQl.js";import{p as $}from"./index-DJIjy7qt.js";import{c as k}from"./vendor-router-D1GqFWiT.js";const J=e=>{const{deployment:{status:t}}=e;return p(t,[i.RUNNING,i.IDLE,i.FAILED,i.STARTING,i.UPDATING])?n.jsx(M,{...e}):n.jsx(E,{...e})},M=({deployment:e})=>{const[t,o]=m.useState(!1),[s,{isLoading:c}]=h(),a=I();return n.jsxs(n.Fragment,{children:[n.jsxs(v,{variant:"outline",size:"sm",disabled:p(e.status,j),onClick:()=>o(!0),children:[n.jsx(D,{className:"size-3.5"}),"Stop"]}),n.jsx(y,{open:t,onOpenChange:o,title:`Stop the deployment ${e.name}`,description:`You are about to stop the deployment ${e.name}. Please be certain.`,confirmLabel:"Stop deployment",cancelLabel:"Back",isLoading:c,onConfirm:async()=>{await s({projectId:a,servingId:e.id}),o(!1)}})]})},E=({title:e,deployment:t})=>{const[o]=C(),s=I();return n.jsxs(v,{variant:"outline",size:"sm",disabled:p(t.status,j),onClick:()=>o({projectId:s,servingId:t.id}),children:[n.jsx(_,{className:"size-3.5"}),e??"Run"]})},j=[i.STOPPING],G=({projectName:e,deploymentName:t})=>`/grafana/d/kserve/kserve?${A.stringify({orgId:1,refresh:"10s","var-namespace":e.toLowerCase().replaceAll("_","-"),"var-configuration":`${t}-.*`,"var-revision":"All"})}`,Z=()=>{const{project:e}=N();return t=>`${b}${G({projectName:(e==null?void 0:e.projectName)??"",deploymentName:t})}`},B=({projectName:e,deploymentName:t})=>`/?_g=()&_a=(columns:!(serving_name,log_message,'@timestamp'),index:'${e.toLowerCase()}_serving-*',interval:auto,query:(language:lucene,query:'serving_name:${t}'),sort:!('@timestamp',desc))`,ee=()=>{const{id:e,project:t}=N(),[o,s]=m.useState(),c=async a=>{const{data:u}=await new x().request({url:`/elastic/jwt/${a} `,type:T.get});u&&s(u.kibanaUrl)};return m.useEffect(()=>{c(e)},[e]),a=>`${L}${o}security_tenant=private#${B({projectName:(t==null?void 0:t.projectName)??"",deploymentName:a})}`},te=e=>{const{id:t}=k(),o=P(),[s,{isFetching:c}]=$(),a=!!e.modelName&&e.modelVersion!=null;return{navigate:m.useCallback(async()=>{var d;if(!(!t||!a))try{const l=await s({projectId:t,modelName:e.modelName,modelVersion:e.modelVersion}).unwrap(),r=(d=l==null?void 0:l.items)==null?void 0:d[0],g=r==null?void 0:r.featureStoreId,f=r==null?void 0:r.featureGroupId;if(!r||g===void 0||f===void 0){S.error({title:"No monitoring available",content:"No monitoring configurations found for this model. Create one via feature_view.create_model_monitoring(...) in the SDK."});return}o(w.project.featureGroup.featureMonitoringList,{fsId:String(g),fgId:String(f)})}catch{S.error({title:"Failed to resolve monitoring",content:"Could not load monitoring configurations for this model."})}},[a,e.modelName,e.modelVersion,s,o,t]),isFetching:c,canNavigate:a}};export{J as D,Z as a,te as b,ee as u};
