import{j as t}from"./@radix-DAoBbclx.js";import{V as u,a3 as g,X as j,r as i,Y as f,Z as S,_ as v,$ as b,a0 as N,a1 as m,aH as k,T as R,aK as T,aJ as w,B as P,e as h,a4 as y}from"./index-DnCFURX3.js";import{S as C}from"./schedule-tag-BTjDF0ye.js";import{L as l,f as _}from"./@react-router-BTai9D5g.js";import{a as E,u as x,b as A}from"./ButtonGroup-Dy9AxLBQ.js";import{S as F}from"./refresh-DhdtzFSJ.js";import{S as D}from"./SearchField-CVlpmsG6.js";import{u as p}from"./all-pipeline-runs-query-DPKpaLFW.js";import{P as I}from"./Pagination-hLnXxv_M.js";import{z as o}from"./@zod-3snSrKBm.js";function Q(){return[{id:"select",meta:{width:"1%"},header:({table:e})=>t.jsx(u,{id:"check-all",checked:e.getIsAllRowsSelected(),onCheckedChange:s=>e.toggleAllRowsSelected(s==="indeterminate"?!0:s)}),cell:({row:e})=>t.jsx(u,{id:`check-${e.id}`,checked:e.getIsSelected(),onCheckedChange:e.getToggleSelectedHandler()})},{id:"run",header:"Run",accessorFn:e=>{var s;return{name:e.name,id:e.id,status:(s=e.body)==null?void 0:s.status}},cell:({getValue:e})=>{const{name:s,status:a,id:r}=e();return t.jsxs("div",{className:"group/copybutton flex min-w-[10rem] items-center gap-2",children:[t.jsx(g,{className:`h-5 w-5 shrink-0 ${j(a)}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(l,{to:i.projects.runs.detail(r),className:"grid grid-cols-1 items-center gap-1",children:t.jsx("h2",{className:"truncate text-text-md font-semibold",children:s})}),t.jsx(f,{children:t.jsxs(S,{children:[t.jsx(v,{className:"hover:text-theme-text-brand hover:underline",children:t.jsx(b,{status:a})}),t.jsx(N,{className:"z-20 capitalize",children:a})]})}),t.jsx(m,{copyText:s})]}),t.jsxs(l,{to:i.projects.runs.detail(r),className:"flex items-center gap-1",children:[t.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),t.jsx(m,{copyText:r})]})]})]})}},{id:"Snapshot",header:"Snapshot",accessorFn:e=>{var s,a;return(a=(s=e.resources)==null?void 0:s.source_snapshot)==null?void 0:a.id},cell:({row:e})=>{var r;const s=(r=e.original.resources)==null?void 0:r.source_snapshot,a=s==null?void 0:s.name;return!s||!a?null:t.jsx(k,{snapshotId:s.id,snapshotName:a})}},{id:"stack",header:"Stack",accessorFn:e=>{var s,a,r,n;return{name:(a=(s=e.resources)==null?void 0:s.stack)==null?void 0:a.name,id:(n=(r=e.resources)==null?void 0:r.stack)==null?void 0:n.id}},cell:({getValue:e})=>{const{name:s,id:a}=e();return!s||!a?null:t.jsx(l,{to:i.stacks.overview,children:t.jsx(R,{rounded:!1,className:"inline-block whitespace-nowrap",color:"turquoise",emphasis:"subtle",children:s})})}},{id:"trigger",header:"Trigger",accessorFn:e=>{var s,a;return(a=(s=e.resources)==null?void 0:s.schedule)==null?void 0:a.name},cell:({row:e})=>{var a;return((a=e.original.resources)==null?void 0:a.schedule)?t.jsx(C,{}):null}},{id:"created",header:"Created at",accessorFn:e=>{var s;return(s=e.body)==null?void 0:s.created},cell:({getValue:e})=>t.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:t.jsx(T,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>{var s;return{author:(s=e.resources)==null?void 0:s.user}},cell:({getValue:e})=>{var a,r;const{author:s}=e();return t.jsx(w,{avatarUrl:((a=s.body)==null?void 0:a.avatar_url)??void 0,username:s.name,isServiceAccount:!!((r=s.body)!=null&&r.is_service_account)})}},{id:"admin_actions",header:"",meta:{width:"5%"},cell:({row:e})=>t.jsx(E,{id:e.original.id})}]}function V({params:e}){const{refetch:s}=p({params:e},{throwOnError:!0}),{selectedRowCount:a}=x();return t.jsxs("div",{className:"flex items-center justify-between",children:[a?t.jsx(A,{}):t.jsx(D,{searchParams:e}),t.jsxs(P,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>s(),children:[t.jsx(F,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}function X({params:e,columns:s}){const{rowSelection:a,setRowSelection:r}=x(),n=p({params:e},{throwOnError:!0});if(n.isPending)return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx(h,{className:"h-[500px] w-full"}),t.jsx(h,{className:"h-[36px] w-[300px]"})]});if(n.isError)return t.jsx("p",{children:"Error fetching pipeline runs"});const c=n.data;return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(y,{rowSelection:a,onRowSelectionChange:r,columns:s,data:c.items})}),c.total_pages>1&&t.jsx(I,{searchParams:e,paginate:c})]})}const d=1,z=o.object({page:o.coerce.number().min(d).optional().default(d).catch(d),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function Y(){const[e]=_(),{page:s,name:a,operator:r}=z.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:a,logical_operator:r}}export{X as P,V as R,Q as g,Y as u};
