import{j as a,a as f}from"./@tanstack-D1KSn3AD.js";import{m as j,z as o,k as y,l as g,j as b,n as P,F as N,r as i,o as v,T as u,h as S,D as R,S as p}from"./index-M2LMbZSu.js";import{P as T}from"./PageHeader-hJZEYC_E.js";import{f as k,L as c,g as h}from"./@react-router-t1nY6c48.js";import{R as F}from"./refresh-Cx_kzUlu.js";import{o as E}from"./url-BxOqGmlk.js";import{S as w,P as C}from"./Pagination-cwZwDAZA.js";import{S as _}from"./terminal-C3Pq8EZ0.js";import{g as A,E as D,C as x}from"./CopyButton-D9wonjFm.js";import{D as I}from"./DisplayDate-xz7bjv92.js";import{I as q}from"./InlineAvatar-BAaIb0BW.js";import"./@radix-Mqgm9uyP.js";import"./@reactflow-DOgoC88E.js";import"./chevron-right-double-BdbmNpRk.js";import"./check-circle-B_YRDK8p.js";import"./copy-Vxjjuv3p.js";function z({namespace:e}){return a.jsx(T,{children:a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(j,{className:"h-5 w-5 fill-neutral-400"}),a.jsx("h1",{className:"text-display-xs font-semibold",children:decodeURIComponent(e)})]})})}const l=1,B=o.object({page:o.coerce.number().min(l).optional().default(l).catch(l),name:o.string().optional(),operator:o.enum(["and","or"]).optional()});function L(){const[e]=k(),{page:s,name:t,operator:r}=B.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:t,logical_operator:r}}function U({params:e}){return["runs",e]}async function G({params:e}){const s=y(g.runs.all+"?"+E(e)),t=await b(s,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&P(),!t.ok)throw new N({message:"Error while fetching pipeline runs",status:t.status,statusText:t.statusText});return t.json()}function H(e,s){return f({queryKey:U(e),queryFn:()=>G(e),...s})}function K(){return[{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:t,id:r}=e();return a.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[a.jsx(_,{className:`h-5 w-5 ${A(t)}`}),a.jsxs("div",{children:[a.jsxs(c,{to:i.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("h2",{className:"text-text-md font-semibold",children:s}),a.jsx(D,{status:t}),a.jsx(x,{copyText:s})]}),a.jsxs(c,{to:i.runs.detail(r),className:"flex items-center gap-1",children:[a.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:r.split("-")[0]}),a.jsx(x,{copyText:r})]})]})]})}},{id:"version",header:"Version",accessorFn:e=>{var s,t,r;return(r=(t=(s=e.body)==null?void 0:s.pipeline)==null?void 0:t.body)==null?void 0:r.version},cell:({getValue:e})=>{const s=e();return a.jsx(v,{color:"purple",className:"inline-flex",size:"sm",children:s})}},{id:"stack",header:"Stack",accessorFn:e=>{var s,t,r,n;return{name:(t=(s=e.body)==null?void 0:s.stack)==null?void 0:t.name,id:(n=(r=e.body)==null?void 0:r.stack)==null?void 0:n.id}},cell:({getValue:e})=>{const{name:s,id:t}=e();return!s||!t?null:a.jsx(c,{to:i.stacks.overview,children:a.jsx(u,{rounded:!1,className:"inline-block",color:"turquoise",emphasis:"subtle",children:s})})}},{id:"repository",header:"Repository",accessorFn:e=>{var s,t,r,n,m,d;return{name:(r=(t=(s=e.body)==null?void 0:s.code_reference)==null?void 0:t.body)==null?void 0:r.code_repository.name,id:(d=(m=(n=e.body)==null?void 0:n.code_reference)==null?void 0:m.body)==null?void 0:d.code_repository.id}},cell:({getValue:e})=>{const{name:s,id:t}=e();return!s||!t?null:a.jsx("div",{children:a.jsx(u,{rounded:!1,className:"inline-block",color:"grey",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})=>a.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:a.jsx(I,{dateString:e()})})},{id:"author",header:"Author",accessorFn:e=>{var s;return{author:(s=e.body)==null?void 0:s.user}},cell:({getValue:e})=>{const{author:s}=e();return a.jsx(q,{username:s.name})}}]}function Q(){const{namespace:e}=h(),s=L(),t=K(),{data:r,refetch:n}=H({params:{pipeline_name:decodeURIComponent(e),...s,sort_by:"desc:updated"}},{throwOnError:!0});return a.jsxs("div",{className:"flex flex-col gap-5 p-5",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx(w,{searchParams:s}),a.jsxs(S,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[a.jsx(F,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]}),a.jsxs("div",{className:"flex flex-col items-center gap-5",children:[a.jsx("div",{className:"w-full",children:r?a.jsx(R,{columns:t,data:r.items}):a.jsx(p,{className:"h-[500px] w-full"})}),r?r.total_pages>1&&a.jsx(C,{searchParams:s,paginate:r}):a.jsx(p,{className:"h-[36px] w-[300px]"})]})]})}function ie(){const{namespace:e}=h();return a.jsxs("div",{children:[a.jsx(z,{namespace:e}),a.jsx(Q,{})]})}export{ie as default};
