import{aJ as s}from"./@ui-core-DKdciH1Z.js";import{_ as l,aY as g,a0 as j,aS as f,r as d,a1 as v,a2 as S,a3 as N,a4 as b,a5 as y,a6 as m,T as k,al as R,ak as w,B as C,a7 as P,a8 as T,e as u}from"./index-D7KLAbvI.js";import{P as A}from"./Pagination-Bl0X6mOG.js";import{S as F}from"./SearchField-DEer4oQ6.js";import{u as _}from"./all-pipeline-runs-query-CQbINLBU.js";import{a as I,u as B,b as D}from"./ButtonGroup-BirxIr-W.js";import{P as E}from"./pipeline-link-DyLNQTVa.js";import{A as z}from"./action-cell-CsLz-mf4.js";import{S as L}from"./schedule-tag-Cpi_jTxz.js";import{L as p,f as q}from"./@react-router-DaIuhn3X.js";import{z as o}from"./@zod-DKyD3xVW.js";const G=[{id:"select",meta:{width:"1%"},header:({table:e})=>s.jsx(l,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:a=>e.toggleAllRowsSelected(a==="indeterminate"?!0:a)}),cell:({row:e})=>s.jsx(l,{id:`check-${e.id}`,checked:e.getIsSelected(),onCheckedChange:e.getToggleSelectedHandler()})},{id:"name",header:"Run",accessorFn:e=>({id:e.id,name:e.name,status:e.body?.status}),cell:({row:e})=>{const{name:a,id:t}=e.original,r=e.original.body?.status,n=e.original.body?.index;return s.jsxs("div",{className:"group/copybutton flex min-w-[10rem] items-center gap-2",children:[s.jsx(g,{className:`h-5 w-5 shrink-0 ${j(r)}`}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(p,{to:d.projects.runs.detail(t),className:"grid grid-cols-1 items-center gap-1",children:s.jsx("span",{className:"truncate text-text-md font-semibold text-theme-text-primary",children:s.jsx(f,{name:a,index:n})})}),s.jsx(v,{children:s.jsxs(S,{children:[s.jsx(N,{className:"hover:text-theme-text-brand hover:underline",children:s.jsx(b,{status:r})}),s.jsx(y,{className:"z-20 capitalize",children:r})]})}),s.jsx(m,{copyText:a})]}),s.jsxs(p,{to:d.projects.runs.detail(t),className:"flex items-center gap-1",children:[s.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:t.split("-")[0]}),s.jsx(m,{copyText:t})]})]})]})}},{id:"pipeline",header:"Pipeline",accessorFn:e=>e.resources?.pipeline?.name,cell:({row:e})=>{const a=e.original.resources?.pipeline?.name,t=e.original.resources?.pipeline?.id;return!a||!t?null:s.jsx(E,{pipelineId:t,pipelineName:a})}},{id:"stack",header:"Stack",accessorFn:e=>({name:e.resources?.stack?.name,id:e.resources?.stack?.id}),cell:({getValue:e})=>{const{name:a,id:t}=e();return!a||!t?null:s.jsx(k,{rounded:!1,className:"inline-block whitespace-nowrap",color:"turquoise",emphasis:"subtle",children:a})}},{id:"trigger",header:"Trigger",accessorFn:e=>e.resources?.schedule?.name,cell:({row:e})=>e.original.resources?.schedule?s.jsx(L,{}):null},{id:"created-at",header:"Created at",accessorFn:e=>({date:e.body?.created}),cell:({getValue:e})=>{const{date:a}=e();return s.jsx("span",{className:"whitespace-nowrap",children:s.jsx(R,{dateString:a})})}},{id:"author",header:"Author",accessorFn:e=>({name:e.resources?.user?.name}),cell:({row:e})=>{const a=e.original.resources?.user;return a?s.jsx(w,{avatarUrl:a.body?.avatar_url??void 0,username:a.name,isServiceAccount:!!a.body?.is_service_account}):null}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>s.jsx(z,{children:s.jsx(I,{id:e.original.id})})}],c=1,U=o.object({page:o.coerce.number().min(c).optional().default(c).catch(c),name:o.string().optional(),operator:o.enum(["and","or"]).optional(),status:o.enum(["pending","running","completed"]).optional()});function $(){const[e]=q(),{page:a,name:t,operator:r,status:n}=U.parse({page:e.get("page")||void 0,name:e.get("name")||void 0,operator:e.get("operator")||void 0,status:e.get("status")||void 0});return{page:a,name:t,logical_operator:r,status:n}}function ee({fixedQueryParams:e={}}){const{selectedRowCount:a,rowSelection:t,setRowSelection:r}=B(),n=$(),{data:i,refetch:h}=_({params:{...n,sort_by:"desc:updated",...e}});return s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[a?s.jsx(D,{}):s.jsx(F,{searchParams:n}),s.jsx("div",{className:"flex justify-between",children:s.jsxs(C,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>h(),children:[s.jsx(P,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})})]}),s.jsxs("div",{className:"flex flex-col items-center gap-5",children:[s.jsx("div",{className:"w-full",children:i?s.jsx(T,{rowSelection:t,onRowSelectionChange:r,columns:G,getRowId:x=>x.id,data:i.items}):s.jsx(u,{className:"h-[500px] w-full"})}),i?i.total_pages>1&&s.jsx(A,{searchParams:n,paginate:i}):s.jsx(u,{className:"h-[36px] w-[300px]"})]})]})}export{ee as R};
