import{j as e,L as x,r as d,t as g,s as p}from"./vendor-tanstack-DE4ALVGD.js";import{E as f,t as C,v as k,w as y,x as W,q as h,I as m,D as N,y as l,W as v,A as S,F as P,G as b,H as D,J as E,K as T,M as _,N as I,C as L,m as w,n as R,O as M,o as O,Q as A,T as z,U as $,V as F}from"./index-CNL5pSma.js";import{W as Q}from"./header-CsA-ed2X.js";import{D as B,a as H,b as K,c as U,d as u}from"./dropdown-menu-D34zumpn.js";import{m as V}from"./vendor-date-Bck8LDfw.js";import"./vendor-react-HBv6Kpyp.js";import"./vendor-radix-K8EF6rBE.js";import"./vendor-recharts-B3wzJa9e.js";import"./vendor-forms-BvpM0AtX.js";const q=()=>e.jsxs(f,{children:[e.jsx(C,{id:"Cpu"}),e.jsx(k,{children:"Add a work pool to get started"}),e.jsx(y,{children:"Work pools allow you to prioritize and manage deployments and control the infrastructure they run on."}),e.jsxs(W,{children:[e.jsx(x,{to:"/work-pools/create",children:e.jsxs(h,{children:["Add Work Pool ",e.jsx(m,{id:"Plus",className:"size-4 ml-2"})]})}),e.jsx(N,{id:"work-pools-guide"})]})]}),J=({workPool:s,onDelete:n})=>{const a=r=>{navigator.clipboard.writeText(r),l.success("ID copied")};return e.jsxs(B,{children:[e.jsx(H,{asChild:!0,children:e.jsxs(h,{variant:"outline",className:"size-8 p-0",children:[e.jsx("span",{className:"sr-only",children:"Open menu"}),e.jsx(m,{id:"MoreVertical",className:"size-4"})]})}),e.jsxs(K,{align:"end",children:[e.jsx(U,{children:"Actions"}),e.jsx(u,{onClick:()=>a(s.id),children:"Copy ID"}),e.jsx(x,{to:"/work-pools/work-pool/$workPoolName/edit",params:{workPoolName:s.name},children:e.jsx(u,{children:"Edit"})}),e.jsx(u,{onClick:n,children:"Delete"})]})]})},Y=({workPoolName:s})=>e.jsx(v,{workPoolName:s}),G=({workPool:s})=>{const[n,a]=d.useState(s.status==="PAUSED"),{pauseWorkPool:r,isPending:c}=S(),{resumeWorkPool:i,isPending:t}=P(),o=d.useMemo(()=>c||t,[c,t]),j=()=>{n?i(s.name,{onSuccess:()=>{a(!1),l.success(`${s.name} resumed`)},onError:()=>{l.error(`Failed to resume ${s.name}`)}}):r(s.name,{onSuccess:()=>{a(!0),l.success(`${s.name} paused`)},onError:()=>{l.error(`Failed to pause ${s.name}`)}})};return e.jsx(b,{checked:!n,onCheckedChange:j,disabled:o,"aria-label":n?"Resume work pool":"Pause work pool"})},X={process:"Process",ecs:"ECS","azure-container-instance":"Azure Container Instance",docker:"Docker","cloud-run":"Cloud Run","cloud-run-v2":"Cloud Run v2","vertex-ai":"Vertex AI",kubernetes:"Kubernetes"},Z={process:"Cpu",ecs:"Cpu","azure-container-instance":"Cpu",docker:"Cpu","cloud-run":"Cpu","cloud-run-v2":"Cpu","vertex-ai":"Cpu",kubernetes:"Cpu"},ee=s=>X[s]??s,se=s=>Z[s]??"Cpu",te=({type:s})=>e.jsxs(D,{children:[e.jsx(m,{id:se(s)}),ee(s)]}),ae=({workPool:s})=>{const{deleteWorkPool:n}=E(),a=T({interval:1e3}),{data:r}=g(_(s.name)),c=()=>{n(s.name,{onSuccess:()=>{l.success(`${s.name} deleted`)},onError:o=>{l.error(`Failed to delete work pool: ${o instanceof Error?o.message:"Unknown error"}`)}})},i=r&&r.length>0?V(r.filter(o=>o.last_heartbeat_time).map(o=>new Date(o.last_heartbeat_time))):null,t=i?I(i,a):null;return e.jsxs(L,{className:"gap-2",children:[e.jsxs(w,{className:"flex flex-row items-center justify-between",children:[e.jsxs(R,{className:"flex items-center gap-2",children:[e.jsx(Y,{workPoolName:s.name}),s.status&&e.jsx(M,{status:s.status,showTooltip:!0})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{workPool:s}),e.jsx(J,{workPool:s,onDelete:c})]})]}),e.jsxs(O,{className:"flex flex-col gap-1",children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx(te,{type:s.type})}),e.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-1 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Concurrency Limit"})," ",e.jsx("span",{className:"text-foreground",children:s.concurrency_limit?s.concurrency_limit:"Unlimited"})]}),t&&e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:"Last Polled"})," ",e.jsx("span",{className:"text-foreground",children:t})]})]})]})]})};function pe(){const[s,n]=d.useState(""),{data:a=0}=p(A()),{data:r=[]}=p(z({limit:200,offset:0})),c=d.useMemo(()=>r.filter(t=>[t.name,t.description,t.type,JSON.stringify(t.base_job_template),t.id,t.default_queue_id,t.status].join(" ").toLowerCase().includes(s.toLowerCase())),[r,s]),i=t=>{n(t.target.value)};return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Q,{}),a<1?e.jsx(q,{}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-end justify-between",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[a," ",$(a,"work pool")]}),e.jsx("div",{className:"flex gap-2",children:e.jsx(F,{placeholder:"Search work pools...",value:s,onChange:i})})]}),e.jsx("div",{className:"flex flex-col gap-4",children:c.map(t=>e.jsx(ae,{workPool:t},t.id))})]})]})}export{pe as component};
//# sourceMappingURL=index-Bh7dCo06.js.map
