import{a as m,j as s}from"./@tanstack-CEbkxrhX.js";import{g as u,E as p,C as d,R as h}from"./CopyButton-CTrzKmUO.js";import{P as f}from"./PageHeader-B0pUife2.js";import{S as x,P as g}from"./Pagination-B9WG_9cJ.js";import{k as j,l as P,j as y,n as b,F as N,m as v,r as o,T as w,z as r,o as S,h as E,D as T,S as l}from"./index-BawkpTlr.js";import{o as C}from"./url-CgvM-IVM.js";import{S as _}from"./terminal-B2ovgWuz.js";import{L as c,b as F}from"./@react-router-DYovave8.js";import{r as R}from"./@radix-C9DBgJhe.js";import"./check-circle-BVvhm5dy.js";import"./copy-BRhQz3j-.js";import"./chevron-right-double-CJ50E9Gr.js";import"./@reactflow-DYIyhCfd.js";function k({params:e}){return["pipeline_namespaces",e]}async function A({params:e}){const a=j(P.pipelines.namespaces+"?"+C(e)),t=await y(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(t.status===404&&b(),!t.ok)throw new N({message:"Error while fetching pipeline namespaces",status:t.status,statusText:t.statusText});return t.json()}function z(e,a){return m({queryKey:k(e),queryFn:()=>A(e),...a})}function B(){return[{id:"name",header:"Pipeline",accessorFn:e=>{var a;return{name:e.name,status:(a=e.body)==null?void 0:a.latest_run_status}},cell:({getValue:e})=>{const{name:a,status:t}=e();return s.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[s.jsx(v,{className:`h-5 w-5 ${u(t)}`}),s.jsxs(c,{to:o.pipelines.namespace(encodeURIComponent(a)),className:"flex items-center gap-1",children:[s.jsx("h2",{className:"text-text-md font-semibold",children:a}),s.jsx(p,{status:t}),s.jsx(d,{copyText:a})]})]})}},{id:"latest-run",header:"Latest Run",accessorFn:e=>{var a,t;return{status:(a=e.body)==null?void 0:a.latest_run_status,runId:(t=e.body)==null?void 0:t.latest_run_id}},cell:({getValue:e})=>{const{runId:a,status:t}=e();return!a||!t?s.jsx("div",{children:"No run"}):s.jsx(c,{to:o.runs.detail(a),children:s.jsxs(w,{emphasis:"subtle",rounded:!1,className:"inline-flex items-center gap-0.5",color:L(t),children:[s.jsx(_,{className:`h-3 w-3 ${D(t)}`}),a==null?void 0:a.split("-")[0]]})})}}]}function D(e){if(!e)return"fill-theme-text-brand";switch(e){case"running":return"fill-orange-700";case"cached":return"fill-theme-text-secondary";case"completed":return"fill-success-800";case"failed":return"fill-error-800";case"initializing":return"fill-theme-text-brand"}}function L(e){if(!e)return"purple";switch(e){case"running":return"orange";case"cached":return"grey";case"completed":return"green";case"failed":return"red";case"initializing":return"purple"}}const i=1,q=r.object({page:r.coerce.number().min(i).optional().default(i).catch(i),name:r.string().optional(),operator:r.enum(["and","or"]).optional()});function I(){const[e]=F(),{page:a,name:t,operator:n}=q.parse({page:e.get("page")||void 0,name:e.get("name")||void 0,operator:e.get("operator")||void 0});return{page:a,name:t,logical_operator:n}}function Z(){const{setCurrentBreadcrumbData:e}=S(),a=I(),{data:t,refetch:n}=z({params:{...a,sort_by:"desc:updated"}},{throwOnError:!0});return R.useEffect(()=>{e({segment:"pipelines",data:null})},[]),s.jsxs("div",{children:[s.jsx(f,{children:s.jsx("h1",{className:"text-display-xs font-semibold",children:"Pipelines"})}),s.jsx("section",{className:"p-5",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(x,{searchParams:a}),s.jsx("div",{className:"flex justify-between",children:s.jsxs(E,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>n(),children:[s.jsx(h,{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:t?s.jsx(T,{columns:B(),data:t.items}):s.jsx(l,{className:"h-[500px] w-full"})}),t?t.total_pages>1&&s.jsx(g,{searchParams:a,paginate:t}):s.jsx(l,{className:"h-[36px] w-[300px]"})]})]})})]})}export{Z as default};
