import{aM as x,aJ as t}from"./@ui-core-DKdciH1Z.js";import{P as g}from"./Pagination-Bl0X6mOG.js";import{af as h,e as m,a8 as j,B as y,a7 as v,bm as S,r as u,a6 as p,bg as D,ah as N,ak as b,al as C}from"./index-D7KLAbvI.js";import{c as P}from"./helper-DWeonard.js";import{S as w}from"./SearchField-DEer4oQ6.js";import{B as k}from"./button-group-basic-1Ecitaf4.js";import{f as F,L as d}from"./@react-router-DaIuhn3X.js";import{z as r}from"./@zod-DKyD3xVW.js";import{D as R}from"./deployment-status-tag-9Q9AOMJF.js";import{P as T}from"./pipeline-link-DyLNQTVa.js";const{ContextProvider:M,useContext:c}=P();function q({params:e,columns:s}){const{rowSelection:a,setRowSelection:n}=c(),o=x({...h.list(e),throwOnError:!0});if(o.isPending)return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(m,{className:"h-[500px] w-full"})}),t.jsx(m,{className:"h-[36px] w-[300px]"})]});if(o.isError)return t.jsx("p",{children:"Error fetching deployments"});const i=o.data;return t.jsxs("div",{className:"flex flex-col items-center gap-5",children:[t.jsx("div",{className:"w-full",children:t.jsx(j,{columns:s,data:i.items,rowSelection:a,onRowSelectionChange:n,getRowId:f=>f.id})}),i.total_pages>1&&t.jsx(g,{searchParams:e,paginate:i})]})}function B(){const{selectedRowCount:e}=c();async function s(){}return t.jsx(k,{itemName:"Pipeline Snapshot",selectedItemCount:e,onDeleteSelected:s})}function H({params:e}){const{refetch:s}=x({...h.list(e),throwOnError:!0}),{selectedRowCount:a}=c();return t.jsxs("div",{className:"flex items-center justify-between",children:[a?t.jsx(B,{}):t.jsx(w,{searchParams:e}),t.jsxs(y,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>s(),children:[t.jsx(v,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]})]})}const l=1,E=r.object({page:r.coerce.number().min(l).optional().default(l).catch(l),name:r.string().optional(),operator:r.enum(["and","or"]).optional()});function K(){const[e]=F(),{page:s,name:a,operator:n}=E.parse({page:e.get("page")||void 0,name:e.get("name")||void 0});return{page:s,name:a,logical_operator:n}}function V(){return{id:"name",header:"Deployment",accessorFn:e=>e.name,cell:({row:e})=>{const s=e.original.name,a=e.original.id;return t.jsxs("div",{className:"group/copybutton flex min-w-[10rem] items-center gap-2",children:[t.jsx(S,{className:"h-5 w-5 shrink-0 fill-primary-400"}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(d,{to:u.projects.deployments.detail.overview(a),className:"grid grid-cols-1 items-center gap-1",children:t.jsx("span",{className:"truncate text-text-md font-semibold text-theme-text-primary",children:s??"Unnamed"})}),t.jsx(p,{copyText:s??""})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(d,{to:u.projects.deployments.detail.overview(a),className:"flex items-center gap-1",children:t.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:D(a)})}),t.jsx(p,{copyText:a})]})]})]})}}}function W(){return{id:"status",header:"Status",accessorFn:e=>e.body?.status,cell:({row:e})=>{const s=e.original.body?.status;return s?t.jsx(R,{size:"sm",status:s}):t.jsx("div",{children:"No status"})}}}function X(){return{id:"pipeline",header:"Pipeline",accessorFn:e=>e.resources?.pipeline?.name,cell:({row:e})=>{const s=e.original.resources?.pipeline;return s?t.jsx(T,{pipelineId:s.id,pipelineName:s.name}):null}}}function Y(){return{id:"snapshot",header:"Snapshot",accessorFn:e=>e.resources?.snapshot?.name,cell:({row:e})=>{const s=e.original.resources?.snapshot,a=s?.name,n=s?.id;return!a||!n?null:t.jsx(N,{size:"sm",snapshotId:n,snapshotName:a})}}}function Z(){return{id:"author",header:"Author",accessorFn:e=>e.resources?.user?.name,cell:({row:e})=>{const s=e.original.resources?.user;return s?t.jsx(b,{username:s.name,isServiceAccount:!!s.body?.is_service_account,avatarUrl:s.body?.avatar_url??void 0}):null}}}function $(){return{id:"created",header:"Created at",accessorFn:e=>({date:e.body?.created}),cell:({getValue:e})=>{const{date:s}=e();return t.jsx(C,{dateString:s})}}}export{H as D,q as P,W as a,Y as b,V as c,Z as d,$ as e,M as f,X as g,K as u};
