import{j as t}from"./@radix-3bj3otF9.js";import{V as u,a3 as j,X as g,r as c,Y as f,Z as S,_ as v,$ as b,a0 as N,a1 as m,ae as k,T as R,ac as P,ab as T,B as y,e as h,a4 as C,z as o}from"./index-Cs2FY84s.js";import{L as l,f as w}from"./@react-router-Ct_TgVUW.js";import{a as _,u as x,b as E}from"./ButtonGroup-C4ao6wx2.js";import{S as A}from"./refresh-BaK7e0kN.js";import{S as F}from"./SearchField-Bd1JmJXg.js";import{u as p}from"./all-pipeline-runs-query-DjqFvEha.js";import{P as D}from"./Pagination-Du1A_aqP.js";function H(){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 items-center gap-2",children:[t.jsx(j,{className:`h-5 w-5 shrink-0 ${g(a)}`}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(l,{to:c.projects.runs.detail(r),className:"flex items-center gap-1",children:t.jsx("h2",{className:"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:c.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:c.stacks.overview,children:t.jsx(R,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})})}},{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(P,{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(T,{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(_,{id:e.original.id})}]}function Q({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(E,{}):t.jsx(F,{searchParams:e}),t.jsxs(y,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>s(),children:[t.jsx(A,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}function V({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 i=n.data;return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(C,{rowSelection:a,onRowSelectionChange:r,columns:s,data:i.items})}),i.total_pages>1&&t.jsx(D,{searchParams:e,paginate:i})]})}const d=1,I=o.object({page:o.coerce.number().min(d).optional().default(d).catch(d),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function X(){const[e]=w(),{page:s,name:a,operator:r}=I.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:a,logical_operator:r}}export{V as P,Q as R,H as g,X as u};
