import{r as o,z as C,j as e}from"./vendor-tanstack-BpuysabX.js";import{co as S,ak as v,al as w,am as N,an as g,ao as z,ap as k,aq as E,ar as h,as as x,T as L}from"./index-CREafGO4.js";const _=2,M=({selectedDeployments:a,onSelectDeployments:t})=>{const[i,u]=o.useState(""),n=o.useDeferredValue(i),{data:c=[]}=C(S({deployments:n?{operator:"and_",name:{like_:n}}:void 0,limit:100,offset:0,sort:"NAME_ASC"})),{data:f=[]}=C(S({deployments:a.size>0?{operator:"and_",id:{any_:Array.from(a)}}:void 0,limit:a.size||1,offset:0,sort:"NAME_ASC"},{enabled:a.size>0})),j=s=>{const r=new Set(a);a.has(s)?r.delete(s):r.add(s),t(r)},p=()=>{t(new Set)},b=()=>{if(a.size===0)return"All deployments";const s=f.filter(d=>a.has(d.id)).map(d=>d.name),r=s.slice(0,_),m=s.length-_;return e.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:r.join(", ")})}),m>0&&e.jsxs("p",{className:"text-sm shrink-0",children:["+ ",m]})]})},l=o.useMemo(()=>c.filter(s=>!n||s.name.toLowerCase().includes(n.toLowerCase())),[c,n]);return e.jsxs(v,{children:[e.jsx(w,{"aria-label":"Filter by deployment",selected:a.size===0,children:b()}),e.jsxs(N,{children:[e.jsx(g,{value:i,onValueChange:u,placeholder:"Search deployments..."}),e.jsxs(z,{children:[e.jsx(k,{children:"No deployments found"}),e.jsxs(E,{children:[e.jsxs(h,{"aria-label":"All deployments",onSelect:p,closeOnSelect:!1,value:"__all__",children:[e.jsx(x,{checked:a.size===0}),"All deployments"]}),l.map(s=>e.jsxs(h,{"aria-label":s.name,onSelect:()=>j(s.id),closeOnSelect:!1,value:s.id,children:[e.jsx(x,{checked:a.has(s.id)}),s.name]},s.id))]})]})]})]})},A=2,D=({selectedWorkPools:a,onSelectWorkPools:t})=>{const[i,u]=o.useState(""),n=o.useDeferredValue(i),{data:c=[]}=C(L({limit:100,offset:0})),f=l=>{const s=new Set(a);a.has(l)?s.delete(l):s.add(l),t(s)},j=()=>{t(new Set)},p=()=>{if(a.size===0)return"All work pools";const l=Array.from(a).sort((m,d)=>m.localeCompare(d)),s=l.slice(0,A),r=l.length-A;return e.jsxs("div",{className:"flex flex-1 min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex flex-1 min-w-0 items-center gap-2 overflow-hidden",children:e.jsx("span",{className:"truncate",children:s.join(", ")})}),r>0&&e.jsxs("p",{className:"text-sm shrink-0",children:["+ ",r]})]})},b=o.useMemo(()=>c.filter(l=>!n||l.name.toLowerCase().includes(n.toLowerCase())).sort((l,s)=>l.name.localeCompare(s.name)),[c,n]);return e.jsxs(v,{children:[e.jsx(w,{"aria-label":"Filter by work pool",selected:a.size===0,children:p()}),e.jsxs(N,{children:[e.jsx(g,{value:i,onValueChange:u,placeholder:"Search work pools..."}),e.jsxs(z,{children:[e.jsx(k,{children:"No work pools found"}),e.jsxs(E,{children:[e.jsxs(h,{"aria-label":"All work pools",onSelect:j,closeOnSelect:!1,value:"__all__",children:[e.jsx(x,{checked:a.size===0}),"All work pools"]}),b.map(l=>e.jsxs(h,{"aria-label":l.name,onSelect:()=>f(l.name),closeOnSelect:!1,value:l.name,children:[e.jsx(x,{checked:a.has(l.name)}),l.name]},l.name))]})]})]})]})};export{M as D,D as W};
//# sourceMappingURL=work-pool-filter-D882VRNA.js.map
