import{G as e,K as t,Q as n,i as r,k as i,r as a,tt as o}from"./branding-ClCX8iZg.js";import{t as s}from"./createLucideIcon-Bj0ivoOU.js";import{t as c}from"./use-revalidate-on-event-BcNsgp8a.js";import{t as l}from"./RunFilters-BRtDqL9g.js";import{t as u}from"./plus-BXvgCskW.js";import{C as d,F as f}from"./index-CQbBgNYK.js";import{t as p}from"./HeaderApp-HWu4NOgP.js";import{t as m}from"./use-document-meta-Br4UMxjt.js";import{o as h,r as g}from"./dist-Bhj00vNp.js";import{t as _}from"./RunsTable-BsNO6kjS.js";var v=s(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),y=r();function b(e,t){return t<=7?Array.from({length:t},(e,t)=>t+1):e<=3?[1,2,3,4,`ellipsis`,t]:e>=t-2?[1,`ellipsis`,t-3,t-2,t-1,t]:[1,`ellipsis`,e-1,e,e+1,`ellipsis`,t]}function x({currentPage:e,totalPages:t,total:n,onPageChange:r,className:o}){if(t<=1)return(0,y.jsx)(`div`,{className:i(`flex items-center justify-between`,o),children:(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[n,` result`,n===1?``:`s`]})});let s=b(e,t);return(0,y.jsxs)(`div`,{className:i(`flex items-center justify-between`,o),children:[(0,y.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Page `,e,` of `,t,` (`,n,` total)`]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,y.jsx)(a,{variant:`outline`,size:`sm`,className:`size-8 p-0`,onClick:()=>r(e-1),disabled:e<=1,children:(0,y.jsx)(v,{className:`size-4`})}),s.map((t,n)=>t===`ellipsis`?(0,y.jsx)(`span`,{className:`px-1 text-sm text-muted-foreground select-none`,children:`...`},`ellipsis-${n}`):(0,y.jsx)(a,{variant:t===e?`default`:`outline`,size:`sm`,className:`size-8 p-0 text-xs`,onClick:()=>r(t),children:t},t)),(0,y.jsx)(a,{variant:`outline`,size:`sm`,className:`size-8 p-0`,onClick:()=>r(e+1),disabled:e>=t,children:(0,y.jsx)(d,{className:`size-4`})})]})]})}var S=20;async function C({request:t}){let n=new URL(t.url),r=n.searchParams.get(`page`)??`1`,i=n.searchParams.get(`workflow`)??``,a=n.searchParams.get(`status`)??``,o=n.searchParams.get(`has_steps`)??`true`,s=n.searchParams.get(`label`)??``,c=new URLSearchParams;c.set(`page`,r),c.set(`per_page`,String(S)),i&&c.set(`workflow`,i),a&&c.set(`status`,a),o===`true`&&c.set(`has_steps`,`true`),s&&c.set(`label`,s);let l=await e.get(`/runs?${c}`);return{runs:l.data,meta:l.meta}}function w(){let{runs:e,meta:r}=n(),i=o().state===`loading`,s=f(e=>e.auth),d=s.status===`authenticated`&&s.user.is_admin;m({title:`Runs`,description:`Monitor and manage workflow executions.`}),c();let[v,b]=h({page:g.withDefault(1).withOptions({shallow:!1})},{history:`push`}),S=v.page,C=r?Math.ceil(r.total/r.per_page):1;return(0,y.jsx)(p,{title:`Runs`,description:`Monitor and manage workflow executions.`,titleItem:d?(0,y.jsx)(t,{to:`/workflows`,className:`block`,children:(0,y.jsxs)(a,{className:`w-full sm:w-fit gap-1.5`,children:[(0,y.jsx)(u,{className:`w-4 h-4`}),`New Run`]})}):void 0,children:(0,y.jsxs)(`div`,{className:`space-y-6`,children:[(0,y.jsx)(l,{}),(0,y.jsx)(`div`,{className:i?`opacity-50 pointer-events-none transition-opacity`:``,children:(0,y.jsx)(_,{runs:e})}),(0,y.jsx)(x,{currentPage:S,totalPages:C,total:r?.total??e.length,onPageChange:e=>{b({page:e})}})]})})}export{w as Component,C as loader};