import{j as i,r as d}from"./vendor-react-wBh_31cN.js";import{T as f}from"./tooltip-DFFgUYh6.js";import{a7 as h,d as c}from"./index-dNe6i2rS.js";import{V as m}from"./vendor-icons-BUUmD6ht.js";const b=h.injectEndpoints({endpoints:e=>({getWebSocketPoolStatus:e.query({query:()=>({url:"websocket-pool/status"}),extraOptions:{skipError:!0}})})}),{useGetWebSocketPoolStatusQuery:a}=b,r=3e4;function g(e,t){return e==="instance"?t?"This instance is full":"This instance is close to its limit":t?"Cluster is full":"Cluster is close to its limit"}function x(e,t,s){return e==="instance"?t?`This Hopsworks instance has no free sessions. Starting a new ${s} on this instance will fail; refreshing the page or signing back in may land you on another instance that still has capacity. If the cluster badge is also red, every instance is at the limit and you will have to wait for sessions to close.`:`This Hopsworks instance is close to its session limit. Starting a new ${s} may begin to fail soon. Closing notebooks, terminals, or apps you no longer need will free up capacity.`:t?`Every Hopsworks instance has reached its session limit. Starting a new ${s} will fail until existing sessions close. If this happens often, contact your administrator to raise the limit.`:"The cluster is close to its session limit. Closing notebooks, terminals, or apps you no longer need will free up capacity."}function l({scope:e,status:t,currentTool:s}){if(t==="OK")return null;const n=t==="CRITICAL",o=g(e,n),u=x(e,n,s),p=n?"bg-quartz-label-red-shade2 text-quartz-label-red border-quartz-label-red":"bg-quartz-label-orange-shade2 text-quartz-label-orange border-quartz-label-orange";return i.jsx(f,{content:u,children:i.jsxs("div",{role:"status",className:c("inline-flex items-center gap-1.5 rounded-md border px-2 py-1",p),children:[i.jsx(m,{className:"size-4 shrink-0"}),i.jsx("span",{className:"text-xs font-medium whitespace-nowrap",children:o})]})})}function I({currentTool:e,className:t}){const{data:s}=a(void 0,{pollingInterval:r});if(!s)return null;const n=s.instanceStatus!=="OK",o=s.clusterStatus!=="OK";return!n&&!o?null:i.jsxs("div",{className:c("inline-flex items-center gap-2",t),children:[n&&i.jsx(l,{scope:"instance",status:s.instanceStatus,currentTool:e}),o&&i.jsx(l,{scope:"cluster",status:s.clusterStatus,currentTool:e})]})}function C(){const{data:e}=a(void 0,{pollingInterval:r});return(e==null?void 0:e.clusterStatus)==="CRITICAL"}function v(){const{data:e,refetch:t}=a(void 0,{pollingInterval:r}),s=d.useCallback(()=>t().unwrap(),[t]);return{isCritical:(e==null?void 0:e.clusterStatus)==="CRITICAL",refresh:s}}export{I as W,C as a,v as u};
