bunqueue-dashboard 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +11 -8
  2. package/agent/backup/resultValidation.ts +1 -1
  3. package/agent/flow/routes.ts +2 -0
  4. package/agent/flow/service.ts +7 -2
  5. package/agent/managedConnection.ts +35 -0
  6. package/agent/manager/config.ts +1 -1
  7. package/agent/queue/routes.ts +33 -3
  8. package/agent/queue/runtime.ts +51 -5
  9. package/agent/queue/types.ts +16 -1
  10. package/agent/queue/validation.ts +8 -0
  11. package/agent/workflow/runtime.ts +2 -6
  12. package/agent/workflow/runtimeConfig.ts +2 -2
  13. package/agent/workflows.ts +1 -1
  14. package/dist/.vite/manifest.json +130 -127
  15. package/dist/assets/AddJob-FNaPbs_V.js +3 -0
  16. package/dist/assets/{Alerts-CYwfGLSQ.js → Alerts-C961Al5D.js} +1 -1
  17. package/dist/assets/{Benchmark-BINaJvak.js → Benchmark-DQNZV7dM.js} +1 -1
  18. package/dist/assets/BulkAddJobs-IiL1uud0.js +5 -0
  19. package/dist/assets/{CopilotPanel-DjHfX9ta.js → CopilotPanel-Dlm8XwBj.js} +1 -1
  20. package/dist/assets/{Cron-CSoEPVeq.js → Cron-1DZTZWXO.js} +1 -1
  21. package/dist/assets/{CronManager-s4xjNhGD.js → CronManager-B6xLLgI5.js} +1 -1
  22. package/dist/assets/{Database-x6iWCu3-.js → Database-DGM2BIHy.js} +1 -1
  23. package/dist/assets/{Diagnostics-DFshXeHl.js → Diagnostics-_Sh3UyaT.js} +1 -1
  24. package/dist/assets/{Dlq-Cayt1PEN.js → Dlq-mtInIoTh.js} +1 -1
  25. package/dist/assets/{DlqControl-BBQc6uu9.js → DlqControl-Lq9ISb9b.js} +1 -1
  26. package/dist/assets/{DlqPro-BmrnGQ-3.js → DlqPro-0_75vrd1.js} +1 -1
  27. package/dist/assets/Flows-CE7KzaFN.js +2 -0
  28. package/dist/assets/{JobInspector-BMjVR96H.js → JobInspector-DyWZk1eW.js} +2 -2
  29. package/dist/assets/{Jobs-NN0fJ3BQ.js → Jobs-ELSH1Wbd.js} +1 -1
  30. package/dist/assets/JobsPro-BlWwDeFN.js +1 -0
  31. package/dist/assets/{Logs-BGeTppXO.js → Logs-DMukqmHy.js} +1 -1
  32. package/dist/assets/{LogsPro-D7vvgZmb.js → LogsPro-BfYbmZHi.js} +1 -1
  33. package/dist/assets/{McpServer-AsaFGnYZ.js → McpServer-DNrOEp9j.js} +2 -2
  34. package/dist/assets/{Metrics-CvoY4uhX.js → Metrics-Cm5ZvfTo.js} +1 -1
  35. package/dist/assets/{MetricsPro-C01FjqvR.js → MetricsPro-C9g1sp-u.js} +1 -1
  36. package/dist/assets/{Overview-WStfS5ee.js → Overview-CKAA3h9f.js} +1 -1
  37. package/dist/assets/{QueueActions-D51CYOjo.js → QueueActions-BWnmNEqV.js} +1 -1
  38. package/dist/assets/QueueControl-Bvm8GUQa.js +1 -0
  39. package/dist/assets/{QueueDetail-D5TKm4bv.js → QueueDetail-BRDATlp0.js} +1 -1
  40. package/dist/assets/{QueueDetailPro-CFNQcKho.js → QueueDetailPro-Dkz4-1wn.js} +1 -1
  41. package/dist/assets/{Queues-DlznHsfh.js → Queues-BV99vr68.js} +1 -1
  42. package/dist/assets/{QueuesOverview-DGtapyV0.js → QueuesOverview-CT6JBaim.js} +1 -1
  43. package/dist/assets/{S3Backup-CxwbLJGK.js → S3Backup-DNABHR2Q.js} +1 -1
  44. package/dist/assets/{S3BackupPro-8y0J0-3_.js → S3BackupPro-CjR0y18n.js} +3 -3
  45. package/dist/assets/{ServerControl-DpE7t-OF.js → ServerControl-BH6Doax0.js} +1 -1
  46. package/dist/assets/{Settings-Bw5MtDTF.js → Settings-CL7odwoU.js} +1 -1
  47. package/dist/assets/{Usage-DpShi3FE.js → Usage-BWZkz7Se.js} +1 -1
  48. package/dist/assets/{UsagePro-D4cGbozz.js → UsagePro-CoBbI-Cl.js} +1 -1
  49. package/dist/assets/{Webhooks-UYiTg6hn.js → Webhooks-DT2LK17V.js} +1 -1
  50. package/dist/assets/{Workers-D70B_uAI.js → Workers-CBEDvXm_.js} +1 -1
  51. package/dist/assets/{WorkersPro-YycNhm9w.js → WorkersPro-Dk4NfplT.js} +1 -1
  52. package/dist/assets/{Workflows-BxlrgGEB.js → Workflows-DZZA6aGW.js} +1 -1
  53. package/dist/assets/{api-BAGaBh6R.js → api-BgWE-705.js} +1 -1
  54. package/dist/assets/bq-F5BbTG1T.js +1 -0
  55. package/dist/assets/{flowMutationSafety-DSd3JLAV.js → flowMutationSafety-YKTHxqKv.js} +1 -1
  56. package/dist/assets/flowOperationPolicy-B2Etcb3f.js +1 -0
  57. package/dist/assets/{index-ByvrmBif.js → index-BFW2_47n.js} +3 -3
  58. package/dist/assets/{index-CxhXRVH_.css → index-C9yGKhQ8.css} +1 -1
  59. package/dist/assets/{install-C5y2ohOo.js → install-oydLpc1T.js} +2 -2
  60. package/dist/assets/responses-BkR2JTH9.js +1 -0
  61. package/dist/assets/{upstreamPaths-B_cyinGI.js → upstreamPaths-DQeKSxGc.js} +1 -1
  62. package/dist/assets/{useThroughputSeries-Cagm3qzB.js → useThroughputSeries-DgO8uicf.js} +1 -1
  63. package/dist/index.html +5 -5
  64. package/package.json +11 -5
  65. package/scripts/embedded.gen.ts +164 -164
  66. package/shared/flowOperationPolicy.ts +66 -0
  67. package/dist/assets/AddJob-CFnESFEU.js +0 -3
  68. package/dist/assets/BulkAddJobs-vyGFvlO3.js +0 -5
  69. package/dist/assets/Flows-CcNdf_jS.js +0 -2
  70. package/dist/assets/JobsPro-D_l1c80Q.js +0 -1
  71. package/dist/assets/QueueControl-Ce-O1L4p.js +0 -1
  72. package/dist/assets/bq-Qh0VFLKV.js +0 -1
  73. package/dist/assets/jobActions-LQD4KfCc.js +0 -1
  74. package/dist/assets/responses-DiIfPXXq.js +0 -1
@@ -1 +1 @@
1
- import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,l as i,t as a}from"./react-vendor-CvwrP0tU.js";import{a as o}from"./connectionStore-BJLihGaC.js";import{t as s}from"./upstreamPaths-B_cyinGI.js";import{s as c,t as l}from"./bq-Qh0VFLKV.js";import{t as u}from"./toastStore-IZn6OPLZ.js";import{n as d}from"./usePolledData-0CVelkl2.js";import{t as f}from"./Card-CWxrC8OY.js";import{i as p,n as m,r as h,t as g}from"./feedback-QDN1AsYt.js";import{t as _}from"./StatusBadge-BoOVTnKu.js";import{t as v}from"./PageHeader-CvIyaFOO.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as w}from"./useControlActionGuard-B-bzKZKI.js";var T={"/workflows":{id:`overview`,label:`Overview`,description:`The complete durable command center for Bunqueue Workflow Engine.`,kind:`active`,state:``},"/workflows/executions":{id:`executions`,label:`Executions`,description:`Inspect every active execution, step record, decision, and nested run.`,kind:`active`,state:``},"/workflows/waiting":{id:`waiting`,label:`Waiting & Signals`,description:`Focus on parked executions and their durable signal payloads.`,kind:`active`,state:`waiting`,lockKind:!0,lockState:!0},"/workflows/compensation":{id:`compensation`,label:`Compensation`,description:`See running, completed, skipped, failed, and parked saga compensation outcomes.`,kind:`active`,state:`compensation`,lockKind:!0,lockState:!0},"/workflows/archive":{id:`archive`,label:`Archive`,description:`Audit terminal executions retained by Workflow Engine archival.`,kind:`archive`,state:``,lockKind:!0}};function ee(e){return T[e]??T[`/workflows`]}function te(e,t){return e?.source===`link`||e&&t.some(t=>t.id===e.id)?e:t[0]?{id:t[0].id,source:`page`}:null}var E=e(r(),1),ne=[`waiting`,`failed`,`compensation-stuck`];async function re(e,t){let[n,r]=await Promise.all([e.stats(),e.list(t)]);return{stats:n,page:r}}async function ie(e,t){let[n,...r]=await Promise.all([e.stats(),...ne.map(n=>e.list({kind:`active`,state:n,limit:t,offset:0}))]),i=r.flatMap(e=>e.executions).sort(ae).slice(0,t);return{stats:n,page:{ok:r.every(e=>e.ok),available:r.every(e=>e.available),executions:i,total:r.reduce((e,t)=>e+t.total,0),limit:t,offset:0}}}function ae(e,t){return t.createdAt-e.createdAt||t.id.localeCompare(e.id)}var D=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function O(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:ce(e.get(`workflow`)),a=ue(e.get(`state`),t),o=t.id===`overview`?0:le(e.get(`offset`)),c=e.get(`execution`),l=c&&s(c,`Workflow execution id`)===null?c:null,u=e.get(`tab`),d=t.id===`overview`||t.id===`executions`;return{kind:r,workflowName:i,state:a,offset:o,executionId:l,tab:l&&d&&D.has(u)?u:`summary`}}function k(e,t){let n=new URLSearchParams;return e.id===`executions`&&t.kind===`archive`&&n.set(`kind`,`archive`),e.id!==`overview`&&t.workflowName&&n.set(`workflow`,t.workflowName),j(e)&&t.state&&n.set(`state`,t.state),e.id!==`overview`&&t.offset>0&&n.set(`offset`,String(t.offset)),t.executionId&&n.set(`execution`,t.executionId),t.executionId&&t.tab!==`summary`&&(e.id===`overview`||e.id===`executions`)&&n.set(`tab`,t.tab),n}function A(e,t,n){return k(t,{...O(e,t),...n})}function se(e){return D.has(e)}function ce(e){return e&&e.length<=256?e:``}function le(e){if(!e||!/^(0|[1-9]\d*)$/.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t<=1e6?Math.floor(t/25)*25:0}function ue(e,t){return j(t)?e?t.id===`archive`?e===`completed`||e===`failed`?e:``:oe.has(e)?e:``:``:t.state}function j(e){return e.id===`executions`||e.id===`archive`}var de=e=>`${e}?target=${encodeURIComponent(o())}`,M=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});async function N(e,t){return(await c(de(e),t)).result}var P={status:()=>N(`/workflows/runtime`),reload:()=>N(`/workflows/runtime/reload`,M()),start:async(e,t)=>(await N(`/workflows/start`,M({workflowName:e,input:t}))).run,signal:async(e,t,n)=>{await N(`/workflows/${encodeURIComponent(e)}/signal`,M({event:t,payload:n}))},recover:async()=>(await N(`/workflows/recover`,M())).recovered,resumeCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/resume-compensation`,M())},abandonCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/abandon-compensation`,M())},archive:async(e,t)=>(await N(`/workflows/archive`,M({maxAgeMs:e,states:t}))).affected,cleanup:async(e,t)=>(await N(`/workflows/cleanup`,M({maxAgeMs:e,states:t}))).affected},fe={stats:()=>l.workflows.stats(),list:e=>l.workflows.list(e),get:(e,t)=>l.workflows.get(e,t)};function pe(e){let[t,r]=n(),i=t.toString(),a=(0,E.useMemo)(()=>O(new URLSearchParams(i),e),[i,e]),o=(0,E.useMemo)(()=>k(e,a).toString(),[e,a]),s=(0,E.useRef)(null);(0,E.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,E.useCallback)((t,n=!1)=>{r(n=>A(n,e,t),{replace:n})},[e,r]),l=(0,E.useCallback)((e,t=!1)=>{s.current=e,c({executionId:e?.id??null,tab:`summary`},t)},[c]),u=a.executionId?{id:a.executionId,source:s.current?.id===a.executionId?s.current.source:`link`}:null;return{...a,selected:u,update:c,select:l}}function F(e){let t=S(),n=`workflow-command:${e.operationGroup}`,r=w(n),i=(0,E.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),a=(0,E.useRef)(e);a.current=e;let o=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useRef)(i),l=(0,E.useRef)(0);if(!Object.is(c.current,i)){let e=c.current.connectionEpoch!==t;c.current=i,l.current+=1,e&&(o.current=null)}let[u,d]=(0,E.useState)(()=>I(i,t));(0,E.useEffect)(()=>(s.current=!0,()=>{s.current=!1,l.current+=1,o.current=null}),[]);let f=(e,t)=>s.current&&e===l.current&&t===C(),p=async(e,c)=>{if(o.current||t!==C())return;let u=r.begin(n);if(!u)return;let p=Symbol(`workflow-command`);o.current=p;let m=l.current,h=t,{onApplied:g,onSucceeded:_}=a.current;try{d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:null});let n=await c();if(!f(m,h))return;d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:{label:e,value:n}});try{_?.(e,n)}catch{}try{await g?.()}catch(e){f(m,h)&&d(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(n){f(m,h)&&d({connectionEpoch:t,scope:i,busy:e,error:L(n),receipt:null})}finally{u.finish(),o.current===p&&(o.current=null,s.current&&h===C()&&d(e=>({...e,busy:``})))}},m=Object.is(u.scope,i)?u:I(i,t);return{busy:u.connectionEpoch===t?u.busy:``,error:m.error,result:m.receipt?.value,succeeded:m.receipt?.label??``,run:p,clearResult:()=>d(e=>({...e,receipt:null}))}}function I(e,t){return{connectionEpoch:t,scope:e,busy:``,error:``,receipt:null}}function L(e){return e instanceof Error?e.message:String(e)}var R=a(),z=e=>JSON.stringify(e,null,2)??`null`;function B({value:e,empty:t=`None`}){return e==null||typeof e==`object`&&Object.keys(e).length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:t}):(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs leading-5 text-muted`,children:z(e)})}function V({label:e,value:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-0.5 break-words text-muted`,children:t})]})}var me=3600*1e3;function he({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(`720`),[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)(!0),c=F({operationGroup:`maintenance`,scopeKey:(0,E.useMemo)(()=>Symbol(`workflow-maintenance:${n.length}:${i}:${o}`),[i,o,n]),onApplied:t}),l=[...i?[`completed`]:[],...o?[`failed`]:[]],u=Number(n),d=Number.isFinite(u)&&u>=0&&l.length>0,f=t=>{if(!d)return;let n=t===`archive`?`Archive ${l.join(` and `)} workflows at least ${u} hours old?`:`Permanently delete ${l.join(` and `)} workflows at least ${u} hours old from the active execution store? Archive records are not deleted.`;if(!window.confirm(n))return;let r=Math.round(u*me);c.run(t,async()=>({operation:t,affected:t===`archive`?await e.archive(r,l):await e.cleanup(r,l)}))};return(0,R.jsxs)(`section`,{className:`mb-5 rounded-lg border border-line bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Retention operations`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Archive moves terminal runs into retention. Cleanup permanently deletes eligible terminal runs from the active store only; archive records remain intact.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Minimum age (hours)`,(0,R.jsx)(`input`,{"aria-label":`Workflow retention age hours`,type:`number`,min:`0`,step:`1`,value:n,onChange:e=>r(e.target.value),className:`mt-1 block h-9 w-32 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`Completed`]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failed`]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`archive`),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Archive eligible`}),(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`cleanup`),className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Delete eligible`})]}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:c.result})})]})}var ge=[[`Active`,`activeTotal`,`text-fg`],[`Running`,`running`,`text-blue-400`],[`Waiting`,`waiting`,`text-warning`],[`Completed`,`completed`,`text-success`],[`Failed`,`failed`,`text-danger`],[`Compensating`,`compensating`,`text-violet-400`],[`Stuck`,`compensation-stuck`,`text-danger`]];function _e({stats:e}){return(0,R.jsx)(`dl`,{className:`mb-4 grid grid-cols-2 divide-x divide-y divide-line overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-4 xl:grid-cols-7 xl:divide-y-0`,children:ge.map(([n,r,i])=>(0,R.jsxs)(`div`,{className:`px-3 py-2.5 first:border-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wider text-faint`,children:n}),(0,R.jsx)(`dd`,{className:t(`mt-1 tnum font-mono text-lg font-semibold`,i),children:r===`activeTotal`?e.activeTotal:e.states[r]})]},r))})}function ve({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(`{}`),o=(0,E.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=d(()=>e.status(),[e],{intervalMs:5e3}),c=F({operationGroup:`runtime`,scopeKey:o,onApplied:async()=>{await s.refetch(),await t?.()}}),l=s.data?.ready===!0;return(0,R.jsxs)(`section`,{className:`mb-5 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workflow runtime`}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-faint`,children:`Registered application handlers stay in the agent-side runtime; commands never edit SQLite directly.`})]}),(0,R.jsx)(ye,{ready:l,configured:s.data?.configured===!0,unavailable:!!(s.error&&!s.data)})]}),s.data?.configured&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-line px-4 py-2 text-[11px] text-faint`,children:[(0,R.jsxs)(`span`,{children:[`Module`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.moduleName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Queue`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.queueName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Concurrency`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.concurrency??`—`})]})]}),s.error&&s.data&&(0,R.jsx)(p,{message:`Runtime status refresh failed; showing the last snapshot.`,onRetry:s.refetch}),s.error&&!s.data&&(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(m,{error:s.error,onRetry:s.refetch})}),(0,R.jsxs)(`div`,{className:`grid gap-5 p-4 lg:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Registered workflow`,(0,R.jsx)(`input`,{"aria-label":`Registered workflow`,list:`workflow-runtime-names`,value:n,onChange:e=>r(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`}),(0,R.jsx)(`datalist`,{id:`workflow-runtime-names`,children:s.data?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e},e))})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Input JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow input JSON`,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap content-start gap-2 lg:w-48 lg:flex-col`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!l||!n.trim()||!!c.busy,onClick:()=>{let t;try{t=JSON.parse(i)}catch{c.run(`start`,async()=>{throw Error(`Workflow input must be valid JSON.`)});return}c.run(`start`,()=>e.start(n.trim(),t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c.busy===`start`?`Starting…`:`Start execution`}),(0,R.jsx)(`button`,{type:`button`,disabled:!l||!!c.busy,onClick:()=>{window.confirm(`Recover every orphaned workflow using the registered idempotent handlers?`)&&c.run(`recover`,()=>e.recover())},className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Recover orphaned`}),(0,R.jsx)(`button`,{type:`button`,disabled:!s.data?.configured||!!c.busy,onClick:()=>void c.run(`reload`,()=>e.reload()),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Reload definitions`})]})]}),!s.loading&&!s.error&&!s.data?.configured&&(0,R.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-xs text-warning`,children:[`Set `,(0,R.jsx)(`code`,{children:`BUNQUEUE_WORKFLOW_MODULE`}),` to an absolute module path in Server → Extra environment, then start the managed server.`]}),s.data?.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:s.data.error}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-line p-4`,children:(0,R.jsx)(B,{value:c.result})})]})}function ye({ready:e,configured:t,unavailable:n}){return(0,R.jsx)(`span`,{className:e?`rounded-full bg-success/10 px-2 py-1 text-[11px] text-success`:`rounded-full bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:e?`Handlers loaded`:n?`Status unavailable`:t?`Unavailable`:`Not configured`})}var be=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function xe({section:e,kind:t,workflowName:n,state:r,stats:i,total:a,onKind:o,onWorkflowName:s,onState:c}){return(0,R.jsx)(f,{className:`mb-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[e.lockKind?(0,R.jsx)(H,{label:`Store`,value:`${e.kind}${e.kind===`archive`&&i?` · ${i.archiveTotal}`:``}`,capitalize:!0}):(0,R.jsx)(Se,{kind:t,archiveTotal:i?.archiveTotal,onChange:o}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Workflow`,(0,R.jsxs)(`select`,{value:n,onChange:e=>s(e.target.value),className:`mt-1 block h-9 min-w-48 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),i?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),e.lockState?(0,R.jsx)(H,{label:`State scope`,value:e.state===`compensation`?`Compensating + stuck`:e.state}):(0,R.jsx)(Ce,{state:r,onChange:c}),a!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-faint`,children:[a,` execution`,a===1?``:`s`]})]})})}function Se({kind:e,archiveTotal:n,onChange:r}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:`Store`}),(0,R.jsx)(`div`,{className:`flex rounded-lg border border-line p-0.5`,children:[`active`,`archive`].map(i=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e===i,onClick:()=>r(i),className:t(`rounded-md px-3 py-1.5 text-xs capitalize`,e===i?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:[i,i===`archive`&&n!==void 0?` (${n})`:``]},i))})]})}function Ce({state:e,onChange:t}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`State`,(0,R.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`mt-1 block h-9 min-w-44 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:be.map(e=>(0,R.jsx)(`option`,{value:e,children:e===`compensation`?`All compensation`:e||`All states`},e||`all`))})]})}function H({label:e,value:n,capitalize:r=!1}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:e}),(0,R.jsx)(`span`,{className:t(`inline-flex h-9 items-center rounded-lg border border-line bg-surface-2 px-3 text-xs text-fg`,r&&`capitalize`),children:n})]})}function we({label:e=`Workflow`,value:t,stats:n,onChange:r}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,R.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-1 block h-9 min-w-52 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),n?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})}function Te(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(xe,{...e}):(0,R.jsxs)(`div`,{className:`mb-5 flex items-end gap-4 rounded-lg border border-line bg-surface px-4 py-3`,children:[(0,R.jsx)(we,{value:e.workflowName,stats:e.stats,onChange:e.onWorkflowName}),e.section.id===`archive`&&(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Outcome`,(0,R.jsxs)(`select`,{value:e.state,onChange:t=>e.onState(t.target.value),className:`mt-1 block h-9 min-w-36 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All outcomes`}),(0,R.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed`})]})]}),(0,R.jsxs)(`span`,{className:`ml-auto pb-2 text-xs text-faint`,children:[e.total??0,` `,e.section.id===`archive`?`records`:`executions`]})]})}function Ee(e){let t=[{id:`execution-started`,at:e.createdAt,title:`Execution started`,detail:e.workflowName,status:`running`,category:`execution`}];for(let[n,r]of Object.entries(e.steps))t.push(...De(n,r));for(let n of Object.keys(e.signals))t.push({id:`signal:${n}`,title:`Signal persisted: ${n}`,detail:`The store does not expose an exact signal timestamp.`,category:`signal`});return e.state!==`running`&&e.state!==`waiting`&&t.push({id:`execution-settled`,at:e.updatedAt,title:`Execution ${e.state}`,detail:e.failureReason,status:e.state,category:`execution`}),t.sort(Oe)}function De(e,t){let n=[];return t.startedAt!==void 0&&n.push({id:`step:${e}:started`,at:t.startedAt,title:`Step started: ${e}`,detail:t.attempts?`Attempt ${t.attempts}`:void 0,status:`running`,category:`step`}),(t.completedAt!==void 0||t.status===`failed`)&&n.push({id:`step:${e}:settled`,at:t.completedAt,title:`Step ${t.status}: ${e}`,detail:t.error,status:t.status,category:`step`}),t.compensation&&n.push({id:`step:${e}:compensation`,at:t.compensation.at,title:`Compensation ${t.compensation.status}: ${e}`,detail:t.compensation.error,status:t.compensation.status,category:`compensation`}),n}function Oe(e,t){return e.at===void 0&&t.at===void 0?e.id.localeCompare(t.id):e.at===void 0?1:t.at===void 0?-1:e.at-t.at||e.id.localeCompare(t.id)}function U({execution:e}){let t=Ee(e);return(0,R.jsx)(`ol`,{className:`divide-y divide-line/70 border-y border-line/70`,children:t.map((e,n)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`relative flex justify-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1.5 size-2 rounded-full border-2 border-surface bg-accent ring-1 ring-line`}),n<t.length-1&&(0,R.jsx)(`span`,{className:`absolute top-5 bottom-[-13px] w-px bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),e.status&&(0,R.jsx)(_,{status:e.status})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 text-xs text-faint`,children:[(0,R.jsx)(`span`,{className:`capitalize`,children:e.category}),(0,R.jsx)(`span`,{children:e.at===void 0?`Timestamp unavailable`:b(e.at)})]}),e.detail&&(0,R.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-muted`,children:e.detail})]})]},e.id))})}var W={now:Date.now,subscribe:e=>{let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)}};function ke({since:e,clock:t=W}){let n=G(t);return(0,R.jsx)(R.Fragment,{children:y(Math.max(0,n-e))})}function G(e=W,t=!0){let[n,r]=(0,E.useState)(()=>e.now());return(0,E.useEffect)(()=>{if(r(e.now()),t)return e.subscribe(()=>r(e.now()))},[e,t]),n}function K({error:e,onRetry:t}){return e?(0,R.jsx)(p,{message:`Execution refresh failed; showing the last persisted snapshot.`,onRetry:t}):null}async function q(e,t){await Promise.all([e(),t?.()])}function Ae({repository:e,id:t,pollIntervalMs:n=1e4}){let{data:r,error:i,loading:a,refetch:o}=d(()=>e.get(t,`archive`),[e,t],{intervalMs:n});if(a&&!r)return(0,R.jsx)(h,{label:`Loading audit record…`});if(i&&!r)return(0,R.jsx)(m,{error:i,onRetry:o});let s=r?.execution;return s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:i,onRetry:o}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Immutable audit record`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:s.id})]}),(0,R.jsx)(_,{status:s.state})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Workflow`,value:s.workflowName}),(0,R.jsx)(V,{label:`Runtime`,value:y(s.updatedAt-s.createdAt)}),(0,R.jsx)(V,{label:`Archived`,value:s.archivedAt?b(s.archivedAt):`Unavailable`}),(0,R.jsx)(V,{label:`Definition hash`,value:s.definitionHash??`Unavailable`}),(0,R.jsx)(V,{label:`Final node`,value:String(s.currentNodeIndex)}),(0,R.jsx)(V,{label:`Final transition`,value:b(s.updatedAt)})]}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(U,{execution:s})})]})]}):null}function je({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({operationGroup:`compensation`,scopeKey:`${t}:${n}`,onApplied:r,onSucceeded:e=>u.success(e===`resume`?`Compensation resumed`:`Compensation abandoned`,t)});return n?(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Operator decision`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Retry after fixing the reversal, or explicitly abandon the remaining compensation steps.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Retry the stuck compensation for ${t}? Handlers must be idempotent.`)&&i.run(`resume`,()=>e.resumeCompensation(t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Resume compensation`}),(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Abandon remaining compensation for ${t}? This is irreversible.`)&&i.run(`abandon`,()=>e.abandonCompensation(t))},className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Abandon remainder`})]}),i.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:i.error}),i.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:i.succeeded===`resume`?`Resume command accepted; recovery state refreshed.`:`Abandon command accepted; recovery state refreshed.`}),i.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:i.result})})]}):null}function Me({repository:e,controlRepository:t,id:n,onApplied:r,pollIntervalMs:i=5e3}){let{data:a,error:o,loading:s,refetch:c}=d(()=>e.get(n,`active`),[e,n],{intervalMs:i});if(s&&!a)return(0,R.jsx)(h,{label:`Loading recovery plan…`});if(o&&!a)return(0,R.jsx)(m,{error:o,onRetry:c});let l=a?.execution;if(!l)return null;let u=Object.entries(l.steps).filter(([,e])=>e.compensatable||e.compensation);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:o,onRetry:c}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-violet-400`,children:`Recovery plan`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:l.id})]}),(0,R.jsx)(_,{status:l.state})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Compensation pivot`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.committedAt===void 0?`Not committed`:`Node ${l.committedAt}`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Rollback state`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.rollbackStatus??l.state})]})]}),l.failureReason&&(0,R.jsx)(`div`,{role:`alert`,className:`border-b border-danger/30 bg-danger/[0.06] px-4 py-3 text-xs text-danger`,children:l.failureReason}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Compensation ledger`}),u.length?(0,R.jsx)(`ol`,{className:`space-y-2`,children:u.reverse().map(([e,t])=>(0,R.jsxs)(`li`,{className:`grid gap-2 rounded-md border border-line px-3 py-2 text-xs sm:grid-cols-[1fr_auto]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-mono text-fg`,children:e}),(0,R.jsx)(`div`,{className:`mt-1 text-faint`,children:t.compensation?.error??`Compensation handler registered`})]}),(0,R.jsxs)(`div`,{className:`text-right text-muted`,children:[t.compensation?t.compensation.status:`pending`,t.compensation?.at?(0,R.jsx)(`div`,{className:`mt-1 text-[10px] text-faint`,children:b(t.compensation.at)}):null]})]},e))}):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No compensatable step was persisted.`})]}),(0,R.jsx)(je,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Ne({execution:e}){return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(J,{title:`Input`,value:e.input}),(0,R.jsx)(J,{title:`Signals`,value:e.signals}),(0,R.jsx)(J,{title:`Resolved steps`,value:e.resolvedSteps}),(0,R.jsx)(J,{title:`Decisions`,value:e.decisions})]})}function J({title:e,value:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(B,{value:t})]})}function Pe({steps:e,onSelect:t}){let n=Object.entries(e);return n.length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:`No persisted step records.`}):(0,R.jsx)(`ol`,{className:`space-y-3`,children:n.map(([e,r],i)=>(0,R.jsx)(Fe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Fe({name:e,step:t,last:n,onSelect:r}){let i=t.startedAt!==void 0&&t.completedAt!==void 0?t.completedAt-t.startedAt:void 0;return(0,R.jsxs)(`li`,{className:`relative grid grid-cols-[18px_1fr] gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col items-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full bg-current text-accent`}),!n&&(0,R.jsx)(`span`,{className:`mt-1 w-px flex-1 bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-line bg-surface-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{translate:`no`,className:`break-all font-mono text-sm font-medium text-fg`,children:e}),(0,R.jsx)(_,{status:t.status})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-faint`,children:[t.attempts!==void 0&&(0,R.jsxs)(`span`,{children:[t.attempts,` attempt`,t.attempts===1?``:`s`]}),i!==void 0&&(0,R.jsx)(`span`,{children:y(i)}),t.occurrence!==void 0&&(0,R.jsxs)(`span`,{children:[`Occurrence `,t.occurrence]}),t.loopIndex!==void 0&&(0,R.jsxs)(`span`,{children:[`Loop index `,t.loopIndex]}),t.compensatable&&(0,R.jsx)(`span`,{children:`Compensatable`})]}),t.idempotencyKey&&(0,R.jsxs)(`div`,{className:`mt-2 break-all font-mono text-[11px] text-faint`,children:[`Idempotency: `,t.idempotencyKey]}),t.childExecutionId&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.childExecutionId),className:`mt-2 break-all font-mono text-xs text-accent hover:underline`,children:[`Child execution: `,t.childExecutionId]}),t.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 whitespace-pre-wrap text-xs text-danger`,children:t.error}),t.compensation&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-md border border-line px-3 py-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-faint`,children:`Compensation`}),(0,R.jsx)(_,{status:t.compensation.status}),(0,R.jsx)(`span`,{className:`text-faint`,children:b(t.compensation.at)})]}),t.compensation.error&&(0,R.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-danger`,children:t.compensation.error})]}),(0,R.jsx)(Ie,{step:t})]})]})}function Ie({step:e}){return(0,R.jsxs)(R.Fragment,{children:[Object.hasOwn(e,`result`)&&(0,R.jsx)(Y,{label:`Result`,value:e.result}),Object.hasOwn(e,`loopItem`)&&(0,R.jsx)(Y,{label:`Loop item`,value:e.loopItem})]})}function Y({label:e,value:t}){return(0,R.jsxs)(`details`,{className:`mt-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted`,children:e}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(B,{value:t})})]})}function Le({execution:e,onSelect:t}){let n=Object.values(e.steps),r=n.filter(e=>e.status===`completed`).length;return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 border-b border-line pb-5 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Current node`,value:String(e.currentNodeIndex)}),(0,R.jsx)(V,{label:`Step progress`,value:`${r}/${n.length} completed`}),(0,R.jsx)(V,{label:`Duration`,value:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(V,{label:`Started`,value:b(e.createdAt)}),(0,R.jsx)(V,{label:`Last transition`,value:b(e.updatedAt)}),(0,R.jsx)(V,{label:`Rollback`,value:e.rollbackStatus??`Not started`})]}),e.failureReason&&(0,R.jsxs)(`div`,{role:`alert`,className:`border-l-2 border-danger bg-danger/[0.06] px-3 py-2 text-xs text-danger`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-medium`,children:`Failure`}),(0,R.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.failureReason})]}),(0,R.jsx)(Re,{execution:e,onSelect:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Step state`}),(0,R.jsx)(Pe,{steps:e.steps,onSelect:t})]})]})}function Re({execution:e,onSelect:t}){return!e.parentExecutionId&&!e.definitionHash&&e.committedAt===void 0?null:(0,R.jsxs)(`div`,{className:`grid gap-3 border-b border-line pb-5 text-xs sm:grid-cols-2`,children:[e.parentExecutionId&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Parent execution`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.parentExecutionId),className:`mt-1 break-all font-mono text-accent hover:underline`,children:e.parentExecutionId})]}),e.definitionHash&&(0,R.jsx)(V,{label:`Definition hash`,value:e.definitionHash}),e.committedAt!==void 0&&(0,R.jsx)(V,{label:`Compensation pivot`,value:`Node ${e.committedAt}`}),(0,R.jsx)(`div`,{className:`flex items-end`,children:(0,R.jsx)(_,{status:e.state})})]})}var ze=[{id:`summary`,label:`Summary`},{id:`history`,label:`History`},{id:`payloads`,label:`Payloads`}];function X({repository:e,id:t,kind:n,onSelect:r}){return(0,R.jsx)(Be,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function Be({repository:e,id:r,kind:i,onSelect:a}){let[o,s]=n(),c=o.get(`tab`),l=se(c)?c:`summary`,{data:u,error:f,loading:g,refetch:v}=d(()=>e.get(r,i),[e,r,i],{intervalMs:5e3});if(g&&!u)return(0,R.jsx)(Z,{children:(0,R.jsx)(h,{label:`Loading execution…`})});if(f&&!u)return(0,R.jsx)(Z,{children:(0,R.jsx)(m,{error:f,onRetry:v})});let y=u?.execution;return y?(0,R.jsxs)(Z,{children:[f&&(0,R.jsx)(p,{message:`Execution refresh failed. Showing the last snapshot.`,onRetry:v}),(0,R.jsx)(`header`,{className:`border-b border-line px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Execution`}),(0,R.jsx)(`h2`,{translate:`no`,className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:y.id}),(0,R.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:y.workflowName})]}),(0,R.jsx)(_,{status:y.state})]})}),(0,R.jsx)(`nav`,{"aria-label":`Execution detail`,className:`flex border-b border-line px-2`,children:ze.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>{s(t=>{let n=new URLSearchParams(t);return e.id===`summary`?n.delete(`tab`):n.set(`tab`,e.id),n})},className:t(`border-b-2 px-3 py-2 text-xs font-medium`,l===e.id?`border-accent text-fg`:`border-transparent text-faint hover:text-muted`),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`p-4`,"aria-live":`polite`,children:[l===`summary`&&(0,R.jsx)(Le,{execution:y,onSelect:a}),l===`history`&&(0,R.jsx)(U,{execution:y}),l===`payloads`&&(0,R.jsx)(Ne,{execution:y})]})]}):null}function Z({children:e}){return(0,R.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-lg border border-line bg-surface`,children:e})}function Q({total:e,offset:t,pageSize:n,count:r,onPage:i}){let a=r===0?0:t+1,o=Math.min(t+r,e);return(0,R.jsxs)(`nav`,{"aria-label":`Workflow execution pages`,className:`mt-3 flex items-center justify-between`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>i(Math.max(0,t-n)),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Previous`}),(0,R.jsxs)(`span`,{className:`text-xs text-faint`,children:[a,`–`,o,` of `,e]}),(0,R.jsx)(`button`,{type:`button`,disabled:t+n>=e,onClick:()=>i(t+n),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Next`})]})}var Ve=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function He({executions:e,total:t,offset:n,pageSize:r,selected:i,onSelect:a,onPage:o}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,R.jsx)(`thead`,{className:`bg-surface-2/80`,children:(0,R.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow / execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium md:table-cell`,children:`Node`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium lg:table-cell`,children:`Elapsed`}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Updated`})]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(Ue,{execution:e,selected:i?.id===e.id,onSelect:a},e.id))})]})}),(0,R.jsx)(Q,{total:t,offset:n,pageSize:r,count:e.length,onPage:o})]})}function Ue({execution:e,selected:n,onSelect:r}){return(0,R.jsxs)(`tr`,{className:t(`border-b border-line/70 last:border-0`,n&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,source:`page`}),className:`block w-full px-3 py-2.5 text-left focus-visible:outline-2 focus-visible:outline-inset focus-visible:outline-accent`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{translate:`no`,title:e.id,className:`mt-0.5 block font-mono text-[11px] text-faint`,children:Ve(e.id)})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,R.jsx)(_,{status:e.state})}),(0,R.jsx)(`td`,{className:`hidden px-3 py-2.5 font-mono text-xs text-muted md:table-cell`,children:e.currentNodeIndex}),(0,R.jsx)(`td`,{className:`hidden whitespace-nowrap px-3 py-2.5 font-mono text-xs text-muted lg:table-cell`,children:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(`td`,{title:b(e.updatedAt),className:`whitespace-nowrap px-3 py-2.5 text-right text-xs text-muted`,children:x(e.updatedAt)})]})}function We({mode:e,rows:n,selected:r,onSelect:i,total:a,offset:o,pageSize:s,onPage:c,clock:l=W}){let u=G(l,e===`waiting`);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`section`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[560px] text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b border-line bg-surface-2/80 text-left text-[10px] uppercase tracking-wider text-faint`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e===`archive`?`Execution record`:`Execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:Ge(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ke(e)})]})}),(0,R.jsx)(`tbody`,{children:n.map(n=>(0,R.jsxs)(`tr`,{className:t(`border-b border-line last:border-0`,r?.id===n.id&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-3 text-left font-mono text-xs text-fg`,onClick:()=>i({id:n.id,source:`page`}),children:n.id})}),(0,R.jsx)(`td`,{className:`px-3 py-3 text-muted`,children:n.workflowName}),(0,R.jsx)(`td`,{className:`px-3 py-3`,children:(0,R.jsx)(qe,{mode:e,row:n})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:Je(e,n,u)})]},n.id))})]})}),(0,R.jsx)(Q,{total:a,offset:o,pageSize:s,count:n.length,onPage:c})]})}var Ge=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ke=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function qe({mode:e,row:t}){return e===`waiting`?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-warning`,children:[`Node `,t.currentNodeIndex]}):(0,R.jsx)(_,{status:t.state})}function Je(e,t,n){return e===`archive`?t.archivedAt?b(t.archivedAt):`Unavailable`:e===`waiting`?y(Math.max(0,n-t.updatedAt)):x(t.updatedAt)}function $({stats:e,page:t,repository:n,kind:r,selected:i,onSelect:a}){let o=t.executions.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state));return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(Ye,{stats:e}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(320px,0.7fr)_minmax(0,1.3fr)]`,children:[(0,R.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Needs attention`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs text-faint`,children:[`Waiting, failed, and stuck executions · showing `,o.length,` of `,t.total,`.`]})]}),(0,R.jsx)(Xe,{rows:o,selected:i,onSelect:a})]}),i&&(0,R.jsx)(X,{repository:n,id:i.id,kind:r,onSelect:e=>a({id:e,source:`link`})})]})]})}function Ye({stats:e}){return(0,R.jsx)(`dl`,{className:`grid overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-2 xl:grid-cols-4`,children:[[`Open executions`,e.activeTotal],[`Waiting for signal`,e.states.waiting],[`Recovery required`,e.states[`compensation-stuck`]+e.states.failed],[`Retained in archive`,e.archiveTotal]].map(([e,t])=>(0,R.jsxs)(`div`,{className:`border-b border-line px-4 py-3 sm:border-r xl:border-b-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-1 font-mono text-xl font-semibold text-fg`,children:t})]},e))})}function Xe({rows:e,selected:t,onSelect:n}){return e.length?(0,R.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,R.jsx)(`li`,{className:t?.id===e.id?`bg-surface-2`:void 0,children:(0,R.jsxs)(`button`,{type:`button`,className:`w-full px-4 py-3 text-left`,onClick:()=>n({id:e.id,source:`page`}),children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{className:`text-xs text-faint`,children:x(e.updatedAt)})]}),(0,R.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-3 font-mono text-[11px] text-faint`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.id}),(0,R.jsx)(`span`,{children:e.state})]})]})},e.id))}):(0,R.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No intervention required.`})}function Ze({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(`{}`),s=F({operationGroup:`signal`,scopeKey:t,onApplied:n,onSucceeded:()=>u.success(`Workflow signal accepted`,`${r.trim()} · ${t}`)});return(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Send signal`}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Event name`,(0,R.jsx)(`input`,{"aria-label":`Workflow signal event`,value:r,onChange:e=>i(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow signal payload`,value:a,onChange:e=>o(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||!!s.busy,onClick:()=>{let n;try{n=JSON.parse(a)}catch{s.run(`signal`,async()=>{throw Error(`Signal payload must be valid JSON.`)});return}window.confirm(`Send durable signal "${r.trim()}" to ${t}?`)&&s.run(`signal`,()=>e.signal(t,r.trim(),n))},className:`mt-3 rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:s.busy?`Sending…`:`Send durable signal`}),s.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s.error}),s.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:`Durable signal accepted; execution and list refreshed.`}),s.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:s.result})})]})}function Qe({repository:e,controlRepository:t,id:n,onApplied:r,clock:i,pollIntervalMs:a=5e3}){let{data:o,error:s,loading:c,refetch:l}=d(()=>e.get(n,`active`),[e,n],{intervalMs:a});if(c&&!o)return(0,R.jsx)(h,{label:`Loading signal inbox…`});if(s&&!o)return(0,R.jsx)(m,{error:s,onRetry:l});let u=o?.execution;if(!u)return null;let f=Object.entries(u.signals);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:s,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-warning`,children:`Signal inbox`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Waiting at node`,value:String(u.currentNodeIndex)}),(0,R.jsx)(V,{label:`Parked for`,value:(0,R.jsx)(ke,{since:u.updatedAt,clock:i})}),(0,R.jsx)(V,{label:`Last transition`,value:b(u.updatedAt)})]}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Durable signals`}),f.length?f.map(([e,t])=>(0,R.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-mono text-xs text-warning`,children:e}),(0,R.jsx)(B,{value:t})]},e)):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No signal has been persisted yet. The execution remains parked.`})]}),(0,R.jsx)(Ze,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function $e(e){return e.section.id===`overview`?(0,R.jsx)($,{...e}):e.section.id===`executions`?(0,R.jsx)(et,{...e}):(0,R.jsx)(tt,{...e})}function et({repository:e,kind:t,page:n,selected:r,offset:i,pageSize:a,onSelect:o,onPage:s}){return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(390px,0.8fr)_minmax(0,1.4fr)]`,children:[(0,R.jsx)(He,{executions:n.executions,total:n.total,offset:i,pageSize:a,selected:r,onSelect:o,onPage:s}),r&&(0,R.jsx)(X,{repository:e,id:r.id,kind:t,onSelect:e=>o({id:e,source:`link`})})]})}function tt(e){let t=e.section.id;return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(420px,0.95fr)_minmax(0,1.05fr)]`,children:[(0,R.jsx)(We,{mode:t,rows:e.page.executions,selected:e.selected,onSelect:e.onSelect,total:e.page.total,offset:e.offset,pageSize:e.pageSize,onPage:e.onPage}),e.selected&&(0,R.jsx)(nt,{...e,id:e.selected.id})]})}function nt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Qe,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(Me,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(Ae,{repository:t,id:i})}function rt({repository:e=fe,controlRepository:t=P}){let{pathname:n}=i(),r=ee(n),a=pe(r),{kind:o,workflowName:s,state:c,offset:l,selected:u,update:f,select:m}=a,h={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:g,error:_,loading:y,refetch:b}=d(()=>r.id===`overview`?ie(e,25):re(e,h),[e,r.id,o,s,c,l],{intervalMs:5e3});(0,E.useEffect)(()=>{let e=g?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&f({offset:t,executionId:null,tab:`summary`},!0)},[g?.page.total,l,f]),(0,E.useEffect)(()=>{let e=g?.page.executions;if(e){let t=r.id===`overview`?e.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state)):e,n=te(u,t);n?.id!==u?.id&&m(n,!0)}},[g?.page.executions,r.id,u,m]);let x=g?.stats,S=g?.page;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(v,{title:(0,R.jsxs)(R.Fragment,{children:[`Workflow `,(0,R.jsxs)(`span`,{className:`text-faint`,children:[`/ `,r.label]})]}),description:r.description,live:!!(g&&!_),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),r.id===`overview`&&(0,R.jsx)(ve,{repository:t,onApplied:b}),r.id===`archive`&&(0,R.jsx)(he,{repository:t,onApplied:b}),r.id===`executions`&&x&&(0,R.jsx)(_e,{stats:x}),(0,R.jsx)(Te,{section:r,kind:o,workflowName:s,state:c,stats:x??void 0,total:S?.total,onKind:e=>{a.update({kind:e,offset:0,executionId:null,tab:`summary`},!1)},onWorkflowName:e=>{a.update({workflowName:e,offset:0,executionId:null,tab:`summary`},!1)},onState:e=>{a.update({state:e,offset:0,executionId:null,tab:`summary`},!1)}}),_&&g&&(0,R.jsx)(p,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:b}),(0,R.jsx)(it,{repository:e,controlRepository:t,section:r,stats:x,kind:o,page:S,error:_,loading:y,dataPresent:!!g,selected:u,offset:l,onRetry:b,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function it({repository:e,controlRepository:t,section:n,stats:r,kind:i,page:a,error:o,loading:s,dataPresent:c,selected:l,offset:u,onRetry:d,onSelect:f,onPage:p}){return o&&!c?(0,R.jsx)(m,{error:o,onRetry:d}):s&&!c?(0,R.jsx)(h,{label:`Loading workflows…`}):a?.available?a.executions.length===0&&a.total>0&&u>0?(0,R.jsx)(h,{label:`Loading workflow page…`}):a.executions.length===0?(0,R.jsx)(g,{title:`No executions match these filters`,hint:`Change the store, workflow, or state filter.`}):r?(0,R.jsx)($e,{section:n,repository:e,controlRepository:t,kind:i,stats:r,page:a,selected:l,offset:u,pageSize:25,onSelect:f,onPage:p,onRefresh:d}):null:(0,R.jsx)(g,{title:`Workflow store not initialized`,hint:`Start a Bunqueue Workflow Engine with this server dataPath; its official workflow_executions tables will appear here automatically.`})}export{rt as Workflows};
1
+ import{i as e,t}from"./cn-zFEt5SO8.js";import{f as n,g as r,l as i,t as a}from"./react-vendor-CvwrP0tU.js";import{a as o}from"./connectionStore-BJLihGaC.js";import{t as s}from"./upstreamPaths-DQeKSxGc.js";import{s as c,t as l}from"./bq-F5BbTG1T.js";import{t as u}from"./toastStore-IZn6OPLZ.js";import{n as d}from"./usePolledData-0CVelkl2.js";import{t as f}from"./Card-CWxrC8OY.js";import{i as p,n as m,r as h,t as g}from"./feedback-QDN1AsYt.js";import{t as _}from"./StatusBadge-BoOVTnKu.js";import{t as v}from"./PageHeader-CvIyaFOO.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-CZsS0wAb.js";import{t as w}from"./useControlActionGuard-B-bzKZKI.js";var T={"/workflows":{id:`overview`,label:`Overview`,description:`The complete durable command center for Bunqueue Workflow Engine.`,kind:`active`,state:``},"/workflows/executions":{id:`executions`,label:`Executions`,description:`Inspect every active execution, step record, decision, and nested run.`,kind:`active`,state:``},"/workflows/waiting":{id:`waiting`,label:`Waiting & Signals`,description:`Focus on parked executions and their durable signal payloads.`,kind:`active`,state:`waiting`,lockKind:!0,lockState:!0},"/workflows/compensation":{id:`compensation`,label:`Compensation`,description:`See running, completed, skipped, failed, and parked saga compensation outcomes.`,kind:`active`,state:`compensation`,lockKind:!0,lockState:!0},"/workflows/archive":{id:`archive`,label:`Archive`,description:`Audit terminal executions retained by Workflow Engine archival.`,kind:`archive`,state:``,lockKind:!0}};function ee(e){return T[e]??T[`/workflows`]}function te(e,t){return e?.source===`link`||e&&t.some(t=>t.id===e.id)?e:t[0]?{id:t[0].id,source:`page`}:null}var E=e(r(),1),ne=[`waiting`,`failed`,`compensation-stuck`];async function re(e,t){let[n,r]=await Promise.all([e.stats(),e.list(t)]);return{stats:n,page:r}}async function ie(e,t){let[n,...r]=await Promise.all([e.stats(),...ne.map(n=>e.list({kind:`active`,state:n,limit:t,offset:0}))]),i=r.flatMap(e=>e.executions).sort(ae).slice(0,t);return{stats:n,page:{ok:r.every(e=>e.ok),available:r.every(e=>e.available),executions:i,total:r.reduce((e,t)=>e+t.total,0),limit:t,offset:0}}}function ae(e,t){return t.createdAt-e.createdAt||t.id.localeCompare(e.id)}var D=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function O(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:ce(e.get(`workflow`)),a=ue(e.get(`state`),t),o=t.id===`overview`?0:le(e.get(`offset`)),c=e.get(`execution`),l=c&&s(c,`Workflow execution id`)===null?c:null,u=e.get(`tab`),d=t.id===`overview`||t.id===`executions`;return{kind:r,workflowName:i,state:a,offset:o,executionId:l,tab:l&&d&&D.has(u)?u:`summary`}}function k(e,t){let n=new URLSearchParams;return e.id===`executions`&&t.kind===`archive`&&n.set(`kind`,`archive`),e.id!==`overview`&&t.workflowName&&n.set(`workflow`,t.workflowName),j(e)&&t.state&&n.set(`state`,t.state),e.id!==`overview`&&t.offset>0&&n.set(`offset`,String(t.offset)),t.executionId&&n.set(`execution`,t.executionId),t.executionId&&t.tab!==`summary`&&(e.id===`overview`||e.id===`executions`)&&n.set(`tab`,t.tab),n}function A(e,t,n){return k(t,{...O(e,t),...n})}function se(e){return D.has(e)}function ce(e){return e&&e.length<=256?e:``}function le(e){if(!e||!/^(0|[1-9]\d*)$/.test(e))return 0;let t=Number(e);return Number.isSafeInteger(t)&&t<=1e6?Math.floor(t/25)*25:0}function ue(e,t){return j(t)?e?t.id===`archive`?e===`completed`||e===`failed`?e:``:oe.has(e)?e:``:``:t.state}function j(e){return e.id===`executions`||e.id===`archive`}var de=e=>`${e}?target=${encodeURIComponent(o())}`,M=e=>({method:`POST`,headers:e===void 0?void 0:{"Content-Type":`application/json`},body:e===void 0?void 0:JSON.stringify(e)});async function N(e,t){return(await c(de(e),t)).result}var P={status:()=>N(`/workflows/runtime`),reload:()=>N(`/workflows/runtime/reload`,M()),start:async(e,t)=>(await N(`/workflows/start`,M({workflowName:e,input:t}))).run,signal:async(e,t,n)=>{await N(`/workflows/${encodeURIComponent(e)}/signal`,M({event:t,payload:n}))},recover:async()=>(await N(`/workflows/recover`,M())).recovered,resumeCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/resume-compensation`,M())},abandonCompensation:async e=>{await N(`/workflows/${encodeURIComponent(e)}/abandon-compensation`,M())},archive:async(e,t)=>(await N(`/workflows/archive`,M({maxAgeMs:e,states:t}))).affected,cleanup:async(e,t)=>(await N(`/workflows/cleanup`,M({maxAgeMs:e,states:t}))).affected},fe={stats:()=>l.workflows.stats(),list:e=>l.workflows.list(e),get:(e,t)=>l.workflows.get(e,t)};function pe(e){let[t,r]=n(),i=t.toString(),a=(0,E.useMemo)(()=>O(new URLSearchParams(i),e),[i,e]),o=(0,E.useMemo)(()=>k(e,a).toString(),[e,a]),s=(0,E.useRef)(null);(0,E.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,E.useCallback)((t,n=!1)=>{r(n=>A(n,e,t),{replace:n})},[e,r]),l=(0,E.useCallback)((e,t=!1)=>{s.current=e,c({executionId:e?.id??null,tab:`summary`},t)},[c]),u=a.executionId?{id:a.executionId,source:s.current?.id===a.executionId?s.current.source:`link`}:null;return{...a,selected:u,update:c,select:l}}function F(e){let t=S(),n=`workflow-command:${e.operationGroup}`,r=w(n),i=(0,E.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),a=(0,E.useRef)(e);a.current=e;let o=(0,E.useRef)(null),s=(0,E.useRef)(!0),c=(0,E.useRef)(i),l=(0,E.useRef)(0);if(!Object.is(c.current,i)){let e=c.current.connectionEpoch!==t;c.current=i,l.current+=1,e&&(o.current=null)}let[u,d]=(0,E.useState)(()=>I(i,t));(0,E.useEffect)(()=>(s.current=!0,()=>{s.current=!1,l.current+=1,o.current=null}),[]);let f=(e,t)=>s.current&&e===l.current&&t===C(),p=async(e,c)=>{if(o.current||t!==C())return;let u=r.begin(n);if(!u)return;let p=Symbol(`workflow-command`);o.current=p;let m=l.current,h=t,{onApplied:g,onSucceeded:_}=a.current;try{d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:null});let n=await c();if(!f(m,h))return;d({connectionEpoch:t,scope:i,busy:e,error:``,receipt:{label:e,value:n}});try{_?.(e,n)}catch{}try{await g?.()}catch(e){f(m,h)&&d(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(n){f(m,h)&&d({connectionEpoch:t,scope:i,busy:e,error:L(n),receipt:null})}finally{u.finish(),o.current===p&&(o.current=null,s.current&&h===C()&&d(e=>({...e,busy:``})))}},m=Object.is(u.scope,i)?u:I(i,t);return{busy:u.connectionEpoch===t?u.busy:``,error:m.error,result:m.receipt?.value,succeeded:m.receipt?.label??``,run:p,clearResult:()=>d(e=>({...e,receipt:null}))}}function I(e,t){return{connectionEpoch:t,scope:e,busy:``,error:``,receipt:null}}function L(e){return e instanceof Error?e.message:String(e)}var R=a(),z=e=>JSON.stringify(e,null,2)??`null`;function B({value:e,empty:t=`None`}){return e==null||typeof e==`object`&&Object.keys(e).length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:t}):(0,R.jsx)(`pre`,{className:`max-h-80 overflow-auto whitespace-pre-wrap break-words rounded-lg border border-line bg-surface-2 p-3 font-mono text-xs leading-5 text-muted`,children:z(e)})}function V({label:e,value:t}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-0.5 break-words text-muted`,children:t})]})}var me=3600*1e3;function he({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(`720`),[i,a]=(0,E.useState)(!0),[o,s]=(0,E.useState)(!0),c=F({operationGroup:`maintenance`,scopeKey:(0,E.useMemo)(()=>Symbol(`workflow-maintenance:${n.length}:${i}:${o}`),[i,o,n]),onApplied:t}),l=[...i?[`completed`]:[],...o?[`failed`]:[]],u=Number(n),d=Number.isFinite(u)&&u>=0&&l.length>0,f=t=>{if(!d)return;let n=t===`archive`?`Archive ${l.join(` and `)} workflows at least ${u} hours old?`:`Permanently delete ${l.join(` and `)} workflows at least ${u} hours old from the active execution store? Archive records are not deleted.`;if(!window.confirm(n))return;let r=Math.round(u*me);c.run(t,async()=>({operation:t,affected:t===`archive`?await e.archive(r,l):await e.cleanup(r,l)}))};return(0,R.jsxs)(`section`,{className:`mb-5 rounded-lg border border-line bg-surface p-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Retention operations`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-faint`,children:`Archive moves terminal runs into retention. Cleanup permanently deletes eligible terminal runs from the active store only; archive records remain intact.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Minimum age (hours)`,(0,R.jsx)(`input`,{"aria-label":`Workflow retention age hours`,type:`number`,min:`0`,step:`1`,value:n,onChange:e=>r(e.target.value),className:`mt-1 block h-9 w-32 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:i,onChange:e=>a(e.target.checked)}),`Completed`]}),(0,R.jsxs)(`label`,{className:`flex h-9 items-center gap-2 text-xs text-muted`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Failed`]})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`archive`),className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Archive eligible`}),(0,R.jsx)(`button`,{type:`button`,disabled:!d||!!c.busy,onClick:()=>f(`cleanup`),className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Delete eligible`})]}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:c.result})})]})}var ge=[[`Active`,`activeTotal`,`text-fg`],[`Running`,`running`,`text-blue-400`],[`Waiting`,`waiting`,`text-warning`],[`Completed`,`completed`,`text-success`],[`Failed`,`failed`,`text-danger`],[`Compensating`,`compensating`,`text-violet-400`],[`Stuck`,`compensation-stuck`,`text-danger`]];function _e({stats:e}){return(0,R.jsx)(`dl`,{className:`mb-4 grid grid-cols-2 divide-x divide-y divide-line overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-4 xl:grid-cols-7 xl:divide-y-0`,children:ge.map(([n,r,i])=>(0,R.jsxs)(`div`,{className:`px-3 py-2.5 first:border-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] font-medium uppercase tracking-wider text-faint`,children:n}),(0,R.jsx)(`dd`,{className:t(`mt-1 tnum font-mono text-lg font-semibold`,i),children:r===`activeTotal`?e.activeTotal:e.states[r]})]},r))})}function ve({repository:e=P,onApplied:t}){let[n,r]=(0,E.useState)(``),[i,a]=(0,E.useState)(`{}`),o=(0,E.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=d(()=>e.status(),[e],{intervalMs:5e3}),c=F({operationGroup:`runtime`,scopeKey:o,onApplied:async()=>{await s.refetch(),await t?.()}}),l=s.data?.ready===!0;return(0,R.jsxs)(`section`,{className:`mb-5 overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Workflow runtime`}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-faint`,children:`Registered application handlers stay in the agent-side runtime; commands never edit SQLite directly.`})]}),(0,R.jsx)(ye,{ready:l,configured:s.data?.configured===!0,unavailable:!!(s.error&&!s.data)})]}),s.data?.configured&&(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-1 border-b border-line px-4 py-2 text-[11px] text-faint`,children:[(0,R.jsxs)(`span`,{children:[`Module`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.moduleName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Queue`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.queueName??`—`})]}),(0,R.jsxs)(`span`,{children:[`Concurrency`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-medium text-muted`,children:s.data.concurrency??`—`})]})]}),s.error&&s.data&&(0,R.jsx)(p,{message:`Runtime status refresh failed; showing the last snapshot.`,onRetry:s.refetch}),s.error&&!s.data&&(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(m,{error:s.error,onRetry:s.refetch})}),(0,R.jsxs)(`div`,{className:`grid gap-5 p-4 lg:grid-cols-[minmax(0,1fr)_auto]`,children:[(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Registered workflow`,(0,R.jsx)(`input`,{"aria-label":`Registered workflow`,list:`workflow-runtime-names`,value:n,onChange:e=>r(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`}),(0,R.jsx)(`datalist`,{id:`workflow-runtime-names`,children:s.data?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e},e))})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Input JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow input JSON`,value:i,onChange:e=>a(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap content-start gap-2 lg:w-48 lg:flex-col`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!l||!n.trim()||!!c.busy,onClick:()=>{let t;try{t=JSON.parse(i)}catch{c.run(`start`,async()=>{throw Error(`Workflow input must be valid JSON.`)});return}c.run(`start`,()=>e.start(n.trim(),t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:c.busy===`start`?`Starting…`:`Start execution`}),(0,R.jsx)(`button`,{type:`button`,disabled:!l||!!c.busy,onClick:()=>{window.confirm(`Recover every orphaned workflow using the registered idempotent handlers?`)&&c.run(`recover`,()=>e.recover())},className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Recover orphaned`}),(0,R.jsx)(`button`,{type:`button`,disabled:!s.data?.configured||!!c.busy,onClick:()=>void c.run(`reload`,()=>e.reload()),className:`rounded-md border border-line px-3 py-2 text-xs text-muted disabled:opacity-40`,children:`Reload definitions`})]})]}),!s.loading&&!s.error&&!s.data?.configured&&(0,R.jsxs)(`p`,{className:`border-t border-line px-4 py-3 text-xs text-warning`,children:[`Set `,(0,R.jsx)(`code`,{children:`BUNQUEUE_WORKFLOW_MODULE`}),` to an absolute module path in Server → Extra environment, then start the managed server.`]}),s.data?.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:s.data.error}),c.error&&(0,R.jsx)(`p`,{role:`alert`,className:`border-t border-line px-4 py-3 text-xs text-danger`,children:c.error}),c.result!==void 0&&(0,R.jsx)(`div`,{className:`border-t border-line p-4`,children:(0,R.jsx)(B,{value:c.result})})]})}function ye({ready:e,configured:t,unavailable:n}){return(0,R.jsx)(`span`,{className:e?`rounded-full bg-success/10 px-2 py-1 text-[11px] text-success`:`rounded-full bg-warning/10 px-2 py-1 text-[11px] text-warning`,children:e?`Handlers loaded`:n?`Status unavailable`:t?`Unavailable`:`Not configured`})}var be=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function xe({section:e,kind:t,workflowName:n,state:r,stats:i,total:a,onKind:o,onWorkflowName:s,onState:c}){return(0,R.jsx)(f,{className:`mb-5`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[e.lockKind?(0,R.jsx)(H,{label:`Store`,value:`${e.kind}${e.kind===`archive`&&i?` · ${i.archiveTotal}`:``}`,capitalize:!0}):(0,R.jsx)(Se,{kind:t,archiveTotal:i?.archiveTotal,onChange:o}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Workflow`,(0,R.jsxs)(`select`,{value:n,onChange:e=>s(e.target.value),className:`mt-1 block h-9 min-w-48 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),i?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),e.lockState?(0,R.jsx)(H,{label:`State scope`,value:e.state===`compensation`?`Compensating + stuck`:e.state}):(0,R.jsx)(Ce,{state:r,onChange:c}),a!==void 0&&(0,R.jsxs)(`span`,{className:`ml-auto text-xs text-faint`,children:[a,` execution`,a===1?``:`s`]})]})})}function Se({kind:e,archiveTotal:n,onChange:r}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:`Store`}),(0,R.jsx)(`div`,{className:`flex rounded-lg border border-line p-0.5`,children:[`active`,`archive`].map(i=>(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":e===i,onClick:()=>r(i),className:t(`rounded-md px-3 py-1.5 text-xs capitalize`,e===i?`bg-surface-2 text-fg`:`text-muted hover:text-fg`),children:[i,i===`archive`&&n!==void 0?` (${n})`:``]},i))})]})}function Ce({state:e,onChange:t}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`State`,(0,R.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`mt-1 block h-9 min-w-44 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:be.map(e=>(0,R.jsx)(`option`,{value:e,children:e===`compensation`?`All compensation`:e||`All states`},e||`all`))})]})}function H({label:e,value:n,capitalize:r=!1}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`span`,{className:`mb-1 block text-xs text-faint`,children:e}),(0,R.jsx)(`span`,{className:t(`inline-flex h-9 items-center rounded-lg border border-line bg-surface-2 px-3 text-xs text-fg`,r&&`capitalize`),children:n})]})}function we({label:e=`Workflow`,value:t,stats:n,onChange:r}){return(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[e,(0,R.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`mt-1 block h-9 min-w-52 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All workflows`}),n?.workflowNames.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]})}function Te(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(xe,{...e}):(0,R.jsxs)(`div`,{className:`mb-5 flex items-end gap-4 rounded-lg border border-line bg-surface px-4 py-3`,children:[(0,R.jsx)(we,{value:e.workflowName,stats:e.stats,onChange:e.onWorkflowName}),e.section.id===`archive`&&(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Outcome`,(0,R.jsxs)(`select`,{value:e.state,onChange:t=>e.onState(t.target.value),className:`mt-1 block h-9 min-w-36 rounded-lg border border-line bg-surface-2 px-3 text-sm text-fg`,children:[(0,R.jsx)(`option`,{value:``,children:`All outcomes`}),(0,R.jsx)(`option`,{value:`completed`,children:`Completed`}),(0,R.jsx)(`option`,{value:`failed`,children:`Failed`})]})]}),(0,R.jsxs)(`span`,{className:`ml-auto pb-2 text-xs text-faint`,children:[e.total??0,` `,e.section.id===`archive`?`records`:`executions`]})]})}function Ee(e){let t=[{id:`execution-started`,at:e.createdAt,title:`Execution started`,detail:e.workflowName,status:`running`,category:`execution`}];for(let[n,r]of Object.entries(e.steps))t.push(...De(n,r));for(let n of Object.keys(e.signals))t.push({id:`signal:${n}`,title:`Signal persisted: ${n}`,detail:`The store does not expose an exact signal timestamp.`,category:`signal`});return e.state!==`running`&&e.state!==`waiting`&&t.push({id:`execution-settled`,at:e.updatedAt,title:`Execution ${e.state}`,detail:e.failureReason,status:e.state,category:`execution`}),t.sort(Oe)}function De(e,t){let n=[];return t.startedAt!==void 0&&n.push({id:`step:${e}:started`,at:t.startedAt,title:`Step started: ${e}`,detail:t.attempts?`Attempt ${t.attempts}`:void 0,status:`running`,category:`step`}),(t.completedAt!==void 0||t.status===`failed`)&&n.push({id:`step:${e}:settled`,at:t.completedAt,title:`Step ${t.status}: ${e}`,detail:t.error,status:t.status,category:`step`}),t.compensation&&n.push({id:`step:${e}:compensation`,at:t.compensation.at,title:`Compensation ${t.compensation.status}: ${e}`,detail:t.compensation.error,status:t.compensation.status,category:`compensation`}),n}function Oe(e,t){return e.at===void 0&&t.at===void 0?e.id.localeCompare(t.id):e.at===void 0?1:t.at===void 0?-1:e.at-t.at||e.id.localeCompare(t.id)}function U({execution:e}){let t=Ee(e);return(0,R.jsx)(`ol`,{className:`divide-y divide-line/70 border-y border-line/70`,children:t.map((e,n)=>(0,R.jsxs)(`li`,{className:`grid grid-cols-[28px_minmax(0,1fr)] gap-3 py-3`,children:[(0,R.jsxs)(`div`,{className:`relative flex justify-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1.5 size-2 rounded-full border-2 border-surface bg-accent ring-1 ring-line`}),n<t.length-1&&(0,R.jsx)(`span`,{className:`absolute top-5 bottom-[-13px] w-px bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`break-words text-sm font-medium text-fg`,children:e.title}),e.status&&(0,R.jsx)(_,{status:e.status})]}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-x-3 text-xs text-faint`,children:[(0,R.jsx)(`span`,{className:`capitalize`,children:e.category}),(0,R.jsx)(`span`,{children:e.at===void 0?`Timestamp unavailable`:b(e.at)})]}),e.detail&&(0,R.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs text-muted`,children:e.detail})]})]},e.id))})}var W={now:Date.now,subscribe:e=>{let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)}};function ke({since:e,clock:t=W}){let n=G(t);return(0,R.jsx)(R.Fragment,{children:y(Math.max(0,n-e))})}function G(e=W,t=!0){let[n,r]=(0,E.useState)(()=>e.now());return(0,E.useEffect)(()=>{if(r(e.now()),t)return e.subscribe(()=>r(e.now()))},[e,t]),n}function K({error:e,onRetry:t}){return e?(0,R.jsx)(p,{message:`Execution refresh failed; showing the last persisted snapshot.`,onRetry:t}):null}async function q(e,t){await Promise.all([e(),t?.()])}function Ae({repository:e,id:t,pollIntervalMs:n=1e4}){let{data:r,error:i,loading:a,refetch:o}=d(()=>e.get(t,`archive`),[e,t],{intervalMs:n});if(a&&!r)return(0,R.jsx)(h,{label:`Loading audit record…`});if(i&&!r)return(0,R.jsx)(m,{error:i,onRetry:o});let s=r?.execution;return s?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:i,onRetry:o}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Immutable audit record`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:s.id})]}),(0,R.jsx)(_,{status:s.state})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Workflow`,value:s.workflowName}),(0,R.jsx)(V,{label:`Runtime`,value:y(s.updatedAt-s.createdAt)}),(0,R.jsx)(V,{label:`Archived`,value:s.archivedAt?b(s.archivedAt):`Unavailable`}),(0,R.jsx)(V,{label:`Definition hash`,value:s.definitionHash??`Unavailable`}),(0,R.jsx)(V,{label:`Final node`,value:String(s.currentNodeIndex)}),(0,R.jsx)(V,{label:`Final transition`,value:b(s.updatedAt)})]}),(0,R.jsx)(`div`,{className:`p-4`,children:(0,R.jsx)(U,{execution:s})})]})]}):null}function je({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({operationGroup:`compensation`,scopeKey:`${t}:${n}`,onApplied:r,onSucceeded:e=>u.success(e===`resume`?`Compensation resumed`:`Compensation abandoned`,t)});return n?(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Operator decision`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Retry after fixing the reversal, or explicitly abandon the remaining compensation steps.`}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Retry the stuck compensation for ${t}? Handlers must be idempotent.`)&&i.run(`resume`,()=>e.resumeCompensation(t))},className:`rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:`Resume compensation`}),(0,R.jsx)(`button`,{type:`button`,disabled:!!i.busy,onClick:()=>{window.confirm(`Abandon remaining compensation for ${t}? This is irreversible.`)&&i.run(`abandon`,()=>e.abandonCompensation(t))},className:`rounded-md border border-danger/40 px-3 py-2 text-xs text-danger disabled:opacity-40`,children:`Abandon remainder`})]}),i.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:i.error}),i.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:i.succeeded===`resume`?`Resume command accepted; recovery state refreshed.`:`Abandon command accepted; recovery state refreshed.`}),i.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:i.result})})]}):null}function Me({repository:e,controlRepository:t,id:n,onApplied:r,pollIntervalMs:i=5e3}){let{data:a,error:o,loading:s,refetch:c}=d(()=>e.get(n,`active`),[e,n],{intervalMs:i});if(s&&!a)return(0,R.jsx)(h,{label:`Loading recovery plan…`});if(o&&!a)return(0,R.jsx)(m,{error:o,onRetry:c});let l=a?.execution;if(!l)return null;let u=Object.entries(l.steps).filter(([,e])=>e.compensatable||e.compensation);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:o,onRetry:c}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-line px-4 py-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-violet-400`,children:`Recovery plan`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:l.id})]}),(0,R.jsx)(_,{status:l.state})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Compensation pivot`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.committedAt===void 0?`Not committed`:`Node ${l.committedAt}`})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Rollback state`}),(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:l.rollbackStatus??l.state})]})]}),l.failureReason&&(0,R.jsx)(`div`,{role:`alert`,className:`border-b border-danger/30 bg-danger/[0.06] px-4 py-3 text-xs text-danger`,children:l.failureReason}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Compensation ledger`}),u.length?(0,R.jsx)(`ol`,{className:`space-y-2`,children:u.reverse().map(([e,t])=>(0,R.jsxs)(`li`,{className:`grid gap-2 rounded-md border border-line px-3 py-2 text-xs sm:grid-cols-[1fr_auto]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-mono text-fg`,children:e}),(0,R.jsx)(`div`,{className:`mt-1 text-faint`,children:t.compensation?.error??`Compensation handler registered`})]}),(0,R.jsxs)(`div`,{className:`text-right text-muted`,children:[t.compensation?t.compensation.status:`pending`,t.compensation?.at?(0,R.jsx)(`div`,{className:`mt-1 text-[10px] text-faint`,children:b(t.compensation.at)}):null]})]},e))}):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No compensatable step was persisted.`})]}),(0,R.jsx)(je,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Ne({execution:e}){return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(J,{title:`Input`,value:e.input}),(0,R.jsx)(J,{title:`Signals`,value:e.signals}),(0,R.jsx)(J,{title:`Resolved steps`,value:e.resolvedSteps}),(0,R.jsx)(J,{title:`Decisions`,value:e.decisions})]})}function J({title:e,value:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h3`,{className:`mb-2 text-xs font-semibold uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(B,{value:t})]})}function Pe({steps:e,onSelect:t}){let n=Object.entries(e);return n.length===0?(0,R.jsx)(`p`,{className:`text-xs text-faint`,children:`No persisted step records.`}):(0,R.jsx)(`ol`,{className:`space-y-3`,children:n.map(([e,r],i)=>(0,R.jsx)(Fe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Fe({name:e,step:t,last:n,onSelect:r}){let i=t.startedAt!==void 0&&t.completedAt!==void 0?t.completedAt-t.startedAt:void 0;return(0,R.jsxs)(`li`,{className:`relative grid grid-cols-[18px_1fr] gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col items-center`,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:`mt-1 size-2.5 rounded-full bg-current text-accent`}),!n&&(0,R.jsx)(`span`,{className:`mt-1 w-px flex-1 bg-line`})]}),(0,R.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-line bg-surface-2 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{translate:`no`,className:`break-all font-mono text-sm font-medium text-fg`,children:e}),(0,R.jsx)(_,{status:t.status})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-x-4 gap-y-1 text-xs text-faint`,children:[t.attempts!==void 0&&(0,R.jsxs)(`span`,{children:[t.attempts,` attempt`,t.attempts===1?``:`s`]}),i!==void 0&&(0,R.jsx)(`span`,{children:y(i)}),t.occurrence!==void 0&&(0,R.jsxs)(`span`,{children:[`Occurrence `,t.occurrence]}),t.loopIndex!==void 0&&(0,R.jsxs)(`span`,{children:[`Loop index `,t.loopIndex]}),t.compensatable&&(0,R.jsx)(`span`,{children:`Compensatable`})]}),t.idempotencyKey&&(0,R.jsxs)(`div`,{className:`mt-2 break-all font-mono text-[11px] text-faint`,children:[`Idempotency: `,t.idempotencyKey]}),t.childExecutionId&&(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r(t.childExecutionId),className:`mt-2 break-all font-mono text-xs text-accent hover:underline`,children:[`Child execution: `,t.childExecutionId]}),t.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-2 whitespace-pre-wrap text-xs text-danger`,children:t.error}),t.compensation&&(0,R.jsxs)(`div`,{className:`mt-3 rounded-md border border-line px-3 py-2 text-xs`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-faint`,children:`Compensation`}),(0,R.jsx)(_,{status:t.compensation.status}),(0,R.jsx)(`span`,{className:`text-faint`,children:b(t.compensation.at)})]}),t.compensation.error&&(0,R.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap text-danger`,children:t.compensation.error})]}),(0,R.jsx)(Ie,{step:t})]})]})}function Ie({step:e}){return(0,R.jsxs)(R.Fragment,{children:[Object.hasOwn(e,`result`)&&(0,R.jsx)(Y,{label:`Result`,value:e.result}),Object.hasOwn(e,`loopItem`)&&(0,R.jsx)(Y,{label:`Loop item`,value:e.loopItem})]})}function Y({label:e,value:t}){return(0,R.jsxs)(`details`,{className:`mt-3`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted`,children:e}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(B,{value:t})})]})}function Le({execution:e,onSelect:t}){let n=Object.values(e.steps),r=n.filter(e=>e.status===`completed`).length;return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 border-b border-line pb-5 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Current node`,value:String(e.currentNodeIndex)}),(0,R.jsx)(V,{label:`Step progress`,value:`${r}/${n.length} completed`}),(0,R.jsx)(V,{label:`Duration`,value:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(V,{label:`Started`,value:b(e.createdAt)}),(0,R.jsx)(V,{label:`Last transition`,value:b(e.updatedAt)}),(0,R.jsx)(V,{label:`Rollback`,value:e.rollbackStatus??`Not started`})]}),e.failureReason&&(0,R.jsxs)(`div`,{role:`alert`,className:`border-l-2 border-danger bg-danger/[0.06] px-3 py-2 text-xs text-danger`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-medium`,children:`Failure`}),(0,R.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.failureReason})]}),(0,R.jsx)(Re,{execution:e,onSelect:t}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Step state`}),(0,R.jsx)(Pe,{steps:e.steps,onSelect:t})]})]})}function Re({execution:e,onSelect:t}){return!e.parentExecutionId&&!e.definitionHash&&e.committedAt===void 0?null:(0,R.jsxs)(`div`,{className:`grid gap-3 border-b border-line pb-5 text-xs sm:grid-cols-2`,children:[e.parentExecutionId&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-faint`,children:`Parent execution`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(e.parentExecutionId),className:`mt-1 break-all font-mono text-accent hover:underline`,children:e.parentExecutionId})]}),e.definitionHash&&(0,R.jsx)(V,{label:`Definition hash`,value:e.definitionHash}),e.committedAt!==void 0&&(0,R.jsx)(V,{label:`Compensation pivot`,value:`Node ${e.committedAt}`}),(0,R.jsx)(`div`,{className:`flex items-end`,children:(0,R.jsx)(_,{status:e.state})})]})}var ze=[{id:`summary`,label:`Summary`},{id:`history`,label:`History`},{id:`payloads`,label:`Payloads`}];function X({repository:e,id:t,kind:n,onSelect:r}){return(0,R.jsx)(Be,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function Be({repository:e,id:r,kind:i,onSelect:a}){let[o,s]=n(),c=o.get(`tab`),l=se(c)?c:`summary`,{data:u,error:f,loading:g,refetch:v}=d(()=>e.get(r,i),[e,r,i],{intervalMs:5e3});if(g&&!u)return(0,R.jsx)(Z,{children:(0,R.jsx)(h,{label:`Loading execution…`})});if(f&&!u)return(0,R.jsx)(Z,{children:(0,R.jsx)(m,{error:f,onRetry:v})});let y=u?.execution;return y?(0,R.jsxs)(Z,{children:[f&&(0,R.jsx)(p,{message:`Execution refresh failed. Showing the last snapshot.`,onRetry:v}),(0,R.jsx)(`header`,{className:`border-b border-line px-4 py-3`,children:(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-faint`,children:`Execution`}),(0,R.jsx)(`h2`,{translate:`no`,className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:y.id}),(0,R.jsx)(`div`,{className:`mt-1 text-xs text-muted`,children:y.workflowName})]}),(0,R.jsx)(_,{status:y.state})]})}),(0,R.jsx)(`nav`,{"aria-label":`Execution detail`,className:`flex border-b border-line px-2`,children:ze.map(e=>(0,R.jsx)(`button`,{type:`button`,"aria-pressed":l===e.id,onClick:()=>{s(t=>{let n=new URLSearchParams(t);return e.id===`summary`?n.delete(`tab`):n.set(`tab`,e.id),n})},className:t(`border-b-2 px-3 py-2 text-xs font-medium`,l===e.id?`border-accent text-fg`:`border-transparent text-faint hover:text-muted`),children:e.label},e.id))}),(0,R.jsxs)(`div`,{className:`p-4`,"aria-live":`polite`,children:[l===`summary`&&(0,R.jsx)(Le,{execution:y,onSelect:a}),l===`history`&&(0,R.jsx)(U,{execution:y}),l===`payloads`&&(0,R.jsx)(Ne,{execution:y})]})]}):null}function Z({children:e}){return(0,R.jsx)(`section`,{className:`min-w-0 overflow-hidden rounded-lg border border-line bg-surface`,children:e})}function Q({total:e,offset:t,pageSize:n,count:r,onPage:i}){let a=r===0?0:t+1,o=Math.min(t+r,e);return(0,R.jsxs)(`nav`,{"aria-label":`Workflow execution pages`,className:`mt-3 flex items-center justify-between`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:t===0,onClick:()=>i(Math.max(0,t-n)),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Previous`}),(0,R.jsxs)(`span`,{className:`text-xs text-faint`,children:[a,`–`,o,` of `,e]}),(0,R.jsx)(`button`,{type:`button`,disabled:t+n>=e,onClick:()=>i(t+n),className:`rounded-lg border border-line px-3 py-1.5 text-xs text-muted disabled:opacity-40`,children:`Next`})]})}var Ve=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function He({executions:e,total:t,offset:n,pageSize:r,selected:i,onSelect:a,onPage:o}){return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,R.jsx)(`thead`,{className:`bg-surface-2/80`,children:(0,R.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow / execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Status`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium md:table-cell`,children:`Node`}),(0,R.jsx)(`th`,{className:`hidden px-3 py-2 font-medium lg:table-cell`,children:`Elapsed`}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:`Updated`})]})}),(0,R.jsx)(`tbody`,{children:e.map(e=>(0,R.jsx)(Ue,{execution:e,selected:i?.id===e.id,onSelect:a},e.id))})]})}),(0,R.jsx)(Q,{total:t,offset:n,pageSize:r,count:e.length,onPage:o})]})}function Ue({execution:e,selected:n,onSelect:r}){return(0,R.jsxs)(`tr`,{className:t(`border-b border-line/70 last:border-0`,n&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>r({id:e.id,source:`page`}),className:`block w-full px-3 py-2.5 text-left focus-visible:outline-2 focus-visible:outline-inset focus-visible:outline-accent`,children:[(0,R.jsx)(`span`,{className:`block truncate font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{translate:`no`,title:e.id,className:`mt-0.5 block font-mono text-[11px] text-faint`,children:Ve(e.id)})]})}),(0,R.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,R.jsx)(_,{status:e.state})}),(0,R.jsx)(`td`,{className:`hidden px-3 py-2.5 font-mono text-xs text-muted md:table-cell`,children:e.currentNodeIndex}),(0,R.jsx)(`td`,{className:`hidden whitespace-nowrap px-3 py-2.5 font-mono text-xs text-muted lg:table-cell`,children:y(e.updatedAt-e.createdAt)}),(0,R.jsx)(`td`,{title:b(e.updatedAt),className:`whitespace-nowrap px-3 py-2.5 text-right text-xs text-muted`,children:x(e.updatedAt)})]})}function We({mode:e,rows:n,selected:r,onSelect:i,total:a,offset:o,pageSize:s,onPage:c,clock:l=W}){let u=G(l,e===`waiting`);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`section`,{className:`overflow-x-auto rounded-lg border border-line bg-surface`,children:(0,R.jsxs)(`table`,{className:`w-full min-w-[560px] text-sm`,children:[(0,R.jsx)(`thead`,{className:`border-b border-line bg-surface-2/80 text-left text-[10px] uppercase tracking-wider text-faint`,children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:e===`archive`?`Execution record`:`Execution`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:`Workflow`}),(0,R.jsx)(`th`,{className:`px-3 py-2 font-medium`,children:Ge(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ke(e)})]})}),(0,R.jsx)(`tbody`,{children:n.map(n=>(0,R.jsxs)(`tr`,{className:t(`border-b border-line last:border-0`,r?.id===n.id&&`bg-surface-2`),children:[(0,R.jsx)(`td`,{className:`p-0`,children:(0,R.jsx)(`button`,{type:`button`,className:`block w-full px-3 py-3 text-left font-mono text-xs text-fg`,onClick:()=>i({id:n.id,source:`page`}),children:n.id})}),(0,R.jsx)(`td`,{className:`px-3 py-3 text-muted`,children:n.workflowName}),(0,R.jsx)(`td`,{className:`px-3 py-3`,children:(0,R.jsx)(qe,{mode:e,row:n})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:Je(e,n,u)})]},n.id))})]})}),(0,R.jsx)(Q,{total:a,offset:o,pageSize:s,count:n.length,onPage:c})]})}var Ge=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ke=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function qe({mode:e,row:t}){return e===`waiting`?(0,R.jsxs)(`span`,{className:`font-mono text-xs text-warning`,children:[`Node `,t.currentNodeIndex]}):(0,R.jsx)(_,{status:t.state})}function Je(e,t,n){return e===`archive`?t.archivedAt?b(t.archivedAt):`Unavailable`:e===`waiting`?y(Math.max(0,n-t.updatedAt)):x(t.updatedAt)}function $({stats:e,page:t,repository:n,kind:r,selected:i,onSelect:a}){let o=t.executions.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state));return(0,R.jsxs)(`div`,{className:`space-y-5`,children:[(0,R.jsx)(Ye,{stats:e}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(320px,0.7fr)_minmax(0,1.3fr)]`,children:[(0,R.jsxs)(`section`,{className:`rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Needs attention`}),(0,R.jsxs)(`p`,{className:`mt-0.5 text-xs text-faint`,children:[`Waiting, failed, and stuck executions · showing `,o.length,` of `,t.total,`.`]})]}),(0,R.jsx)(Xe,{rows:o,selected:i,onSelect:a})]}),i&&(0,R.jsx)(X,{repository:n,id:i.id,kind:r,onSelect:e=>a({id:e,source:`link`})})]})]})}function Ye({stats:e}){return(0,R.jsx)(`dl`,{className:`grid overflow-hidden rounded-lg border border-line bg-surface sm:grid-cols-2 xl:grid-cols-4`,children:[[`Open executions`,e.activeTotal],[`Waiting for signal`,e.states.waiting],[`Recovery required`,e.states[`compensation-stuck`]+e.states.failed],[`Retained in archive`,e.archiveTotal]].map(([e,t])=>(0,R.jsxs)(`div`,{className:`border-b border-line px-4 py-3 sm:border-r xl:border-b-0`,children:[(0,R.jsx)(`dt`,{className:`text-[10px] uppercase tracking-wider text-faint`,children:e}),(0,R.jsx)(`dd`,{className:`mt-1 font-mono text-xl font-semibold text-fg`,children:t})]},e))})}function Xe({rows:e,selected:t,onSelect:n}){return e.length?(0,R.jsx)(`ul`,{className:`divide-y divide-line`,children:e.map(e=>(0,R.jsx)(`li`,{className:t?.id===e.id?`bg-surface-2`:void 0,children:(0,R.jsxs)(`button`,{type:`button`,className:`w-full px-4 py-3 text-left`,onClick:()=>n({id:e.id,source:`page`}),children:[(0,R.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.workflowName}),(0,R.jsx)(`span`,{className:`text-xs text-faint`,children:x(e.updatedAt)})]}),(0,R.jsxs)(`span`,{className:`mt-1 flex items-center justify-between gap-3 font-mono text-[11px] text-faint`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e.id}),(0,R.jsx)(`span`,{children:e.state})]})]})},e.id))}):(0,R.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted`,children:`No intervention required.`})}function Ze({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,E.useState)(``),[a,o]=(0,E.useState)(`{}`),s=F({operationGroup:`signal`,scopeKey:t,onApplied:n,onSucceeded:()=>u.success(`Workflow signal accepted`,`${r.trim()} · ${t}`)});return(0,R.jsxs)(`div`,{className:`border-t border-line p-4`,children:[(0,R.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wider text-faint`,children:`Send signal`}),(0,R.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Event name`,(0,R.jsx)(`input`,{"aria-label":`Workflow signal event`,value:r,onChange:e=>i(e.target.value),className:`mt-1 h-9 w-full rounded-lg border border-line bg-surface-2 px-3 font-mono text-sm text-fg`})]}),(0,R.jsxs)(`label`,{className:`text-xs text-faint`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Workflow signal payload`,value:a,onChange:e=>o(e.target.value),className:`mt-1 min-h-20 w-full resize-y rounded-lg border border-line bg-surface-2 p-2 font-mono text-xs text-fg`})]})]}),(0,R.jsx)(`button`,{type:`button`,disabled:!r.trim()||!!s.busy,onClick:()=>{let n;try{n=JSON.parse(a)}catch{s.run(`signal`,async()=>{throw Error(`Signal payload must be valid JSON.`)});return}window.confirm(`Send durable signal "${r.trim()}" to ${t}?`)&&s.run(`signal`,()=>e.signal(t,r.trim(),n))},className:`mt-3 rounded-md bg-accent px-3 py-2 text-xs font-medium text-accent-fg disabled:opacity-40`,children:s.busy?`Sending…`:`Send durable signal`}),s.error&&(0,R.jsx)(`p`,{role:`alert`,className:`mt-3 text-xs text-danger`,children:s.error}),s.succeeded&&(0,R.jsx)(`p`,{role:`status`,className:`mt-3 text-xs text-success`,children:`Durable signal accepted; execution and list refreshed.`}),s.result!==void 0&&(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(B,{value:s.result})})]})}function Qe({repository:e,controlRepository:t,id:n,onApplied:r,clock:i,pollIntervalMs:a=5e3}){let{data:o,error:s,loading:c,refetch:l}=d(()=>e.get(n,`active`),[e,n],{intervalMs:a});if(c&&!o)return(0,R.jsx)(h,{label:`Loading signal inbox…`});if(s&&!o)return(0,R.jsx)(m,{error:s,onRetry:l});let u=o?.execution;if(!u)return null;let f=Object.entries(u.signals);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(K,{error:s,onRetry:l}),(0,R.jsxs)(`section`,{className:`overflow-hidden rounded-lg border border-line bg-surface`,children:[(0,R.jsxs)(`header`,{className:`border-b border-line px-4 py-3`,children:[(0,R.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-warning`,children:`Signal inbox`}),(0,R.jsx)(`h2`,{className:`mt-1 break-all font-mono text-sm font-semibold text-fg`,children:u.id})]}),(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 border-b border-line p-4 text-xs sm:grid-cols-3`,children:[(0,R.jsx)(V,{label:`Waiting at node`,value:String(u.currentNodeIndex)}),(0,R.jsx)(V,{label:`Parked for`,value:(0,R.jsx)(ke,{since:u.updatedAt,clock:i})}),(0,R.jsx)(V,{label:`Last transition`,value:b(u.updatedAt)})]}),(0,R.jsxs)(`div`,{className:`p-4`,children:[(0,R.jsx)(`h3`,{className:`mb-3 text-xs font-semibold uppercase tracking-wider text-faint`,children:`Durable signals`}),f.length?f.map(([e,t])=>(0,R.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`mb-1 font-mono text-xs text-warning`,children:e}),(0,R.jsx)(B,{value:t})]},e)):(0,R.jsx)(`p`,{className:`text-sm text-muted`,children:`No signal has been persisted yet. The execution remains parked.`})]}),(0,R.jsx)(Ze,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function $e(e){return e.section.id===`overview`?(0,R.jsx)($,{...e}):e.section.id===`executions`?(0,R.jsx)(et,{...e}):(0,R.jsx)(tt,{...e})}function et({repository:e,kind:t,page:n,selected:r,offset:i,pageSize:a,onSelect:o,onPage:s}){return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(390px,0.8fr)_minmax(0,1.4fr)]`,children:[(0,R.jsx)(He,{executions:n.executions,total:n.total,offset:i,pageSize:a,selected:r,onSelect:o,onPage:s}),r&&(0,R.jsx)(X,{repository:e,id:r.id,kind:t,onSelect:e=>o({id:e,source:`link`})})]})}function tt(e){let t=e.section.id;return(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(420px,0.95fr)_minmax(0,1.05fr)]`,children:[(0,R.jsx)(We,{mode:t,rows:e.page.executions,selected:e.selected,onSelect:e.onSelect,total:e.page.total,offset:e.offset,pageSize:e.pageSize,onPage:e.onPage}),e.selected&&(0,R.jsx)(nt,{...e,id:e.selected.id})]})}function nt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Qe,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(Me,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(Ae,{repository:t,id:i})}function rt({repository:e=fe,controlRepository:t=P}){let{pathname:n}=i(),r=ee(n),a=pe(r),{kind:o,workflowName:s,state:c,offset:l,selected:u,update:f,select:m}=a,h={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:g,error:_,loading:y,refetch:b}=d(()=>r.id===`overview`?ie(e,25):re(e,h),[e,r.id,o,s,c,l],{intervalMs:5e3});(0,E.useEffect)(()=>{let e=g?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&f({offset:t,executionId:null,tab:`summary`},!0)},[g?.page.total,l,f]),(0,E.useEffect)(()=>{let e=g?.page.executions;if(e){let t=r.id===`overview`?e.filter(e=>[`waiting`,`failed`,`compensation-stuck`].includes(e.state)):e,n=te(u,t);n?.id!==u?.id&&m(n,!0)}},[g?.page.executions,r.id,u,m]);let x=g?.stats,S=g?.page;return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(v,{title:(0,R.jsxs)(R.Fragment,{children:[`Workflow `,(0,R.jsxs)(`span`,{className:`text-faint`,children:[`/ `,r.label]})]}),description:r.description,live:!!(g&&!_),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void b(),className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Refresh`})}),r.id===`overview`&&(0,R.jsx)(ve,{repository:t,onApplied:b}),r.id===`archive`&&(0,R.jsx)(he,{repository:t,onApplied:b}),r.id===`executions`&&x&&(0,R.jsx)(_e,{stats:x}),(0,R.jsx)(Te,{section:r,kind:o,workflowName:s,state:c,stats:x??void 0,total:S?.total,onKind:e=>{a.update({kind:e,offset:0,executionId:null,tab:`summary`},!1)},onWorkflowName:e=>{a.update({workflowName:e,offset:0,executionId:null,tab:`summary`},!1)},onState:e=>{a.update({state:e,offset:0,executionId:null,tab:`summary`},!1)}}),_&&g&&(0,R.jsx)(p,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:b}),(0,R.jsx)(it,{repository:e,controlRepository:t,section:r,stats:x,kind:o,page:S,error:_,loading:y,dataPresent:!!g,selected:u,offset:l,onRetry:b,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function it({repository:e,controlRepository:t,section:n,stats:r,kind:i,page:a,error:o,loading:s,dataPresent:c,selected:l,offset:u,onRetry:d,onSelect:f,onPage:p}){return o&&!c?(0,R.jsx)(m,{error:o,onRetry:d}):s&&!c?(0,R.jsx)(h,{label:`Loading workflows…`}):a?.available?a.executions.length===0&&a.total>0&&u>0?(0,R.jsx)(h,{label:`Loading workflow page…`}):a.executions.length===0?(0,R.jsx)(g,{title:`No executions match these filters`,hint:`Change the store, workflow, or state filter.`}):r?(0,R.jsx)($e,{section:n,repository:e,controlRepository:t,kind:i,stats:r,page:a,selected:l,offset:u,pageSize:25,onSelect:f,onPage:p,onRefresh:d}):null:(0,R.jsx)(g,{title:`Workflow store not initialized`,hint:`Start a Bunqueue Workflow Engine with this server dataPath; its official workflow_executions tables will appear here automatically.`})}export{rt as Workflows};
@@ -1 +1 @@
1
- import{a as e,i as t}from"./connectionStore-BJLihGaC.js";import{a as n,n as r,r as i,s as a}from"./upstreamPaths-B_cyinGI.js";var o=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}},s=3e4;async function c(n,r,i=!0,a=[],c=`json`){let l=AbortSignal.timeout(s),u=r?.signal?AbortSignal.any([r.signal,l]):l,d=new Headers(t());r?.headers&&new Headers(r.headers).forEach((e,t)=>{d.set(t,e)}),r?.body!=null&&!d.has(`Content-Type`)&&d.set(`Content-Type`,`application/json`);let f;try{f=await fetch(e()+n,{...r,headers:d,signal:u})}catch(e){throw l.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new o(`Request timed out`,0):e}if(!f.ok&&!a.includes(f.status)){let e=`HTTP ${f.status}`;try{let t=await f.json();t?.error&&(e=t.error)}catch{}throw new o(e,f.status)}if(f.status===204)return;let p;try{p=await f.text()}catch(e){throw l.aborted&&!r?.signal?.aborted?new o(`Request timed out`,0):e}if(!p)return;if(c===`text`)return p;let m;try{m=JSON.parse(p)}catch{throw new o(`Invalid JSON response (HTTP ${f.status})`,f.status)}if(i&&m&&typeof m==`object`&&m.ok===!1){let e=m.error;throw new o(e??`Operation failed`,f.status)}return m}var l=a,u=(e,t)=>c(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),d=(e,t)=>c(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),f=e=>c(e,{method:`DELETE`}),p={overview:()=>c(`/dashboard`),queues:(e=200,t=0)=>c(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>c(`/dashboard/queues/${l(e)}?includeJobs=${t}`),stats:()=>c(`/stats`),storage:()=>c(`/storage`,void 0,!1),health:()=>c(`/health`,void 0,!1,[503]),healthz:()=>c(`/healthz`,void 0,!0,[],`text`),live:()=>c(`/live`,void 0,!0,[],`text`),ready:()=>c(`/ready`,void 0,!1,[503]),metrics:()=>c(`/metrics`),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),c(`/queues/${l(e)}/jobs/list?${n.toString()}`)},job:e=>c(`/jobs/${n(e)}`),cancelJob:e=>f(`/jobs/${n(e)}`),promoteJob:e=>u(`/jobs/${n(e)}/promote`),retryJob:e=>u(`/jobs/${n(e)}/move-to-wait`),pause:e=>u(`/queues/${l(e)}/pause`),resume:e=>u(`/queues/${l(e)}/resume`),drain:e=>u(`/queues/${l(e)}/drain`),obliterate:e=>u(`/queues/${l(e)}/obliterate`),clean:(e,t=0,n=1e3)=>u(`/queues/${l(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.2 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t)=>d(`/queues/${l(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>f(`/queues/${l(e)}/rate-limit`),setConcurrency:(e,t)=>d(`/queues/${l(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>f(`/queues/${l(e)}/concurrency`),dlq:(e,t=50,n=0)=>c(`/queues/${l(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>c(`/queues/${l(e)}/dlq/stats`),retryDlq:e=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.2 because the endpoint has no atomic flow-safety precondition.`)},purgeDlq:e=>u(`/queues/${l(e)}/dlq/purge`),crons:()=>c(`/crons`),deleteCron:e=>f(`/crons/${r(e,`Cron name`,256)}`),workers:()=>c(`/workers`),eventsUrl:t=>e()+(t?`/events/queues/${i(t)}`:`/events`)};export{p as t};
1
+ import{a as e,i as t}from"./connectionStore-BJLihGaC.js";import{a as n,n as r,r as i,s as a}from"./upstreamPaths-DQeKSxGc.js";var o=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`ApiError`}},s=3e4;async function c(n,r,i=!0,a=[],c=`json`){let l=AbortSignal.timeout(s),u=r?.signal?AbortSignal.any([r.signal,l]):l,d=new Headers(t());r?.headers&&new Headers(r.headers).forEach((e,t)=>{d.set(t,e)}),r?.body!=null&&!d.has(`Content-Type`)&&d.set(`Content-Type`,`application/json`);let f;try{f=await fetch(e()+n,{...r,headers:d,signal:u})}catch(e){throw l.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new o(`Request timed out`,0):e}if(!f.ok&&!a.includes(f.status)){let e=`HTTP ${f.status}`;try{let t=await f.json();t?.error&&(e=t.error)}catch{}throw new o(e,f.status)}if(f.status===204)return;let p;try{p=await f.text()}catch(e){throw l.aborted&&!r?.signal?.aborted?new o(`Request timed out`,0):e}if(!p)return;if(c===`text`)return p;let m;try{m=JSON.parse(p)}catch{throw new o(`Invalid JSON response (HTTP ${f.status})`,f.status)}if(i&&m&&typeof m==`object`&&m.ok===!1){let e=m.error;throw new o(e??`Operation failed`,f.status)}return m}var l=a,u=(e,t)=>c(e,{method:`POST`,body:t?JSON.stringify(t):void 0}),d=(e,t)=>c(e,{method:`PUT`,body:t?JSON.stringify(t):void 0}),f=e=>c(e,{method:`DELETE`}),p={overview:()=>c(`/dashboard`),queues:(e=200,t=0)=>c(`/dashboard/queues?limit=${e}&offset=${t}`),queueDetail:(e,t=!0)=>c(`/dashboard/queues/${l(e)}?includeJobs=${t}`),stats:()=>c(`/stats`),storage:()=>c(`/storage`,void 0,!1),health:()=>c(`/health`,void 0,!1,[503]),healthz:()=>c(`/healthz`,void 0,!0,[],`text`),live:()=>c(`/live`,void 0,!0,[],`text`),ready:()=>c(`/ready`,void 0,!1,[503]),metrics:()=>c(`/metrics`),jobsList:(e,t={})=>{let n=new URLSearchParams;return t.states?.length&&n.set(`states`,t.states.join(`,`)),n.set(`limit`,String(t.limit??50)),n.set(`offset`,String(t.offset??0)),c(`/queues/${l(e)}/jobs/list?${n.toString()}`)},job:e=>c(`/jobs/${n(e)}`),cancelJob:e=>f(`/jobs/${n(e)}`),promoteJob:e=>u(`/jobs/${n(e)}/promote`),retryJob:e=>u(`/jobs/${n(e)}/move-to-wait`),pause:e=>u(`/queues/${l(e)}/pause`),resume:e=>u(`/queues/${l(e)}/resume`),drain:e=>u(`/queues/${l(e)}/drain`),obliterate:e=>u(`/queues/${l(e)}/obliterate`),clean:(e,t=0,n=1e3)=>u(`/queues/${l(e)}/clean`,{grace:t,limit:n}),retryCompleted:e=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t)=>d(`/queues/${l(e)}/rate-limit`,{limit:t}),clearRateLimit:e=>f(`/queues/${l(e)}/rate-limit`),setConcurrency:(e,t)=>d(`/queues/${l(e)}/concurrency`,{concurrency:t}),clearConcurrency:e=>f(`/queues/${l(e)}/concurrency`),dlq:(e,t=50,n=0)=>c(`/queues/${l(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>c(`/queues/${l(e)}/dlq/stats`),retryDlq:e=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic flow-safety precondition.`)},purgeDlq:e=>u(`/queues/${l(e)}/dlq/purge`),crons:()=>c(`/crons`),deleteCron:e=>f(`/crons/${r(e,`Cron name`,256)}`),workers:()=>c(`/workers`),eventsUrl:t=>e()+(t?`/events/queues/${i(t)}`:`/events`)};export{p as t};
@@ -0,0 +1 @@
1
+ import{a as e,i as t,n,r}from"./connectionStore-BJLihGaC.js";import{a as i,i as a,n as o,r as s,s as c}from"./upstreamPaths-DQeKSxGc.js";var l=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`BqError`}},u=3e4,d=()=>u;async function f(e,t,n,r,i=!0,a=`server`,o=[],s=u){let c=AbortSignal.timeout(s),d=r?.signal?AbortSignal.any([r.signal,c]):c,f=new Headers(n);r?.headers&&new Headers(r.headers).forEach((e,t)=>{f.set(t,e)}),r?.body!=null&&!f.has(`Content-Type`)&&f.set(`Content-Type`,`application/json`);let p;try{p=await fetch(e+t,{...r,headers:f,signal:d})}catch(e){throw c.aborted&&!r?.signal?.aborted||e?.name===`TimeoutError`?new l(`Request timed out`,0):e}if(!p.ok&&!o.includes(p.status)){let t=`HTTP ${p.status}`;try{let e=await p.json();e?.error&&(t=e.error)}catch{}throw p.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:a,auth:f.get(`Authorization`)??void 0,target:e}})),new l(t,p.status)}if(p.status===204)return;let m;try{m=await p.text()}catch(e){throw c.aborted&&!r?.signal?.aborted?new l(`Request timed out`,0):e}if(!m)return;let h;try{h=JSON.parse(m)}catch{throw new l(`Invalid JSON response (HTTP ${p.status})`,p.status)}if(i&&h&&typeof h==`object`&&h.ok===!1)throw new l(h.error??`Operation failed`,p.status);return h}var p=(n,r,i=!0,a=[],o=u)=>f(e(),n,t(),r,i,`server`,a,o),m=()=>r(),h=(e,t,r=u)=>f(m(),e,n(),t,!0,`agent`,[],r),g=(e,t)=>({method:e,body:t===void 0?void 0:JSON.stringify(t)}),_=3e5,v=(e,t)=>g(e,t),y=new WeakMap,b=new WeakMap;function x(){let n=Object.freeze({baseUrl:e()});return y.set(n,Object.freeze({...t()})),n}function S(){let e=Object.freeze({baseUrl:m()});return b.set(e,Object.freeze({...n()})),e}function C(e){let t=y.get(e);if(!t)throw TypeError(`Invalid server request target.`);return t}function w(e){let t=b.get(e);if(!t)throw TypeError(`Invalid agent request target.`);return t}function ee(e,t){let n=Object.entries(e);return n.length===Object.keys(t).length&&n.every(([e,n])=>t[e]===n)}function te(n){let r=C(n);if(n.baseUrl!==e()||!ee(r,t()))throw Error(`Server connection changed after confirmation was requested for ${n.baseUrl}; action refused.`)}async function T(e,t,n){n?.throwIfAborted();let r=await f(e.baseUrl,`/jobs/${i(t)}`,{...C(e)},n?{signal:n}:void 0);return n?.throwIfAborted(),r}var E=encodeURIComponent,ne={info:()=>h(`/db/info`),tables:()=>h(`/db/tables`),schema:e=>h(`/db/tables/${o(e,`Database table`)}/schema`),rows:(e,t=50,n=0,r,i=`asc`,a)=>h(`/db/tables/${o(e,`Database table`)}?limit=${t}&offset=${n}${r?`&orderBy=${E(r)}&dir=${i}`:``}${a?.value?`&fcol=${E(a.column)}&fop=${a.op}&fval=${E(a.value)}`:``}`),cell:(e,t,n)=>h(`/db/tables/${o(e,`Database table`)}/cell?rowid=${E(String(t))}&column=${E(n)}`),query:e=>h(`/db/query`,g(`POST`,{sql:e}))},re={status:()=>h(`/control/status`),start:()=>h(`/control/start`,{method:`POST`}),stop:()=>h(`/control/stop`,{method:`POST`}),restart:()=>h(`/control/restart`,{method:`POST`}),logs:()=>h(`/control/logs`),getConfig:()=>h(`/control/config`),setConfig:(e,t)=>h(`/control/config`,g(`PUT`,{...e,...t===void 0?{}:{expectedRevision:t}}))},ie={stats:()=>h(`/workflows/stats`),list:(e={})=>{let t=new URLSearchParams;return e.kind&&t.set(`kind`,e.kind),e.workflowName&&t.set(`workflowName`,e.workflowName),e.state&&t.set(`state`,e.state),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),h(`/workflows${t.size?`?${t}`:``}`)},get:(e,t=`active`)=>h(`/workflows/${o(e,`Workflow execution id`)}?kind=${t}`)},ae=2e5,oe=16*1024*1024,se=12e4,ce=64*1024,D=encodeURIComponent;async function le(e,t,n=50,r=0,i,a=`asc`,s,c){c?.throwIfAborted();let l=await f(e.baseUrl,`/db/tables/${o(t,`Database table`)}?limit=${n}&offset=${r}${i?`&orderBy=${D(i)}&dir=${a}`:``}${s?.value?`&fcol=${D(s.column)}&fop=${s.op}&fval=${D(s.value)}`:``}`,{...w(e)},c?{signal:c}:void 0,!0,`agent`);return c?.throwIfAborted(),l}function O(e,t,n,r=!0){let i=e.get(t);if(!i||!/^\d+$/.test(i))throw new l(`Malformed database export response: invalid ${t} header.`,200);let a=Number(i);if(!Number.isSafeInteger(a)||a>n||!r&&a===0)throw new l(`Malformed database export response: invalid ${t} header.`,200);return a}async function ue(e){if(!e.body)return``;let t=e.body.getReader(),n=new Uint8Array(ce),r=0;try{for(;;){let e=await t.read();if(e.done)break;if(r+e.value.byteLength>n.byteLength)return t.cancel().catch(()=>void 0),``;n.set(e.value,r),r+=e.value.byteLength}}finally{t.releaseLock()}return new TextDecoder().decode(n.subarray(0,r))}async function de(e,t,n){if(!e.body)throw new l(`Malformed database export response: missing CSV body.`,200);let r=new Uint8Array(t),i=e.body.getReader(),a=0;try{for(;;){n?.throwIfAborted();let e=await i.read();if(e.done)break;if(a+e.value.byteLength>t)throw i.cancel().catch(()=>void 0),new l(`Malformed database export response: body exceeds declared ${t} bytes.`,200);r.set(e.value,a),a+=e.value.byteLength}}finally{i.releaseLock()}if(n?.throwIfAborted(),a!==t)throw new l(`Malformed database export response: received ${a} of ${t} declared bytes.`,200);return r}function fe(e){if(!e||typeof e!=`object`||Array.isArray(e))throw TypeError(`Invalid database export request.`);if(typeof e.table!=`string`||!e.table)throw TypeError(`Database export table must not be empty.`);if(e.dir!==`asc`&&e.dir!==`desc`)throw TypeError(`Invalid database export sort direction.`);if(e.orderBy!==void 0&&(typeof e.orderBy!=`string`||!e.orderBy))throw TypeError(`Database export sort column must not be empty.`);let t=e.filter;if(t&&(typeof t!=`object`||Array.isArray(t)||typeof t.column!=`string`||!t.column||typeof t.value!=`string`||!t.value||![`contains`,`eq`,`ne`].includes(t.op)))throw TypeError(`Invalid database export filter.`);return Object.freeze({table:e.table,orderBy:e.orderBy,dir:e.dir,filter:t?Object.freeze({...t}):void 0})}async function pe(e,t,n){e.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`agent`,auth:new Headers(n).get(`Authorization`)??void 0,target:t.baseUrl}}));let r=`HTTP ${e.status}`,i=await ue(e);if(i)try{let e=JSON.parse(i);typeof e?.error==`string`&&(r=e.error)}catch{}return new l(r,e.status)}async function me(e,t,n){n?.throwIfAborted();let r={...w(e)},i=fe(t),a=new URLSearchParams;i.orderBy&&a.set(`orderBy`,i.orderBy),a.set(`dir`,i.dir),i.filter&&(a.set(`fcol`,i.filter.column),a.set(`fop`,i.filter.op),a.set(`fval`,i.filter.value));let s=`/db/tables/${o(i.table,`Database table`)}/export?${a}`,c=AbortSignal.timeout(se),u=n?AbortSignal.any([n,c]):c;try{let t=await fetch(e.baseUrl+s,{headers:r,signal:u});if(!t.ok)throw await pe(t,e,r);if(t.headers.get(`X-Bunqueue-Db-Export-Version`)!==`1`)throw new l(`Malformed database export response: unsupported contract version.`,200);if(!/^text\/csv(?:;|$)/i.test(t.headers.get(`Content-Type`)??``))throw new l(`Malformed database export response: expected CSV content.`,200);let a;try{let e=t.headers.get(`X-Bunqueue-Db-Export-Table`);if(!e)throw Error(`missing`);a=decodeURIComponent(e)}catch{throw new l(`Malformed database export response: invalid table identity.`,200)}if(a!==i.table)throw new l(`Database export target changed: requested "${i.table}", received "${a}".`,200);let o=O(t.headers,`X-Bunqueue-Db-Export-Rows`,ae),c=O(t.headers,`X-Bunqueue-Db-Export-Bytes`,oe,!1);if(O(t.headers,`Content-Length`,16777216,!1)!==c)throw new l(`Malformed database export response: Content-Length does not match X-Bunqueue-Db-Export-Bytes.`,200);let d=t.headers.get(`X-Bunqueue-Db-Export-Cap`);if(d!==`none`&&d!==`rows`&&d!==`bytes`)throw new l(`Malformed database export response: invalid export cap.`,200);if(d===`rows`&&o!==2e5)throw new l(`Malformed database export response: inconsistent row cap.`,200);let f=await de(t,c,u);return n?.throwIfAborted(),{table:a,content:f,rowCount:o,bytes:c,cap:d===`none`?null:d}}catch(e){throw c.aborted&&!n?.aborted?new l(`Database export timed out`,0):e}}var he={counts:e=>p(`/queues/${c(e)}/counts`),pause:e=>p(`/queues/${c(e)}/pause`,g(`POST`)),resume:e=>p(`/queues/${c(e)}/resume`,g(`POST`)),drain:e=>p(`/queues/${c(e)}/drain`,v(`POST`),!0,[],_),obliterate:e=>p(`/queues/${c(e)}/obliterate`,v(`POST`),!0,[],_),clean:(e,t={})=>p(`/queues/${c(e)}/clean`,g(`POST`,t)),promoteJobs:(e,t)=>p(`/queues/${c(e)}/promote-jobs`,g(`POST`,t==null?void 0:{count:t})),retryCompleted:(e,t)=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.9.3 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t,n,r)=>p(`/queues/${c(e)}/rate-limit`,g(`PUT`,{limit:t,...n===void 0?{}:{duration:n},...r===void 0?{}:{ttl:r}})),clearRateLimit:e=>p(`/queues/${c(e)}/rate-limit`,{method:`DELETE`}),setConcurrency:(e,t)=>p(`/queues/${c(e)}/concurrency`,g(`PUT`,{concurrency:t})),clearConcurrency:e=>p(`/queues/${c(e)}/concurrency`,{method:`DELETE`}),getStallConfig:e=>p(`/queues/${c(e)}/stall-config`),setStallConfig:(e,t)=>p(`/queues/${c(e)}/stall-config`,g(`PUT`,{config:t})),getDlqConfig:e=>p(`/queues/${c(e)}/dlq-config`),setDlqConfig:(e,t)=>{if(t.autoRetry===!0)throw TypeError(`DLQ auto-retry is unavailable: Bunqueue v2.9.3 does not rebuild flow dependency registration.`);if(t.maxAge!==void 0||t.maxEntries!==void 0)throw TypeError(`DLQ retention is read-only: maxAge/maxEntries can destructively expire or evict flow jobs without an atomic dependency check.`);return p(`/queues/${c(e)}/dlq-config`,g(`PUT`,{config:t}))},dlq:(e,t=100,n=0)=>p(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),dlqStats:e=>p(`/queues/${c(e)}/dlq/stats`),retryDlq:(e,t)=>{throw TypeError(`DLQ retry is unavailable in Bunqueue v2.9.3 because the endpoint has no atomic job-generation, state, or flow-topology precondition.`)},purgeDlq:e=>p(`/queues/${c(e)}/dlq/purge`,g(`POST`))},k=()=>encodeURIComponent(e()),ge={limits:(e,t)=>{let n=t===void 0?``:`&maxJobs=${t}`;return h(`/queue-operations/${c(e)}/limits?target=${k()}${n}`)},group:(t,n,r,i,a,o)=>{let s=new URLSearchParams({target:e(),groupId:n});return r!==void 0&&s.set(`maxJobs`,String(r)),i!==void 0&&s.set(`maxCount`,String(i)),a!==void 0&&s.set(`start`,String(a)),o!==void 0&&s.set(`end`,String(o)),h(`/queue-operations/${c(t)}/groups?${s}`)},setGroupRateLimit:(e,t,n,r)=>h(`/queue-operations/${c(e)}/groups/rate-limit?target=${k()}`,g(`POST`,{groupId:t,max:n,duration:r})),removeGroupRateLimit:(e,t)=>h(`/queue-operations/${c(e)}/groups/rate-limit/remove?target=${k()}`,g(`POST`,{groupId:t})),setGroupConcurrency:(e,t,n)=>h(`/queue-operations/${c(e)}/groups/concurrency?target=${k()}`,g(`POST`,{groupId:t,concurrency:n})),removeGroupConcurrency:(e,t)=>h(`/queue-operations/${c(e)}/groups/concurrency/remove?target=${k()}`,g(`POST`,{groupId:t})),pauseGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/pause?target=${k()}`,g(`POST`,{groupId:t})),resumeGroup:(e,t)=>h(`/queue-operations/${c(e)}/groups/resume?target=${k()}`,g(`POST`,{groupId:t})),deduplicationJobId:(t,n)=>h(`/queue-operations/${c(t)}/deduplication?${new URLSearchParams({target:e(),deduplicationId:n})}`),removeDeduplicationKey:(e,t)=>h(`/queue-operations/${c(e)}/deduplication/remove?target=${k()}`,g(`POST`,{deduplicationId:t})),metrics:(t,n,r,i)=>h(`/queue-operations/${c(t)}/metrics?${new URLSearchParams({target:e(),type:n,start:String(r),end:String(i)})}`),trimEvents:(e,t)=>h(`/queue-operations/${c(e)}/events/trim?target=${k()}`,g(`POST`,{maxLength:t}))},A=1e4,_e=1e3,ve=864e13,ye=new Set([`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`,`job.stalled`]);function j(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function M(e,t,n=!1){if(typeof e!=`string`||e.length>t||!n&&e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<32||n===127)return!1}return!0}function N(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function be(e){return typeof e==`number`&&Number.isFinite(e)}function P(e){return N(e)&&e<=ve}function xe(e,t){return e===null||M(e,t)}function Se(e,t,n){if(!Array.isArray(e)||e.length>t)return!1;let r=new Set;for(let t of e){if(!M(t,n)||r.has(t))return!1;r.add(t)}return!0}function F(e,t){let n=j(e),r=n&&j(n.data);if(n?.ok!==!0||!r)throw Error(`Malformed ${t} response.`);return r}function I(e){if(!Array.isArray(e))throw Error(`Malformed queue summary response.`);let t=new Set,n=[];for(let r of e){let e=j(r),i=e&&j(e.counts);if(!e||!M(e.name,256)||t.has(e.name)||typeof e.paused!=`boolean`||!i||!N(i.waiting)||!N(i.prioritized)||!N(i.active)||!N(i.completed)||!N(i.failed)||!N(i.delayed))throw Error(`Malformed queue summary response.`);t.add(e.name),n.push(r)}return n}function L(e){let t=F(e,`workers`);if(!Array.isArray(t.workers)||t.workers.length>A)throw Error(`Malformed workers response.`);let n=new Set,r=[],i=[];for(let e=0;e<t.workers.length;e++){let a=t.workers[e],o=j(a),s=o&&typeof o.id==`string`?o.id:null,c=[];if(o?(M(o.id,1024)?n.has(o.id)&&c.push(`duplicate id`):c.push(`id`),M(o.name,512,!0)||c.push(`name`),Se(o.queues,_e,256)||c.push(`queues`),(!N(o.concurrency)||o.concurrency<1)&&c.push(`concurrency`),M(o.hostname,512,!0)||c.push(`hostname`),N(o.pid)||c.push(`pid`),o.status!==`active`&&o.status!==`stale`&&c.push(`status`),P(o.registeredAt)||c.push(`registeredAt`),P(o.lastSeen)||c.push(`lastSeen`),N(o.activeJobs)||c.push(`activeJobs`),N(o.processedJobs)||c.push(`processedJobs`),N(o.failedJobs)||c.push(`failedJobs`),xe(o.currentJob,1024)||c.push(`currentJob`),be(o.uptime)||c.push(`uptime`)):c.push(`entry is not an object`),s&&n.add(s),c.length>0){i.push({index:e,id:s,reason:c.join(`, `)});continue}r.push(a)}return{ok:!0,data:{workers:r,quarantinedWorkers:i,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}function Ce(e){if(!M(e,2048))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function we(e){let t=F(e,`webhooks`);if(!Array.isArray(t.webhooks)||t.webhooks.length>A)throw Error(`Malformed webhooks response.`);let n=new Set,r=[];for(let e of t.webhooks){let t=j(e);if(!t||!M(t.id,1024)||n.has(t.id)||!Ce(t.url)||!Array.isArray(t.events)||!t.events.every(e=>ye.has(e))||!(t.queue===null||typeof t.queue==`string`)||!P(t.createdAt)||!(t.lastTriggered===null||P(t.lastTriggered))||!N(t.successCount)||!N(t.failureCount)||typeof t.enabled!=`boolean`)throw Error(`Malformed webhooks response.`);n.add(t.id),r.push(e)}return{ok:!0,data:{webhooks:r,...Object.hasOwn(t,`stats`)?{stats:t.stats}:{}}}}var Te={crons:()=>p(`/crons`),createCron:e=>p(`/crons`,g(`POST`,e)),deleteCron:e=>p(`/crons/${o(e,`Cron name`,256)}`,{method:`DELETE`}),webhooks:async()=>we(await p(`/webhooks`)),addWebhook:e=>p(`/webhooks`,g(`POST`,e)),removeWebhook:e=>p(`/webhooks/${i(e)}`,{method:`DELETE`}),setWebhookEnabled:(e,t)=>p(`/webhooks/${i(e)}/enabled`,g(`PUT`,{enabled:t})),workers:async()=>L(await p(`/workers`)),unregisterWorker:e=>p(`/workers/${i(e)}`,{method:`DELETE`}),eventsUrl:t=>e()+(t?`/events/queues/${s(t)}`:`/events`)},R=365*24*60*60*1e3,z=2097151,B=64*1024*1024,V=1e4,Ee=[`childrenIds`,`parentId`,`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`,`keepLogs`,`sizeLimit`,`debounceId`,`debounceTtl`];function H(e){if(e===void 0)return;if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError(`Repeat must be an object with a positive "every" interval`);let t=Object.keys(e).filter(e=>e!==`every`&&e!==`limit`);if(t.length)throw TypeError(`Unsupported repeat option(s): ${t.join(`, `)}. bunqueue v2.9.3 pattern repeats are unsafe; use the Cron API instead.`);if(!Number.isSafeInteger(e.every)||e.every<1||e.every>R)throw TypeError(`Repeat "every" must be a whole number from 1 to ${R} ms`);if(e.limit!==void 0&&(!Number.isSafeInteger(e.limit)||e.limit<1))throw TypeError(`Repeat "limit" must be a whole number of at least 1`)}function U(e){if(e!==void 0&&(typeof e!=`string`||!e||e.length>256))throw TypeError(`Job name must be a non-empty string of at most 256 characters`)}function W(e){let t=e,n=Ee.filter(e=>t[e]!==void 0);if(n.length)throw TypeError(`Unsupported Bunqueue v2.9.3 enqueue option(s): ${n.join(`, `)}. Flow topology must use the atomic flow API; inert compatibility fields are not sent.`)}function G(e){let t=e.groupId;if(t!==void 0&&(typeof t!=`string`||!t||t.length>256||t.includes(`\0`)))throw TypeError(`groupId must be a non-empty string of at most 256 characters without NUL`);if(e.groupMaxSize!==void 0){if(t===void 0)throw TypeError(`groupMaxSize requires groupId`);if(!Number.isSafeInteger(e.groupMaxSize)||e.groupMaxSize<1)throw TypeError(`groupMaxSize must be a positive safe integer`)}if(t!==void 0&&e.priority!==void 0&&(!Number.isSafeInteger(e.priority)||e.priority<0||e.priority>z))throw TypeError(`Grouped priority must be an integer from 0 to ${z}`)}function K(e,t){let n=a(t);if(n)throw TypeError(`${e}: ${n}. The job would not be manageable through v2.9.3 HTTP.`)}function De(e){if(U(e.name),H(e.repeat),W(e),G(e),e.groupMaxSize!==void 0)throw TypeError(`groupMaxSize is not forwarded by Bunqueue 2.9.3 single-job HTTP; use the bulk transport`);if(e.dependsOn!==void 0&&(!Array.isArray(e.dependsOn)||!e.dependsOn.every(e=>typeof e==`string`)))throw TypeError(`dependsOn must be an array of job ID strings`);e.jobId!==void 0&&K(`jobId`,e.jobId);for(let t of e.dependsOn??[])K(`dependsOn`,t)}function Oe(e){let t;try{t=JSON.stringify(e)}catch{throw TypeError(`Job payload must be JSON serializable`)}if(t===void 0)throw TypeError(`Job payload must be JSON serializable`);let n;try{n=JSON.parse(t)}catch{throw TypeError(`Job payload encoding failed`)}if(typeof n!=`object`||!n||Array.isArray(n))throw TypeError(`Job payload must serialize to a JSON object`);return De(n),t}function ke({jobId:e,...t}){return e===void 0?t:{...t,customId:e}}function Ae(e){let t=JSON.parse(e);if(typeof t!=`object`||!t||Array.isArray(t))throw TypeError(`must serialize to a JSON object`);let n=t;if(n.jobId!==void 0)throw TypeError(`serialized jobId is invalid; the bulk transport requires customId`);if(U(n.name),H(n.repeat),W(n),G(n),n.customId!==void 0){if(typeof n.customId!=`string`)throw TypeError(`customId must be a string`);K(`customId`,n.customId)}if(n.dependsOn!==void 0){if(!Array.isArray(n.dependsOn)||!n.dependsOn.every(e=>typeof e==`string`))throw TypeError(`dependsOn must be an array of job ID strings`);for(let e of n.dependsOn)K(`dependsOn`,e)}}function je(e,t){let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);if(i<=127?n+=1:i<=2047?n+=2:i>=55296&&i<=56319&&r+1<e.length&&e.charCodeAt(r+1)>=56320&&e.charCodeAt(r+1)<=57343?(n+=4,r+=1):n+=3,n>t)return n}return n}function q(e,t,n){if(!Array.isArray(e)||e.length>1e4)return{ok:!1,error:`Bulk request must contain at most ${V} jobs`};if(!Number.isSafeInteger(t)||t<0)return{ok:!1,error:`Bulk request payload limit is invalid`};let r=11,i=n?Array(e.length):null;for(let a=0;a<e.length;a++){if(a&&(r+=1),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};let o;try{o=JSON.stringify(ke(e[a]))}catch{return{ok:!1,error:`Bulk request payload must be JSON serializable`}}if(o===void 0)return{ok:!1,error:`Bulk request payload must be JSON serializable`};if(r+=je(o,t-r),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};if(n)try{Ae(o)}catch(e){return{ok:!1,error:`Bulk job ${a+1}: ${e instanceof Error?e.message:String(e)}`}}i&&(i[a]=o)}return{ok:!0,bytes:r,body:i?`{"jobs":[${i.join(`,`)}]}`:void 0}}function Me(e,t=B){let n=q(e,t,!1);return n.ok?null:n.error}function J(e){let t=q(e,B,!0);if(!t.ok)throw TypeError(t.error);if(t.body===void 0)throw TypeError(`Bulk request payload encoding failed`);return t.body}function Y(e){if(!Array.isArray(e)||e.length>1e4)throw TypeError(`Bulk request must contain at most ${V} jobs`)}var Ne={overview:e=>p(`/dashboard`,e),queues:(e=500,t=0)=>p(`/dashboard/queues?limit=${e}&offset=${t}`),queuesSummary:async()=>I(await p(`/queues/summary`)),queueDetail:(e,t=!0)=>p(`/dashboard/queues/${c(e)}?includeJobs=${t}`),stats:e=>p(`/stats`,e),storage:()=>p(`/storage`,void 0,!1),health:()=>p(`/health`,void 0,!1,[503]),ping:()=>p(`/ping`),prometheusUrl:()=>`${e()}/prometheus`,gc:()=>p(`/gc`,g(`POST`)),heapStats:()=>p(`/heapstats`)},Pe={jobsList:(e,t,n=50,r=0)=>{let i=new URLSearchParams;return t?.length&&i.set(`states`,t.join(`,`)),i.set(`limit`,String(n)),i.set(`offset`,String(r)),p(`/queues/${c(e)}/jobs/list?${i}`)},job:e=>p(`/jobs/${i(e)}`),jobByCustomId:e=>p(`/jobs/custom/${o(e,`Custom job ID`)}`),jobResult:e=>p(`/jobs/${i(e)}/result`),jobLogs:e=>p(`/jobs/${i(e)}/logs`),jobChildren:e=>p(`/jobs/${i(e)}/children`),addJob:async(e,t)=>p(`/queues/${c(e)}/jobs`,{method:`POST`,body:Oe(t)}),addJobsBulk:async(e,t)=>(Y(t),p(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:J(t)},!0,[],_)),pullBatch:(e,t,n)=>p(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),ackBatch:(e,t)=>p(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),cancelJob:e=>p(`/jobs/${i(e)}`,{method:`DELETE`}),promoteJob:e=>p(`/jobs/${i(e)}/promote`,g(`POST`)),discardJob:e=>p(`/jobs/${i(e)}/discard`,g(`POST`)),retryJob:e=>p(`/jobs/${i(e)}/move-to-wait`,g(`POST`)),failJob:(e,t,n={})=>p(`/jobs/${i(e)}/fail`,g(`POST`,{error:t,...n})),updateJobData:(e,t)=>p(`/jobs/${i(e)}/data`,g(`PUT`,{data:t})),changePriority:(e,t,n)=>p(`/jobs/${i(e)}/priority`,g(`PUT`,{priority:t,...n===void 0?{}:{lifo:n}})),changeDelay:(e,t)=>p(`/jobs/${i(e)}/delay`,g(`PUT`,{delay:t})),moveToDelayed:(e,t)=>p(`/jobs/${i(e)}/move-to-delayed`,g(`POST`,{delay:t})),addJobLog:(e,t,n)=>p(`/jobs/${i(e)}/logs`,g(`POST`,{message:t,level:n})),clearJobLogs:e=>p(`/jobs/${i(e)}/logs`,{method:`DELETE`}),setJobProgress:(e,t,n)=>p(`/jobs/${i(e)}/progress`,g(`POST`,{progress:t,message:n}))};function X(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw new l(`Malformed ${t} response.`,200);return e}function Z(e,t){let n=X(e,t);if(n.ok!==!0)throw new l(`Malformed ${t} response.`,200);return n}var Q=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function $(e,t){if(e!==void 0)return Z(e,t)}function Fe(e,t){let n={...C(e)},r=(r,i,a=d())=>{let o=t?{...i,signal:i?.signal?AbortSignal.any([i.signal,t]):t}:i;return f(e.baseUrl,r,n,o,!0,`server`,[],a)};return Object.freeze({queuesSummary:async()=>I(await r(`/queues/summary`)),overview:()=>r(`/dashboard`),counts:async e=>{let t=X(Z(await r(`/queues/${c(e)}/counts`),`queue counts`).counts,`queue counts`);if(!Object.values(t).every(Q))throw new l(`Malformed queue counts response.`,200);return{ok:!0,counts:t}},jobsList:async(e,t,n=50,i=0)=>{let a=new URLSearchParams;t?.length&&a.set(`states`,t.join(`,`)),a.set(`limit`,String(n)),a.set(`offset`,String(i));let o=Z(await r(`/queues/${c(e)}/jobs/list?${a}`),`jobs list`);if(!Array.isArray(o.jobs)||!o.jobs.every(t=>{let n=t;return typeof n==`object`&&!!n&&!Array.isArray(n)&&typeof n.id==`string`&&n.id.length>0&&(n.queue===void 0||n.queue===e)}))throw new l(`Malformed jobs list response.`,200);return{ok:!0,jobs:o.jobs}},job:async e=>{let t=X(Z(await r(`/jobs/${i(e)}`),`job`).job,`job`);if(t.id!==e)throw new l(`Malformed job response.`,200);return{ok:!0,job:t}},dlqStats:async e=>{let t=X(Z(await r(`/queues/${c(e)}/dlq/stats`),`DLQ stats`).stats,`DLQ stats`);if(!Q(t.total))throw new l(`Malformed DLQ stats response.`,200);return{ok:!0,stats:t}},dlq:async(e,t=100,n=0)=>{let i=Z(await r(`/queues/${c(e)}/dlq?limit=${t}&offset=${n}`),`DLQ list`);if(!Array.isArray(i.entries)||!Q(i.total))throw new l(`Malformed DLQ list response.`,200);for(let e of i.entries){let t=X(X(e,`DLQ list`).job,`DLQ list`);if(typeof t.id!=`string`||!t.id)throw new l(`Malformed DLQ list response.`,200)}return{ok:!0,entries:i.entries,total:i.total}},health:async()=>X(await f(e.baseUrl,`/health`,n,t?{signal:t}:void 0,!1,`server`,[503]),`health`),stats:async()=>{let e=await r(`/stats`);return X(Z(e,`server stats`).stats,`server stats`),e},workers:async()=>L(await r(`/workers`)),crons:async()=>{let e=Z(await r(`/crons`),`crons`);if(!Array.isArray(e.crons)||!e.crons.every(e=>{let t=e;return typeof t==`object`&&!!t&&!Array.isArray(t)&&typeof t.name==`string`&&!!t.name&&typeof t.queue==`string`&&!!t.queue}))throw new l(`Malformed crons response.`,200);return{ok:!0,crons:e.crons}},addJobsBulk:async(e,t)=>(Y(t),r(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:J(t)},_)),pullBatch:(e,t,n)=>r(`/queues/${c(e)}/jobs/pull-batch`,g(`POST`,{count:t,...n?{owner:n}:{}})),heartbeatBatch:(e,t)=>r(`/jobs/heartbeat-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),ackBatch:(e,t)=>r(`/jobs/ack-batch`,g(`POST`,{ids:e,...t?{tokens:t}:{}})),retryJob:(e,t)=>r(`/jobs/${i(e)}/move-to-wait`,g(`POST`,t?{token:t}:{})),promoteJob:async e=>$(await r(`/jobs/${i(e)}/promote`,g(`POST`)),`promote job`),pause:async e=>$(await r(`/queues/${c(e)}/pause`,g(`POST`)),`pause queue`),resume:async e=>$(await r(`/queues/${c(e)}/resume`,g(`POST`)),`resume queue`),clean:(e,t={})=>r(`/queues/${c(e)}/clean`,g(`POST`,t))})}var Ie={...Ne,captureServerRequestTarget:x,createServerTargetClient:Fe,getJobAtTarget:T,captureAgentRequestTarget:S,getDbRowsAtTarget:le,getDbExportAtTarget:me,...Pe,...he,queueOperations:ge,...Te,db:ne,get agentBase(){return m()},control:re,workflows:ie};Object.defineProperty(Ie,"agentBase",{configurable:!1});export{l as a,te as c,x as d,T as f,oe as i,f as l,Fe as n,w as o,Me as r,h as s,Ie as t,S as u};
@@ -1 +1 @@
1
- var e=`Unavailable in Bunqueue v2.9.2: the server cannot inspect reverse flow dependencies or delete/discard topology atomically.`,t=`DLQ retry is unavailable in Bunqueue v2.9.2: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`,n=t,r=`Completed-job requeue is unavailable in Bunqueue v2.9.2 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`,i=`DLQ max age and max entries are read-only: changing them can expire or immediately evict a flow child without an atomic reverse-dependency check.`;export{n as a,i,r as n,e as r,t};
1
+ var e=`Unavailable in Bunqueue v2.9.3: the server cannot inspect reverse flow dependencies or delete/discard topology atomically.`,t=`DLQ retry is unavailable in Bunqueue v2.9.3: its GET and retry POST have no atomic job-generation, state, or flow-topology precondition.`,n=t,r=`Completed-job requeue is unavailable in Bunqueue v2.9.3 because retry-completed re-inserts a child without rebuilding its flow dependency registration.`,i=`DLQ max age and max entries are read-only: changing them can expire or immediately evict a flow child without an atomic reverse-dependency check.`;export{n as a,i,r as n,e as r,t};
@@ -0,0 +1 @@
1
+ function e(e){let t=e===`waiting`||e===`delayed`||e===`prioritized`;return{cancel:!1,discard:!1,promote:e===`delayed`,retryDlq:!1,requeueCompleted:!1,setPriority:t,setDelay:t}}function t(e){return e===`updateData`?`Flow data is read-only: replacing the payload can remove dependency metadata.`:e===`retry`?`Flow retry is unavailable: Bunqueue has no atomic job-generation or state precondition.`:e===`remove`||e===`removeUnprocessedChildren`?`Flow removal is unavailable: Bunqueue cannot atomically protect reverse dependencies.`:null}function n(e){let n=t(e);if(n)throw Error(n)}export{n,t as r,e as t};