import{a as l,b as w}from"./vendor-query-B2UbickB.js";import{c as a,N as e}from"./index-BZu5zewH.js";function f(s){const o=[];switch(s.type.split(".")[0]){case"task":o.push(["tasks"]),o.push(["jobs"]),o.push(["processes"]),s.workflowId&&(o.push(["workflowExecution",s.workflowId]),o.push(["workflowState",s.workflowId]),o.push(["mcpQueryExecution",s.workflowId])),s.originId&&o.push(["processes",s.originId]);break;case"escalation":o.push(["escalations"]),o.push(["escalationStats"]),s.workflowId&&o.push(["workflowExecution",s.workflowId]);break;case"workflow":o.push(["jobs"]),o.push(["tasks"]),o.push(["processes"]),s.workflowId&&(o.push(["workflowExecution",s.workflowId]),o.push(["workflowState",s.workflowId]),o.push(["mcpQueryExecution",s.workflowId]),o.push(["mcpQueryResult",s.workflowId]),o.push(["builderResult",s.workflowId]));break;case"activity":s.workflowId&&o.push(["mcpRunExecution",s.workflowId]),o.push(["mcpRuns"]);break;case"milestone":s.workflowId&&(o.push(["workflowExecution",s.workflowId]),o.push(["mcpQueryExecution",s.workflowId])),o.push(["tasks"]);break;case"knowledge":o.push(["knowledge"]);break;case"file":o.push(["files"]);break;case"agent":o.push(["agents"]);break;default:o.push(["jobs"]),o.push(["tasks"]);break}return o}function r(s=500){const o=w(),t=l.useRef(new Set),c=l.useRef(null);return l.useCallback(n=>{for(const i of n)t.current.add(JSON.stringify(i));c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{for(const i of t.current)o.invalidateQueries({queryKey:JSON.parse(i)});t.current.clear(),c.current=null},s)},[o,s])}function d(){const s=r(300);a(`${e}.task.>`,()=>{s([["jobs"]])}),a(`${e}.workflow.>`,()=>{s([["jobs"]])})}function h(s){const o=r(400);a(`${e}.>`,t=>{var u;if(!s||!(t.workflowId===s||((u=t.workflowId)==null?void 0:u.includes(s))))return;const n=t.type.split(".")[0],i=f(t);n==="escalation"&&i.push(["escalations","by-workflow",s]),o(i)})}function y(s){const o=r(400);a(`${e}.>`,t=>{var u;if(!s||!(t.workflowId===s||((u=t.workflowId)==null?void 0:u.includes(s))))return;const n=t.type.split(".")[0],i=f(t);n==="escalation"&&i.push(["escalations","by-workflow",s]),o(i)})}function E(s){const o=r(400);a(`${e}.>`,t=>{var i;if(!s||!(t.workflowId===s||((i=t.workflowId)==null?void 0:i.includes(s))))return;const n=f(t);n.push(["workflowSets"]),n.push(["yamlWorkflows"]),o(n)})}function b(s){const o=r(300),t=l.useCallback(c=>{s&&(c.originId!==s&&c.workflowId!==s||o([["processes",s]]))},[s,o]);a(`${e}.task.>`,t),a(`${e}.workflow.>`,t),a(`${e}.escalation.>`,t)}function I(){const s=r(300);a(`${e}.escalation.>`,()=>{s([["escalationStats"]])})}function m(){const s=r(300);a(`${e}.escalation.>`,()=>{s([["escalations"]])})}function g(s){const o=r(300);a(`${e}.escalation.>`,t=>{s&&t.escalationId===s&&o([["escalations",s],["escalations"],["escalationStats"]])})}function $(){const s=r(300);a(`${e}.agent.>`,()=>{s([["agents"]])})}function R(){const s=r(300);a(`${e}.task.>`,()=>{s([["processes"]])}),a(`${e}.workflow.>`,()=>{s([["processes"]])})}export{b as a,d as b,y as c,E as d,I as e,m as f,g,h,$ as i,R as u};
//# sourceMappingURL=useEventHooks-CPxcH6zx.js.map
