bunqueue-dashboard 0.0.37 → 0.0.38
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.
- package/README.md +5 -3
- package/dist/.vite/manifest.json +114 -114
- package/dist/assets/{AddJob-CWkkVHmf.js → AddJob-CC4bfHLH.js} +1 -1
- package/dist/assets/{Alerts-Gh1pVbqj.js → Alerts-C2bAi-Kj.js} +1 -1
- package/dist/assets/{Benchmark-Dir2A1CQ.js → Benchmark-ClJmYZoC.js} +1 -1
- package/dist/assets/{BulkAddJobs-Di_IgRSH.js → BulkAddJobs-BBWqQpP7.js} +1 -1
- package/dist/assets/{CopilotPanel-Db5nYpo1.js → CopilotPanel-Bhh-uCpN.js} +3 -3
- package/dist/assets/{Cron-BRgWcBGk.js → Cron-pJJ5KXFG.js} +1 -1
- package/dist/assets/{CronManager-CbM0x_s0.js → CronManager-lNZ4lHh1.js} +1 -1
- package/dist/assets/{Database-BeoEreW0.js → Database-DxiXsUl4.js} +1 -1
- package/dist/assets/{Diagnostics-Cw9iJ84f.js → Diagnostics-DLvCT7zI.js} +1 -1
- package/dist/assets/{Dlq-DfCg04Jd.js → Dlq-Bx4YXTp5.js} +1 -1
- package/dist/assets/{DlqControl-BRCkUXvb.js → DlqControl-DJGhuyu3.js} +1 -1
- package/dist/assets/{DlqPro-BHJwBYsN.js → DlqPro-BhXIKtrt.js} +1 -1
- package/dist/assets/{Flows-BAzbFP_W.js → Flows-Bb9j-YhZ.js} +1 -1
- package/dist/assets/{JobInspector-qvW_APO6.js → JobInspector-DfqBq4O5.js} +2 -2
- package/dist/assets/{Jobs-URpnFjC6.js → Jobs-Blavwd1H.js} +1 -1
- package/dist/assets/{JobsPro-pQ_RFSU3.js → JobsPro-D8dH9um7.js} +1 -1
- package/dist/assets/{Logs-C5jX2OPE.js → Logs-B3dsGSF8.js} +1 -1
- package/dist/assets/{LogsPro-Cq_npmmS.js → LogsPro-BCB7etG2.js} +1 -1
- package/dist/assets/{McpServer-DtCTmQBu.js → McpServer-Cz1-GwD5.js} +1 -1
- package/dist/assets/{Metrics-BdxitePr.js → Metrics-Bkuy6Ntb.js} +1 -1
- package/dist/assets/{MetricsPro-orHfW0mg.js → MetricsPro-BbJmy0oO.js} +1 -1
- package/dist/assets/{Overview-DaNns1aj.js → Overview-Ba5odzYe.js} +1 -1
- package/dist/assets/{QueueActions-jiTzndPH.js → QueueActions-B6M0ByGt.js} +1 -1
- package/dist/assets/{QueueControl-l5bSdMgb.js → QueueControl-CWHsVfWU.js} +1 -1
- package/dist/assets/{QueueDetail-URK2pjtH.js → QueueDetail-BClRbWC5.js} +1 -1
- package/dist/assets/{QueueDetailPro-C9M5CV4K.js → QueueDetailPro-CIimG0pX.js} +1 -1
- package/dist/assets/{Queues-DeLXlww2.js → Queues-CGPgEkVm.js} +1 -1
- package/dist/assets/{QueuesOverview-DoQ-MUfT.js → QueuesOverview-ChC5Dtqh.js} +1 -1
- package/dist/assets/{S3Backup-D2agV9_z.js → S3Backup-5OKa8G13.js} +1 -1
- package/dist/assets/S3BackupPro-BkwTXdtw.js +3 -0
- package/dist/assets/{ServerControl-QVd6m_iR.js → ServerControl-DJHKMaf9.js} +1 -1
- package/dist/assets/{Settings-CiJRj_SM.js → Settings-C1HtCK6h.js} +1 -1
- package/dist/assets/{Usage-DbHJgA4t.js → Usage-QyZkUhgs.js} +1 -1
- package/dist/assets/{UsagePro-LoPo3k1L.js → UsagePro-DMxrXxur.js} +1 -1
- package/dist/assets/{Webhooks-CuzIJHwk.js → Webhooks-D0JQQf0q.js} +1 -1
- package/dist/assets/{Workers-BpUgpwUH.js → Workers-Cn8Bkgy1.js} +1 -1
- package/dist/assets/{WorkersPro-BYY0P1Pt.js → WorkersPro-BOTuX9EP.js} +1 -1
- package/dist/assets/{Workflows-ByJw4FFH.js → Workflows-DqTKWPmT.js} +1 -1
- package/dist/assets/bq-Bmysbg0r.js +1 -0
- package/dist/assets/index-Cue53Myw.js +8 -0
- package/dist/assets/install-CFiYX86d.js +3 -0
- package/dist/assets/{usePolledData-c53tx1jw.js → usePolledData-g80Z_UB-.js} +1 -1
- package/dist/assets/useThroughputSeries-CrsZYKbT.js +1 -0
- package/dist/index.html +3 -3
- package/package.json +10 -5
- package/scripts/embedded.gen.ts +142 -142
- package/dist/assets/S3BackupPro--WSZWTQn.js +0 -3
- package/dist/assets/bq-DYmbVkgR.js +0 -1
- package/dist/assets/index-D64v2vNO.js +0 -8
- package/dist/assets/install-jXi1SOYY.js +0 -3
- package/dist/assets/useThroughputSeries-DWHQl7cM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-
|
|
1
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{g as n,t as r}from"./react-vendor-CyjgmGTq.js";import{t as i}from"./bq-Bmysbg0r.js";import{A as a,O as o}from"./icons-CIvFfU2b.js";import{n as s}from"./usePolledData-g80Z_UB-.js";import{n as c}from"./Button-BPqpRZJD.js";import{i as l,n as u,r as d,t as f}from"./feedback-BnGE2oW2.js";import{t as p}from"./PageHeader-BXlZSBcc.js";import{l as m,s as h}from"./format-Cg7VCIZW.js";import{n as g}from"./index-Cue53Myw.js";import{r as _,t as v}from"./useServerActionGuard-OTv6_fU0.js";var y=e(n(),1),b=r(),x=100,S=`No heartbeat recently — derived from lastSeen`;function C(){let{data:e,error:n,loading:r,refetch:C}=s(async()=>(await i.workers()).data,[]),[T,E]=(0,y.useState)(new Set),[D,O]=(0,y.useState)(null),[k,A]=(0,y.useState)(null),j=_(`workers-pro`);if((0,y.useEffect)(()=>{E(new Set),O(null)},[j.scopeKey]),r&&!e&&!n)return(0,b.jsx)(d,{label:`Loading workers…`});if(n&&!e)return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Worker inventory is unavailable.`}),(0,b.jsx)(u,{error:n,onRetry:C})]});let M=e?.workers??[],N=e?.quarantinedWorkers??[],P=(k?[...M].sort((e,t)=>{let n=k.key===`failed`?e.failedJobs??0:e.lastSeen??0,r=k.key===`failed`?t.failedJobs??0:t.lastSeen??0;return k.dir===`asc`?n-r:r-n}):M).slice(0,x),F=e=>A(t=>t?.key===e?{key:e,dir:t.dir===`desc`?`asc`:`desc`}:{key:e,dir:`desc`}),I=M.filter(e=>e.status===`active`).length,L=M.length-I,R=M.reduce((e,t)=>e+(t.activeJobs??0),0),z=async e=>{if(!window.confirm(`Remove the stale registry record for worker "${e}"? This does not stop the worker process. Continue only after confirming that process is stopped; Bunqueue v2.8.59 workers do not automatically re-register after their heartbeat record is removed.`))return;let t=j.begin(`worker:${e}`);if(t){E(t=>new Set(t).add(e)),O(null);try{if(v(await i.unregisterWorker(e),`Remove stale worker registry record`),!t.isCurrent())return;O({ok:!0,text:`Removed stale registry record for ${e} ✓`}),C()}catch(e){if(!t.isCurrent())return;O({ok:!1,text:`Removal failed: ${e.message}`})}finally{t.finish()&&E(t=>{let n=new Set(t);return n.delete(e),n})}}};return(0,b.jsxs)(`div`,{children:[(0,b.jsx)(p,{title:`Workers`,description:`Registered workers and their throughput.`,live:!!e&&!n}),n&&(0,b.jsx)(l,{message:`Worker refresh failed — showing the last successful inventory.`,onRetry:C}),(0,b.jsxs)(`div`,{className:`mb-6 grid grid-cols-2 gap-4 md:grid-cols-5`,children:[(0,b.jsx)(g,{label:`Total`,value:h(M.length+N.length),compact:!0}),(0,b.jsx)(g,{label:`Active`,value:h(I),tone:`green`,compact:!0}),(0,b.jsx)(`div`,{title:S,children:(0,b.jsx)(g,{label:`Stale`,value:h(L),tone:L?`amber`:`default`,compact:!0})}),(0,b.jsx)(g,{label:`Active Jobs`,value:h(R),tone:`blue`,compact:!0}),(0,b.jsx)(g,{label:`Quarantined`,value:h(N.length),tone:N.length?`red`:`default`,compact:!0})]}),N.length>0&&(0,b.jsxs)(`div`,{role:`alert`,className:`mb-4 rounded-lg border border-danger/30 bg-danger/5 p-4`,children:[(0,b.jsxs)(`p`,{className:`text-sm font-medium text-danger`,children:[N.length,` worker registration(s) contain values accepted by Bunqueue 2.8.59 but unsafe to render. Healthy workers remain available below.`]}),(0,b.jsx)(`p`,{className:`mt-1 text-xs text-muted`,children:`Their status and active-job count are unknown, so this dashboard will not offer the registry-only removal action for them.`}),(0,b.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-muted`,children:N.slice(0,20).map(e=>(0,b.jsxs)(`li`,{className:`truncate font-mono`,children:[`#`,e.index+1,` `,e.id??`(unaddressable id)`,` — `,e.reason]},`${e.index}:${e.id??`unknown`}`))})]}),D&&(0,b.jsx)(`div`,{className:t(`mb-3 text-sm`,D.ok?`text-success`:`text-danger`),children:D.text}),M.length===0?(0,b.jsx)(f,{icon:(0,b.jsx)(a,{}),title:N.length?`No renderable workers`:`No workers registered`,hint:N.length?`Malformed registrations are isolated above instead of taking down the inventory.`:`Workers appear here once they connect and register with the server.`}):(0,b.jsx)(`div`,{className:`overflow-x-auto rounded-xl border border-line bg-surface`,children:(0,b.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,b.jsx)(`thead`,{children:(0,b.jsxs)(`tr`,{className:`border-b border-line text-left text-[11px] uppercase tracking-wider text-faint`,children:[(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Worker`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Queues`}),(0,b.jsx)(`th`,{className:`px-5 py-3 font-medium`,children:`Status`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Active`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:`Processed`}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Failed`,active:k?.key===`failed`?k.dir:null,onClick:()=>F(`failed`)})}),(0,b.jsx)(`th`,{className:`px-5 py-3 text-right font-medium`,children:(0,b.jsx)(w,{label:`Last Seen`,active:k?.key===`lastSeen`?k.dir:null,onClick:()=>F(`lastSeen`)})}),(0,b.jsx)(`th`,{className:`w-16 px-5 py-3 text-right font-medium`,children:`Actions`})]})}),(0,b.jsx)(`tbody`,{children:P.map(e=>(0,b.jsxs)(`tr`,{className:`border-b border-line last:border-0 hover:bg-surface-2/40`,children:[(0,b.jsxs)(`td`,{className:`px-5 py-3`,children:[(0,b.jsx)(`div`,{className:`font-medium text-fg`,children:e.name||`worker`}),(0,b.jsx)(`div`,{className:`font-mono text-[11px] text-faint`,children:e.id})]}),(0,b.jsx)(`td`,{className:`px-5 py-3 font-mono text-xs text-muted`,children:e.queues.join(`, `)||`—`}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`span`,{title:e.status===`active`?void 0:S,className:t(`rounded-full px-2 py-0.5 text-[11px] font-medium`,e.status===`active`?`bg-emerald-500/10 text-success`:`bg-amber-500/10 text-warning`),children:e.status})}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-blue-400`,children:h(e.activeJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.processedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right tnum text-muted`,children:h(e.failedJobs)}),(0,b.jsx)(`td`,{className:`px-5 py-3 text-right text-faint`,children:m(e.lastSeen)}),(0,b.jsx)(`td`,{className:`px-5 py-3`,children:(0,b.jsx)(`div`,{className:`flex justify-end`,children:e.status===`stale`&&e.activeJobs===0?(0,b.jsx)(c,{"aria-label":`Remove stale registry record for worker ${e.id}`,title:`Registry cleanup only — does not stop the worker process`,disabled:T.has(e.id),onClick:()=>z(e.id),children:(0,b.jsx)(o,{className:`size-3.5`})}):(0,b.jsx)(`span`,{className:`text-xs text-faint`,title:e.status===`stale`?`Registry cleanup is blocked while active jobs are reported`:`Only stale, idle registry records can be removed`,children:`—`})})})]},e.id))})]})}),M.length>x&&(0,b.jsxs)(`p`,{className:`mt-3 text-xs text-warning`,children:[`Showing first `,h(x),` of `,h(M.length),` workers.`]})]})}function w({label:e,active:n,onClick:r}){return(0,b.jsxs)(`button`,{type:`button`,onClick:r,title:`Sort by ${e}`,className:t(`inline-flex items-center gap-1 uppercase tracking-wider transition-colors hover:text-fg`,n?`text-fg`:`text-faint`),children:[e,(0,b.jsx)(`span`,{"aria-hidden":`true`,children:n===`desc`?`↓`:n===`asc`?`↑`:``})]})}export{C as WorkersPro};
|
|
@@ -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-CyjgmGTq.js";import{i as o}from"./connectionStore-CKFQrxDo.js";import{t as s}from"./upstreamPaths-CDVsu6IM.js";import{o as c,t as l}from"./bq-DYmbVkgR.js";import{t as u}from"./toastStore-B7n0zS0y.js";import{n as d}from"./usePolledData-c53tx1jw.js";import{t as f}from"./Card-C7NMhqUt.js";import{i as p,n as m,r as h,t as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./StatusBadge-B0I7hNBX.js";import{t as v}from"./PageHeader-BXlZSBcc.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-JM4omZ6j.js";var w={"/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 w[e]??w[`/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 T=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 E=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function D(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:se(e.get(`workflow`)),a=le(e.get(`state`),t),o=t.id===`overview`?0:ce(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&&E.has(u)?u:`summary`}}function O(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 k(e,t,n){return O(t,{...D(e,t),...n})}function A(e){return E.has(e)}function se(e){return e&&e.length<=256?e:``}function ce(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 le(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 ue=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(ue(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},de={stats:()=>l.workflows.stats(),list:e=>l.workflows.list(e),get:(e,t)=>l.workflows.get(e,t)};function fe(e){let[t,r]=n(),i=t.toString(),a=(0,T.useMemo)(()=>D(new URLSearchParams(i),e),[i,e]),o=(0,T.useMemo)(()=>O(e,a).toString(),[e,a]),s=(0,T.useRef)(null);(0,T.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,T.useCallback)((t,n=!1)=>{r(n=>k(n,e,t),{replace:n})},[e,r]),l=(0,T.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=(0,T.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),r=(0,T.useRef)(e);r.current=e;let i=(0,T.useRef)(!1),a=(0,T.useRef)(!0),o=(0,T.useRef)(n),s=(0,T.useRef)(0);Object.is(o.current,n)||(o.current=n,s.current+=1,i.current=!1);let[c,l]=(0,T.useState)(()=>I(n));(0,T.useEffect)(()=>(a.current=!0,()=>{a.current=!1,s.current+=1,i.current=!1}),[]);let u=(e,t)=>a.current&&e===s.current&&t===C(),d=async(e,a)=>{if(i.current||t!==C())return;i.current=!0;let o=s.current,c=t,{onApplied:d,onSucceeded:f}=r.current;l({scope:n,busy:e,error:``,receipt:null});try{let t=await a();if(!u(o,c))return;l({scope:n,busy:e,error:``,receipt:{label:e,value:t}});try{f?.(e,t)}catch{}try{await d?.()}catch(e){u(o,c)&&l(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(t){u(o,c)&&l({scope:n,busy:e,error:L(t),receipt:null})}finally{u(o,c)&&(i.current=!1,l(e=>({...e,busy:``})))}},f=Object.is(c.scope,n)?c:I(n);return{busy:f.busy,error:f.error,result:f.receipt?.value,succeeded:f.receipt?.label??``,run:d,clearResult:()=>l(e=>({...e,receipt:null}))}}function I(e){return{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 pe=3600*1e3;function me({repository:e=P,onApplied:t}){let[n,r]=(0,T.useState)(`720`),[i,a]=(0,T.useState)(!0),[o,s]=(0,T.useState)(!0),c=F({scopeKey:(0,T.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*pe);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 he=[[`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 ge({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:he.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 _e({repository:e=P,onApplied:t}){let[n,r]=(0,T.useState)(``),[i,a]=(0,T.useState)(`{}`),o=(0,T.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=d(()=>e.status(),[e],{intervalMs:5e3}),c=F({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)(ve,{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 ve({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 ye=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function be({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)(xe,{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)(Se,{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 xe({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 Se({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:ye.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 Ce({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 we(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(be,{...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)(Ce,{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 Te(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(...Ee(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(De)}function Ee(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 De(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=Te(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 Oe({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,T.useState)(()=>e.now());return(0,T.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 ke({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 Ae({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({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 je({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)(Ae,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Me({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 Ne({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)(Pe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Pe({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)(Fe,{step:t})]})]})}function Fe({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 Ie({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)(Le,{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)(Ne,{steps:e.steps,onSelect:t})]})]})}function Le({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 Re=[{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)(ze,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function ze({repository:e,id:r,kind:i,onSelect:a}){let[o,s]=n(),c=o.get(`tab`),l=A(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:Re.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)(Ie,{execution:y,onSelect:a}),l===`history`&&(0,R.jsx)(U,{execution:y}),l===`payloads`&&(0,R.jsx)(Me,{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 Be=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function Ve({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)(He,{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 He({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:Be(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 Ue({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:We(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ge(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)(Ke,{mode:e,row:n})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:qe(e,n,u)})]},n.id))})]})}),(0,R.jsx)(Q,{total:a,offset:o,pageSize:s,count:n.length,onPage:c})]})}var We=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ge=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function Ke({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 qe(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 Je({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)($,{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)(Ye,{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 $({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 Ye({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 Xe({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,T.useState)(``),[a,o]=(0,T.useState)(`{}`),s=F({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 Ze({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)(Oe,{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)(Xe,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function Qe(e){return e.section.id===`overview`?(0,R.jsx)(Je,{...e}):e.section.id===`executions`?(0,R.jsx)($e,{...e}):(0,R.jsx)(et,{...e})}function $e({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)(Ve,{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 et(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)(Ue,{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)(tt,{...e,id:e.selected.id})]})}function tt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Ze,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(je,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(ke,{repository:t,id:i})}function nt({repository:e=de,controlRepository:t=P}){let{pathname:n}=i(),r=ee(n),a=fe(r),{kind:o,workflowName:s,state:c,offset:l,selected:u}=a,f={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:m,error:h,loading:g,refetch:_}=d(()=>r.id===`overview`?ie(e,25):re(e,f),[e,r.id,o,s,c,l],{intervalMs:5e3});(0,T.useEffect)(()=>{let e=m?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&a.update({offset:t,executionId:null,tab:`summary`},!0)},[m?.page.total,l,a.update]),(0,T.useEffect)(()=>{let e=m?.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&&a.select(n,!0)}},[m?.page.executions,r.id,u,a.select]);let y=m?.stats,b=m?.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:!!(m&&!h),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void _(),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)(_e,{repository:t,onApplied:_}),r.id===`archive`&&(0,R.jsx)(me,{repository:t,onApplied:_}),r.id===`executions`&&y&&(0,R.jsx)(ge,{stats:y}),(0,R.jsx)(we,{section:r,kind:o,workflowName:s,state:c,stats:y??void 0,total:b?.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)}}),h&&m&&(0,R.jsx)(p,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:_}),(0,R.jsx)(rt,{repository:e,controlRepository:t,section:r,stats:y,kind:o,page:b,error:h,loading:g,dataPresent:!!m,selected:u,offset:l,onRetry:_,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function rt({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)(Qe,{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{nt 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-CyjgmGTq.js";import{i as o}from"./connectionStore-CKFQrxDo.js";import{t as s}from"./upstreamPaths-CDVsu6IM.js";import{s as c,t as l}from"./bq-Bmysbg0r.js";import{t as u}from"./toastStore-B7n0zS0y.js";import{n as d}from"./usePolledData-g80Z_UB-.js";import{t as f}from"./Card-C7NMhqUt.js";import{i as p,n as m,r as h,t as g}from"./feedback-BnGE2oW2.js";import{t as _}from"./StatusBadge-B0I7hNBX.js";import{t as v}from"./PageHeader-BXlZSBcc.js";import{a as y,i as b,l as x}from"./format-Cg7VCIZW.js";import{n as S,t as C}from"./controlConnectionEpoch-JM4omZ6j.js";var w={"/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 w[e]??w[`/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 T=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 E=new Set([`summary`,`history`,`payloads`]),oe=new Set([`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`]);function D(e,t){let n=e.get(`kind`),r=t.id===`executions`&&(n===`active`||n===`archive`)?n:t.kind,i=t.id===`overview`?``:se(e.get(`workflow`)),a=le(e.get(`state`),t),o=t.id===`overview`?0:ce(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&&E.has(u)?u:`summary`}}function O(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 k(e,t,n){return O(t,{...D(e,t),...n})}function A(e){return E.has(e)}function se(e){return e&&e.length<=256?e:``}function ce(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 le(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 ue=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(ue(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},de={stats:()=>l.workflows.stats(),list:e=>l.workflows.list(e),get:(e,t)=>l.workflows.get(e,t)};function fe(e){let[t,r]=n(),i=t.toString(),a=(0,T.useMemo)(()=>D(new URLSearchParams(i),e),[i,e]),o=(0,T.useMemo)(()=>O(e,a).toString(),[e,a]),s=(0,T.useRef)(null);(0,T.useEffect)(()=>{o!==i&&r(o,{replace:!0})},[o,i,r]);let c=(0,T.useCallback)((t,n=!1)=>{r(n=>k(n,e,t),{replace:n})},[e,r]),l=(0,T.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=(0,T.useMemo)(()=>({local:e.scopeKey,connectionEpoch:t}),[t,e.scopeKey]),r=(0,T.useRef)(e);r.current=e;let i=(0,T.useRef)(!1),a=(0,T.useRef)(!0),o=(0,T.useRef)(n),s=(0,T.useRef)(0);Object.is(o.current,n)||(o.current=n,s.current+=1,i.current=!1);let[c,l]=(0,T.useState)(()=>I(n));(0,T.useEffect)(()=>(a.current=!0,()=>{a.current=!1,s.current+=1,i.current=!1}),[]);let u=(e,t)=>a.current&&e===s.current&&t===C(),d=async(e,a)=>{if(i.current||t!==C())return;i.current=!0;let o=s.current,c=t,{onApplied:d,onSucceeded:f}=r.current;l({scope:n,busy:e,error:``,receipt:null});try{let t=await a();if(!u(o,c))return;l({scope:n,busy:e,error:``,receipt:{label:e,value:t}});try{f?.(e,t)}catch{}try{await d?.()}catch(e){u(o,c)&&l(t=>({...t,error:`Command succeeded; refresh failed: ${L(e)}`}))}}catch(t){u(o,c)&&l({scope:n,busy:e,error:L(t),receipt:null})}finally{u(o,c)&&(i.current=!1,l(e=>({...e,busy:``})))}},f=Object.is(c.scope,n)?c:I(n);return{busy:f.busy,error:f.error,result:f.receipt?.value,succeeded:f.receipt?.label??``,run:d,clearResult:()=>l(e=>({...e,receipt:null}))}}function I(e){return{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 pe=3600*1e3;function me({repository:e=P,onApplied:t}){let[n,r]=(0,T.useState)(`720`),[i,a]=(0,T.useState)(!0),[o,s]=(0,T.useState)(!0),c=F({scopeKey:(0,T.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*pe);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 he=[[`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 ge({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:he.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 _e({repository:e=P,onApplied:t}){let[n,r]=(0,T.useState)(``),[i,a]=(0,T.useState)(`{}`),o=(0,T.useMemo)(()=>Symbol(`workflow-runtime:${n.length}:${i.length}`),[i,n]),s=d(()=>e.status(),[e],{intervalMs:5e3}),c=F({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)(ve,{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 ve({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 ye=[``,`running`,`waiting`,`completed`,`failed`,`compensating`,`compensation-stuck`,`compensation`];function be({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)(xe,{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)(Se,{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 xe({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 Se({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:ye.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 Ce({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 we(e){return e.section.id===`overview`?null:e.section.id===`executions`?(0,R.jsx)(be,{...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)(Ce,{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 Te(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(...Ee(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(De)}function Ee(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 De(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=Te(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 Oe({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,T.useState)(()=>e.now());return(0,T.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 ke({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 Ae({repository:e,executionId:t,stuck:n,onApplied:r}){let i=F({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 je({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)(Ae,{repository:t,executionId:n,stuck:l.state===`compensation-stuck`,onApplied:()=>q(c,r)},n)]})]})}function Me({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 Ne({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)(Pe,{name:e,step:r,last:i===n.length-1,onSelect:t},e))})}function Pe({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)(Fe,{step:t})]})]})}function Fe({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 Ie({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)(Le,{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)(Ne,{steps:e.steps,onSelect:t})]})]})}function Le({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 Re=[{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)(ze,{repository:e,id:t,kind:n,onSelect:r},`${n}:${t}`)}function ze({repository:e,id:r,kind:i,onSelect:a}){let[o,s]=n(),c=o.get(`tab`),l=A(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:Re.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)(Ie,{execution:y,onSelect:a}),l===`history`&&(0,R.jsx)(U,{execution:y}),l===`payloads`&&(0,R.jsx)(Me,{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 Be=e=>e.length>22?`${e.slice(0,12)}…${e.slice(-7)}`:e;function Ve({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)(He,{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 He({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:Be(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 Ue({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:We(e)}),(0,R.jsx)(`th`,{className:`px-3 py-2 text-right font-medium`,children:Ge(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)(Ke,{mode:e,row:n})}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-3 text-right text-xs text-muted`,children:qe(e,n,u)})]},n.id))})]})}),(0,R.jsx)(Q,{total:a,offset:o,pageSize:s,count:n.length,onPage:c})]})}var We=e=>e===`waiting`?`Resume node`:e===`compensation`?`Recovery state`:`Outcome`,Ge=e=>e===`archive`?`Archived`:e===`waiting`?`Waiting`:`Updated`;function Ke({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 qe(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 Je({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)($,{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)(Ye,{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 $({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 Ye({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 Xe({repository:e,executionId:t,onApplied:n}){let[r,i]=(0,T.useState)(``),[a,o]=(0,T.useState)(`{}`),s=F({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 Ze({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)(Oe,{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)(Xe,{repository:t,executionId:n,onApplied:()=>q(l,r)},n)]})]})}function Qe(e){return e.section.id===`overview`?(0,R.jsx)(Je,{...e}):e.section.id===`executions`?(0,R.jsx)($e,{...e}):(0,R.jsx)(et,{...e})}function $e({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)(Ve,{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 et(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)(Ue,{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)(tt,{...e,id:e.selected.id})]})}function tt({section:e,repository:t,controlRepository:n,onRefresh:r,id:i}){return e.id===`waiting`?(0,R.jsx)(Ze,{repository:t,controlRepository:n,id:i,onApplied:r}):e.id===`compensation`?(0,R.jsx)(je,{repository:t,controlRepository:n,id:i,onApplied:r}):(0,R.jsx)(ke,{repository:t,id:i})}function nt({repository:e=de,controlRepository:t=P}){let{pathname:n}=i(),r=ee(n),a=fe(r),{kind:o,workflowName:s,state:c,offset:l,selected:u}=a,f={kind:o,workflowName:s||void 0,state:c||void 0,limit:25,offset:l},{data:m,error:h,loading:g,refetch:_}=d(()=>r.id===`overview`?ie(e,25):re(e,f),[e,r.id,o,s,c,l],{intervalMs:5e3});(0,T.useEffect)(()=>{let e=m?.page.total;if(e===void 0||l===0)return;let t=e===0?0:Math.floor((e-1)/25)*25;l>t&&a.update({offset:t,executionId:null,tab:`summary`},!0)},[m?.page.total,l,a.update]),(0,T.useEffect)(()=>{let e=m?.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&&a.select(n,!0)}},[m?.page.executions,r.id,u,a.select]);let y=m?.stats,b=m?.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:!!(m&&!h),actions:(0,R.jsx)(`button`,{type:`button`,onClick:()=>void _(),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)(_e,{repository:t,onApplied:_}),r.id===`archive`&&(0,R.jsx)(me,{repository:t,onApplied:_}),r.id===`executions`&&y&&(0,R.jsx)(ge,{stats:y}),(0,R.jsx)(we,{section:r,kind:o,workflowName:s,state:c,stats:y??void 0,total:b?.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)}}),h&&m&&(0,R.jsx)(p,{message:`Workflow refresh failed — showing the last snapshot.`,onRetry:_}),(0,R.jsx)(rt,{repository:e,controlRepository:t,section:r,stats:y,kind:o,page:b,error:h,loading:g,dataPresent:!!m,selected:u,offset:l,onRetry:_,onSelect:e=>a.select(e),onPage:e=>{a.update({offset:e,executionId:null,tab:`summary`})}})]})}function rt({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)(Qe,{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{nt as Workflows};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,i as t,n,r}from"./connectionStore-CKFQrxDo.js";import{a as i,i as a,n as o,r as s,s as c}from"./upstreamPaths-CDVsu6IM.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=(e,n,i=!0,a=[],o=u)=>f(t(),e,r(),n,i,`server`,a,o);function m(t,n){return e(t)??e(n)??`http://localhost:6800`}function h(){try{return globalThis.__BUNQUEUE_AGENT_URL__}catch{return}}var g=m(h(),void 0),ee=()=>g,_=(e,t,r=u)=>f(g,e,n(),t,!0,`agent`,[],r),v=(e,t)=>({method:e,body:t===void 0?void 0:JSON.stringify(t)}),y=3e5,b=(e,t)=>v(e,t),x=new WeakMap,te=new WeakMap;function S(){let e=Object.freeze({baseUrl:t()});return x.set(e,Object.freeze({...r()})),e}function C(){let e=Object.freeze({baseUrl:g});return te.set(e,Object.freeze({...n()})),e}function w(e){let t=x.get(e);if(!t)throw TypeError(`Invalid server request target.`);return t}function T(e){let t=te.get(e);if(!t)throw TypeError(`Invalid agent request target.`);return t}function ne(e,t){let n=Object.entries(e);return n.length===Object.keys(t).length&&n.every(([e,n])=>t[e]===n)}function re(e){let n=w(e);if(e.baseUrl!==t()||!ne(n,r()))throw Error(`Server connection changed after confirmation was requested for ${e.baseUrl}; action refused.`)}async function E(e,t,n){n?.throwIfAborted();let r=await f(e.baseUrl,`/jobs/${i(t)}`,{...w(e)},n?{signal:n}:void 0);return n?.throwIfAborted(),r}var D=encodeURIComponent,ie={info:()=>_(`/db/info`),tables:()=>_(`/db/tables`),schema:e=>_(`/db/tables/${o(e,`Database table`)}/schema`),rows:(e,t=50,n=0,r,i=`asc`,a)=>_(`/db/tables/${o(e,`Database table`)}?limit=${t}&offset=${n}${r?`&orderBy=${D(r)}&dir=${i}`:``}${a?.value?`&fcol=${D(a.column)}&fop=${a.op}&fval=${D(a.value)}`:``}`),cell:(e,t,n)=>_(`/db/tables/${o(e,`Database table`)}/cell?rowid=${D(String(t))}&column=${D(n)}`),query:e=>_(`/db/query`,v(`POST`,{sql:e}))},ae={status:()=>_(`/control/status`),start:()=>_(`/control/start`,{method:`POST`}),stop:()=>_(`/control/stop`,{method:`POST`}),restart:()=>_(`/control/restart`,{method:`POST`}),logs:()=>_(`/control/logs`),getConfig:()=>_(`/control/config`),setConfig:e=>_(`/control/config`,v(`PUT`,e))},oe={stats:()=>_(`/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)),_(`/workflows${t.size?`?${t}`:``}`)},get:(e,t=`active`)=>_(`/workflows/${o(e,`Workflow execution id`)}?kind=${t}`)},se=2e5,O=16*1024*1024,ce=12e4,le=64*1024,k=encodeURIComponent;async function ue(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=${k(i)}&dir=${a}`:``}${s?.value?`&fcol=${k(s.column)}&fop=${s.op}&fval=${k(s.value)}`:``}`,{...T(e)},c?{signal:c}:void 0,!0,`agent`);return c?.throwIfAborted(),l}function A(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 de(e){if(!e.body)return``;let t=e.body.getReader(),n=new Uint8Array(le),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 fe(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 pe(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 me(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 de(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 he(e,t,n){n?.throwIfAborted();let r={...T(e)},i=pe(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(ce),u=n?AbortSignal.any([n,c]):c;try{let t=await fetch(e.baseUrl+s,{headers:r,signal:u});if(!t.ok)throw await me(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=A(t.headers,`X-Bunqueue-Db-Export-Rows`,se),c=A(t.headers,`X-Bunqueue-Db-Export-Bytes`,O,!1);if(A(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 fe(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 ge={counts:e=>p(`/queues/${c(e)}/counts`),pause:e=>p(`/queues/${c(e)}/pause`,v(`POST`)),resume:e=>p(`/queues/${c(e)}/resume`,v(`POST`)),drain:e=>p(`/queues/${c(e)}/drain`,b(`POST`),!0,[],y),obliterate:e=>p(`/queues/${c(e)}/obliterate`,b(`POST`),!0,[],y),clean:(e,t={})=>p(`/queues/${c(e)}/clean`,v(`POST`,t)),promoteJobs:(e,t)=>p(`/queues/${c(e)}/promote-jobs`,v(`POST`,t==null?void 0:{count:t})),retryCompleted:(e,t)=>{throw TypeError(`Completed-job requeue is unavailable in Bunqueue v2.8.59 because flow dependency registration is not rebuilt.`)},setRateLimit:(e,t,n,r)=>p(`/queues/${c(e)}/rate-limit`,v(`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`,v(`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`,v(`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.8.59 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`,v(`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.8.59 because the endpoint has no atomic job-generation, state, or flow-topology precondition.`)},purgeDlq:e=>p(`/queues/${c(e)}/dlq/purge`,v(`POST`))},j=()=>encodeURIComponent(t()),_e={limits:(e,t)=>{let n=t===void 0?``:`&maxJobs=${t}`;return _(`/queue-operations/${c(e)}/limits?target=${j()}${n}`)},deduplicationJobId:(e,n)=>_(`/queue-operations/${c(e)}/deduplication?${new URLSearchParams({target:t(),deduplicationId:n})}`),removeDeduplicationKey:(e,t)=>_(`/queue-operations/${c(e)}/deduplication/remove?target=${j()}`,v(`POST`,{deduplicationId:t})),metrics:(e,n,r,i)=>_(`/queue-operations/${c(e)}/metrics?${new URLSearchParams({target:t(),type:n,start:String(r),end:String(i)})}`),trimEvents:(e,t)=>_(`/queue-operations/${c(e)}/events/trim?target=${j()}`,v(`POST`,{maxLength:t}))},M=1e4,ve=1e3,ye=864e13,be=new Set([`job.pushed`,`job.started`,`job.completed`,`job.failed`,`job.progress`,`job.stalled`]);function N(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:null}function P(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 F(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function xe(e){return typeof e==`number`&&Number.isFinite(e)}function I(e){return F(e)&&e<=ye}function Se(e,t){return e===null||P(e,t)}function Ce(e,t,n){if(!Array.isArray(e)||e.length>t)return!1;let r=new Set;for(let t of e){if(!P(t,n)||r.has(t))return!1;r.add(t)}return!0}function L(e,t){let n=N(e),r=n&&N(n.data);if(n?.ok!==!0||!r)throw Error(`Malformed ${t} response.`);return r}function R(e){if(!Array.isArray(e))throw Error(`Malformed queue summary response.`);let t=new Set,n=[];for(let r of e){let e=N(r),i=e&&N(e.counts);if(!e||!P(e.name,256)||t.has(e.name)||typeof e.paused!=`boolean`||!i||!F(i.waiting)||!F(i.prioritized)||!F(i.active)||!F(i.completed)||!F(i.failed)||!F(i.delayed))throw Error(`Malformed queue summary response.`);t.add(e.name),n.push(r)}return n}function z(e){let t=L(e,`workers`);if(!Array.isArray(t.workers)||t.workers.length>M)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=N(a),s=o&&typeof o.id==`string`?o.id:null,c=[];if(o?(P(o.id,1024)?n.has(o.id)&&c.push(`duplicate id`):c.push(`id`),P(o.name,512,!0)||c.push(`name`),Ce(o.queues,ve,256)||c.push(`queues`),(!F(o.concurrency)||o.concurrency<1)&&c.push(`concurrency`),P(o.hostname,512,!0)||c.push(`hostname`),F(o.pid)||c.push(`pid`),o.status!==`active`&&o.status!==`stale`&&c.push(`status`),I(o.registeredAt)||c.push(`registeredAt`),I(o.lastSeen)||c.push(`lastSeen`),F(o.activeJobs)||c.push(`activeJobs`),F(o.processedJobs)||c.push(`processedJobs`),F(o.failedJobs)||c.push(`failedJobs`),Se(o.currentJob,1024)||c.push(`currentJob`),xe(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 we(e){if(!P(e,2048))return!1;try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function Te(e){let t=L(e,`webhooks`);if(!Array.isArray(t.webhooks)||t.webhooks.length>M)throw Error(`Malformed webhooks response.`);let n=new Set,r=[];for(let e of t.webhooks){let t=N(e);if(!t||!P(t.id,1024)||n.has(t.id)||!we(t.url)||!Array.isArray(t.events)||!t.events.every(e=>be.has(e))||!(t.queue===null||typeof t.queue==`string`)||!I(t.createdAt)||!(t.lastTriggered===null||I(t.lastTriggered))||!F(t.successCount)||!F(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 Ee={crons:()=>p(`/crons`),createCron:e=>p(`/crons`,v(`POST`,e)),deleteCron:e=>p(`/crons/${o(e,`Cron name`,256)}`,{method:`DELETE`}),webhooks:async()=>Te(await p(`/webhooks`)),addWebhook:e=>p(`/webhooks`,v(`POST`,e)),removeWebhook:e=>p(`/webhooks/${i(e)}`,{method:`DELETE`}),setWebhookEnabled:(e,t)=>p(`/webhooks/${i(e)}/enabled`,v(`PUT`,{enabled:t})),workers:async()=>z(await p(`/workers`)),unregisterWorker:e=>p(`/workers/${i(e)}`,{method:`DELETE`}),eventsUrl:e=>t()+(e?`/events/queues/${s(e)}`:`/events`)},B=365*24*60*60*1e3,V=64*1024*1024,H=1e4,De=[`childrenIds`,`parentId`,`failParentOnFailure`,`removeDependencyOnFailure`,`continueParentOnFailure`,`ignoreDependencyOnFailure`,`keepLogs`,`sizeLimit`,`debounceId`,`debounceTtl`];function U(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.8.59 pattern repeats are unsafe; use the Cron API instead.`);if(!Number.isSafeInteger(e.every)||e.every<1||e.every>B)throw TypeError(`Repeat "every" must be a whole number from 1 to ${B} 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 W(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 G(e){let t=e,n=De.filter(e=>t[e]!==void 0);if(n.length)throw TypeError(`Unsupported Bunqueue v2.8.59 enqueue option(s): ${n.join(`, `)}. Flow topology must use the atomic flow API; inert compatibility fields are not sent.`)}function K(e,t){let n=a(t);if(n)throw TypeError(`${e}: ${n}. The job would not be manageable through v2.8.59 HTTP.`)}function Oe(e){if(W(e.name),U(e.repeat),G(e),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 ke(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 Oe(n),t}function Ae({jobId:e,...t}){return e===void 0?t:{...t,customId:e}}function je(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(W(n.name),U(n.repeat),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 Me(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 ${H} 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(Ae(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+=Me(o,t-r),r>t)return{ok:!1,error:`Bulk request payload exceeds the 64 MiB UTF-8 safety limit`};if(n)try{je(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 Ne(e,t=V){let n=q(e,t,!1);return n.ok?null:n.error}function J(e){let t=q(e,V,!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 ${H} jobs`)}var Pe={overview:e=>p(`/dashboard`,e),queues:(e=500,t=0)=>p(`/dashboard/queues?limit=${e}&offset=${t}`),queuesSummary:async()=>R(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:()=>`${t()}/prometheus`,gc:()=>p(`/gc`,v(`POST`)),heapStats:()=>p(`/heapstats`)},Fe={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:ke(t)}),addJobsBulk:async(e,t)=>(Y(t),p(`/queues/${c(e)}/jobs/bulk`,{method:`POST`,body:J(t)},!0,[],y)),pullBatch:(e,t)=>p(`/queues/${c(e)}/jobs/pull-batch`,v(`POST`,{count:t})),ackBatch:e=>p(`/jobs/ack-batch`,v(`POST`,{ids:e})),cancelJob:e=>p(`/jobs/${i(e)}`,{method:`DELETE`}),promoteJob:e=>p(`/jobs/${i(e)}/promote`,v(`POST`)),discardJob:e=>p(`/jobs/${i(e)}/discard`,v(`POST`)),retryJob:e=>p(`/jobs/${i(e)}/move-to-wait`,v(`POST`)),failJob:(e,t,n={})=>p(`/jobs/${i(e)}/fail`,v(`POST`,{error:t,...n})),updateJobData:(e,t)=>p(`/jobs/${i(e)}/data`,v(`PUT`,{data:t})),changePriority:(e,t,n)=>p(`/jobs/${i(e)}/priority`,v(`PUT`,{priority:t,...n===void 0?{}:{lifo:n}})),changeDelay:(e,t)=>p(`/jobs/${i(e)}/delay`,v(`PUT`,{delay:t})),moveToDelayed:(e,t)=>p(`/jobs/${i(e)}/move-to-delayed`,v(`POST`,{delay:t})),addJobLog:(e,t,n)=>p(`/jobs/${i(e)}/logs`,v(`POST`,{message:t,level:n})),clearJobLogs:e=>p(`/jobs/${i(e)}/logs`,{method:`DELETE`}),setJobProgress:(e,t,n)=>p(`/jobs/${i(e)}/progress`,v(`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 Ie(e,t){let n={...w(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()=>R(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()=>z(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)},y)),pullBatch:(e,t)=>r(`/queues/${c(e)}/jobs/pull-batch`,v(`POST`,{count:t})),heartbeatBatch:e=>r(`/jobs/heartbeat-batch`,v(`POST`,{ids:e})),ackBatch:e=>r(`/jobs/ack-batch`,v(`POST`,{ids:e})),retryJob:e=>r(`/jobs/${i(e)}/move-to-wait`,v(`POST`)),promoteJob:async e=>$(await r(`/jobs/${i(e)}/promote`,v(`POST`)),`promote job`),pause:async e=>$(await r(`/queues/${c(e)}/pause`,v(`POST`)),`pause queue`),resume:async e=>$(await r(`/queues/${c(e)}/resume`,v(`POST`)),`resume queue`),clean:(e,t={})=>r(`/queues/${c(e)}/clean`,v(`POST`,t))})}var Le={...Pe,captureServerRequestTarget:S,createServerTargetClient:Ie,getJobAtTarget:E,captureAgentRequestTarget:C,getDbRowsAtTarget:ue,getDbExportAtTarget:he,...Fe,...ge,queueOperations:_e,...Ee,db:ie,get agentBase(){return ee()},control:ae,workflows:oe};Object.defineProperty(Le,"agentBase",{configurable:!1});export{l as a,re as c,S as d,E as f,O as i,f as l,Ie as n,T as o,Ne as r,_ as s,Le as t,C as u};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CopilotPanel-Bhh-uCpN.js","assets/cn-zFEt5SO8.js","assets/react-vendor-CyjgmGTq.js","assets/bq-Bmysbg0r.js","assets/connectionStore-CKFQrxDo.js","assets/upstreamPaths-CDVsu6IM.js","assets/dist-DZL8soAh.js","assets/form-tC20r4Ma.js","assets/AddJob-CC4bfHLH.js","assets/toastStore-B7n0zS0y.js","assets/usePolledData-g80Z_UB-.js","assets/Button-BPqpRZJD.js","assets/Card-C7NMhqUt.js","assets/PageHeader-BXlZSBcc.js","assets/StatusBadge-B0I7hNBX.js","assets/useServerActionGuard-OTv6_fU0.js","assets/responses-CBLyy1Ob.js","assets/Benchmark-ClJmYZoC.js","assets/icons-CIvFfU2b.js","assets/format-Cg7VCIZW.js","assets/AreaChart-w0ruozXH.js","assets/BulkAddJobs-BBWqQpP7.js","assets/CronManager-lNZ4lHh1.js","assets/feedback-BnGE2oW2.js","assets/Pagination-Q-vf4hsX.js","assets/Database-DxiXsUl4.js","assets/Diagnostics-DLvCT7zI.js","assets/api-V_sVpHDo.js","assets/DlqControl-DJGhuyu3.js","assets/flowMutationSafety-DObp9nJo.js","assets/exportFile-C7xhE8Yh.js","assets/QueueControl-CWHsVfWU.js","assets/QueueActions-B6M0ByGt.js","assets/DlqPro-BhXIKtrt.js","assets/Flows-Bb9j-YhZ.js","assets/controlConnectionEpoch-JM4omZ6j.js","assets/JobInspector-DfqBq4O5.js","assets/jobActions-LQD4KfCc.js","assets/JobsPro-D8dH9um7.js","assets/LogsPro-BCB7etG2.js","assets/McpServer-Cz1-GwD5.js","assets/MetricsPro-BbJmy0oO.js","assets/useThroughputSeries-CrsZYKbT.js","assets/QueueDetailPro-CIimG0pX.js","assets/QueuesOverview-ChC5Dtqh.js","assets/promisePool-BVfQ9n9Q.js","assets/S3BackupPro-BkwTXdtw.js","assets/ServerControl-DJHKMaf9.js","assets/UsagePro-DMxrXxur.js","assets/Webhooks-D0JQQf0q.js","assets/WorkersPro-BOTuX9EP.js","assets/Workflows-DqTKWPmT.js","assets/Alerts-C2bAi-Kj.js","assets/Cron-pJJ5KXFG.js","assets/Dlq-Bx4YXTp5.js","assets/Jobs-Blavwd1H.js","assets/Logs-B3dsGSF8.js","assets/Metrics-Bkuy6Ntb.js","assets/Overview-Ba5odzYe.js","assets/QueueDetail-BClRbWC5.js","assets/Queues-CGPgEkVm.js","assets/S3Backup-5OKa8G13.js","assets/Settings-C1HtCK6h.js","assets/Usage-QyZkUhgs.js","assets/Workers-Cn8Bkgy1.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{i as e,t}from"./cn-zFEt5SO8.js";import{a as n,c as r,g as i,i as a,l as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./react-vendor-CyjgmGTq.js";import{a as h,c as g,d as _,f as v,i as y,l as b,n as x,o as S,r as C,s as ee,u as w}from"./connectionStore-CKFQrxDo.js";import{t as T}from"./bq-Bmysbg0r.js";import{n as te,t as ne}from"./toastStore-B7n0zS0y.js";import{A as re,D as ie,E as ae,S as oe,T as se,_ as ce,c as le,f as ue,g as de,h as fe,k as pe,l as me,m as he,n as ge,o as _e,p as E,r as ve,s as ye,t as be,u as D,v as xe,w as Se,y as Ce}from"./icons-CIvFfU2b.js";import{t as we}from"./api-V_sVpHDo.js";import{n as Te}from"./usePolledData-g80Z_UB-.js";import{t as Ee}from"./Button-BPqpRZJD.js";import{t as O}from"./Card-C7NMhqUt.js";import{i as De,n as Oe,r as ke}from"./feedback-BnGE2oW2.js";import{t as Ae}from"./PageHeader-BXlZSBcc.js";import{c as je,l as Me,n as Ne,r as Pe,s as k,t as Fe,u as Ie}from"./format-Cg7VCIZW.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var A=e(i(),1),Le=s(),Re=`bq-dash-alerts`,ze=1,Be=[`email`,`webhook`,`slack`],Ve=[`error_rate`,`p99_latency`,`waiting`,`failed`,`dlq`],He=[`>=`,`>`,`<=`,`<`],Ue=128,We=200,Ge=2048,Ke=256,qe=/^[^\s@]+@[^\s@]+\.[^\s@]+$/u,Je=()=>`${Date.now().toString(36)}${Math.floor(Math.random()*1e6).toString(36)}`;function Ye(e){let t=new Set(e.map(e=>e.id)),n=Je();if(!t.has(n))return n;let r=1;for(;t.has(`${n}-${r}`);)r+=1;return`${n}-${r}`}function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ze(e){return Be.includes(e)}function Qe(e){return Ve.includes(e)}function $e(e){return He.includes(e)}function et(e,t){let n=t.trim();if(!n||n.length>Ge)return!1;if(e===`email`)return n.length<=320&&qe.test(n);try{let e=new URL(n);return[`http:`,`https:`].includes(e.protocol)&&!e.username&&!e.password}catch{return!1}}function tt(e){if(!Xe(e)||typeof e.id!=`string`||!Ze(e.type)||typeof e.target!=`string`)return null;let t=e.id.trim(),n=e.target.trim();return!t||t.length>Ue||n.length>Ge||e.type===`email`&&!et(e.type,n)?null:{id:t,type:e.type,target:e.type===`email`?n:``}}function nt(e){if(!Xe(e)||typeof e.id!=`string`||typeof e.name!=`string`||!Qe(e.metric)||!$e(e.operator)||typeof e.threshold!=`number`||!Number.isFinite(e.threshold)||typeof e.queue!=`string`||!Ze(e.channel)||typeof e.enabled!=`boolean`)return null;let t=e.id.trim(),n=e.name.trim(),r=e.queue.trim();return!t||t.length>Ue||!n||n.length>We||r.length>Ke||e.threshold<0||e.metric===`error_rate`&&e.threshold>100?null:{id:t,name:n,metric:e.metric,operator:e.operator,threshold:e.threshold,queue:r,channel:e.channel,enabled:e.enabled}}function j(e){let t=Xe(e)?e:{},n=[],r=new Set;if(Array.isArray(t.channels))for(let e of t.channels){if(n.length>=100)break;let t=tt(e);!t||r.has(t.id)||(r.add(t.id),n.push(t))}let i=[],a=new Set;if(Array.isArray(t.rules))for(let e of t.rules){if(i.length>=500)break;let t=nt(e);!t||a.has(t.id)||(a.add(t.id),i.push(t))}return{channels:n,rules:i}}function rt(e){return j({channels:e.channels,rules:e.rules})}var it=b({key:Re,version:ze,sanitizeState:j}),M=v()(_(e=>({channels:[],rules:[],addChannel:(t,n)=>{let r={ok:!1,error:`Alert destination was rejected.`};return e(e=>{let i=n.trim();return!Ze(t)||!et(t,i)?(r={ok:!1,error:`Alert destination is invalid.`},e):e.channels.length>=100?(r={ok:!1,error:`A maximum of 100 alert destinations can be stored in this browser.`},e):(r={ok:!0},{channels:[...e.channels,{id:Ye(e.channels),type:t,target:i}]})}),r},removeChannel:t=>e(e=>({channels:e.channels.filter(e=>e.id!==t)})),addRule:t=>{let n={ok:!1,error:`Alert rule was rejected.`};return e(e=>{if(e.rules.length>=500)return n={ok:!1,error:`A maximum of 500 alert rules can be stored in this browser.`},e;let r=nt({...t,id:Ye(e.rules)});return r?(n={ok:!0},{rules:[...e.rules,r]}):(n={ok:!1,error:`Alert rule contains invalid fields.`},e)}),n},removeRule:t=>e(e=>({rules:e.rules.filter(e=>e.id!==t)})),toggleRule:t=>e(e=>({rules:e.rules.map(e=>e.id===t?{...e,enabled:!e.enabled}:e)}))}),{name:Re,version:ze,storage:w(()=>it),partialize:rt,migrate:j,merge:(e,t)=>({...t,...j(e)})})),at={error_rate:`error rate`,p99_latency:`p99 latency`,waiting:`waiting jobs`,failed:`failed jobs`,dlq:`DLQ size`},ot=10500,st=500,ct=21,lt=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0;function ut(e,t,n){return t===`>=`?e>=n:t===`>`?e>n:t===`<=`?e<=n:t===`<`&&e<n}function dt(e){if(!Array.isArray(e)||e.length>ot)return null;let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`||Array.isArray(r))return null;let e=r,i=e.counts;if(typeof e.name!=`string`||!e.name||e.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(e.name)||t.has(e.name)||typeof e.paused!=`boolean`||!i||typeof i!=`object`||Array.isArray(i))return null;let a=i;if(![`waiting`,`active`,`completed`,`failed`,`delayed`].every(e=>lt(a[e])))return null;t.add(e.name),n.push(r)}return n}function ft(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(t.ok!==!0||!t.latency||typeof t.latency!=`object`||Array.isArray(t.latency))return null;let n=t.latency.percentiles;if(!n||typeof n!=`object`||Array.isArray(n))return null;for(let e of Object.values(n)){let t=e?.p99;if(!e||typeof e!=`object`||Array.isArray(e)||typeof t!=`number`||!Number.isFinite(t)||t<0)return null}return e}var pt=(e,t)=>{let n=e+t;return n>0?t/n*100:null};function mt(e,t){let n=e.queue.trim();if(e.metric===`waiting`||e.metric===`failed`){if(!t.summary)return null;let r=e.metric;return n?t.summary.find(e=>e.name===n)?.counts[r]??null:t.summary.reduce((e,t)=>e+t.counts[r],0)}if(e.metric===`dlq`)return t.queues?n?t.queues.find(e=>e.name===n)?.dlq??null:t.queues.reduce((e,t)=>e+(t.dlq??0),0):null;if(e.metric===`error_rate`){if(!t.summary)return null;if(n){let e=t.summary.find(e=>e.name===n);return e?pt(e.counts.completed,e.counts.failed):null}return pt(t.summary.reduce((e,t)=>e+t.counts.completed,0),t.summary.reduce((e,t)=>e+t.counts.failed,0))}let r=t.overview?.latency?.percentiles;if(!r)return null;let i=Object.values(r).map(e=>e.p99).filter(Number.isFinite);return i.length?Math.max(...i):null}function ht(e,t,n){if(typeof e!=`object`||!e||Array.isArray(e))return null;let r=e;if(r.ok!==!0||!Array.isArray(r.queues)||!Number.isSafeInteger(r.total)||r.total<0||r.total>ot||n!==null&&r.total!==n||r.offset!==t||r.limit!==st)return null;let i=r.total;if(r.queues.length!==Math.min(st,i-t))return null;let a=[];for(let e of r.queues){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;if(typeof t.name!=`string`||!t.name||t.name.length>256||!/^[a-zA-Z0-9_\-.:]+$/.test(t.name)||!lt(t.dlq))return null;a.push(e)}return{queues:a,total:i}}async function gt(e=T){try{let t=[],n=new Set,r=null;for(let i=0;i<ct;i++){let i=ht(await e.queues(st,t.length),t.length,r);if(!i)return null;r??=i.total;for(let e of i.queues){if(n.has(e.name))return null;n.add(e.name),t.push(e)}if(t.length===r)return t}return null}catch{return null}}var _t=3,vt=e=>`${e.queue||`All queues`}: ${e.metricLabel} ${e.operator} ${e.threshold} (now ${Math.round(e.value)})`;function yt(e){if(globalThis.Notification?.permission===`granted`)try{new Notification(`bunqueue alert: ${e.ruleName}`,{body:vt(e),tag:e.ruleId})}catch{}}function bt(e){if(e.length<=_t){for(let t of e)ne.error(`Alert: ${t.ruleName}`,vt(t)),yt(t);return}ne.error(`${e.length} alert rules breaching`,e.map(e=>e.ruleName).join(`, `));for(let t of e)yt(t)}var xt=3e4,St=(e,t)=>JSON.stringify([e,t]);function Ct(e){let t=JSON.parse(e);if(!Array.isArray(t)||t.length!==2)throw TypeError(`Invalid alert connection identity.`);let[n,r]=t,i=h(n);if(!i||typeof r!=`string`)throw TypeError(`Invalid alert server target.`);let a=r.trim();return Object.freeze({baseUrl:i,...a?{authorization:`Bearer ${a}`}:{}})}function wt(e,t){let n=new Headers({Accept:`application/json`});e.authorization&&n.set(`Authorization`,e.authorization);let r=async r=>{t.throwIfAborted();let i=AbortSignal.any([t,AbortSignal.timeout(xt)]),a=await fetch(e.baseUrl+r,{headers:n,signal:i});if(t.throwIfAborted(),!a.ok)throw await a.body?.cancel().catch(()=>{}),a.status===401&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(`auth:required`,{detail:{scope:`server`,auth:e.authorization,target:e.baseUrl}})),Error(`Alert metrics request failed: HTTP ${a.status}`);let o=await a.text();if(t.throwIfAborted(),!o)throw Error(`Alert metrics request returned an empty response.`);try{return JSON.parse(o)}catch{throw Error(`Alert metrics request returned invalid JSON (HTTP ${a.status}).`)}};return Object.freeze({queuesSummary:()=>r(`/queues/summary`),queues:(e=500,t=0)=>r(`/dashboard/queues?limit=${e}&offset=${t}`),overview:()=>r(`/dashboard`)})}var Tt=15e3,Et=6e4,N=v(e=>({breaching:[],status:`idle`,error:null,connectionIdentity:null,setBreaching:t=>e({breaching:t})}));async function Dt(){if(typeof Notification>`u`)return`denied`;if(Notification.permission===`granted`)return`granted`;try{return await Notification.requestPermission()}catch{return`denied`}}function Ot(){let e=M(e=>e.rules),t=S(e=>St(e.baseUrl,e.token)),n=(0,A.useRef)(new Map),r=(0,A.useRef)(new Map),i=(0,A.useRef)(new Map),a=(0,A.useRef)(new Map),o=(0,A.useRef)(t),s=(0,A.useRef)(0),c=JSON.stringify(e.filter(e=>e.enabled).map(e=>[e.id,e.metric,e.operator,e.threshold,e.queue]));(0,A.useEffect)(()=>{let e=()=>{n.current.clear(),r.current.clear(),i.current.clear(),a.current.clear()},l=o.current!==t;if(l&&(o.current=t,e()),c===`[]`){e(),N.setState({breaching:[],status:`idle`,error:null,connectionIdentity:t});return}let u=new Set(M.getState().rules.filter(e=>e.enabled).map(e=>e.id)),d=l?[]:N.getState().breaching.filter(e=>u.has(e.ruleId));N.setState({breaching:d,status:`checking`,error:null,connectionIdentity:t});let f;try{f=Ct(t)}catch(e){N.setState({breaching:[],status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t});return}let p=new AbortController,m=++s.current,h=!1,g=!1,_=()=>{if(h||s.current!==m)return!1;let e=S.getState();return St(e.baseUrl,e.token)===t},v=e=>{for(let t of[...n.current.keys()])e.has(t)||(n.current.delete(t),r.current.delete(t),i.current.delete(t),a.current.delete(t))},y=async()=>{if(!g){g=!0;try{let e=wt(f,p.signal),[o,s,c]=await Promise.all([e.queuesSummary().then(dt).catch(()=>null),gt(e),e.overview().then(ft).catch(()=>null)]);if(!_())return;let l=M.getState().rules.filter(e=>e.enabled),u=new Set(l.map(e=>e.id));if(v(u),!c){let e=N.getState().breaching.filter(e=>u.has(e.ruleId));if(!_())return;N.setState({breaching:e,status:`degraded`,error:`The bunqueue overview endpoint is unavailable; alert results may be stale.`,connectionIdentity:t});return}let d=Date.now(),m=[],h=[],g=!1;for(let e of l){let t=mt(e,{summary:o,queues:s,overview:c});if(t==null){g=!0;let t=n.current.get(e.id)?a.current.get(e.id):void 0;t&&m.push(t);continue}let l=ut(t,e.operator,e.threshold),u=n.current.get(e.id)??!1;if(l){let n=u?i.current.get(e.id)??d:d;i.current.set(e.id,n);let o={ruleId:e.id,ruleName:e.name,metricLabel:at[e.metric],operator:e.operator,threshold:e.threshold,value:t,queue:e.queue,at:n};m.push(o),a.current.set(e.id,o);let s=r.current.get(e.id)??0;d-s>Et&&s<n&&(h.push(o),r.current.set(e.id,d))}else i.current.delete(e.id),a.current.delete(e.id);n.current.set(e.id,l)}if(!_())return;bt(h);let y=!o||!s||g;N.setState({breaching:m,status:y?`degraded`:`live`,error:y?`Some alert rules could not be evaluated; affected results remain unknown.`:null,connectionIdentity:t})}catch(e){if(!_())return;N.setState({status:`degraded`,error:`Alert evaluation failed: ${e.message}`,connectionIdentity:t})}finally{g=!1}}};y();let b=setInterval(y,Tt);return()=>{h=!0,s.current===m&&(s.current+=1),p.abort(),clearInterval(b)}},[c,t])}function kt(){return Ot(),null}var At={authentication:100,"command-palette":80,copilot:60,"database-row":40,"mobile-navigation":20},P=v((e,t)=>({active:null,request(n){let r=t().active;return r===n?!0:r&&At[r]>At[n]?!1:(e({active:n}),!0)},release(n){t().active===n&&e({active:null})},reset(){e({active:null})}}));function F(e){let t=P.getState().active;return t===null||t===e}var I=p();function jt(e){return{scope:e,auth:e===`agent`?x().Authorization:C().Authorization,target:e===`agent`?T.agentBase:y()}}function L(e,t){return e?.scope===t.scope&&e.auth===t.auth&&e.target===t.target}function Mt(){let[e,t]=(0,A.useState)(!1),[n,r]=(0,A.useState)(`server`),[i,a]=(0,A.useState)(``),o=S(e=>e.baseUrl),s=S(e=>e.setToken),c=S(e=>e.setAgentToken),l=(0,A.useRef)(null),u=(0,A.useRef)(null),f=(0,A.useRef)(null),p=(0,A.useRef)(null),m=P(e=>e.active),h=e&&m===`authentication`;(0,A.useEffect)(()=>{let e=e=>{let n=e.detail;if(n?.scope!==`server`&&n?.scope!==`agent`)return;let i=jt(n.scope);n.auth!==i.auth||n.target!==i.target||(L(f.current,i)||(p.current=null,a(``)),f.current=i,P.getState().request(`authentication`),r(i.scope),t(!0),window.dispatchEvent(new window.Event(`auth:gate-opened`)))};return window.addEventListener(`auth:required`,e),()=>window.removeEventListener(`auth:required`,e)},[]),(0,A.useEffect)(()=>()=>{P.getState().release(`authentication`)},[]),(0,A.useEffect)(()=>{if(!h)return;let e=document.activeElement,t=document.getElementById(`app-shell`)?[]:[`app-nav`,`app-content`].map(e=>document.getElementById(e)).filter(e=>e!==null),n=t.map(e=>({element:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of t)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);let r=window.requestAnimationFrame(()=>l.current?.focus()),i=()=>u.current?Array.from(u.current.querySelectorAll(`a[href], button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],a=e=>{if(e.key!==`Tab`)return;let t=i();if(!t.length){e.preventDefault();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())};return window.addEventListener(`keydown`,a),()=>{window.cancelAnimationFrame(r),window.removeEventListener(`keydown`,a);for(let e of n)e.element.inert=e.inert,e.ariaHidden===null?e.element.removeAttribute(`aria-hidden`):e.element.setAttribute(`aria-hidden`,e.ariaHidden);F(`authentication`)&&e?.isConnected&&e.focus()}},[h]);let g=()=>{f.current=null,p.current=null,a(``),t(!1),P.getState().release(`authentication`)};return h?(0,I.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,children:(0,I.jsxs)(`form`,{ref:u,onSubmit:e=>{e.preventDefault();let t=f.current,n=p.current;if(!t||!n||!L(n.identity,t)||!L(t,jt(t.scope))){g();return}let r=n.value.trim();r&&(t.scope===`agent`?c(r):s(r),g())},role:`dialog`,"aria-modal":`true`,"aria-label":`Authentication required`,className:`w-full max-w-sm rounded-xl border border-line-strong bg-surface p-6 shadow-2xl`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:`Authentication required`}),n===`agent`?(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The control agent at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:T.agentBase}),` `,`rejected the request (401). Enter its`,` `,(0,I.jsx)(`span`,{className:`font-mono text-fg`,children:`AGENT_TOKEN`}),` to continue.`]}):(0,I.jsxs)(`p`,{className:`mt-1 text-sm text-muted`,children:[`The server at `,(0,I.jsx)(`span`,{className:`break-all font-mono text-fg`,children:o}),` rejected the request (401). Enter its bearer token to continue.`]}),(0,I.jsx)(`input`,{ref:l,type:`password`,value:i,onInput:e=>{let t=e.currentTarget.value;a(t);let n=f.current;p.current=n?{identity:n,value:t}:null},placeholder:n===`agent`?`AGENT_TOKEN`:`Bearer token`,"aria-label":n===`agent`?`Agent token`:`Bearer token`,name:n===`agent`?`agent-token`:`server-token`,autoComplete:`current-password`,className:`mt-4 w-full rounded-lg border border-line bg-surface-2 px-3 py-2 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3`,children:[(0,I.jsx)(d,{to:`/settings`,onClick:g,className:`text-xs text-muted underline-offset-2 hover:text-fg hover:underline`,children:`Open Settings instead`}),(0,I.jsx)(`button`,{type:`submit`,disabled:!i.trim(),className:`rounded-lg bg-accent px-4 py-2 text-sm font-medium text-accent-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 disabled:opacity-50`,children:`Unlock`})]})]})}):null}var Nt=`bq-dash-theme`,Pt=1;function R(e){return e===`light`?`light`:`dark`}function z(){try{return globalThis.localStorage??null}catch{return null}}var Ft={getItem(e){let t=z();if(!t)return null;try{let n=t.getItem(e);if(n===null||e!==Nt)return n;let r=JSON.parse(n),i=r&&typeof r==`object`&&!Array.isArray(r)?r:{},a=i.state&&typeof i.state==`object`&&!Array.isArray(i.state)?i.state:{},o=JSON.stringify({state:{theme:R(a.theme)},version:Pt});if(n!==o)try{t.setItem(e,o)}catch{}return o}catch{try{t.removeItem(e)}catch{}return null}},setItem(e,t){try{z()?.setItem(e,t)}catch{}},removeItem(e){try{z()?.removeItem(e)}catch{}}};function B(e){typeof document<`u`&&(document.documentElement.dataset.theme=e,document.documentElement.style.colorScheme=e)}var V=v()(_((e,t)=>({theme:`dark`,toggle:()=>{let n=t().theme===`dark`?`light`:`dark`;B(n),e({theme:n})},setTheme:t=>{let n=R(t);B(n),e({theme:n})}}),{name:Nt,version:Pt,storage:w(()=>Ft),partialize:e=>({theme:R(e.theme)}),merge:(e,t)=>{let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{...t,theme:R(n.theme)}},onRehydrateStorage:()=>e=>{e&&B(R(e.theme))}}));function It(){B(R(V.getState().theme))}var Lt={connecting:{dot:`bg-zinc-500`,label:`connecting`},connected:{dot:`bg-emerald-400`,label:`connected`},degraded:{dot:`bg-amber-400`,label:`reachable, degraded`},offline:{dot:`bg-red-400`,label:`offline`}};function Rt(){let e=S(e=>e.baseUrl),{data:n,error:r,loading:i}=Te(async()=>{let e=await we.health();if(typeof e.ok!=`boolean`)throw Error(`Malformed health response`);return{healthy:e.ok}},[],{intervalMs:15e3}),a=Lt[i?`connecting`:r||!n?`offline`:n.healthy?`connected`:`degraded`],o=e.replace(/^https?:\/\//,``)||`local`;return(0,I.jsxs)(`div`,{className:`mx-3 mb-4 flex items-center gap-2 rounded-lg border border-line bg-surface px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:t(`size-1.5 rounded-full`,a.dot),title:a.label}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] text-muted`,title:e,children:o}),(0,I.jsx)(`span`,{className:`sr-only`,children:a.label})]})}function zt(e){let t=null;try{return t=document.createElement(`textarea`),t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t?.remove()}}function Bt({value:e,className:n}){let[r,i]=(0,A.useState)(`idle`),a=(0,A.useRef)(null);(0,A.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let o=async()=>{let t=!1;if(navigator.clipboard)try{await navigator.clipboard.writeText(e),t=!0}catch{}t||=zt(e),i(t?`copied`:`failed`),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>i(`idle`),1500)},s=r===`copied`?`Copied to clipboard`:r===`failed`?`Copy failed`:`Copy to clipboard`;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,onClick:o,"aria-label":s,title:s,className:t(`inline-flex size-6 shrink-0 items-center justify-center rounded-md text-faint transition-colors hover:bg-surface-2 hover:text-fg`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-accent`,n),children:r===`copied`?(0,I.jsx)(ve,{className:`size-3.5 text-success`}):r===`failed`?(0,I.jsx)(_e,{className:`size-3.5 text-danger`}):(0,I.jsx)(ye,{className:`size-3.5`})}),(0,I.jsx)(`span`,{className:`sr-only`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,children:r===`idle`?``:s})]})}var Vt;function H(){return Vt===void 0&&(Vt=Ht()),Vt}function Ht(){if(typeof window>`u`)return!1;let{search:e,hash:t}=window.location;return new URLSearchParams(e).has(`demo`)||t.replace(/^#/,``)===`demo`}var Ut=`https://github.com/egeominotti/bunqueue-dashboard`,Wt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Gt=`bunx bunqueue-dashboard`;function Kt(){return(0,I.jsxs)(`div`,{className:`mx-3 mb-2 rounded-lg border border-accent/30 bg-accent/5 p-3`,children:[(0,I.jsx)(`p`,{className:`mb-2 text-[11px] font-medium leading-snug text-fg`,children:`Like it? Run it on your own bunqueue server.`}),(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 rounded-md border border-line bg-surface-2 px-2 py-1`,children:[(0,I.jsx)(`code`,{className:`min-w-0 flex-1 truncate font-mono text-[11px] text-fg`,children:Gt}),(0,I.jsx)(Bt,{value:Gt})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`a`,{href:Ut,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center gap-1 rounded-md bg-accent px-2 py-1.5 text-[11px] font-semibold text-accent-fg transition-opacity hover:opacity-90`,children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:`★`}),` Star`]}),(0,I.jsx)(`a`,{href:Wt,target:`_blank`,rel:`noreferrer`,className:`flex flex-1 items-center justify-center rounded-md border border-line px-2 py-1.5 text-[11px] font-medium text-muted transition-colors hover:bg-surface-2 hover:text-fg`,children:`Docs`})]})]})}function qt(){let e=S(e=>e.baseUrl),t=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``);return(0,I.jsxs)(I.Fragment,{children:[H()&&(0,I.jsx)(Kt,{}),(0,I.jsxs)(`div`,{className:`mx-3 mb-3 flex items-center gap-2.5 rounded-lg border border-line bg-surface px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-[11px] font-bold text-white`,children:`bq`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-xs font-medium text-fg`,children:`bunqueue`}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[10px] text-faint`,title:e,children:t})]}),(0,I.jsx)(d,{to:`/settings`,"aria-label":`Settings`,className:`text-faint transition-colors hover:text-fg`,children:(0,I.jsx)(ae,{className:`size-4`})})]})]})}var Jt=[{section:null,items:[{to:`/`,label:`Overview`,icon:Ce,end:!0}]},{section:`Queues`,items:[{to:`/queues`,label:`Queues`,icon:oe,end:!0},{to:`/jobs`,label:`Jobs`,icon:E,end:!0},{to:`/dlq`,label:`Dead Letter Queue`,icon:D},{to:`/cron`,label:`Cron Jobs`,icon:le}]},{section:`Workflow`,items:[{to:`/workflows`,label:`Overview`,icon:Ce,end:!0},{to:`/flows`,label:`Job Flows`,icon:ge,end:!0},{to:`/workflows/executions`,label:`Executions`,icon:E,end:!0},{to:`/workflows/waiting`,label:`Waiting & Signals`,icon:le,end:!0},{to:`/workflows/compensation`,label:`Compensation`,icon:D,end:!0},{to:`/workflows/archive`,label:`Archive`,icon:me,end:!0}]},{section:`Monitoring`,items:[{to:`/metrics`,label:`Metrics`,icon:ce},{to:`/workers`,label:`Workers`,icon:re},{to:`/logs`,label:`Logs`,icon:fe},{to:`/alerts`,label:`Alerts`,icon:be}]},{section:`Control`,items:[{to:`/server`,label:`Server`,icon:re},{to:`/add-job`,label:`Add Job`,icon:E},{to:`/jobs/bulk-add`,label:`Bulk Add`,icon:E},{to:`/job`,label:`Job Inspector`,icon:ue},{to:`/queue-control`,label:`Queue Control`,icon:oe},{to:`/dlq-control`,label:`DLQ Control`,icon:D},{to:`/webhooks`,label:`Webhooks`,icon:he},{to:`/diagnostics`,label:`Diagnostics`,icon:ce},{to:`/benchmark`,label:`Benchmark`,icon:he}]},{section:`Management`,items:[{to:`/database`,label:`Database`,icon:me},{to:`/mcp`,label:`MCP`,icon:he},{to:`/usage`,label:`Usage`,icon:pe},{to:`/s3`,label:`S3 Backup`,icon:Se},{to:`/settings`,label:`Settings`,icon:ae}]}];function Yt(){let e=V(e=>e.theme),t=V(e=>e.toggle),n=e===`dark`;return(0,I.jsxs)(`button`,{type:`button`,onClick:t,className:`mx-3 mb-3 flex items-center gap-3 rounded-lg px-3 py-2 text-sm text-muted transition-colors hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:[n?(0,I.jsx)(ie,{className:`size-4`}):(0,I.jsx)(xe,{className:`size-4`}),n?`Light Mode`:`Dark Mode`]})}function Xt({open:e=!1,blocked:n=!1,onClose:r}){return(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`Close navigation`,tabIndex:-1,onClick:r,className:`fixed inset-0 z-40 bg-black/50 lg:hidden`}),(0,I.jsxs)(`div`,{id:`app-nav`,role:e?`dialog`:`complementary`,"aria-modal":e||void 0,"aria-label":e?`Navigation menu`:void 0,inert:n?!0:void 0,"aria-hidden":n||void 0,className:t(`flex w-60 shrink-0 flex-col border-r border-line bg-sidebar`,`fixed inset-y-0 left-0 z-50 transition-[transform,visibility] lg:static lg:z-auto lg:translate-x-0`,e?`translate-x-0`:`-translate-x-full lg:translate-x-0 invisible lg:visible`),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-5`,children:[(0,I.jsx)(`span`,{className:`text-lg font-bold tracking-tight text-fg`,children:`bunqueue`}),(0,I.jsx)(`span`,{className:`rounded-md bg-accent/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-accent`,children:`dash`}),(0,I.jsx)(`span`,{title:`Beta — under active development`,className:`rounded-md bg-amber-500/15 px-1.5 py-0.5 text-[10px] font-bold uppercase tracking-wider text-warning`,children:`beta`})]}),(0,I.jsx)(`nav`,{className:`flex-1 overscroll-contain overflow-y-auto px-3 pb-4`,children:Jt.map(e=>(0,I.jsxs)(`div`,{className:`mb-4`,children:[e.section&&(0,I.jsx)(`div`,{className:`px-2 pb-2 pt-1 text-[10px] font-semibold uppercase tracking-wider text-faint`,children:e.section}),(0,I.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:e.items.map(({to:e,label:n,icon:r,end:i})=>(0,I.jsx)(a,{to:e,end:i,className:({isActive:e})=>t(`group relative flex items-center gap-3 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,e?`bg-surface-2 text-fg`:`text-muted hover:bg-surface-2/60 hover:text-fg`),children:({isActive:e})=>(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsx)(`span`,{className:`absolute inset-y-1.5 left-0 w-0.5 rounded-full bg-accent`}),(0,I.jsx)(r,{className:`size-[18px] shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:n})]})},e))})]},e.section??`root`))}),(0,I.jsx)(Rt,{}),(0,I.jsx)(Yt,{}),(0,I.jsx)(qt,{})]})]})}var Zt=`https://egeominotti.github.io/bunqueue-dashboard/docs/`,Qt=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function $t(e){let t=e.parentElement;if(!t)return()=>{};let n=Array.from(t.children).filter(t=>t!==e),r=n.map(e=>({node:e,inert:e.inert,ariaHidden:e.getAttribute(`aria-hidden`)}));for(let e of n)e.inert=!0,e.setAttribute(`aria-hidden`,`true`);return()=>{for(let{node:e,inert:t,ariaHidden:n}of r)e.inert=t,n==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,n)}}function en(){let[e,t]=(0,A.useState)(``),[n,r]=(0,A.useState)(0),i=P(e=>e.active===`command-palette`),a=P(e=>e.release),o=m(),s=V(e=>e.toggle),c=(0,A.useRef)(null),l=(0,A.useRef)(null),u=(0,A.useRef)(null),d=(0,A.useRef)(null),f=(0,A.useCallback)(()=>a(`command-palette`),[a]),p=(0,A.useMemo)(()=>{let e=Jt.flatMap(e=>e.items.map(t=>({id:`nav:${t.to}`,label:t.label,hint:e.section??`Home`,run:()=>o(t.to)}))),t=[{id:`act:theme`,label:`Toggle theme (dark / light)`,hint:`Action`,run:s},{id:`act:docs`,label:`Open documentation`,hint:`Action`,run:()=>window.open(Zt,`_blank`,`noopener`)}];return[...e,...t]},[o,s]),h=(0,A.useMemo)(()=>{let t=e.trim().toLowerCase();return t?p.filter(e=>`${e.label} ${e.hint}`.toLowerCase().includes(t)):p},[p,e]);(0,A.useEffect)(()=>{let e=e=>{if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`k`){e.preventDefault();let t=P.getState();t.active===`command-palette`?t.release(`command-palette`):t.request(`command-palette`)}},t=()=>P.getState().request(`command-palette`);return window.addEventListener(`keydown`,e),window.addEventListener(`command-palette:open`,t),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`command-palette:open`,t)}},[]),(0,A.useEffect)(()=>{if(!i)return;let e=document.activeElement;t(``),r(0);let n=u.current&&!document.getElementById(`app-shell`)?$t(u.current):()=>{},a=requestAnimationFrame(()=>c.current?.focus()),o=e=>{if(e.key===`Escape`){e.preventDefault(),f();return}if(e.key!==`Tab`)return;let t=d.current;if(!t)return;let n=Array.from(t.querySelectorAll(Qt));if(n.length===0){e.preventDefault(),t.focus();return}let r=n[0],i=n[n.length-1],a=document.activeElement;e.shiftKey&&(a===r||!t.contains(a))?(e.preventDefault(),i.focus()):!e.shiftKey&&(a===i||!t.contains(a))&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,o),()=>{cancelAnimationFrame(a),document.removeEventListener(`keydown`,o),n(),F(`command-palette`)&&e?.isConnected&&e.focus()}},[i,f]),(0,A.useEffect)(()=>{l.current?.querySelector(`[data-idx="${n}"]`)?.scrollIntoView({block:`nearest`})},[n]);let g=(0,A.useCallback)(e=>{e&&(e.run(),f())},[f]);return i?(0,I.jsxs)(`div`,{ref:u,className:`fixed inset-0 z-50 flex items-start justify-center p-4 pt-[12vh]`,children:[(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Close command palette`,onClick:f,className:`fixed inset-0 bg-black/50`}),(0,I.jsxs)(`div`,{ref:d,tabIndex:-1,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`relative z-10 w-full max-w-lg overflow-hidden rounded-xl border border-line-strong bg-surface shadow-2xl`,children:[(0,I.jsx)(`input`,{ref:c,role:`combobox`,value:e,onChange:e=>{t(e.target.value),r(0)},onKeyDown:e=>{e.key===`Escape`?(e.preventDefault(),f()):e.key===`ArrowDown`?(e.preventDefault(),r(e=>Math.min(e+1,Math.max(0,h.length-1)))):e.key===`ArrowUp`?(e.preventDefault(),r(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),g(h[n]))},placeholder:`Search pages and actions…`,"aria-label":`Search pages and actions`,"aria-autocomplete":`list`,"aria-expanded":`true`,"aria-controls":`command-palette-results`,"aria-activedescendant":h[n]?`command-palette-option-${n}`:void 0,autoComplete:`off`,name:`command-palette-search`,className:`w-full border-b border-line bg-transparent px-4 py-3 text-sm text-fg outline-none placeholder:text-faint focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent/50`}),(0,I.jsxs)(`div`,{ref:l,id:`command-palette-results`,role:`listbox`,className:`max-h-80 overflow-y-auto overscroll-contain py-2`,"aria-label":`Results`,children:[h.length===0&&(0,I.jsx)(`div`,{role:`presentation`,className:`px-4 py-6 text-center text-sm text-faint`,children:`No matches`}),h.map((e,t)=>(0,I.jsx)(`div`,{role:`presentation`,children:(0,I.jsxs)(`button`,{type:`button`,id:`command-palette-option-${t}`,role:`option`,"aria-selected":t===n,tabIndex:-1,"data-idx":t,onMouseEnter:()=>r(t),onClick:()=>g(e),className:`flex w-full items-center justify-between gap-3 px-4 py-2 text-left text-sm transition-colors ${t===n?`bg-accent/15 text-fg`:`text-muted`}`,children:[(0,I.jsx)(`span`,{className:`truncate`,children:e.label}),(0,I.jsx)(`span`,{className:`shrink-0 text-xs text-faint`,children:e.hint})]})},e.id))]}),(0,I.jsxs)(`div`,{className:`flex items-center justify-between border-t border-line px-4 py-2 text-xs text-faint`,children:[(0,I.jsx)(`span`,{children:`↑↓ navigate · ↵ open · esc close`}),(0,I.jsx)(`span`,{className:`font-mono`,children:`⌘K`})]})]})]}):null}var tn=`bq-dash-copilot`,nn=1,rn=new Set([`anthropic`,`openai`,`google`,`zai`,`openrouter`,`custom`]),U={provider:`anthropic`,baseURL:``,model:`claude-opus-4-8`,apiKey:``};function an(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function on(e,t){return typeof e==`string`?e:t}function sn(e){return typeof e==`string`&&rn.has(e)?e:U.provider}function cn(e,t=``){let n=an(e)?e:{},r=sn(n.provider);return{provider:r,baseURL:r===`custom`?on(n.baseURL,U.baseURL):U.baseURL,model:on(n.model,U.model),apiKey:t}}function W(e){let t=cn((an(e)?e:{}).config);return{config:{provider:t.provider,baseURL:t.baseURL,model:t.model}}}var ln=0,un=()=>globalThis.crypto?.randomUUID?.()??`${Date.now()}-${(ln++).toString(36)}-${Math.random().toString(36).slice(2,8)}`,G=new Map,K=(e,t,n)=>e.map(e=>e.id===t?n(e):e);function dn(e){return W(e)}var fn=b({key:tn,version:nn,sanitizeState:W}),pn=v()(_(e=>({open:!1,config:{...U},messages:[],pending:[],busy:!1,setOpen:t=>e({open:t}),toggle:()=>e(e=>({open:!e.open})),setConfig:t=>e(e=>{let n={...e.config,...t};return{config:cn(n,on(n.apiKey,``))}}),clear:()=>{for(let e of G.values())e(!1);G.clear(),e({messages:[],pending:[]})},cancelPending:()=>{for(let e of G.values())e(!1);G.clear(),e({pending:[]})},setBusy:t=>e({busy:t}),addUser:t=>e(e=>({messages:[...e.messages,{id:un(),role:`user`,content:t}]})),startAssistant:()=>{let t=un();return e(e=>({messages:[...e.messages,{id:t,role:`assistant`,content:``,tools:[]}]})),t},appendAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,content:e.content+n}))})),finishAssistant:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,done:!0,error:!!n?.error,content:n?.error?e.content?`${e.content}\n\n${n.error}`:n.error:e.content}))})),addTool:(t,n)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:[...e.tools??[],n]}))})),updateTool:(t,n,r)=>e(e=>({messages:K(e.messages,t,e=>({...e,tools:(e.tools??[]).map(e=>e.id===n?{...e,...r}:e)}))})),requestConfirm:t=>new Promise(n=>{let r=un();G.set(r,n),e(e=>({pending:[...e.pending,{...t,id:r}]}))}),resolveConfirm:(t,n)=>{let r=G.get(t);r&&(G.delete(t),r(n)),e(e=>({pending:e.pending.filter(e=>e.id!==t)}))}}),{name:tn,version:nn,storage:w(()=>fn),partialize:e=>dn(e),migrate:W,merge:(e,t)=>{let n=W(e);return{...t,config:{...n.config,apiKey:``}}}})),mn=(0,A.lazy)(()=>u(()=>import(`./CopilotPanel-Bhh-uCpN.js`).then(e=>({default:e.CopilotPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),hn=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function gn(e){let t=[],n=e;for(;n?.parentElement&&n.parentElement!==document.documentElement;){let e=n.parentElement;for(let r of Array.from(e.children))r===n||!(r instanceof window.HTMLElement)||(t.push({node:r,inert:r.inert,ariaHidden:r.getAttribute(`aria-hidden`)}),r.inert=!0,r.setAttribute(`aria-hidden`,`true`));n=e}return()=>{for(let{node:e,inert:n,ariaHidden:r}of t)e.inert=n,r==null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,r)}}function _n({className:e}){return(0,I.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{d:`M12 3l1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3z`,fill:`currentColor`}),(0,I.jsx)(`path`,{d:`M19 14l.8 2 2 .8-2 .8-.8 2-.8-2-2-.8 2-.8.8-2z`,fill:`currentColor`,opacity:`0.7`})]})}var vn=class extends A.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,I.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Copilot failed to load`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md flex-col items-center justify-center gap-3 border-l border-line bg-surface px-6 text-center`,children:[(0,I.jsx)(`p`,{className:`text-sm text-fg`,children:`Copilot failed to load.`}),(0,I.jsx)(`p`,{className:`text-xs text-muted`,children:`The panel is loaded on demand; the request failed. If the dashboard was just redeployed, reload the page. The rest of the dashboard is unaffected.`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{this.setState({failed:!1}),this.props.onClose()},className:`rounded-lg border border-line px-3 py-1.5 text-sm text-muted hover:bg-surface-2 hover:text-fg`,children:`Close`})]}):this.props.children}};function yn(){let e=pn(e=>e.open),t=pn(e=>e.setOpen),n=P(e=>e.active),r=e&&n===`copilot`,i=(0,A.useRef)(null),a=(0,A.useRef)(null),o=(0,A.useRef)(null);return(0,A.useEffect)(()=>{let r=P.getState();if(e){if(n===`copilot`)return;r.request(`copilot`)||t(!1);return}r.release(`copilot`)},[e,n,t]),(0,A.useEffect)(()=>()=>{P.getState().release(`copilot`)},[]),(0,A.useEffect)(()=>{if(!r||!i.current)return;let e=i.current,n=document.getElementById(`app-shell`)?()=>{}:gn(e),s=requestAnimationFrame(()=>{let t=e.querySelector(hn),n=e.querySelector(`[role="dialog"]`);(t??n??e).focus()}),c=n=>{if(n.key===`Escape`){n.preventDefault(),t(!1);return}if(n.key!==`Tab`)return;let r=Array.from(e.querySelectorAll(hn));if(r.length===0){n.preventDefault(),(e.querySelector(`[role="dialog"]`)??e).focus();return}let i=r[0],a=r[r.length-1],o=document.activeElement;n.shiftKey&&(o===i||!e.contains(o))?(n.preventDefault(),a.focus()):!n.shiftKey&&(o===a||!e.contains(o))&&(n.preventDefault(),i.focus())};return document.addEventListener(`keydown`,c),()=>{cancelAnimationFrame(s),document.removeEventListener(`keydown`,c),n();let e=a.current;requestAnimationFrame(()=>{F(`copilot`)&&(e?.isConnected?e.focus():o.current?.focus())})}},[r,t]),(0,I.jsxs)(I.Fragment,{children:[!r&&(0,I.jsxs)(`button`,{ref:o,type:`button`,onClick:e=>{a.current=e.currentTarget,P.getState().request(`copilot`)&&t(!0)},className:`fixed bottom-5 right-5 z-40 flex items-center gap-2 rounded-full border border-line bg-surface px-4 py-2.5 text-sm font-medium text-fg shadow-lg transition-colors hover:border-accent/50 hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,"aria-label":`Open Copilot`,children:[(0,I.jsx)(_n,{className:`size-4 text-accent`}),`Copilot`,(0,I.jsx)(`span`,{className:`rounded bg-accent/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-accent`,children:`beta`})]}),r&&(0,I.jsx)(`div`,{ref:i,tabIndex:-1,className:`contents`,children:(0,I.jsx)(vn,{onClose:()=>t(!1),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Loading Copilot`,tabIndex:-1,className:`fixed inset-y-0 right-0 z-[60] flex w-full max-w-md items-center justify-center border-l border-line bg-surface text-sm text-muted`,children:`Loading Copilot…`}),children:(0,I.jsx)(mn,{})})})})]})}var bn=class extends A.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error`,e,t.componentStack)}componentDidUpdate(e){this.state.error&&e.resetKey!==this.props.resetKey&&this.setState({error:null})}render(){let{error:e}=this.state;return e?(0,I.jsx)(`div`,{className:`flex min-h-screen items-center justify-center p-6`,children:(0,I.jsxs)(O,{className:`w-full max-w-lg`,children:[(0,I.jsx)(Oe,{error:e}),(0,I.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,I.jsx)(Ee,{onClick:()=>window.location.reload(),children:`Reload`})})]})}):this.props.children}},xn={success:{bar:`bg-emerald-500`,title:`text-success`},error:{bar:`bg-red-500`,title:`text-danger`},info:{bar:`bg-accent`,title:`text-accent`}};function Sn({toast:e,dismiss:n}){(0,A.useEffect)(()=>{let t=window.setTimeout(()=>n(e.id),e.ttlMs);return()=>window.clearTimeout(t)},[e.id,e.ttlMs,n]);let r=xn[e.level];return(0,I.jsxs)(`div`,{className:`pointer-events-auto flex w-80 max-w-[calc(100vw-2rem)] overflow-hidden rounded-lg border border-line bg-surface shadow-lg`,children:[(0,I.jsx)(`span`,{className:t(`w-1 shrink-0`,r.bar),"aria-hidden":`true`}),(0,I.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 px-3 py-2.5`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:t(`text-sm font-medium`,r.title),children:e.title}),e.detail&&(0,I.jsx)(`div`,{className:`mt-0.5 break-words text-xs text-muted`,children:e.detail})]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>n(e.id),"aria-label":`Dismiss notification`,className:`-mr-1 shrink-0 rounded p-0.5 text-faint hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:(0,I.jsx)(_e,{className:`size-4`})})]})]})}function Cn(){let e=te(e=>e.toasts),t=te(e=>e.dismiss);return e.length===0?null:(0,I.jsx)(`section`,{className:`pointer-events-none fixed bottom-4 right-4 z-[60] flex flex-col gap-2`,"aria-label":`Notifications`,"aria-live":`polite`,children:e.map(e=>(0,I.jsx)(Sn,{toast:e,dismiss:t},e.id))})}function wn(e,t){(0,A.useLayoutEffect)(()=>{let t=e.current;t&&(t.scrollTop=0,t.scrollLeft=0)},[t,e])}var Tn={"/":`Overview`,"/queues":`Queues`,"/jobs":`Jobs`,"/dlq":`Dead Letter Queue`,"/cron":`Cron Jobs`,"/flows":`Flows`,"/workflows":`Workflow · Overview`,"/workflows/executions":`Workflow · Executions`,"/workflows/waiting":`Workflow · Waiting & Signals`,"/workflows/compensation":`Workflow · Compensation`,"/workflows/archive":`Workflow · Archive`,"/metrics":`Metrics`,"/workers":`Workers`,"/logs":`Logs`,"/server":`Server`,"/add-job":`Add Job`,"/jobs/bulk-add":`Bulk Add Jobs`,"/job":`Job Inspector`,"/queue-control":`Queue Control`,"/dlq-control":`DLQ Control`,"/webhooks":`Webhooks`,"/diagnostics":`Diagnostics`,"/alerts":`Alerts`,"/benchmark":`Benchmark`,"/database":`Database`,"/mcp":`MCP`,"/usage":`Usage`,"/s3":`S3 Backup`,"/settings":`Settings`,"/overview-classic":`Overview (classic)`,"/queues-classic":`Queues (classic)`,"/jobs-classic":`Jobs (classic)`,"/dlq-classic":`DLQ (classic)`,"/cron-classic":`Cron Jobs (classic)`,"/metrics-classic":`Metrics (classic)`,"/workers-classic":`Workers (classic)`,"/logs-classic":`Logs (classic)`,"/usage-classic":`Usage (classic)`,"/s3-classic":`S3 Backup (classic)`};function En(e){let t=e.length>1?e.replace(/\/+$/,``):e;if(Tn[t])return Tn[t];let n=t.startsWith(`/queues-classic/`);if(n||t.startsWith(`/queues/`)){let e=t.slice(n?16:8);try{e=decodeURIComponent(e)}catch{}return`${e} · Queue${n?` (classic)`:``}`}return`Page not found`}function Dn(e){(0,A.useEffect)(()=>{document.title=`${e} · bunqueue`},[e])}var On=H();function kn({onMenu:e,navOpen:t=!1}){let{pathname:n}=o(),r=En(n);return Dn(r),(0,I.jsxs)(`header`,{className:`sticky top-0 z-10 flex h-14 items-center justify-between gap-3 border-b border-line bg-bg/80 px-4 backdrop-blur sm:px-6 lg:px-8`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`Open navigation`,"aria-expanded":t,"aria-controls":`app-nav`,onClick:t=>e?.(t.currentTarget),className:`-ml-1 flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 lg:hidden`,children:(0,I.jsx)(de,{className:`size-5`})}),(0,I.jsxs)(`div`,{className:`truncate text-sm text-muted`,children:[(0,I.jsx)(`span`,{className:`text-faint`,children:r}),(0,I.jsx)(`span`,{className:`mx-2 hidden text-faint sm:inline`,children:`·`}),(0,I.jsx)(`span`,{className:`hidden text-faint sm:inline`,children:`bunqueue`})]})]}),(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[On&&(0,I.jsxs)(`span`,{title:`Showing canned sample data. No real bunqueue server is connected.`,className:`hidden items-center gap-1.5 rounded-full border border-accent/40 bg-accent/10 px-2.5 py-1 text-xs font-medium text-accent sm:inline-flex`,children:[(0,I.jsx)(`span`,{className:`size-1.5 rounded-full bg-accent`}),`Live demo`]}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette`,"aria-label":`Open command palette`,className:`flex size-9 shrink-0 items-center justify-center rounded-lg text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:hidden`,children:(0,I.jsx)(se,{className:`size-5`})}),(0,I.jsxs)(`button`,{type:`button`,onClick:()=>window.dispatchEvent(new Event(`command-palette:open`)),title:`Command palette (⌘K)`,"aria-label":`Open command palette`,className:`hidden items-center gap-2 rounded-lg border border-line px-2.5 py-1.5 text-xs text-muted hover:bg-surface-2 hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50 sm:flex`,children:[(0,I.jsx)(`span`,{children:`Search`}),(0,I.jsx)(`kbd`,{className:`rounded border border-line bg-surface-2 px-1 font-mono text-[10px]`,children:`⌘K`})]}),(0,I.jsx)(d,{to:`/settings`,title:`Settings`,"aria-label":`Open settings`,className:`flex size-8 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-accent to-fuchsia-600 text-xs font-bold text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`bq`})]})]})}function An(){let[e,n]=(0,A.useState)(!1),{pathname:r,key:i}=o(),a=(0,A.useRef)(null),s=(0,A.useRef)(null),c=P(e=>e.active),u=P(e=>e.request),d=P(e=>e.release),f=e&&c===`mobile-navigation`,p=(0,A.useCallback)(()=>{n(!1),d(`mobile-navigation`)},[d]);return wn(a,i),(0,A.useEffect)(()=>p(),[r,p]),(0,A.useEffect)(()=>{let e=window.matchMedia(`(min-width: 1024px)`),t=()=>e.matches&&p();return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[p]),(0,A.useEffect)(()=>{if(!f)return;let e=e=>{e.key===`Escape`&&p()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[f,p]),(0,A.useEffect)(()=>{if(!f)return;let e=document.getElementById(`app-nav`),t=()=>e?Array.from(e.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`)):[],n=()=>t()[0]?.focus(),r=setTimeout(n,0),i=setTimeout(()=>{e?.contains(document.activeElement)||n()},200),a=n=>{if(n.key!==`Tab`)return;let r=t();if(!r.length)return;let i=r[0],a=r[r.length-1];e?.contains(document.activeElement)?n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus()):(n.preventDefault(),(n.shiftKey?a:i).focus())};return window.addEventListener(`keydown`,a),()=>{clearTimeout(r),clearTimeout(i),window.removeEventListener(`keydown`,a);let e=s.current;F(`mobile-navigation`)&&e?.isConnected&&e.focus()}},[f]),(0,A.useEffect)(()=>{e&&c!==`mobile-navigation`&&n(!1)},[e,c]),(0,A.useEffect)(()=>{let e=()=>p();return window.addEventListener(`auth:gate-opened`,e),window.addEventListener(`command-palette:open`,e),()=>{window.removeEventListener(`auth:gate-opened`,e),window.removeEventListener(`command-palette:open`,e)}},[p]),(0,A.useEffect)(()=>()=>{P.getState().release(`mobile-navigation`)},[]),(0,I.jsx)(bn,{children:(0,I.jsxs)(`div`,{id:`app-shell`,className:`flex h-screen overflow-hidden bg-bg text-fg`,children:[(0,I.jsx)(`a`,{href:`#main`,inert:c!==null||void 0,tabIndex:c===null?void 0:-1,className:`sr-only rounded-md bg-accent px-3 py-2 text-sm font-medium text-accent-fg shadow-lg focus:not-sr-only focus:absolute focus:left-4 focus:top-3 focus:z-50`,children:`Skip to content`}),(0,I.jsx)(Xt,{open:f,blocked:c!==null&&c!==`mobile-navigation`,onClose:p}),(0,I.jsxs)(`div`,{id:`app-content`,className:`flex min-w-0 flex-1 flex-col`,inert:c!==null||void 0,"aria-hidden":c!==null||void 0,children:[(0,I.jsx)(kn,{navOpen:f,onMenu:e=>{u(`mobile-navigation`)&&(s.current=e,n(!0))}}),(0,I.jsx)(`main`,{ref:a,id:`main`,tabIndex:-1,className:t(`flex-1 px-4 pt-5 pb-24 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-accent sm:px-6 lg:px-8 lg:pt-6`,f?`overflow-hidden`:`overflow-y-auto`),children:(0,I.jsx)(A.Suspense,{fallback:(0,I.jsx)(`div`,{className:`p-2 text-sm text-muted`,children:`Loading…`}),children:(0,I.jsx)(bn,{resetKey:i,children:(0,I.jsx)(l,{})})})})]}),(0,I.jsx)(en,{}),(0,I.jsx)(Mt,{}),(0,I.jsx)(`div`,{id:`copilot-layer`,inert:c!==null&&c!==`copilot`||void 0,"aria-hidden":c!==null&&c!==`copilot`||void 0,children:(0,I.jsx)(yn,{})}),(0,I.jsx)(Cn,{}),(0,I.jsx)(kt,{})]})})}var jn={default:`text-fg`,green:`text-success`,red:`text-danger`,blue:`text-blue-400 light:text-blue-700`,amber:`text-warning`,accent:`text-accent`};function q({label:e,value:n,tone:r=`default`,hint:i,compact:a}){return(0,I.jsxs)(`div`,{className:t(`rounded-xl border border-line bg-surface`,a?`px-4 py-3`:`px-5 py-4`),children:[(0,I.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wider text-faint`,children:e}),(0,I.jsx)(`div`,{className:t(`mt-2 font-semibold tnum`,a?`text-xl`:`text-3xl`,jn[r]),children:n}),i!=null&&(0,I.jsx)(`div`,{className:`mt-1 text-xs text-faint`,children:i})]})}var Mn={overview:{stats:{waiting:0,active:0,delayed:0,completed:0,dlq:0,totalPushed:0,totalPulled:0,totalCompleted:0,totalFailed:0,uptime:0},throughput:{pushPerSec:0,pullPerSec:0,completePerSec:0,failPerSec:0},memory:{heapUsed:0,heapTotal:0,rss:0},crons:{total:0}},queuesTotal:0,details:[],failedTotal:0,readyTotal:0};function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e,t){return Nn(e)&&t.every(t=>typeof e[t]==`number`&&Number.isFinite(e[t]))}function Pn(e){if(!Nn(e)||!J(e.stats,[`waiting`,`active`,`completed`,`dlq`,`totalPushed`,`totalPulled`,`uptime`])||!J(e.throughput,[`pushPerSec`,`pullPerSec`])||!J(e.memory,[`rss`])||!J(e.crons,[`total`]))throw Error(`Malformed /dashboard response: required overview metrics are missing or non-numeric.`)}var Fn=class extends Error{status;lastEventIdSent;constructor(e,t,n=!1){super(e),this.status=t,this.lastEventIdSent=n,this.name=`SseConnectError`}},In=new Set([400,409,413,431]);function Ln(e){return e instanceof Fn&&e.lastEventIdSent&&In.has(e.status)}function Rn(e){return!e.includes(`\0`)&&e.length<=4096}function zn(e){return!0}function Bn(e){let t=`message`,n,r=[];for(let i of e.split(`
|
|
3
|
+
`)){if(!i||i.startsWith(`:`))continue;let e=i.indexOf(`:`),a=e===-1?i:i.slice(0,e),o=e===-1?``:i.slice(e+1).replace(/^ /,``);a===`event`?t=o:a===`data`?r.push(o):a===`id`&&Rn(o)&&(n=o)}if(r.length===0)return null;let i=r.join(`
|
|
4
|
+
`),a=i;try{a=JSON.parse(i)}catch{}return{id:n,event:t,data:a}}var Vn=45e3,Hn=256*1024;async function Un(e,t,n,r=Vn,i){let a=new AbortController,o=()=>a.abort(n.reason);n.aborted?a.abort(n.reason):n.addEventListener(`abort`,o,{once:!0});let s,c=()=>{clearTimeout(s),s=setTimeout(()=>a.abort(Error(`SSE idle timeout`)),r)};try{c();let n=new Headers({Accept:`text/event-stream`,...C()}),r=!1;if(i&&Rn(i))try{n.set(`Last-Event-ID`,i),r=!0}catch{n.delete(`Last-Event-ID`)}let o=await fetch(e,{headers:n,signal:a.signal});if(!o.ok||!o.body)throw await o.body?.cancel().catch(()=>{}),new Fn(o.ok?`SSE connect failed: empty response body`:`SSE connect failed: HTTP ${o.status}`,o.status,r);let s=o.headers.get(`content-type`)?.split(`;`,1)[0]?.trim().toLowerCase();if(s!==`text/event-stream`)throw await o.body.cancel().catch(()=>{}),new Fn(`SSE connect failed: expected text/event-stream, received ${s||`no Content-Type`}`,o.status,r);let l=o.body.getReader(),u=new TextDecoder,d=``;try{for(;;){let{done:e,value:n}=await l.read();if(e)break;for(c(),d+=u.decode(n,{stream:!0});;){let e=d.indexOf(`
|
|
5
|
+
|
|
6
|
+
`),n=d.indexOf(`\r
|
|
7
|
+
\r
|
|
8
|
+
`),r,i;if(e!==-1&&(n===-1||e<=n))r=e,i=2;else if(n!==-1)r=n,i=4;else{if(d.length>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);break}if(r>262144)throw Error(`SSE frame exceeds the ${Hn}-character limit`);let a=d.slice(0,r);d=d.slice(r+i);let o=Bn(a.replace(/\r/g,``));o&&t(o)}}}finally{l.releaseLock()}}finally{clearTimeout(s),n.removeEventListener(`abort`,o),a.abort()}}var Y={total:0,completed:0,failed:0,waiting:0,active:0},Wn=250,Gn=()=>typeof performance<`u`?performance.now():Date.now();function Kn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(e,t){return typeof e==`string`&&e.length<=t?e:void 0}function qn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Jn(e,t){let n=qn(e);return n!==void 0&&Math.abs(n)<=864e13?n:Number.isFinite(t)&&Math.abs(t)<=864e13?t:0}function Yn(e){let t=Kn(e)?e:{},n=Date.now();return{queue:X(t.queue,256),jobId:X(t.jobId,1024),name:X(t.name,512),timestamp:Jn(t.timestamp,n),error:X(t.error,4096),progress:qn(t.progress)}}function Xn(e){let t=e.includes(`:`)?e.split(`:`)[1]:e;switch(t){case`pushed`:case`added`:return`waiting`;case`pulled`:return`active`;case`progress`:return`active`;default:return t}}function Zn(e){let t=S(e=>e.baseUrl),n=S(e=>e.token),[r,i]=(0,A.useState)([]),[a,o]=(0,A.useState)(Y),[s,c]=(0,A.useState)(0),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),p=(0,A.useRef)([]),m=(0,A.useRef)(0),h=JSON.stringify([t,n,e??null]),g=(0,A.useRef)(h),_=g.current===h,v=_?r:[],y=_?a:Y,b=_?s:0,x=_?l:!1,C=_?d:null;return(0,A.useEffect)(()=>{let t=new AbortController,n=++m.current,r=0,a=!1,s=[],l={...Y},d,_=()=>!a&&m.current===n;g.current=h,i([]),o(Y),c(0),u(!1),f(null),p.current=[];let v=e=>new Promise(n=>{let r=()=>{clearTimeout(i),n()},i=setTimeout(()=>{t.signal.removeEventListener(`abort`,r),n()},e);t.signal.addEventListener(`abort`,r,{once:!0})}),y=e=>{if(!_()||(e.id!==void 0&&(d=e.id||void 0),zn(e)&&(u(e=>_()?!0:e),f(e=>_()?null:e)),!e.event.startsWith(`job:`)))return;let t=Yn(e.data),n=Xn(e.event),i={seq:++r,event:e.event,queue:t.queue,jobId:t.jobId,name:t.name,status:n,timestamp:t.timestamp,error:t.error,progress:t.progress};s.push(i);let a=l;a.total+=1,n===`completed`?a.completed+=1:n===`failed`?a.failed+=1:n===`waiting`?a.waiting+=1:n===`active`&&(a.active+=1),p.current.push(Gn())};(async()=>{let n=0;for(;!a;){let r=null,i=d,a=!1;try{await Un(we.eventsUrl(e),e=>{a=!0,y(e)},t.signal,void 0,i)}catch(e){r=e instanceof Error?e:Error(String(e))}if(i&&!a&&d===i&&Ln(r)&&(d=void 0),!_())break;u(e=>!_()&&e),f(e=>_()?r:e),n=r?Math.min(n+1,8):0,await v(2e3*Math.max(1,n))}})();let b=setInterval(()=>{if(!_())return;if(s.length){let e=s;s=[],e.reverse(),i(t=>_()?[...e,...t].slice(0,Wn):t)}let e=l;e.total&&(l={...Y},o(t=>_()?{total:t.total+e.total,completed:t.completed+e.completed,failed:t.failed+e.failed,waiting:t.waiting+e.waiting,active:t.active+e.active}:t))},150);return()=>{a=!0,m.current===n&&(m.current+=1),t.abort(),clearInterval(b)}},[e,t,n,h]),(0,A.useEffect)(()=>{let e=setInterval(()=>{let e=Gn();p.current=p.current.filter(t=>t<=e&&e-t<5e3),c(p.current.length/5)},1e3);return()=>clearInterval(e)},[]),{events:v,counters:y,throughput:b,connected:x,error:C}}function Qn(){let{events:e,connected:n,error:r}=Zn();return(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Recent Activity`,to:`/logs`}),(0,I.jsxs)(O,{padded:!1,children:[r&&e.length>0&&(0,I.jsxs)(`p`,{className:`border-b border-line px-5 py-2 text-xs text-warning`,children:[`Event stream unavailable — `,r.message,`. Reconnecting…`]}),e.length===0?(0,I.jsx)(`p`,{role:r?`alert`:void 0,className:t(`py-8 text-center text-sm`,r?`text-warning`:`text-faint`),children:r?`Event stream unavailable — ${r.message}. Reconnecting…`:n?`Waiting for live activity…`:`Connecting to the event stream…`}):(0,I.jsx)(`ul`,{className:`divide-y divide-line`,children:e.slice(0,8).map(e=>(0,I.jsxs)(`li`,{className:`flex items-center justify-between px-5 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:t(`size-2 rounded-full`,er(e.status))}),(0,I.jsxs)(`div`,{className:`text-sm`,children:[(0,I.jsx)(`span`,{className:`font-mono font-medium text-fg`,children:e.queue||`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`font-mono text-xs text-faint`,children:e.jobId?e.jobId.slice(0,8):`—`}),(0,I.jsx)(`span`,{className:`text-faint`,children:` · `}),(0,I.jsx)(`span`,{className:`capitalize text-muted`,children:e.status})]})]}),(0,I.jsx)(`span`,{className:`text-xs text-faint`,children:Me(e.timestamp)})]},e.seq))})]})]})}function $n({title:e,to:t}){return(0,I.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-lg font-semibold text-fg`,children:e}),(0,I.jsxs)(d,{to:t,className:`flex items-center gap-1 text-sm text-muted hover:text-fg`,children:[`View All `,(0,I.jsx)(ge,{className:`size-3.5`})]})]})}function Z({label:e,value:n,tone:r}){return(0,I.jsxs)(`span`,{children:[e,` `,(0,I.jsx)(`span`,{className:t(`tnum font-semibold`,r),children:n==null?`—`:k(n)})]})}function er(e){return e===`completed`?`bg-emerald-400`:e===`failed`?`bg-red-400`:e===`active`?`bg-blue-400`:e===`waiting`?`bg-amber-400`:`bg-accent`}function tr(){let e=S(e=>e.baseUrl),n=(0,A.useRef)(null),{data:r,error:i,loading:a,refetch:o}=Te(async()=>{let[e,t]=await Promise.all([T.overview(),T.queuesSummary()]);Pn(e);let r=[...t].sort((e,t)=>(t.counts?.failed??0)-(e.counts?.failed??0)||(t.counts?.waiting??0)+(t.counts?.prioritized??0)-((e.counts?.waiting??0)+(e.counts?.prioritized??0))).slice(0,6).map(e=>({name:e.name,paused:e.paused,counts:e.counts})),i=t.reduce((e,t)=>e+(t.counts?.failed??0),0),a=t.reduce((e,t)=>e+t.counts.waiting+t.counts.prioritized,0);return n.current=Date.now(),{overview:e,queuesTotal:t.length,details:r,failedTotal:i,readyTotal:a}},[]);if(a&&!r&&!i)return(0,I.jsx)(ke,{label:`Loading overview…`});if(i&&!r)return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health is unavailable.`}),(0,I.jsx)(Oe,{error:i,onRetry:o})]});let{overview:s,queuesTotal:c,details:l,failedTotal:u,readyTotal:f}=r??Mn,{stats:p,throughput:m,memory:h,crons:g}=s,_=Fe(p.completed,u),v=e===`/api`?`localhost:6790`:e.replace(/^https?:\/\//,``),y=p.uptime?Ie(p.uptime/1e3):`—`,b=Ne(h.rss*1024*1024),x=!!i;return(0,I.jsxs)(`div`,{children:[(0,I.jsx)(Ae,{title:`Overview`,description:`Real-time system health at a glance.`,live:!!r&&!i}),i&&(0,I.jsx)(De,{message:`Connection lost — showing the last successful overview snapshot.`,onRetry:o}),(0,I.jsxs)(`div`,{className:t(`mb-6 flex flex-wrap items-center justify-between gap-y-2 rounded-xl border px-5 py-4`,x?`border-amber-500/25 bg-amber-500/[0.06]`:`border-emerald-500/25 bg-emerald-500/[0.06]`),children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,I.jsxs)(`span`,{className:`relative flex size-2.5`,children:[!x&&(0,I.jsx)(`span`,{className:`absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60`}),(0,I.jsx)(`span`,{className:t(`relative inline-flex size-2.5 rounded-full`,x?`bg-amber-400`:`bg-emerald-400`)})]}),(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`div`,{className:t(`font-semibold`,x?`text-warning`:`text-success`),children:x?`Connection lost — showing last known data`:`bunqueue server connected`}),(0,I.jsxs)(`div`,{className:`truncate font-mono text-xs text-muted`,children:[v,` · uptime `,y,` · `,b,` RAM`,x&&(0,I.jsxs)(I.Fragment,{children:[` `,`· last updated `,n.current?Me(n.current):`never`]})]})]})]}),(0,I.jsx)(`span`,{className:t(`rounded-full px-3 py-1 text-xs font-medium`,x?`bg-amber-500/15 text-warning`:`bg-emerald-500/15 text-success`),children:x?`Stale`:`Online`})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-3`,children:[(0,I.jsx)(q,{label:`Error Rate`,value:_==null?`—`:je(_),tone:_==null?`default`:_>.05?`red`:`green`,hint:`failed / processed`}),(0,I.jsx)(q,{label:`Failed`,value:k(u),tone:u?`red`:`default`,hint:`recorded across queues`}),(0,I.jsx)(q,{label:`DLQ`,value:k(p.dlq),tone:p.dlq?`red`:`default`,hint:`dead-lettered jobs`})]}),(0,I.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-4 md:grid-cols-3 xl:grid-cols-6`,children:[(0,I.jsx)(q,{label:`Completed`,value:k(p.completed),tone:`green`,compact:!0}),(0,I.jsx)(q,{label:`Active`,value:k(p.active),tone:`blue`,compact:!0}),(0,I.jsx)(q,{label:`Ready backlog`,value:k(f),tone:f>100?`amber`:`default`,hint:`waiting + prioritized`,compact:!0}),(0,I.jsx)(q,{label:`Push/sec`,value:m.pushPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPushed)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Pull/sec`,value:m.pullPerSec.toFixed(1),tone:`accent`,hint:`${Pe(p.totalPulled)} since restart`,compact:!0}),(0,I.jsx)(q,{label:`Queues`,value:k(c),hint:`${g.total} cron active`,compact:!0})]}),(0,I.jsxs)(`div`,{className:`mt-8`,children:[(0,I.jsx)($n,{title:`Queue Health — most loaded`,to:`/queues`}),l.length===0?(0,I.jsx)(O,{children:(0,I.jsx)(`p`,{className:`py-4 text-center text-sm text-faint`,children:`No queues yet.`})}):(0,I.jsx)(`div`,{className:`grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,I.jsxs)(d,{to:`/queues/${encodeURIComponent(e.name)}`,className:`rounded-xl border border-line bg-surface p-4 transition-colors hover:border-line-strong`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate font-mono text-sm font-medium text-accent`,children:e.name}),(0,I.jsx)(`span`,{className:t(`shrink-0 rounded-full px-2 py-0.5 text-[11px] font-medium`,e.paused?`bg-orange-500/10 text-orange-400`:`bg-emerald-500/10 text-success`),children:e.paused?`paused`:`active`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs text-faint`,children:[(0,I.jsx)(Z,{label:`W`,value:e.counts?.waiting,tone:`text-warning`}),(0,I.jsx)(Z,{label:`P`,value:e.counts?.prioritized,tone:`text-orange-400`}),(0,I.jsx)(Z,{label:`A`,value:e.counts?.active,tone:`text-blue-400`}),(0,I.jsx)(Z,{label:`C`,value:e.counts?.completed,tone:`text-success`}),(0,I.jsx)(Z,{label:`F`,value:e.counts?.failed,tone:`text-danger`})]})]},e.name))})]}),(0,I.jsx)(Qn,{})]})}function nr(){return(0,I.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-3 py-24 text-center`,children:[(0,I.jsx)(`h1`,{className:`text-5xl font-bold text-faint`,children:`404`}),(0,I.jsx)(`p`,{className:`text-sm text-muted`,children:`This page does not exist.`}),(0,I.jsx)(d,{to:`/`,className:`rounded-lg border border-line bg-surface-2 px-4 py-2 text-sm font-medium text-fg hover:border-line-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50`,children:`Back to Overview`})]})}var rr=(0,A.lazy)(()=>u(()=>import(`./AddJob-CC4bfHLH.js`).then(e=>e.t).then(e=>({default:e.AddJob})),__vite__mapDeps([8,1,2,5,3,4,9,10,11,12,13,14,7,15,16]))),ir=(0,A.lazy)(()=>u(()=>import(`./Benchmark-ClJmYZoC.js`).then(e=>({default:e.Benchmark})),__vite__mapDeps([17,1,2,4,3,5,18,10,11,12,13,14,19,7,20]))),ar=(0,A.lazy)(()=>u(()=>import(`./BulkAddJobs-BBWqQpP7.js`).then(e=>({default:e.BulkAddJobs})),__vite__mapDeps([21,1,2,5,3,4,9,10,11,12,13,14,7,15,16]))),or=(0,A.lazy)(()=>u(()=>import(`./CronManager-lNZ4lHh1.js`).then(e=>({default:e.CronManager})),__vite__mapDeps([22,1,2,5,3,4,9,18,10,11,12,23,13,14,19,7,24,15,16,8]))),sr=(0,A.lazy)(()=>u(()=>import(`./Database-DxiXsUl4.js`).then(e=>({default:e.Database})),__vite__mapDeps([25,1,2,4,3,5,9,18,10,11,12,23,13,14,19,7,24]))),cr=(0,A.lazy)(()=>u(()=>import(`./Diagnostics-DLvCT7zI.js`).then(e=>({default:e.Diagnostics})),__vite__mapDeps([26,1,2,3,4,5,9,27,10,11,12,23,14,13,19]))),lr=(0,A.lazy)(()=>u(()=>import(`./DlqControl-DJGhuyu3.js`).then(e=>({default:e.DlqControl})),__vite__mapDeps([28,1,2,3,4,5,9,18,10,11,23,13,14,19,7,24,29,30,31,12,15,32]))),ur=(0,A.lazy)(()=>u(()=>import(`./DlqPro-BhXIKtrt.js`).then(e=>({default:e.DlqPro})),__vite__mapDeps([33,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,29,30,31,15,32]))),dr=(0,A.lazy)(()=>u(()=>import(`./Flows-Bb9j-YhZ.js`).then(e=>({default:e.Flows})),__vite__mapDeps([34,1,2,4,5,3,12,23,13,14,35]))),fr=(0,A.lazy)(()=>u(()=>import(`./JobInspector-DfqBq4O5.js`).then(e=>({default:e.JobInspector})),__vite__mapDeps([36,1,2,4,5,3,18,11,12,23,14,13,19,7,29,30,37]))),pr=(0,A.lazy)(()=>u(()=>import(`./JobsPro-D8dH9um7.js`).then(e=>({default:e.JobsPro})),__vite__mapDeps([38,1,2,3,4,5,9,18,10,11,23,14,13,19,7,24,15,30,37]))),mr=(0,A.lazy)(()=>u(()=>import(`./LogsPro-BCB7etG2.js`).then(e=>({default:e.LogsPro})),__vite__mapDeps([39,1,2,4,18,10,11,23,14,13,19,7,24,31,3,5,12,15,32,29]))),hr=(0,A.lazy)(()=>u(()=>import(`./McpServer-Cz1-GwD5.js`).then(e=>({default:e.McpServer})),__vite__mapDeps([40,2,1,12,13,14]))),gr=(0,A.lazy)(()=>u(()=>import(`./MetricsPro-BbJmy0oO.js`).then(e=>({default:e.MetricsPro})),__vite__mapDeps([41,1,2,3,4,5,10,12,23,13,14,19,24,20,42]))),_r=(0,A.lazy)(()=>u(()=>import(`./QueueControl-CWHsVfWU.js`).then(e=>({default:e.QueueControl})),__vite__mapDeps([31,1,2,3,4,5,10,11,12,23,14,13,19,7,15,32,29]))),vr=(0,A.lazy)(()=>u(()=>import(`./QueueDetailPro-CIimG0pX.js`).then(e=>({default:e.QueueDetailPro})),__vite__mapDeps([43,1,2,3,4,5,9,18,10,11,12,23,14,13,19,15,29,20,32,7,42]))),yr=(0,A.lazy)(()=>u(()=>import(`./QueuesOverview-ChC5Dtqh.js`).then(e=>({default:e.QueuesOverview})),__vite__mapDeps([44,1,2,3,4,5,9,18,10,11,23,13,14,19,24,15,45]))),br=(0,A.lazy)(()=>u(()=>import(`./S3BackupPro-BkwTXdtw.js`).then(e=>({default:e.S3BackupPro})),__vite__mapDeps([46,1,2,4,3,5,18,10,11,12,13,14,7]))),xr=(0,A.lazy)(()=>u(()=>import(`./ServerControl-DJHKMaf9.js`).then(e=>({default:e.ServerControl})),__vite__mapDeps([47,1,2,3,4,5,18,10,11,12,23,13,14,19,7]))),Sr=(0,A.lazy)(()=>u(()=>import(`./UsagePro-DMxrXxur.js`).then(e=>({default:e.UsagePro})),__vite__mapDeps([48,2,1,3,4,5,10,12,23,13,14,19]))),Cr=(0,A.lazy)(()=>u(()=>import(`./Webhooks-D0JQQf0q.js`).then(e=>({default:e.Webhooks})),__vite__mapDeps([49,1,2,3,4,5,9,18,10,11,12,23,13,14,19,7,24,15]))),wr=(0,A.lazy)(()=>u(()=>import(`./WorkersPro-BOTuX9EP.js`).then(e=>({default:e.WorkersPro})),__vite__mapDeps([50,1,2,3,4,5,18,10,11,23,13,14,19,15]))),Q=(0,A.lazy)(()=>u(()=>import(`./Workflows-DqTKWPmT.js`).then(e=>({default:e.Workflows})),__vite__mapDeps([51,1,2,4,5,3,9,10,12,23,14,13,19,35]))),Tr=(0,A.lazy)(()=>u(()=>import(`./Alerts-C2bAi-Kj.js`).then(e=>({default:e.Alerts})),__vite__mapDeps([52,1,2,4,18,11,12,23,13,14,19,7]))),Er=(0,A.lazy)(()=>u(()=>import(`./Cron-pJJ5KXFG.js`).then(e=>({default:e.Cron})),__vite__mapDeps([53,1,2,18,27,4,5,10,11,23,13,14,19,24,15]))),Dr=(0,A.lazy)(()=>u(()=>import(`./Dlq-Bx4YXTp5.js`).then(e=>({default:e.Dlq})),__vite__mapDeps([54,1,2,18,27,4,5,10,11,23,13,14,19,7,24,29,55,3,45]))),Or=(0,A.lazy)(()=>u(()=>import(`./Jobs-Blavwd1H.js`).then(e=>({default:e.Jobs})),__vite__mapDeps([55,1,2,3,4,5,18,27,10,23,14,13,19,7,29,45]))),kr=(0,A.lazy)(()=>u(()=>import(`./Logs-B3dsGSF8.js`).then(e=>({default:e.Logs})),__vite__mapDeps([56,1,2,18,10,4,23,14,13,19,7,24,55,3,5,27,29,45]))),Ar=(0,A.lazy)(()=>u(()=>import(`./Metrics-Bkuy6Ntb.js`).then(e=>({default:e.Metrics})),__vite__mapDeps([57,2,1,27,4,5,10,12,23,13,14,19]))),jr=(0,A.lazy)(()=>u(()=>import(`./Overview-Ba5odzYe.js`).then(e=>({default:e.Overview})),__vite__mapDeps([58,2,1,18,27,4,5,10,12,23,13,14,19]))),Mr=(0,A.lazy)(()=>u(()=>import(`./QueueDetail-BClRbWC5.js`).then(e=>({default:e.QueueDetail})),__vite__mapDeps([59,1,2,3,4,5,18,27,10,11,12,23,14,19,7,15,29]))),Nr=(0,A.lazy)(()=>u(()=>import(`./Queues-CGPgEkVm.js`).then(e=>({default:e.Queues})),__vite__mapDeps([60,1,2,18,27,4,5,10,23,13,14,19,24]))),Pr=(0,A.lazy)(()=>u(()=>import(`./S3Backup-5OKa8G13.js`).then(e=>({default:e.S3Backup})),__vite__mapDeps([61,2,1,27,4,5,10,12,23,13,14]))),Fr=(0,A.lazy)(()=>u(()=>import(`./Settings-C1HtCK6h.js`).then(e=>({default:e.Settings})),__vite__mapDeps([62,1,2,4,18,11,12,13,14,7]))),Ir=(0,A.lazy)(()=>u(()=>import(`./Usage-QyZkUhgs.js`).then(e=>({default:e.Usage})),__vite__mapDeps([63,2,1,27,4,5,10,12,23,13,14,19]))),Lr=(0,A.lazy)(()=>u(()=>import(`./Workers-Cn8Bkgy1.js`).then(e=>({default:e.Workers})),__vite__mapDeps([64,1,2,18,27,4,5,10,23,13,14,19,24])));function Rr(){return(0,I.jsx)(r,{children:(0,I.jsxs)(f,{element:(0,I.jsx)(An,{}),children:[(0,I.jsx)(f,{path:`/`,element:(0,I.jsx)(tr,{})}),(0,I.jsx)(f,{path:`/overview-classic`,element:(0,I.jsx)(jr,{})}),(0,I.jsx)(f,{path:`/queues`,element:(0,I.jsx)(yr,{})}),(0,I.jsx)(f,{path:`/queues-classic`,element:(0,I.jsx)(Nr,{})}),(0,I.jsx)(f,{path:`/queues/:name`,element:(0,I.jsx)(vr,{})}),(0,I.jsx)(f,{path:`/queues-classic/:name`,element:(0,I.jsx)(Mr,{})}),(0,I.jsx)(f,{path:`/jobs`,element:(0,I.jsx)(pr,{})}),(0,I.jsx)(f,{path:`/jobs-classic`,element:(0,I.jsx)(Or,{})}),(0,I.jsx)(f,{path:`/dlq`,element:(0,I.jsx)(ur,{})}),(0,I.jsx)(f,{path:`/dlq-classic`,element:(0,I.jsx)(Dr,{})}),(0,I.jsx)(f,{path:`/cron`,element:(0,I.jsx)(or,{})}),(0,I.jsx)(f,{path:`/cron-classic`,element:(0,I.jsx)(Er,{})}),(0,I.jsx)(f,{path:`/flows`,element:(0,I.jsx)(dr,{})}),(0,I.jsx)(f,{path:`/workflows`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/executions`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/waiting`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/compensation`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/workflows/archive`,element:(0,I.jsx)(Q,{})}),(0,I.jsx)(f,{path:`/metrics`,element:(0,I.jsx)(gr,{})}),(0,I.jsx)(f,{path:`/metrics-classic`,element:(0,I.jsx)(Ar,{})}),(0,I.jsx)(f,{path:`/workers`,element:(0,I.jsx)(wr,{})}),(0,I.jsx)(f,{path:`/workers-classic`,element:(0,I.jsx)(Lr,{})}),(0,I.jsx)(f,{path:`/logs`,element:(0,I.jsx)(mr,{})}),(0,I.jsx)(f,{path:`/logs-classic`,element:(0,I.jsx)(kr,{})}),(0,I.jsx)(f,{path:`/server`,element:(0,I.jsx)(xr,{})}),(0,I.jsx)(f,{path:`/add-job`,element:(0,I.jsx)(rr,{})}),(0,I.jsx)(f,{path:`/jobs/bulk-add`,element:(0,I.jsx)(ar,{})}),(0,I.jsx)(f,{path:`/job`,element:(0,I.jsx)(fr,{})}),(0,I.jsx)(f,{path:`/queue-control`,element:(0,I.jsx)(_r,{})}),(0,I.jsx)(f,{path:`/cron-manager`,element:(0,I.jsx)(n,{to:`/cron`,replace:!0})}),(0,I.jsx)(f,{path:`/dlq-control`,element:(0,I.jsx)(lr,{})}),(0,I.jsx)(f,{path:`/webhooks`,element:(0,I.jsx)(Cr,{})}),(0,I.jsx)(f,{path:`/diagnostics`,element:(0,I.jsx)(cr,{})}),(0,I.jsx)(f,{path:`/alerts`,element:(0,I.jsx)(Tr,{})}),(0,I.jsx)(f,{path:`/benchmark`,element:(0,I.jsx)(ir,{})}),(0,I.jsx)(f,{path:`/database`,element:(0,I.jsx)(sr,{})}),(0,I.jsx)(f,{path:`/mcp`,element:(0,I.jsx)(hr,{})}),(0,I.jsx)(f,{path:`/usage`,element:(0,I.jsx)(Sr,{})}),(0,I.jsx)(f,{path:`/usage-classic`,element:(0,I.jsx)(Ir,{})}),(0,I.jsx)(f,{path:`/s3`,element:(0,I.jsx)(br,{})}),(0,I.jsx)(f,{path:`/s3-classic`,element:(0,I.jsx)(Pr,{})}),(0,I.jsx)(f,{path:`/settings`,element:(0,I.jsx)(Fr,{})}),(0,I.jsx)(f,{path:`*`,element:(0,I.jsx)(nr,{})})]})})}var $=new WeakMap;function zr(e,t){let n=document.createElement(`div`);n.setAttribute(`role`,`alert`),n.style.cssText=`padding:2rem;font:14px/1.6 system-ui,sans-serif;max-width:44rem;margin:auto`;let r=document.createElement(`h1`);r.style.cssText=`font-size:1.1rem;font-weight:600;margin-bottom:.5rem`,r.textContent=`Demo data failed to load`;let i=document.createElement(`p`);i.textContent=`This build serves canned data from a bundled chunk that could not be fetched, so there is no backend to talk to. Reload the page (a hard refresh clears a stale cached index.html).`;let a=document.createElement(`p`);a.style.cssText=`margin-top:.75rem;opacity:.7;font-family:ui-monospace,monospace`,a.textContent=t instanceof Error?t.message:String(t),n.append(r,i,a),e.replaceChildren(n)}function Br({root:e,demo:t,loadDemo:n,render:r,reportError:i=e=>console.error(`[demo] failed to load the demo backend`,e)}){let a=$.get(e);if(a)return a===!0?void 0:a;if(!t){$.set(e,!0);try{r()}catch(t){throw $.delete(e),t}return}let o=Promise.resolve().then(async()=>{let t;try{t=await n(),t.installDemo()}catch(t){try{i(t)}catch{}zr(e,t);return}r()});return $.set(e,o),o}It();var Vr=document.getElementById(`root`);if(!Vr)throw Error(`Root element #root not found`);function Hr(){(0,Le.createRoot)(Vr).render((0,I.jsx)(A.StrictMode,{children:(0,I.jsx)(c,{basename:ee(g(`__BUNQUEUE_BASE_PATH__`),`/`),children:(0,I.jsx)(Rr,{})})}))}Br({root:Vr,demo:H(),loadDemo:()=>u(()=>import(`./install-CFiYX86d.js`),[]),render:Hr});export{Bt as a,P as c,St as d,at as f,H as i,Dt as l,q as n,V as o,M as p,pn as r,F as s,Zn as t,N as u};
|