import{u as S,b as p,c as d,a as m}from"./vendor-query-B2UbickB.js";import{b as u,c as g,N as v}from"./index-BZu5zewH.js";const a=["workflowSets"];function C(t={}){const s=new URLSearchParams;return t.status&&s.set("status",t.status),t.search&&s.set("search",t.search),t.limit&&s.set("limit",String(t.limit)),t.offset!==void 0&&s.set("offset",String(t.offset)),S({queryKey:[...a,t],queryFn:()=>u(`/workflow-sets?${s}`)})}function E(t){return S({queryKey:[...a,t],queryFn:()=>u(`/workflow-sets/${t}`),enabled:!!t})}function K(){const t=p();return d({mutationFn:s=>u("/workflow-sets",{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{t.invalidateQueries({queryKey:a,refetchType:"all"})}})}function N(){const t=p();return d({mutationFn:({id:s,...c})=>u(`/workflow-sets/${s}/add`,{method:"POST",body:JSON.stringify(c)}),onSuccess:()=>{t.invalidateQueries({queryKey:a,refetchType:"all"}),t.invalidateQueries({queryKey:["yamlWorkflows"],refetchType:"all"})}})}function W(t){const[s,c]=m.useState([]),w=m.useCallback(i=>{var f;if(!t||i.workflowId!==t||((f=i.type)==null?void 0:f.split(".")[0])!=="activity")return;const n=i.activityName,e=i.data,l=i.type;c(r=>{const y=r.find(o=>o.activityId===n);return l==="activity.started"?y?r.map(o=>o.activityId===n?{...o,status:"running"}:o):[...r,{activityId:n,title:(e==null?void 0:e.title)||n,toolName:e==null?void 0:e.toolName,toolSource:e==null?void 0:e.toolSource,stepIndex:(e==null?void 0:e.stepIndex)??r.length,totalSteps:(e==null?void 0:e.totalSteps)??0,status:"running"}]:l==="activity.completed"&&y?r.map(o=>o.activityId===n?{...o,status:"completed"}:o):l==="activity.failed"&&y?r.map(o=>o.activityId===n?{...o,status:"failed",error:e==null?void 0:e.error}:o):r})},[t]);g(t?`${v}.activity.>`:"",w);const h=s.length>0&&s.every(i=>i.status==="completed"||i.status==="failed"),k=s.some(i=>i.status==="failed");return{steps:s,isComplete:h,isFailed:k}}export{W as a,E as b,N as c,C as d,K as u};
//# sourceMappingURL=useYamlActivityEvents-DnPywDgy.js.map
