import{r as b,j as e}from"./vendor-tanstack-BVzzyDEt.js";import{ce as P,r as L,s as y,q as E,I as _,t as B,v as f,a2 as N,cf as g,a9 as k,a3 as M,cE as A,G as O,b3 as h,S as z,d as R,e as U,f as G,h as V,b4 as W,b5 as q,b6 as m,co as F,b7 as H,b8 as X,cp as Y}from"./index-BJkJ93Lr.js";const C=2,K=({defaultValue:c,selectedFilters:l=c||new Set,onSelectFilter:s})=>{const[n,r]=b.useState(!1),d=b.useMemo(()=>{const a=new Set(P);return l.has("Scheduled")||a.size!==l.size?!1:Array.from(l).every(t=>a.has(t))},[l]),u=()=>{s(new Set(P))},j=()=>{s(new Set)},S=a=>{if(d){s(new Set([a]));return}const t=new Set(l);l.has(a)?t.delete(a):t.add(a),s(t)},p=()=>{if(l.size===0)return"All run states";if(d)return"All except scheduled";const a=Array.from(l),t=a.slice(0,C),o=a.length-C;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:t.map(i=>e.jsx(k,{name:i,type:g[i]},i))}),o>0&&e.jsxs(M,{variant:"bodySmall",className:"shrink-0",children:["+ ",o]})]})};return e.jsxs(L,{open:n,onOpenChange:r,children:[e.jsx(y,{asChild:!0,children:e.jsxs(E,{variant:"outline",className:"justify-between w-full",children:[e.jsx("span",{className:"flex-1 min-w-0",children:p()}),e.jsx(_,{id:"ChevronDown",className:"ml-2 size-4 shrink-0"})]})}),e.jsxs(B,{className:"max-h-96 overflow-x-hidden overflow-y-auto",children:[e.jsxs(f,{onSelect:a=>{a.preventDefault(),u()},children:[e.jsx(N,{checked:d,className:"mr-2"}),"All except scheduled"]}),e.jsxs(f,{onSelect:a=>{a.preventDefault(),j()},children:[e.jsx(N,{checked:l.size===0,className:"mr-2"}),"All run states"]}),Object.keys(g).map(a=>e.jsxs(f,{"aria-label":a,onSelect:t=>{t.preventDefault(),S(a)},children:[e.jsx(N,{"aria-label":a,className:"mr-2",checked:!d&&l.has(a)}),e.jsx(k,{name:a,type:g[a]})]},a))]})]})},ee=({flowRuns:c,onClearFilters:l,...s})=>c?c.length===0?e.jsx("div",{className:"flex justify-center py-4",children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(M,{children:"No runs found"}),l&&e.jsx(E,{onClick:l,children:"Clear Filters"})]})}):e.jsx("ul",{className:"flex flex-col gap-2",children:c.map(n=>"onSelect"in s&&"selectedRows"in s?e.jsx("li",{children:e.jsx(A,{flowRun:n,checked:s.selectedRows.has(n.id),onCheckedChange:r=>s.onSelect(n.id,r)})},n.id):e.jsx("li",{children:e.jsx(A,{flowRun:n})},n.id))}):e.jsx(J,{numSkeletons:5}),J=({numSkeletons:c=1})=>e.jsx("ul",{className:"flex flex-col gap-1",children:Array.from({length:c}).map((l,s)=>e.jsx("li",{children:e.jsxs(O,{className:"flex flex-col gap-2 p-4",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx(h,{className:"h-4 w-[350px]"}),e.jsx(h,{className:"h-4 w-[400px]"})]}),e.jsx(h,{className:"h-4 w-[400px]"}),e.jsx(h,{className:"h-4 w-[200px]"})]})},s))}),Q=[5,10,25,50,100],se=({count:c,pages:l,pagination:s,onChangePagination:n,onPrefetchPage:r})=>{const d=()=>n({limit:s.limit,page:1}),u=()=>n({limit:s.limit,page:s.page-1}),j=()=>n({limit:s.limit,page:s.page+1}),S=()=>n({limit:s.limit,page:l}),p=()=>{s.page>1&&r?.(1)},a=()=>{s.page>1&&r?.(s.page-1)},t=()=>{s.page<l&&r?.(s.page+1)},o=()=>{s.page<l&&r?.(l)},i=s.page<=1,w=s.page>=l,T=x=>{const v=Number(x),D=Math.ceil(c/v),I=Math.min(s.page,D);n({limit:v,page:I})};return e.jsxs("div",{className:"flex flex-row justify-between items-center",children:[e.jsxs("div",{className:"flex flex-row items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{className:"whitespace-nowrap",children:"Items per page"}),e.jsxs(z,{value:String(s.limit),onValueChange:T,children:[e.jsx(R,{"aria-label":"Items per page",children:e.jsx(U,{placeholder:"Theme"})}),e.jsx(G,{children:Q.map(x=>e.jsx(V,{value:String(x),children:x},x))})]})]}),e.jsx(W,{className:"justify-end",children:e.jsxs(q,{children:[e.jsxs(m,{children:[e.jsx(F,{onClick:d,onMouseEnter:p,disabled:i}),e.jsx(H,{onClick:u,onMouseEnter:a,disabled:i})]}),e.jsxs(m,{className:"text-sm",children:["Page ",l===0?0:s.page," of ",l]}),e.jsx(m,{children:e.jsx(X,{onClick:j,onMouseEnter:t,disabled:w})}),e.jsx(m,{children:e.jsx(Y,{onClick:S,onMouseEnter:o,disabled:w})})]})})]})};export{se as F,K as S,ee as a};
//# sourceMappingURL=flow-runs-pagination-b0pvBxt9.js.map
