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