import{r as v,j as e}from"./vendor-tanstack-BpuysabX.js";import{cp as P,q as E,I as L,as as N,cq as f,ax as k,cr as C,C as T,bd as h,S as _,a as y,b as B,c as O,e as z,be as R,bf as U,bg as m,cm as q,bh as V,bi as W,cn as F}from"./index-CREafGO4.js";import{D as G,a as H,b as X,d as g}from"./dropdown-menu-DZExFL3b.js";const A=2,K=({defaultValue:c,selectedFilters:l=c||new Set,onSelectFilter:s})=>{const[t,r]=v.useState(!1),d=v.useMemo(()=>{const a=new Set(P);return l.has("Scheduled")||a.size!==l.size?!1:Array.from(l).every(n=>a.has(n))},[l]),u=()=>{s(new Set(P))},j=()=>{s(new Set)},S=a=>{if(d){s(new Set([a]));return}const n=new Set(l);l.has(a)?n.delete(a):n.add(a),s(n)},p=()=>{if(l.size===0)return"All run states";if(d)return"All except scheduled";const a=Array.from(l),n=a.slice(0,A),o=a.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:n.map(i=>e.jsx(k,{name:i,type:f[i]},i))}),o>0&&e.jsxs("p",{className:"text-sm shrink-0",children:["+ ",o]})]})};return e.jsxs(G,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsxs(E,{variant:"outline",className:"justify-between w-full bg-card dark:bg-background",children:[e.jsx("span",{className:"flex-1 min-w-0",children:p()}),e.jsx(L,{id:"ChevronDown",className:"ml-2 size-4 shrink-0"})]})}),e.jsxs(X,{className:"max-h-96 overflow-x-hidden overflow-y-auto",children:[e.jsxs(g,{onSelect:a=>{a.preventDefault(),u()},children:[e.jsx(N,{checked:d,className:"mr-2"}),"All except scheduled"]}),e.jsxs(g,{onSelect:a=>{a.preventDefault(),j()},children:[e.jsx(N,{checked:l.size===0,className:"mr-2"}),"All run states"]}),Object.keys(f).map(a=>e.jsxs(g,{"aria-label":a,onSelect:n=>{n.preventDefault(),S(a)},children:[e.jsx(N,{"aria-label":a,className:"mr-2",checked:!d&&l.has(a)}),e.jsx(k,{name:a,type:f[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("p",{className:"text-base",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(t=>"onSelect"in s&&"selectedRows"in s?e.jsx("li",{children:e.jsx(C,{flowRun:t,checked:s.selectedRows.has(t.id),onCheckedChange:r=>s.onSelect(t.id,r)})},t.id):e.jsx("li",{children:e.jsx(C,{flowRun:t})},t.id))}):e.jsx(Y,{numSkeletons:5}),Y=({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(T,{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))}),J=[5,10,25,50,100],se=({count:c,pages:l,pagination:s,onChangePagination:t,onPrefetchPage:r})=>{const d=()=>t({limit:s.limit,page:1}),u=()=>t({limit:s.limit,page:s.page-1}),j=()=>t({limit:s.limit,page:s.page+1}),S=()=>t({limit:s.limit,page:l}),p=()=>{s.page>1&&r?.(1)},a=()=>{s.page>1&&r?.(s.page-1)},n=()=>{s.page<l&&r?.(s.page+1)},o=()=>{s.page<l&&r?.(l)},i=s.page<=1,w=s.page>=l,M=x=>{const b=Number(x),D=Math.ceil(c/b),I=Math.min(s.page,D);t({limit:b,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(_,{value:String(s.limit),onValueChange:M,children:[e.jsx(y,{"aria-label":"Items per page",children:e.jsx(B,{placeholder:"Theme"})}),e.jsx(O,{children:J.map(x=>e.jsx(z,{value:String(x),children:x},x))})]})]}),e.jsx(R,{className:"justify-end",children:e.jsxs(U,{children:[e.jsxs(m,{children:[e.jsx(q,{onClick:d,onMouseEnter:p,disabled:i}),e.jsx(V,{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(W,{onClick:j,onMouseEnter:n,disabled:w})}),e.jsx(m,{children:e.jsx(F,{onClick:S,onMouseEnter:o,disabled:w})})]})})]})};export{se as F,K as S,ee as a};
//# sourceMappingURL=flow-runs-pagination-6wLDGHqm.js.map
