import{a as c,j as s}from"./vendor-query-B2UbickB.js";import{u as h}from"./tasks-BQ1c7trT.js";import{u as w}from"./workflows-CD7-d5w8.js";import{u as k}from"./useEventHooks-CPxcH6zx.js";import{u as y}from"./useFilterParams-x-Dg0Vgz.js";import{D as _}from"./DataTable-D9yuBv0w.js";import{T as p}from"./TimestampCell-DGEGdbOW.js";import{S as b}from"./StickyPagination-BWhFSr2d.js";import{F as j,a as v,b as m}from"./FilterBar-Ck4K4rzu.js";import{P}from"./PageHeader-CR6TpJG_.js";import{L as S}from"./ListToolbar-4lObXT3_.js";import{W as N}from"./WorkflowPill-54px0YiY.js";import{c as T}from"./vendor-react-CXumBFUA.js";import"./index-BZu5zewH.js";import"./vendor-icons-CrrAvF2g.js";import"./EmptyState-BcsfPq9T.js";function C(e,t=300){const[i,o]=c.useState(e);return c.useEffect(()=>{const l=setTimeout(()=>o(e),t);return()=>clearTimeout(l)},[e,t]),i}const $=[{value:"active",label:"Active"},{value:"completed",label:"Completed"},{value:"escalated",label:"Escalated"}],F=[{key:"origin_id",label:"Origin",render:e=>s.jsx("span",{className:"font-mono text-xs",title:e.origin_id,children:e.origin_id.length>40?`${e.origin_id.slice(0,40)}…`:e.origin_id})},{key:"workflow_types",label:"Workflows",render:e=>s.jsx("div",{className:"flex flex-wrap gap-1",children:e.workflow_types.map(t=>s.jsx(N,{type:t},t))})},{key:"task_count",label:"Tasks",render:e=>s.jsx("span",{children:e.task_count}),className:"w-20 text-right"},{key:"completed",label:"Completed",render:e=>e.completed>0?s.jsx("span",{className:"text-status-success",children:e.completed}):s.jsx("span",{className:"text-text-tertiary",children:"0"}),className:"w-24 text-right"},{key:"escalated",label:"Escalated",render:e=>e.escalated>0?s.jsx("span",{className:"text-status-error",children:e.escalated}):s.jsx("span",{className:"text-text-tertiary",children:"0"}),className:"w-24 text-right"},{key:"started_at",label:"Started",render:e=>s.jsx(p,{date:e.started_at}),className:"w-44"},{key:"last_activity",label:"Last Activity",render:e=>s.jsx(p,{date:e.last_activity}),className:"w-44"}];function J(){k();const e=T(),{filters:t,setFilter:i,pagination:o}=y({filters:{workflow_type:"",status:"",search:""}}),l=C(t.search,300),{data:d}=w(),f=[...new Set((d??[]).map(a=>a.workflow_type))].sort(),{data:r,isLoading:u,refetch:g,isFetching:x}=h({workflow_type:t.workflow_type||void 0,status:t.status||void 0,search:l||void 0,limit:o.pageSize,offset:o.offset}),n=(r==null?void 0:r.total)??0;return s.jsxs("div",{children:[s.jsx(P,{title:"All Processes",docsHash:"#docs:dashboard.md:processes-overview"}),s.jsxs(j,{actions:s.jsx(S,{onRefresh:()=>g(),isFetching:x,apiPath:`/tasks/processes?limit=${o.pageSize}&offset=${o.offset}${t.workflow_type?`&workflow_type=${t.workflow_type}`:""}${t.status?`&status=${t.status}`:""}${l?`&search=${l}`:""}`}),children:[s.jsx(v,{label:"Search",value:t.search,onChange:a=>i("search",a),placeholder:"origin, workflow, or trace ID"}),s.jsx(m,{label:"Status",value:t.status,onChange:a=>i("status",a),options:$}),s.jsx(m,{label:"Workflow Type",value:t.workflow_type,onChange:a=>i("workflow_type",a),options:f.map(a=>({value:a,label:a}))})]}),s.jsx(_,{columns:F,data:(r==null?void 0:r.processes)??[],keyFn:a=>a.origin_id,onRowClick:a=>e(`/processes/detail/${encodeURIComponent(a.origin_id)}`),isLoading:u,emptyMessage:"No business processes found"}),s.jsx(b,{page:o.page,totalPages:o.totalPages(n),onPageChange:o.setPage,total:n,pageSize:o.pageSize,onPageSizeChange:o.setPageSize})]})}export{J as ProcessesListPage};
//# sourceMappingURL=ProcessesListPage-CPgiDbdS.js.map
