@xopcai/xopc 0.0.150 → 0.0.151
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-B3YP7y9d.js → activity-store-uu1xu9Pl.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BaP05tRU.js → agent-avatar-dicebear-BuO-OVfD.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bpv3h31T.js +2 -0
- package/dist/gateway/static/root/assets/{api-BirUfJgj.js → api-CwL38LEV.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D5Cg_a6I.js → app-management-settings-panel-B6OU3Eol.js} +1 -1
- package/dist/gateway/static/root/assets/appearance-settings-BaP4GFvN.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-DZKNIMRg.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D3OmrvFx.js → archive-plugin-CJX3zIh_.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Cgkm_5mb.js → attachment-load-CI1ejk_l.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-CHvxSz-t.js → automation-suggestion-card-CjmhICbv.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BtZl3B8m.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-dJR5UuzL.js → binary-plugins-CZ8nOXqK.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-v4_7o92L.js → block-editor-BoSfyS_j.js} +46 -46
- package/dist/gateway/static/root/assets/browser-settings-page-CL1UiPcb.js +8 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-BcTjPLiD.js → capability-presets-api-XzDKxPZ8.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CddBf58y.js → capability-presets-settings-panel-Dc_uHYgl.js} +2 -2
- package/dist/gateway/static/root/assets/{channel-recipient-api-BbDlMRm5.js → channel-recipient-api-DYLBAhFF.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-mALvXpJj.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-CZuEsO5b.js +1 -0
- package/dist/gateway/static/root/assets/{connector-logo-BNthqff-.js → connector-logo-BSjlInHT.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-Cm_E3mmI.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-DcJc91-C.js +1 -0
- package/dist/gateway/static/root/assets/desktop-pet-settings-CdeqTa3Q.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-BdWd7m-p.js → directory-picker-path-field-Cp3fpm0k.js} +1 -1
- package/dist/gateway/static/root/assets/{dreaming-settings-CXDhu3Me.js → dreaming-settings-Bwj1O3zr.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-CLJTGozU.js → extension-debug-page-D_1xpKbZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-ClxpGfzA.js → extension-page-CqZNCj96.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CDA3ZJ8k.js → extension-settings-page-5MWbtQaQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-DpXL78pS.js → gateway-config-api-Co_IaS34.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-kmeWm2Pt.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-D0SU7dte.js → gateway-startup-retry-BM_xvzl0.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-FoO-R4_U.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-CkJq7N5g.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api-r71aDqix.js → goals-config-api-DrtsYjXz.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-DRAN-R64.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-CZOLhkTH.js → goals-settings-wq9TKhIZ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-F9S1gIFo.js → heartbeat-settings-B5zDoHbo.js} +1 -1
- package/dist/gateway/static/root/assets/index-DIlxvrlG.css +1 -0
- package/dist/gateway/static/root/assets/index-apLU0Hun.js +196 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-3tC9iD21.js +1 -0
- package/dist/gateway/static/root/assets/local-app-workbench-page-CT-vDTLK.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-n7YJfRkU.js → local-apps-page-B9ruF9GV.js} +1 -1
- package/dist/gateway/static/root/assets/locale-store-GfSwnwIZ.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-Ca1X8X2P.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-1mnXr-JA.js → markdown-split-CzuhSQAB.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-D2bcxXrT.js → media-plugins-a3R4y-EL.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-BH7paqYt.js → messages-B0B40tpO.js} +2 -2
- package/dist/gateway/static/root/assets/models-hub-panel-CbTlz9Of.js +2 -0
- package/dist/gateway/static/root/assets/{notes-page-Wjc2utlj.js → notes-page-BCxDy2dV.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-z6sBX9B2.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-vdljrKuG.js → page-tabs-CJfk6M78.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BHki0l-E.js → preview-open-alternatives-MFopTSgF.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DU29deIr.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-Ck3DLTlZ.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-gLsLyAyi.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-Vy4EmvEh.js → save-bar-controls-D0uhU3Z8.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-CVcwC7k_.js → schedule-field-NGOH-7wV.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-DhMA1vkR.js → schema-form-BJz5LoqG.js} +1 -1
- package/dist/gateway/static/root/assets/schemas-DgQq6Z5S.js +64 -0
- package/dist/gateway/static/root/assets/sessions-page-TmNoWpa_.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CtPhh2m9.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-C0xcL0vB.js → settings-collapsible-section-oDnUHnX_.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Cgj4iVpx.js → settings-form-section-DND90dDt.js} +1 -1
- package/dist/gateway/static/root/assets/settings-loading-skeleton-CEJtaoQp.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-B7_JZ2rM.js → settings-page-B1LJlRi9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CKuQT4SG.js → settings-page-layout-CsrLuDsW.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BPCJPHHY.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BmVw-6SJ.js → share-preview-page-C1PwLh-p.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DCuqr7js.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-kn1Vypcy.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-k6VIqTkK.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-D6d8VAk8.js → system-settings-panel-BEsrEkSx.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-EbMQ3TYi.js → theme-store-Bi6hMBDb.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-D63hJX-S.js → typed-models-lib-dOypdlMf.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-D-I-qki9.js → use-channel-catalog-f8A-PVuq.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-B9Y_Ciav.js +1 -0
- package/dist/gateway/static/root/assets/{user-profile-fields-editor-CPaoS8Zl.js → user-profile-fields-editor-DGC38Lx7.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-Bs13qcx1.js → user-profile-settings-panel-DFkZ-tan.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-3mnkFvPw.js → utils-CEIYZihF.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-DK6gaQsA.js +1 -0
- package/dist/gateway/static/root/assets/work-discovery-page-DSJb9Kq7.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-DVavwV3D.js +1 -0
- package/dist/gateway/static/root/assets/work-page-foJDp0nz.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYqZpFCC.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-DgO0WAzs.js +11 -0
- package/dist/gateway/static/root/index.html +8 -7
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +1 -0
- package/dist/src/agent/service.js +1 -0
- package/dist/src/agent/service.types.d.ts +2 -0
- package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
- package/dist/src/agent/tool-manuals/xopc-use.js +41 -2
- package/dist/src/agent/tools/automation-tool.js +45 -6
- package/dist/src/agent/tools/factory.d.ts +2 -0
- package/dist/src/agent/tools/factory.js +3 -2
- package/dist/src/agent/tools/goal-tool.d.ts +7 -1
- package/dist/src/agent/tools/goal-tool.js +34 -5
- package/dist/src/agent/tools/workflow-tool.js +32 -2
- package/dist/src/agent/tools/write.js +23 -3
- package/dist/src/agent/tools/xopc-use-tool.d.ts +6 -2
- package/dist/src/agent/tools/xopc-use-tool.js +216 -6
- package/dist/src/gateway/service.js +1 -0
- package/package.json +3 -2
- package/dist/gateway/static/root/assets/agents-QArUBYV7.js +0 -2
- package/dist/gateway/static/root/assets/appearance-settings-BBsAkJ56.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-D1uAUndU.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-BWQk03Vu.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-SruFGuBP.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-WI5tQ5tn.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-Dt2EROlf.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DavHJ6rR.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-CVajXkdj.js +0 -1
- package/dist/gateway/static/root/assets/desktop-pet-settings-SHI66eIi.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Co-mXFP_.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BO6G--Ec.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-DK8eog4h.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-AcROW97U.js +0 -2
- package/dist/gateway/static/root/assets/index-C46C7Xee.css +0 -1
- package/dist/gateway/static/root/assets/index-IPmCli0N.js +0 -259
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-B3CUVfZ8.js +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-HVq6NUvQ.js +0 -2
- package/dist/gateway/static/root/assets/locale-store-BvcHGPHU.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-Dgko6r04.js +0 -7
- package/dist/gateway/static/root/assets/models-hub-panel-DD0cEfmR.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-BkA2yg9K.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CXwVNLgg.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-DlfvNcLh.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BQyEX2Ui.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-CqQEW8oT.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-M8fleFSc.js +0 -1
- package/dist/gateway/static/root/assets/settings-loading-skeleton-CC_NmD69.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DvR8Y5YN.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-C0JYYhGx.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DBFBczqN.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-KAI9qBDD.js +0 -2
- package/dist/gateway/static/root/assets/user-context-page-Cuft-EbR.js +0 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-C716UEi9.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-CFSkHa0v.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DaapBdoZ.js +0 -1
- package/dist/gateway/static/root/assets/work-page-DMtX92vs.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-B9FnZNWZ.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-BgvE0_Iv.js +0 -11
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{d as a,l as o,t as s,u as c}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as l}from"./cn-BQ_8x0bT.js";import{t as u}from"./check-BODqo66o.js";import{t as d}from"./copy-to-clipboard-HOJ79TWv.js";import{t as f}from"./messages-BH7paqYt.js";import{n as p,o as m}from"./locale-store-BvcHGPHU.js";import{i as h}from"./vendor-swr-BIWyz7Rc.js";import{$ as g,$c as _,$l as v,A as y,As as b,B as x,Bc as S,E as C,F as w,Fl as T,G as E,Go as D,Gs as O,I as k,Io as A,J as j,K as M,Kc as N,L as P,Lr as F,M as I,N as L,Nc as R,O as z,P as B,Pl as V,Q as H,S as U,Ss as W,St as G,Ts as ee,Tt as te,U as ne,V as re,W as ie,Wo as K,Wr as ae,X as oe,Y as se,Yc as ce,Zc as le,_c as ue,_t as de,ao as q,bt as fe,ct as pe,cu as me,dt as he,et as ge,ft as _e,g as ve,gt as ye,gu as be,hc as xe,hs as J,ht as Se,ic as Ce,j as we,jl as Te,js as Ee,k as De,kl as Oe,ls as ke,lt as Ae,ml as je,nt as Me,oc as Ne,ou as Pe,pt as Fe,q as Ie,ql as Le,qo as Re,rl as ze,rt as Be,sa as Ve,sl as He,tc as Ue,tt as We,tu as Ge,ut as Ke,vt as qe,wt as Je,xc as Ye,xt as Xe,ys as Ze,yt as Qe,z as $e}from"./index-IPmCli0N.js";import{t as et}from"./with-selector-aYPsXwdl.js";import{t as tt}from"./page-tabs-vdljrKuG.js";import{n as nt,r as rt,t as it}from"./workflow-run-setup-panel-B9FnZNWZ.js";var Y=e(t(),1),X=r(),at=[`queued`,`running`,`succeeded`,`attention`],ot=new Set([`failed`,`timeout`,`cancelled`]);function st(e){return e.metadata?.sessionKey?.trim()||null}function ct(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function lt(e,t){if(!e||typeof e!=`object`)return null;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}function ut(e,t=90){let n=e.metadata?.input?.goal?.trim()||(typeof e.metadata?.input?.payload==`string`?e.metadata.input.payload.trim():null)||lt(e.metadata?.input?.payload,[`query`,`goal`,`prompt`,`input`,`message`])||lt(e.metadata?.input?.variables,[`query`,`goal`,`prompt`,`input`,`message`]);return n?ct(n,t):null}function dt(e,t=90){return ut(e,t)??ct(e.title?.trim()||e.definitionId,t)}function ft(e,t=44){return ct(e.title?.trim()||e.definitionId,t)}function pt(e,t){let n=t.trim().toLowerCase();return n?[ut(e,500),e.title,e.definitionId,e.id].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function mt(e,t){let n=t.workflowFilterId.trim();return e.filter(e=>n&&e.definitionId!==n||!w(e,t.triggerFilter??`all`)?!1:pt(e,t.searchQuery))}function ht(e){return e.completedAtMs??e.createdAtMs}function gt(e,t){return e.status===`queued`?`queued`:e.status===`running`?`running`:e.status===`succeeded`?`succeeded`:ot.has(e.status)?`attention`:null}function _t(e,t){let n=[...t];return e===`queued`?n.sort((e,t)=>e.createdAtMs-t.createdAtMs):e===`running`?n.sort((e,t)=>(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)):n.sort((e,t)=>ht(t)-ht(e))}function vt(e,t){let n={queued:[],running:[],succeeded:[],attention:[]};for(let r of e){let e=gt(r,t);e&&n[e].push(r)}return at.map(e=>{if(e===`succeeded`){let t=_t(`succeeded`,n.succeeded);return{id:e,runs:t,totalInWindow:t.length}}return{id:e,runs:_t(e,n[e])}})}var yt=new Map;function bt(e){let t=yt.get(e);return t||(t=new Intl.RelativeTimeFormat(e,{numeric:`auto`}),yt.set(e,t)),t}function xt(e,t,n){let r=Math.round((t-e)/1e3),i=bt(n);if(r<60)return i.format(-r,`second`);let a=Math.round(r/60);if(a<60)return i.format(-a,`minute`);let o=Math.round(a/60);if(o<48)return i.format(-o,`hour`);let s=Math.round(o/24);return i.format(-s,`day`)}function St(e){return e.status===`queued`||e.status===`running`}function Ct(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}var Z=i(),wt=(0,Y.memo)(function(e){let t=(0,X.c)(76),{run:n,language:r,localeTag:i,nowMs:a,selected:o,onOpen:s,onOpenChat:c,onCancel:u,onRetry:d}=e,p=f(r).workflows,[m,h]=(0,Y.useState)(!1),g;t[0]===n?g=t[1]:(g=st(n),t[0]=n,t[1]=g);let _=!g,v;t[2]===n?v=t[3]:(v=St(n),t[2]=n,t[3]=v);let x=v,S=n.status===`running`||n.status===`queued`,C;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(C=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[4]=n.metrics.agentCount,t[5]=n.metrics.doneAgentCount,t[6]=C):C=t[6];let w=C,T=n.metrics.errorAgentCount>0,E=n.startedAtMs??n.createdAtMs,D=y(x?a-E:n.metrics.durationMs),O=I(p.taskArtifacts,{count:n.metrics.artifactCount}),A;t[7]===n?A=t[8]:(A=dt(n),t[7]=n,t[8]=A);let j=A,M;t[9]===n?M=t[10]:(M=ft(n),t[9]=n,t[10]=M);let N=M,P;t[11]!==s||t[12]!==n?(P=()=>{s(n)},t[11]=s,t[12]=n,t[13]=P):P=t[13];let F=P,L;t[14]!==_||t[15]!==c||t[16]!==n?(L=()=>{_||c(n)},t[14]=_,t[15]=c,t[16]=n,t[17]=L):L=t[17];let R=L,z=o&&`ring-1 ring-accent/30`,B;t[18]===z?B=t[19]:(B=l(`group relative min-h-24 overflow-hidden rounded-lg bg-surface-panel px-3 py-3 shadow-surface transition-colors`,z,`hover:bg-surface-hover`),t[18]=z,t[19]=B);let V;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(V=l(`w-full text-left`,ke.focusRingPanel),t[20]=V):V=t[20];let H;t[21]===j?H=t[22]:(H=(0,Z.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5 text-fg`,children:j}),t[21]=j,t[22]=H);let U;t[23]===N?U=t[24]:(U=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:N}),t[23]=N,t[24]=U);let W;t[25]!==H||t[26]!==U?(W=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[H,U]}),t[25]=H,t[26]=U,t[27]=W):W=t[27];let G;t[28]===n.status?G=t[29]:(G=l(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,k(n.status)),t[28]=n.status,t[29]=G);let ee;t[30]!==i||t[31]!==a||t[32]!==E?(ee=xt(E,a,i),t[30]=i,t[31]=a,t[32]=E,t[33]=ee):ee=t[33];let te;t[34]===ee?te=t[35]:(te=(0,Z.jsx)(`span`,{children:ee}),t[34]=ee,t[35]=te);let ne=D===`—`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{children:I(p.taskElapsed,{duration:D})})]}),re;t[36]!==te||t[37]!==ne?(re=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[te,ne]}),t[36]=te,t[37]=ne,t[38]=re):re=t[38];let ie=n.metrics.artifactCount>0?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:O}):null,K=o?(0,Z.jsx)(`span`,{className:`font-medium text-accent-fg`,children:p.taskOpenDetails}):null,ae;t[39]!==ie||t[40]!==K?(ae=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[ie,K]}),t[39]=ie,t[40]=K,t[41]=ae):ae=t[41];let oe=_&&`cursor-not-allowed text-fg-disabled hover:bg-transparent`,se;t[42]===oe?se=t[43]:(se=l(`rounded-md px-2 py-1 text-xs font-medium`,`text-accent-fg hover:bg-accent-soft`,ke.focusRingPanel,oe),t[42]=oe,t[43]=se);let ce;t[44]!==_||t[45]!==R||t[46]!==p.continueInChat||t[47]!==se?(ce=(0,Z.jsx)(`button`,{type:`button`,className:se,disabled:_,onClick:R,children:p.continueInChat}),t[44]=_,t[45]=R,t[46]=p.continueInChat,t[47]=se,t[48]=ce):ce=t[48];let le;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(le=l(`rounded-md px-2 py-1 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,ke.focusRingPanel),t[49]=le):le=t[49];let ue;t[50]!==F||t[51]!==p.taskOpenDetails?(ue=(0,Z.jsx)(`button`,{type:`button`,className:le,onClick:F,children:p.taskOpenDetails}),t[50]=F,t[51]=p.taskOpenDetails,t[52]=ue):ue=t[52];let de;t[53]!==ce||t[54]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 border-t border-edge-subtle pt-2`,children:[ce,ue]}),t[53]=ce,t[54]=ue,t[55]=de):de=t[55];let q;t[56]===h?q=t[57]:(q=()=>h(Et),t[56]=h,t[57]=q);let fe;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Z.jsx)(Oe,{className:`size-4`,"aria-hidden":!0}),t[58]=fe):fe=t[58];let pe;t[59]!==p.taskActionsAria||t[60]!==m||t[61]!==q?(pe=(0,Z.jsx)(J,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":p.taskActionsAria,"aria-expanded":m,onClick:q,children:fe}),t[59]=p.taskActionsAria,t[60]=m,t[61]=q,t[62]=pe):pe=t[62];let me;t[63]!==x||t[64]!==p.cancel||t[65]!==p.rerun||t[66]!==p.taskCloseMenu||t[67]!==m||t[68]!==u||t[69]!==d||t[70]!==n||t[71]!==h?(me=m?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":p.taskCloseMenu,onClick:()=>h(!1)}),(0,Z.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 min-w-36 rounded-lg border border-edge bg-surface-panel py-1 shadow-surface`,children:[x?(0,Z.jsx)(Tt,{label:p.cancel,tone:`danger`,onClick:()=>{h(!1),u(n.id)}}):null,Ct(n)?(0,Z.jsx)(Tt,{label:p.rerun,onClick:()=>{h(!1),d(n.id)}}):null]})]}):null,t[63]=x,t[64]=p.cancel,t[65]=p.rerun,t[66]=p.taskCloseMenu,t[67]=m,t[68]=u,t[69]=d,t[70]=n,t[71]=h,t[72]=me):me=t[72];let he;return t[73]!==pe||t[74]!==me?(he=(0,Z.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[pe,me]}),t[73]=pe,t[74]=me,t[75]=he):he=t[75],(0,Z.jsxs)(`div`,{className:B,children:[(0,Z.jsxs)(`button`,{type:`button`,onClick:F,"aria-label":`${p.taskOpenDetails}: ${j}`,"aria-current":o?`true`:void 0,className:V,children:[(0,Z.jsxs)(`div`,{className:`pr-7`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[W,(0,Z.jsx)(`span`,{className:G,children:p.status[n.status]??n.status})]}),re]}),S?(0,Z.jsxs)(`div`,{className:`mt-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:I(p.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,Z.jsxs)(`span`,{children:[w,`%`]})]}),(0,Z.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${w}%`}})})]}):null,ae,T?(0,Z.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,Z.jsx)(b,{className:`size-3 shrink-0`,"aria-hidden":!0}),I(p.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),de,he]})});function Tt(e){let t=(0,X.c)(8),{label:n,disabled:r,tone:i,onClick:a}=e,o=r?`cursor-not-allowed text-fg-subtle`:`text-fg hover:bg-surface-hover`,s=i===`danger`&&!r&&`text-red-600 dark:text-red-300`,c;t[0]!==o||t[1]!==s?(c=l(`block w-full px-3 py-1.5 text-left text-xs`,o,s),t[0]=o,t[1]=s,t[2]=c):c=t[2];let u;return t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c?(u=(0,Z.jsx)(`button`,{type:`button`,disabled:r,onClick:a,className:c,children:n}),t[3]=r,t[4]=n,t[5]=a,t[6]=c,t[7]=u):u=t[7],u}function Et(e){return!e}function Dt(e,t){return t.boardColumns[e]}var Ot=(0,Y.memo)(function(e){let t=(0,X.c)(17),{column:n,language:r,localeTag:i,nowMs:a,selectedRunId:o,loading:s,onOpenRun:c,onOpenRunChat:u,onCancelRun:d,onRetryRun:p}=e,m=f(r).workflows,[h,g]=(0,Y.useState)(!1),_=n.id===`succeeded`,v=_?5:n.runs.length,y;t[0]!==v||t[1]!==n.runs||t[2]!==h||t[3]!==_?(y=_&&!h?n.runs.slice(0,v):n.runs,t[0]=v,t[1]=n.runs,t[2]=h,t[3]=_,t[4]=y):y=t[4];let b=y,x=_&&n.runs.length>5&&!h,S=_&&h,C;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(C=l(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`),t[5]=C):C=t[5];let w;t[6]===n.runs.length?w=t[7]:(w=(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:n.runs.length}),t[6]=n.runs.length,t[7]=w);let T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(Oe,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}),t[8]=T):T=t[8];let E=s&&b.length===0?(0,Z.jsx)(kt,{}):b.length===0?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:m.boardColumnEmpty}):b.map(e=>(0,Z.jsx)(wt,{run:e,language:r,localeTag:i,nowMs:a,selected:e.id===o,onOpen:c,onOpenChat:u,onCancel:d,onRetry:p},e.id)),D=x?(0,Z.jsx)(J,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!0),children:I(m.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,O;t[9]!==S||t[10]!==m||t[11]!==g?(O=S?(0,Z.jsx)(J,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>g(!1),children:m.boardCollapseSucceeded}):null,t[9]=S,t[10]=m,t[11]=g,t[12]=O):O=t[12];let k;return t[13]!==E||t[14]!==D||t[15]!==O?(k=(0,Z.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[E,D,O]}),t[13]=E,t[14]=D,t[15]=O,t[16]=k):k=t[16],(0,Z.jsxs)(`section`,{className:C,"aria-label":Dt(n.id,m),children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-3`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:Dt(n.id,m)}),w]}),T]}),k]})});function kt(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsxs)(`article`,{className:`min-h-24 rounded-lg bg-surface-panel px-3 py-3 shadow-surface`,"aria-hidden":`true`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(q,{className:`h-4 w-4/5`}),(0,Z.jsx)(q,{className:`mt-2 h-3 w-24`})]}),(0,Z.jsx)(q,{className:`h-5 w-14 rounded-full`})]}),(0,Z.jsx)(q,{className:`mt-3 h-3 w-2/3`}),(0,Z.jsx)(q,{className:`mt-4 h-5 w-20 rounded-full`})]}),e[0]=t):t=e[0],t}function At(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}var jt=(0,Y.memo)(function(e){let t=(0,X.c)(54),{runs:n,language:r,localeTag:i,labels:a,searchQuery:o,workflowFilterId:s,triggerFilter:c,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m,onStart:h}=e,g;t[0]===n?g=t[1]:(g=n.some(Mt),t[0]=n,t[1]=g);let _=g,v=(0,Y.useRef)(null),y=(0,Y.useRef)(null),[b,x]=(0,Y.useState)(Nt),[S,C]=(0,Y.useState)(!1),w,T;t[2]===_?(w=t[3],T=t[4]):(w=()=>{if(!_)return;let e=window.setInterval(()=>x(Date.now()),1e3);return()=>window.clearInterval(e)},T=[_],t[2]=_,t[3]=w,t[4]=T),(0,Y.useEffect)(w,T);let E;t[5]!==b||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(E=vt(mt(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),b),t[5]=b,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=E):E=t[10];let D=E,O=D.reduce(Pt,0),k;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>{let t=y.current;!t||t.pointerId!==e.pointerId||(y.current=null,C(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},t[11]=k):k=t[11];let A=k,j;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(j=e=>{if(e.button!==0||At(e.target))return;let t=v.current;t&&(y.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},t[12]=j):j=t[12];let M=j,N;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{let t=y.current,n=v.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,C(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},t[13]=N):N=t[13];let P=N;if(!u&&O===0){let e;t[14]===a.boardEmptyTitle?e=t[15]:(e=(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:a.boardEmptyTitle}),t[14]=a.boardEmptyTitle,t[15]=e);let n;t[16]===a.boardEmptyHint?n=t[17]:(n=(0,Z.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.boardEmptyHint}),t[16]=a.boardEmptyHint,t[17]=n);let r;t[18]!==a.boardStart||t[19]!==h?(r=(0,Z.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Z.jsx)(J,{variant:`primary`,onClick:h,children:a.boardStart})}),t[18]=a.boardStart,t[19]=h,t[20]=r):r=t[20];let i;return t[21]!==r||t[22]!==e||t[23]!==n?(i=(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center rounded-2xl border border-dashed border-edge bg-surface-panel/40 px-6 py-12 text-center`,children:[e,n,r]}),t[21]=r,t[22]=e,t[23]=n,t[24]=i):i=t[24],i}let F=S?`cursor-grabbing select-none`:`cursor-grab`,I;t[25]===F?I=t[26]:(I=[`min-h-0 h-full min-w-0 overflow-x-auto rounded-lg px-2 py-2`,F],t[25]=F,t[26]=I);let L=I.join(` `),R;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(R=e=>{y.current?.pointerId===e.pointerId&&(y.current=null,C(!1))},t[27]=R):R=t[27];let z;if(t[28]!==D||t[29]!==r||t[30]!==u||t[31]!==i||t[32]!==b||t[33]!==p||t[34]!==d||t[35]!==f||t[36]!==m||t[37]!==l){let e;t[39]!==r||t[40]!==u||t[41]!==i||t[42]!==b||t[43]!==p||t[44]!==d||t[45]!==f||t[46]!==m||t[47]!==l?(e=e=>(0,Z.jsx)(Ot,{column:e,language:r,localeTag:i,nowMs:b,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m},e.id),t[39]=r,t[40]=u,t[41]=i,t[42]=b,t[43]=p,t[44]=d,t[45]=f,t[46]=m,t[47]=l,t[48]=e):e=t[48],z=D.map(e),t[28]=D,t[29]=r,t[30]=u,t[31]=i,t[32]=b,t[33]=p,t[34]=d,t[35]=f,t[36]=m,t[37]=l,t[38]=z}else z=t[38];let B;t[49]===z?B=t[50]:(B=(0,Z.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:z}),t[49]=z,t[50]=B);let V;return t[51]!==L||t[52]!==B?(V=(0,Z.jsx)(`div`,{ref:v,className:L,onPointerDown:M,onPointerMove:P,onPointerUp:A,onPointerCancel:A,onLostPointerCapture:R,children:B}),t[51]=L,t[52]=B,t[53]=V):V=t[53],V});function Mt(e){return e.status===`queued`||e.status===`running`}function Nt(){return Date.now()}function Pt(e,t){return e+t.runs.length}function Ft(e,t){let n=e.metadata.estimatedAgents;return n?n.min===n.max?I(t.agentScaleExact,{count:n.min}):I(t.agentScaleRange,{min:n.min,max:n.max}):null}function It(e){let t=(0,X.c)(73),{definition:n,language:r,labels:i,onPick:a,onDetail:o,onEdit:s}=e,c;t[0]!==n||t[1]!==r?(c=H(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let u=c,d;t[3]!==n||t[4]!==i?(d=Ft(n,i),t[3]=n,t[4]=i,t[5]=d):d=t[5];let f=d,p=n.metadata.source===`user`,m=p?`bg-accent-soft text-accent-fg`:`bg-surface-muted text-fg-muted`,h;t[6]===m?h=t[7]:(h=l(`rounded-full px-2 py-0.5 text-[10px] font-medium`,m),t[6]=m,t[7]=h);let g=p?i.badgeUser:i.badgeBuiltin,v;t[8]!==h||t[9]!==g?(v=(0,Z.jsx)(`span`,{className:h,children:g}),t[8]=h,t[9]=g,t[10]=v):v=t[10];let y;t[11]!==n.inputSchema||t[12]!==i.inputSchemaBadge?(y=n.inputSchema?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-surface-muted px-2 py-0.5 text-[10px] text-fg-subtle`,children:[(0,Z.jsx)(Pe,{className:`size-2.5`,"aria-hidden":!0}),i.inputSchemaBadge]}):null,t[11]=n.inputSchema,t[12]=i.inputSchemaBadge,t[13]=y):y=t[13];let b;t[14]!==v||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=l(`mt-2 line-clamp-2 text-left text-sm font-semibold leading-5 text-fg hover:text-accent-fg`,ke.focusRingPanel),t[17]=x):x=t[17];let S;t[18]!==n||t[19]!==o?(S=()=>o(n),t[18]=n,t[19]=o,t[20]=S):S=t[20];let C;t[21]!==n.title||t[22]!==S?(C=(0,Z.jsx)(`button`,{type:`button`,className:x,onClick:S,children:n.title}),t[21]=n.title,t[22]=S,t[23]=C):C=t[23];let w;t[24]!==C||t[25]!==b?(w=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,C]}),t[24]=C,t[25]=b,t[26]=w):w=t[26];let E=`${p?i.editWorkflow:i.copyAndEditWorkflow}: ${n.title}`,D;t[27]!==n||t[28]!==s?(D=()=>s(n),t[27]=n,t[28]=s,t[29]=D):D=t[29];let O;t[30]===p?O=t[31]:(O=p?(0,Z.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}):(0,Z.jsx)(T,{className:`size-3.5`,"aria-hidden":!0}),t[30]=p,t[31]=O);let k;t[32]!==E||t[33]!==D||t[34]!==O?(k=(0,Z.jsx)(J,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 p-0`,"aria-label":E,onClick:D,children:O}),t[32]=E,t[33]=D,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==w||t[37]!==k?(A=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[w,k]}),t[36]=w,t[37]=k,t[38]=A):A=t[38];let j=u.whenToUse||u.description||n.description,M;t[39]===j?M=t[40]:(M=(0,Z.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:j}),t[39]=j,t[40]=M);let N;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(_,{className:`size-3`,"aria-hidden":!0}),t[41]=N):N=t[41];let P;t[42]!==n.phases.length||t[43]!==i.phaseCount?(P=I(i.phaseCount,{count:n.phases.length}),t[42]=n.phases.length,t[43]=i.phaseCount,t[44]=P):P=t[44];let F;t[45]===P?F=t[46]:(F=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[N,P]}),t[45]=P,t[46]=F);let L;t[47]===f?L=t[48]:(L=f?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Z.jsx)(ee,{className:`size-3`,"aria-hidden":!0}),f]}):null,t[47]=f,t[48]=L);let R;t[49]!==F||t[50]!==L?(R=(0,Z.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-3 pt-4 text-[11px] text-fg-subtle`,children:[F,L]}),t[49]=F,t[50]=L,t[51]=R):R=t[51];let z;t[52]!==n||t[53]!==a?(z=()=>a(n),t[52]=n,t[53]=a,t[54]=z):z=t[54];let B;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,Z.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),t[55]=B):B=t[55];let V;t[56]!==i.configureAndRun||t[57]!==z?(V=(0,Z.jsxs)(J,{type:`button`,variant:`primary`,className:`h-8 flex-1 rounded-lg text-xs`,onClick:z,children:[B,i.configureAndRun]}),t[56]=i.configureAndRun,t[57]=z,t[58]=V):V=t[58];let U;t[59]!==n||t[60]!==o?(U=()=>o(n),t[59]=n,t[60]=o,t[61]=U):U=t[61];let W;t[62]!==i.viewDetails||t[63]!==U?(W=(0,Z.jsx)(J,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:U,children:i.viewDetails}),t[62]=i.viewDetails,t[63]=U,t[64]=W):W=t[64];let G;t[65]!==V||t[66]!==W?(G=(0,Z.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 border-t border-edge-subtle pt-3`,children:[V,W]}),t[65]=V,t[66]=W,t[67]=G):G=t[67];let te;return t[68]!==A||t[69]!==M||t[70]!==R||t[71]!==G?(te=(0,Z.jsxs)(`article`,{className:`flex min-h-48 flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 transition-colors hover:border-edge hover:bg-surface-hover/35`,children:[A,M,R,G]}),t[68]=A,t[69]=M,t[70]=R,t[71]=G,t[72]=te):te=t[72],te}function Lt(e){let t=(0,X.c)(44),{definitions:n,runs:r,language:i,onPick:a,onDetail:o,onEdit:s}=e,c=f(i).workflows,u=i===`zh`?`zh-CN`:`en-US`,[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(`all`),[g,_]=(0,Y.useState)(`all`),v;t[0]!==m||t[1]!==n||t[2]!==d||t[3]!==g?(v=De(n,d,m,g),t[0]=m,t[1]=n,t[2]=d,t[3]=g,t[4]=v):v=t[4];let y=v,b;if(t[5]!==n||t[6]!==r){let e=new Map(n.map(zt)),i=new Set;b=[...r].sort(Rt).flatMap(t=>{if(i.has(t.definitionId))return[];let n=e.get(t.definitionId);return n?(i.add(t.definitionId),[{definition:n,lastRunAtMs:t.startedAtMs??t.createdAtMs}]):[]}).slice(0,3),t[5]=n,t[6]=r,t[7]=b}else b=t[7];let x=b,S=I(c.workflowCount,{count:y.length}),C;t[8]===S?C=t[9]:(C=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:S}),t[8]=S,t[9]=C);let w=c.sourceFilterAria,T;t[10]!==c.sources||t[11]!==_||t[12]!==g?(T=Ie.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:l(`h-8 rounded-md px-2.5 text-xs font-medium transition-colors`,g===e?`bg-surface-base text-fg shadow-surface`:`text-fg-muted hover:text-fg`,ke.focusRingPanel),"aria-pressed":g===e,onClick:()=>_(e),children:c.sources[e]},e)),t[10]=c.sources,t[11]=_,t[12]=g,t[13]=T):T=t[13];let E;t[14]!==c.sourceFilterAria||t[15]!==T?(E=(0,Z.jsx)(`div`,{className:`flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":w,children:T}),t[14]=c.sourceFilterAria,t[15]=T,t[16]=E):E=t[16];let O=c.categoryFilterAria,k;t[17]===h?k=t[18]:(k=e=>h(e.target.value),t[17]=h,t[18]=k);let A;t[19]===c.categories?A=t[20]:(A=ne.map(e=>(0,Z.jsx)(Re,{value:e,children:c.categories[e]},e)),t[19]=c.categories,t[20]=A);let j;t[21]!==m||t[22]!==c.categoryFilterAria||t[23]!==k||t[24]!==A?(j=(0,Z.jsx)(D,{value:m,"aria-label":O,onChange:k,className:`h-9 min-w-36 rounded-lg border border-edge bg-surface-base px-2.5 text-xs font-medium text-fg shadow-surface`,children:A}),t[21]=m,t[22]=c.categoryFilterAria,t[23]=k,t[24]=A,t[25]=j):j=t[25];let M;t[26]!==j||t[27]!==E?(M=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E,j]}),t[26]=j,t[27]=E,t[28]=M):M=t[28];let N;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(Ue,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[29]=N):N=t[29];let P;t[30]===p?P=t[31]:(P=e=>p(e.target.value),t[30]=p,t[31]=P);let F=c.librarySearchPlaceholder,L;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(L=l(`h-10 w-full rounded-lg border border-edge bg-surface-base py-2 pl-10 pr-3 text-sm text-fg`,`placeholder:text-fg-muted`,ke.focusRingPanel),t[32]=L):L=t[32];let R;t[33]!==c.librarySearchPlaceholder||t[34]!==d||t[35]!==P?(R=(0,Z.jsxs)(`div`,{className:`relative max-w-xl`,children:[N,(0,Z.jsx)(`input`,{value:d,onChange:P,placeholder:F,className:L})]}),t[33]=c.librarySearchPlaceholder,t[34]=d,t[35]=P,t[36]=R):R=t[36];let z;return t[37]!==y||t[38]!==c||t[39]!==i||t[40]!==o||t[41]!==s||t[42]!==a?(z=y.length===0?(0,Z.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.noDefinitions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-xs leading-5 text-fg-muted`,children:c.noDefinitionsHint})]}):(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 pt-4 sm:grid-cols-2 xl:grid-cols-3`,children:y.map(e=>(0,Z.jsx)(It,{definition:e,language:i,labels:c,onPick:a,onDetail:o,onEdit:s},e.id))}),t[37]=y,t[38]=c,t[39]=i,t[40]=o,t[41]=s,t[42]=a,t[43]=z):z=t[43],(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-5`,children:[x.length>0&&!d&&m===`all`&&g===`all`?(0,Z.jsxs)(`section`,{"aria-labelledby":`recent-workflows-heading`,children:[(0,Z.jsx)(`h2`,{id:`recent-workflows-heading`,className:`text-sm font-semibold text-fg`,children:c.recentlyUsed}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:x.map(e=>{let{definition:t,lastRunAtMs:n}=e;return(0,Z.jsxs)(`button`,{type:`button`,className:l(`flex min-w-52 flex-1 items-center justify-between gap-3 rounded-lg border border-edge-subtle bg-surface-base px-3 py-2 text-left hover:bg-surface-hover`,`sm:max-w-sm`,ke.focusRingPanel),onClick:()=>a(t),children:[(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:t.title}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-fg-subtle`,children:xt(n,Date.now(),u)})]}),(0,Z.jsx)(ue,{className:`size-3.5 shrink-0 text-accent-fg`,"aria-hidden":!0})]},t.id)})})]}):null,(0,Z.jsxs)(`section`,{"aria-labelledby":`all-workflows-heading`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{id:`all-workflows-heading`,className:`text-sm font-semibold text-fg`,children:c.allWorkflows}),C]}),M]}),R]}),z]})]})}function Rt(e,t){return(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)}function zt(e){return[e.id,e]}var Bt=(0,Y.memo)(function(e){let t=(0,X.c)(108),{run:n,language:r,localeTag:i,nowMs:a,onOpen:o,onOpenChat:s,onCancel:c,onRetry:u}=e,d,p,m,h,g,_,x,S,C,w,T,E,D,O,A,j,M;if(t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==o||t[4]!==n){m=f(r).workflows;let e;t[22]===n?e=t[23]:(e=St(n),t[22]=n,t[23]=e),d=e;let s;t[24]===n?s=t[25]:(s=Ct(n),t[24]=n,t[25]=s),h=s;let c;t[26]===n?c=t[27]:(c=st(n),t[26]=n,t[27]=c),p=!!c;let u=n.startedAtMs??n.createdAtMs,v=y(d?a-u:n.metrics.durationMs),N;t[28]!==n.metrics.agentCount||t[29]!==n.metrics.doneAgentCount?(N=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[28]=n.metrics.agentCount,t[29]=n.metrics.doneAgentCount,t[30]=N):N=t[30];let P=N;C=`group border-b border-edge-subtle last:border-b-0`,S=`flex min-w-0 flex-col gap-3 px-3 py-3 transition-colors hover:bg-surface-hover/55 sm:px-4 lg:flex-row lg:items-center`,j=`button`,t[31]!==o||t[32]!==n?(M=()=>o(n),t[31]=o,t[32]=n,t[33]=M):M=t[33],t[34]===Symbol.for(`react.memo_cache_sentinel`)?(_=l(`min-w-0 flex-1 text-left`,ke.focusRingPanel),t[34]=_):_=t[34];let F=m.taskOpenDetails,L;t[35]===n?L=t[36]:(L=dt(n),t[35]=n,t[36]=L),x=`${F}: ${L}`,O=`flex min-w-0 items-start gap-3`;let R;t[37]===n.status?R=t[38]:(R=l(`mt-0.5 shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold`,k(n.status)),t[37]=n.status,t[38]=R),A=(0,Z.jsx)(`span`,{className:R,children:m.status[n.status]??n.status}),g=`min-w-0 flex-1`;let z;t[39]===n?z=t[40]:(z=dt(n),t[39]=n,t[40]=z),t[41]===z?w=t[42]:(w=(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:z}),t[41]=z,t[42]=w);let B;t[43]===n?B=t[44]:(B=ft(n),t[43]=n,t[44]=B);let V;t[45]===B?V=t[46]:(V=(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:B}),t[45]=B,t[46]=V);let H;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[47]=H):H=t[47];let U;t[48]!==i||t[49]!==a||t[50]!==u?(U=xt(u,a,i),t[48]=i,t[49]=a,t[50]=u,t[51]=U):U=t[51];let W;t[52]===U?W=t[53]:(W=(0,Z.jsx)(`span`,{children:U}),t[52]=U,t[53]=W);let G=v===`—`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{children:I(m.taskElapsed,{duration:v})})]});t[54]!==V||t[55]!==W||t[56]!==G?(T=(0,Z.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-fg-muted`,children:[V,H,W,G]}),t[54]=V,t[55]=W,t[56]=G,t[57]=T):T=t[57],E=d&&n.metrics.agentCount>0?(0,Z.jsxs)(`span`,{className:`mt-2 block max-w-md`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center justify-between text-[11px] text-fg-subtle`,children:[(0,Z.jsx)(`span`,{children:I(m.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,Z.jsxs)(`span`,{className:`tabular-nums`,children:[P,`%`]})]}),(0,Z.jsx)(`span`,{className:`mt-1 block h-1.5 overflow-hidden rounded-full bg-surface-muted`,children:(0,Z.jsx)(`span`,{className:`block h-full rounded-full bg-accent transition-[width] duration-200 motion-reduce:transition-none`,style:{width:`${P}%`}})})]}):null,D=n.metrics.errorAgentCount>0?(0,Z.jsxs)(`span`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,Z.jsx)(b,{className:`size-3 shrink-0`,"aria-hidden":!0}),I(m.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null,t[0]=r,t[1]=i,t[2]=a,t[3]=o,t[4]=n,t[5]=d,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_,t[11]=x,t[12]=S,t[13]=C,t[14]=w,t[15]=T,t[16]=E,t[17]=D,t[18]=O,t[19]=A,t[20]=j,t[21]=M}else d=t[5],p=t[6],m=t[7],h=t[8],g=t[9],_=t[10],x=t[11],S=t[12],C=t[13],w=t[14],T=t[15],E=t[16],D=t[17],O=t[18],A=t[19],j=t[20],M=t[21];let N;t[58]!==g||t[59]!==w||t[60]!==T||t[61]!==E||t[62]!==D?(N=(0,Z.jsxs)(`span`,{className:g,children:[w,T,E,D]}),t[58]=g,t[59]=w,t[60]=T,t[61]=E,t[62]=D,t[63]=N):N=t[63];let P;t[64]!==N||t[65]!==O||t[66]!==A?(P=(0,Z.jsxs)(`div`,{className:O,children:[A,N]}),t[64]=N,t[65]=O,t[66]=A,t[67]=P):P=t[67];let F;t[68]!==_||t[69]!==x||t[70]!==P||t[71]!==j||t[72]!==M?(F=(0,Z.jsx)(`button`,{type:j,onClick:M,className:_,"aria-label":x,children:P}),t[68]=_,t[69]=x,t[70]=P,t[71]=j,t[72]=M,t[73]=F):F=t[73];let L;t[74]!==m.rerun||t[75]!==u||t[76]!==h||t[77]!==n.id?(L=h?(0,Z.jsx)(J,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>u(n.id),children:m.rerun}):null,t[74]=m.rerun,t[75]=u,t[76]=h,t[77]=n.id,t[78]=L):L=t[78];let R;t[79]!==p||t[80]!==m.continueInChat||t[81]!==s||t[82]!==n?(R=n.status===`succeeded`&&p?(0,Z.jsx)(J,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>s(n),children:m.continueInChat}):null,t[79]=p,t[80]=m.continueInChat,t[81]=s,t[82]=n,t[83]=R):R=t[83];let z;t[84]!==d||t[85]!==m.cancel||t[86]!==c||t[87]!==n.id?(z=d?(0,Z.jsx)(J,{type:`button`,variant:`ghost`,className:`h-8 rounded-lg text-xs text-red-600 dark:text-red-300`,onClick:()=>c(n.id),children:m.cancel}):null,t[84]=d,t[85]=m.cancel,t[86]=c,t[87]=n.id,t[88]=z):z=t[88];let B;t[89]!==o||t[90]!==n?(B=()=>o(n),t[89]=o,t[90]=n,t[91]=B):B=t[91];let V;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t[92]=V):V=t[92];let H;t[93]!==m.taskOpenDetails||t[94]!==B?(H=(0,Z.jsx)(J,{type:`button`,variant:`ghost`,className:`size-8 p-0`,"aria-label":m.taskOpenDetails,onClick:B,children:V}),t[93]=m.taskOpenDetails,t[94]=B,t[95]=H):H=t[95];let U;t[96]!==L||t[97]!==R||t[98]!==z||t[99]!==H?(U=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-1.5 pl-7 lg:pl-0`,children:[L,R,z,H]}),t[96]=L,t[97]=R,t[98]=z,t[99]=H,t[100]=U):U=t[100];let W;t[101]!==S||t[102]!==F||t[103]!==U?(W=(0,Z.jsxs)(`div`,{className:S,children:[F,U]}),t[101]=S,t[102]=F,t[103]=U,t[104]=W):W=t[104];let G;return t[105]!==C||t[106]!==W?(G=(0,Z.jsx)(`article`,{className:C,children:W}),t[105]=C,t[106]=W,t[107]=G):G=t[107],G});function Vt(e){let t=(0,X.c)(17),{vm:n}=e,{labels:r,language:i,loading:a,ownerAgentId:o,agentOptions:c,setOwnerAgentId:l,refreshAll:u}=n,d;t[0]!==c||t[1]!==r.agentFilterAria||t[2]!==i||t[3]!==o||t[4]!==l?(d=c.length>1?(0,Z.jsx)(D,{value:o??``,"aria-label":r.agentFilterAria,onChange:e=>l(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:c.map(e=>(0,Z.jsx)(Re,{value:e.id,children:F(e,f(i).agentsSettings)},e.id))}):null,t[0]=c,t[1]=r.agentFilterAria,t[2]=i,t[3]=o,t[4]=l,t[5]=d):d=t[5];let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(xe,{className:`size-4`,"aria-hidden":!0}),t[6]=p):p=t[6];let m;t[7]===r.addWorkflow?m=t[8]:(m=(0,Z.jsx)(J,{asChild:!0,variant:`primary`,className:`h-9 rounded-lg`,children:(0,Z.jsxs)(s,{to:`/workflows/new`,children:[p,r.addWorkflow]})}),t[7]=r.addWorkflow,t[8]=m);let h;t[9]!==r.refresh||t[10]!==a||t[11]!==u?(h=(0,Z.jsx)(Ve,{className:`size-9 shrink-0 p-0`,loading:a,label:r.refresh,onClick:u}),t[9]=r.refresh,t[10]=a,t[11]=u,t[12]=h):h=t[12];let g;return t[13]!==d||t[14]!==m||t[15]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[d,m,h]}),t[13]=d,t[14]=m,t[15]=h,t[16]=g):g=t[16],g}var Ht=new Set([`failed`,`timeout`,`cancelled`]),Ut=[{id:`runs`,icon:N},{id:`library`,icon:ce}],Wt={failed:0,timeout:0,cancelled:0,running:1,queued:2,succeeded:3};function Gt(e){return Ht.has(e.status)}function Kt(e,t){return t===`all`?!0:t===`attention`?Gt(e):e.status===t}function qt(e){return[...e].sort((e,t)=>{let n=(Wt[e.status]??4)-(Wt[t.status]??4);if(n!==0)return n;if(e.status===`queued`&&t.status===`queued`)return e.createdAtMs-t.createdAtMs;let r=e.completedAtMs??e.startedAtMs??e.createdAtMs;return(t.completedAtMs??t.startedAtMs??t.createdAtMs)-r})}function Jt(e,t){return e===`Home`?`runs`:e===`End`?`library`:e===`ArrowLeft`||e===`ArrowRight`?t===`runs`?`library`:`runs`:null}function Yt(){let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(q,{className:`h-5 w-16 rounded-full`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-edge-subtle px-4 py-4 last:border-b-0`,"aria-hidden":`true`,children:[t,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(q,{className:`h-4 w-52 max-w-full`}),(0,Z.jsx)(q,{className:`mt-2 h-3 w-36 max-w-full`})]}),(0,Z.jsx)(q,{className:`hidden h-8 w-20 rounded-lg sm:block`})]}),e[1]=n):n=e[1],n}function Xt(e){let t=(0,X.c)(30),{vm:n}=e,{language:r,localeTag:i,labels:a,hasToken:o,definitions:s,runs:c,searchQuery:u,setSearchQuery:d,workflowFilterId:f,setWorkflowFilterId:p,triggerFilter:m,setTriggerFilter:h,statusFilter:g,setStatusFilter:_,clearRunFilters:v,pageTab:y,setPageTab:x,runLayout:C,setRunLayout:w,openRunDetails:T,openRunInChat:E,openDefinitionDetails:O,openWorkflowEditor:k,startWorkflow:j,actionError:M,loading:N,error:P,cancelRun:F,retryRun:I}=n,L=A(en),R=A($t),z=Date.now(),B=qt(c.filter(Gt)),V;t[0]===g?V=t[1]:(V=e=>Kt(e,g),t[0]=g,t[1]=V);let H=qt(mt(c,{searchQuery:u,workflowFilterId:f,triggerFilter:m}).filter(V)),U=!!(u||f||m!==`all`||g!==`all`),W,G;if(t[2]!==R||t[3]!==o||t[4]!==a.librarySubtitle||t[5]!==a.runsSubtitle||t[6]!==a.title||t[7]!==y||t[8]!==L||t[9]!==n?(W=()=>{if(!o){R();return}return L({startExtra:null,main:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:a.title}),(0,Z.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:y===`runs`?a.runsSubtitle:a.librarySubtitle})]}),end:(0,Z.jsx)(Vt,{vm:n})}),()=>R()},G=[R,o,a.librarySubtitle,a.runsSubtitle,a.title,y,L,n],t[2]=R,t[3]=o,t[4]=a.librarySubtitle,t[5]=a.runsSubtitle,t[6]=a.title,t[7]=y,t[8]=L,t[9]=n,t[10]=W,t[11]=G):(W=t[10],G=t[11]),(0,Y.useLayoutEffect)(W,G),!o){let e;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(je,{className:`size-10 text-accent-fg`,"aria-hidden":!0}),t[12]=e):e=t[12];let n;t[13]===a.title?n=t[14]:(n=(0,Z.jsx)(`h1`,{className:`mt-4 text-xl font-semibold text-fg`,children:a.title}),t[13]=a.title,t[14]=n);let r;t[15]===a.needToken?r=t[16]:(r=(0,Z.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.needToken}),t[15]=a.needToken,t[16]=r);let i;return t[17]!==n||t[18]!==r?(i=(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`flex w-full flex-col items-center px-3 py-16 text-center sm:px-5 xl:px-6`,children:[e,n,r]})}),t[17]=n,t[18]=r,t[19]=i):i=t[19],i}let ee=a.pageTabsAria,te=Ut.map(e=>{let{id:t,icon:n}=e;return(0,Z.jsxs)(`button`,{id:`workflow-tab-${t}`,type:`button`,role:`tab`,"aria-selected":y===t,"aria-controls":`workflow-panel-${t}`,tabIndex:y===t?0:-1,draggable:!1,className:l(`relative inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium`,`transition-transform duration-150 ease-out active:scale-95 motion-reduce:transition-none motion-reduce:active:scale-100`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,y===t?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>x(t),onKeyDown:e=>{let n=Jt(e.key,t);n&&(e.preventDefault(),x(n),window.requestAnimationFrame(()=>{document.getElementById(`workflow-tab-${n}`)?.focus()}))},children:[(0,Z.jsx)(n,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`span`,{children:a.pageTabs[t]}),t===`runs`&&B.length>0?(0,Z.jsx)(`span`,{className:`rounded-full bg-red-500/15 px-1.5 py-0.5 text-[10px] font-semibold text-red-700 dark:text-red-300`,children:B.length}):null]},t)}),ne;t[20]!==a.pageTabsAria||t[21]!==te?(ne=(0,Z.jsx)(`nav`,{className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,"aria-label":ee,role:`tablist`,children:te}),t[20]=a.pageTabsAria,t[21]=te,t[22]=ne):ne=t[22];let re;t[23]!==M||t[24]!==P?(re=M??P?(0,Z.jsx)(`div`,{className:`mt-4 rounded-lg border border-red-500/25 bg-red-500/10 px-3 py-2 text-sm text-red-700 dark:text-red-300`,role:`alert`,children:M??P}):null,t[23]=M,t[24]=P,t[25]=re):re=t[25];let ie=y===`runs`?(0,Z.jsxs)(`div`,{id:`workflow-panel-runs`,role:`tabpanel`,"aria-labelledby":`workflow-tab-runs`,className:`flex flex-col gap-4 py-4`,children:[B.length>0?(0,Z.jsx)(`section`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/8 px-4 py-3`,"aria-labelledby":`workflow-attention-heading`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Z.jsx)(b,{className:`mt-0.5 size-4 shrink-0 text-amber-700 dark:text-amber-300`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{id:`workflow-attention-heading`,className:`text-sm font-semibold text-fg`,children:a.attentionTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-amber-500/15 px-2 py-0.5 text-[10px] font-semibold text-amber-800 dark:text-amber-200`,children:B.length})]}),(0,Z.jsxs)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:[dt(B[0]),` · `,xt(B[0].completedAtMs??B[0].createdAtMs,z,i)]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.attentionHint})]})]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pl-7 lg:pl-0`,children:[(0,Z.jsx)(J,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>T(B[0]),children:a.attentionView}),(0,Z.jsx)(J,{type:`button`,variant:`primary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void I(B[0].id),children:a.rerun})]})]})}):null,(0,Z.jsx)(`section`,{className:`flex flex-col gap-3 rounded-xl border border-edge-subtle bg-surface-base px-3 py-3`,"aria-label":a.runFiltersAria,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative min-w-52 flex-1 sm:max-w-sm`,children:[(0,Z.jsx)(Ue,{className:`pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:a.runsSearchPlaceholder,className:l(`h-9 w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg shadow-surface`,`placeholder:text-fg-muted`,ke.focusRingPanel)})]}),(0,Z.jsx)(D,{value:g,"aria-label":a.statusFilterAria,onChange:e=>_(e.target.value),className:`h-9 min-w-32 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[`all`,`attention`,`running`,`queued`,`succeeded`].map(e=>(0,Z.jsx)(Re,{value:e,children:a.runStatuses[e]},e))}),(0,Z.jsxs)(D,{value:m,"aria-label":a.boardTriggerFilterAria,onChange:e=>h(e.target.value),className:`h-9 min-w-[7.5rem] rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,Z.jsx)(Re,{value:`all`,children:a.boardTriggerFilterAll}),(0,Z.jsx)(Re,{value:`automation`,children:a.boardTriggerFilterAutomation}),(0,Z.jsx)(Re,{value:`webui`,children:a.boardTriggerFilterWebui}),(0,Z.jsx)(Re,{value:`chat`,children:a.boardTriggerFilterChat}),(0,Z.jsx)(Re,{value:`api`,children:a.boardTriggerFilterApi})]}),(0,Z.jsxs)(D,{value:f,"aria-label":a.boardWorkflowFilterAria,onChange:e=>p(e.target.value),className:`h-9 min-w-40 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,children:[(0,Z.jsx)(Re,{value:``,children:a.boardWorkflowFilterAll}),s.map(Qt)]}),U?(0,Z.jsxs)(J,{type:`button`,variant:`ghost`,className:`h-9 rounded-lg text-xs`,onClick:v,children:[(0,Z.jsx)(Ze,{className:`size-3.5`,"aria-hidden":!0}),a.clearFilters]}):null,(0,Z.jsxs)(`div`,{className:`ml-auto flex rounded-lg bg-surface-muted p-0.5`,role:`group`,"aria-label":a.layoutAria,children:[(0,Z.jsxs)(`button`,{type:`button`,className:l(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,C===`list`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,ke.focusRingPanel),"aria-pressed":C===`list`,onClick:()=>w(`list`),children:[(0,Z.jsx)(S,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.list]}),(0,Z.jsxs)(`button`,{type:`button`,className:l(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,C===`board`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`,ke.focusRingPanel),"aria-pressed":C===`board`,onClick:()=>w(`board`),children:[(0,Z.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a.runLayouts.board]})]})]})}),C===`list`?(0,Z.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge-subtle bg-surface-base`,"aria-labelledby":`workflow-runs-heading`,children:[(0,Z.jsxs)(`header`,{className:`flex items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{id:`workflow-runs-heading`,className:`text-sm font-semibold text-fg`,children:a.allRuns}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.allRunsHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs font-semibold tabular-nums text-fg-muted`,children:H.length})]}),N&&H.length===0?Array.from({length:4}).map(Zt):H.length>0?H.map(e=>(0,Z.jsx)(Bt,{run:e,language:r,localeTag:i,nowMs:z,onOpen:T,onOpenChat:E,onCancel:e=>void F(e),onRetry:e=>void I(e)},e.id)):(0,Z.jsxs)(`div`,{className:`flex min-h-64 flex-col items-center justify-center px-4 py-12 text-center`,children:[(0,Z.jsx)(je,{className:`size-8 text-fg-subtle`,"aria-hidden":!0}),(0,Z.jsx)(`h3`,{className:`mt-3 text-sm font-semibold text-fg`,children:U?a.noRunResultsTitle:a.noRunsTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-5 text-fg-muted`,children:U?a.noRunResultsHint:a.noRunsStartHint}),(0,Z.jsx)(J,{type:`button`,variant:U?`secondary`:`primary`,className:`mt-4 h-9 rounded-lg text-xs`,onClick:U?v:()=>x(`library`),children:U?a.clearFilters:a.chooseWorkflow})]})]}):(0,Z.jsx)(`div`,{className:`h-[min(72vh,48rem)] min-h-[24rem] w-full sm:min-h-[28rem]`,children:(0,Z.jsx)(jt,{runs:H,language:r,localeTag:i,labels:{boardEmptyTitle:a.boardEmptyTitle,boardEmptyHint:a.boardEmptyHint,boardStart:a.chooseWorkflow,loading:a.loading},searchQuery:``,workflowFilterId:``,triggerFilter:`all`,selectedRunId:null,loading:N,onOpenRun:T,onOpenRunChat:E,onCancelRun:e=>void F(e),onRetryRun:e=>void I(e),onStart:()=>x(`library`)})})]}):(0,Z.jsxs)(`section`,{id:`workflow-panel-library`,role:`tabpanel`,"aria-labelledby":`workflow-tab-library`,className:`py-5`,children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`h2`,{id:`workflow-library-heading`,className:`text-base font-semibold text-fg`,children:a.libraryTitle}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-2xl text-sm leading-6 text-fg-muted`,children:a.libraryDescription})]}),(0,Z.jsx)(Lt,{definitions:s,runs:c,language:r,onPick:j,onDetail:O,onEdit:k})]}),K;return t[26]!==re||t[27]!==ie||t[28]!==ne?(K=(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`mx-auto flex min-h-full w-full max-w-[96rem] flex-col px-3 py-5 sm:px-5 xl:px-6`,children:[ne,re,ie]})}),t[26]=re,t[27]=ie,t[28]=ne,t[29]=K):K=t[29],K}function Zt(e,t){return(0,Z.jsx)(Yt,{},t)}function Qt(e){return(0,Z.jsx)(Re,{value:e.id,children:e.title},e.id)}function $t(e){return e.clearPageHeader}function en(e){return e.setPageHeader}function tn(){let e=(0,X.c)(114),t=p(sn),n;e[0]===t?n=e[1]:(n=f(t),e[0]=t,e[1]=n);let r=n.workflows,i=t===`zh`?`zh-CN`:`en-US`,s=m(on),c=!!s,l=o(),[u,d]=a(),g;e[2]===u?g=e[3]:(g=u.get(`q`)??``,e[2]=u,e[3]=g);let _=g,v;e[4]===u?v=e[5]:(v=u.get(`wf`)?.trim()??``,e[4]=u,e[5]=v);let y=v,b;e[6]===u?b=e[7]:(b=u.get(`trigger`)?.trim()||`all`,e[6]=u,e[7]=b);let x=b,S,C,w,T;if(e[8]!==u){let t=u.get(`status`)?.trim()??``,n=u.get(`tab`)?.trim()??``,r=u.get(`layout`)?.trim()??``;S=u.get(`agent`)?.trim()??``,C=ie.has(n)?n:`runs`,w=M.has(r)?r:`list`,T=se.has(t)?t:`all`,e[8]=u,e[9]=S,e[10]=C,e[11]=w,e[12]=T}else S=e[9],C=e[10],w=e[11],T=e[12];let D=T,[O,k]=(0,Y.useState)(null),A;e[13]!==c||e[14]!==s?(A=c?[`workflow-agents`,s]:null,e[13]=c,e[14]=s,e[15]=A):A=e[15];let N;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(N={revalidateOnFocus:!1},e[16]=N):N=e[16];let P=h(A,ae,N),F;bb0:{let e=P.data?.agents??[];if(S&&(e.length===0||e.some(e=>e.id===S))){F=S;break bb0}F=P.data?.defaultId}let I=F,L;e[17]!==c||e[18]!==s?(L=c?[`workflow-definitions`,s]:null,e[17]=c,e[18]=s,e[19]=L):L=e[19];let R;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[20]=R):R=e[20];let z=h(L,Se,R),B;e[21]!==c||e[22]!==I||e[23]!==s?(B=c&&I?[`workflow-runs`,s,I]:null,e[21]=c,e[22]=I,e[23]=s,e[24]=B):B=e[24];let V;e[25]===I?V=e[26]:(V=()=>de(100,{ownerAgentId:I}),e[25]=I,e[26]=V);let H;e[27]===Symbol.for(`react.memo_cache_sentinel`)?(H={revalidateOnFocus:!1,refreshInterval:rn},e[27]=H):H=e[27];let U=h(B,V,H),W;e[28]===z.data?W=e[29]:(W=z.data??[],e[28]=z.data,e[29]=W);let G=W,ee;e[30]===U.data?ee=e[31]:(ee=U.data??[],e[30]=U.data,e[31]=ee);let te=ee,ne;e[32]===d?ne=e[33]:(ne=e=>{d(t=>{let n=new URLSearchParams(t);return e(n),n},{replace:!0})},e[32]=d,e[33]=ne);let K=ne,ce;e[34]===K?ce=e[35]:(ce=e=>K(t=>{let n=e.trim();n?t.set(`q`,n):t.delete(`q`)}),e[34]=K,e[35]=ce);let le=ce,ue;e[36]===K?ue=e[37]:(ue=e=>K(t=>{let n=e.trim();n?t.set(re,n):t.delete(re)}),e[36]=K,e[37]=ue);let q=ue,me;e[38]===K?me=e[39]:(me=e=>K(t=>{let n=e.trim();n?t.set(`wf`,n):t.delete(`wf`)}),e[38]=K,e[39]=me);let he=me,ge;e[40]===K?ge=e[41]:(ge=e=>K(t=>{e&&e!==`all`?t.set(oe,e):t.delete(oe)}),e[40]=K,e[41]=ge);let _e=ge,ve;e[42]===K?ve=e[43]:(ve=e=>K(t=>{e===`runs`?t.delete(`tab`):t.set(`tab`,e)}),e[42]=K,e[43]=ve);let ye=ve,be;e[44]===K?be=e[45]:(be=e=>K(t=>{e===`list`?t.delete(E):t.set(E,e)}),e[44]=K,e[45]=be);let xe=be,J;e[46]===K?J=e[47]:(J=e=>K(t=>{e===`all`?t.delete(j):t.set(j,e)}),e[46]=K,e[47]=J);let Ce=J,we;e[48]===K?we=e[49]:(we=()=>K(nn),e[48]=K,e[49]=we);let Te=we,Ee=I?`?agentId=${encodeURIComponent(I)}`:``,De;e[50]!==l||e[51]!==Ee?(De=e=>l(`/workflows/${e.id}${Ee}`),e[50]=l,e[51]=Ee,e[52]=De):De=e[52];let Oe=De,ke=Oe,Ae;e[53]!==l||e[54]!==I||e[55]!==Ee?(Ae=e=>{l(e.metadata.source===`user`?`/workflows/${e.id}/edit${Ee}`:`/workflows/new?copy=${encodeURIComponent(e.id)}${I?`&agentId=${encodeURIComponent(I)}`:``}`)},e[53]=l,e[54]=I,e[55]=Ee,e[56]=Ae):Ae=e[56];let je=Ae,Me;e[57]!==l||e[58]!==Ee?(Me=e=>l(`/workflows/runs/${e.id}${Ee}`),e[57]=l,e[58]=Ee,e[59]=Me):Me=e[59];let Ne=Me,Pe;e[60]===l?Pe=e[61]:(Pe=e=>{let t=st(e);t&&l($e(t))},e[60]=l,e[61]=Pe);let Fe=Pe,Ie;e[62]!==r.cancelFailed||e[63]!==I||e[64]!==U?(Ie=async e=>{try{await pe(e,{ownerAgentId:I}),await U.mutate()}catch(e){let t=e;k(t instanceof Error?t.message:r.cancelFailed)}},e[62]=r.cancelFailed,e[63]=I,e[64]=U,e[65]=Ie):Ie=e[65];let Le=Ie,Re;e[66]!==r.retryFailed||e[67]!==l||e[68]!==I||e[69]!==Ee?(Re=async e=>{try{l(`/workflows/runs/${(await fe(e,{ownerAgentId:I})).runId}${Ee}`)}catch(e){let t=e;k(t instanceof Error?t.message:r.retryFailed)}},e[66]=r.retryFailed,e[67]=l,e[68]=I,e[69]=Ee,e[70]=Re):Re=e[70];let ze=Re,Be,Ve;e[71]===U?(Be=e[72],Ve=e[73]):(Be=()=>{let e=()=>void U.mutate();return window.addEventListener(`workflow-run-updated`,e),window.addEventListener(`workflow-run-error`,e),()=>{window.removeEventListener(`workflow-run-updated`,e),window.removeEventListener(`workflow-run-error`,e)}},Ve=[U],e[71]=U,e[72]=Be,e[73]=Ve),(0,Y.useEffect)(Be,Ve);let He;e[74]!==P||e[75]!==z||e[76]!==U?(He=()=>{Promise.all([P.mutate(),z.mutate(),U.mutate()])},e[74]=P,e[75]=z,e[76]=U,e[77]=He):He=e[77];let Ue=He,We=P.isLoading||z.isLoading||U.isLoading,Ge=P.error?.message??z.error?.message??U.error?.message??null,Ke;e[78]===P.data?.agents?Ke=e[79]:(Ke=P.data?.agents??[],e[78]=P.data?.agents,e[79]=Ke);let qe;return e[80]!==O||e[81]!==Le||e[82]!==Te||e[83]!==G||e[84]!==Ge||e[85]!==c||e[86]!==r||e[87]!==t||e[88]!==We||e[89]!==i||e[90]!==Oe||e[91]!==Ne||e[92]!==Fe||e[93]!==je||e[94]!==I||e[95]!==C||e[96]!==Ue||e[97]!==ze||e[98]!==w||e[99]!==te||e[100]!==_||e[101]!==q||e[102]!==ye||e[103]!==xe||e[104]!==le||e[105]!==Ce||e[106]!==_e||e[107]!==he||e[108]!==ke||e[109]!==D||e[110]!==Ke||e[111]!==x||e[112]!==y?(qe={language:t,localeTag:i,labels:r,hasToken:c,searchQuery:_,setSearchQuery:le,ownerAgentId:I,agentOptions:Ke,setOwnerAgentId:q,workflowFilterId:y,setWorkflowFilterId:he,triggerFilter:x,setTriggerFilter:_e,statusFilter:D,setStatusFilter:Ce,clearRunFilters:Te,pageTab:C,setPageTab:ye,runLayout:w,setRunLayout:xe,definitions:G,runs:te,openDefinitionDetails:Oe,startWorkflow:ke,openWorkflowEditor:je,openRunDetails:Ne,openRunInChat:Fe,actionError:O,loading:We,error:Ge,refreshAll:Ue,cancelRun:Le,retryRun:ze},e[80]=O,e[81]=Le,e[82]=Te,e[83]=G,e[84]=Ge,e[85]=c,e[86]=r,e[87]=t,e[88]=We,e[89]=i,e[90]=Oe,e[91]=Ne,e[92]=Fe,e[93]=je,e[94]=I,e[95]=C,e[96]=Ue,e[97]=ze,e[98]=w,e[99]=te,e[100]=_,e[101]=q,e[102]=ye,e[103]=xe,e[104]=le,e[105]=Ce,e[106]=_e,e[107]=he,e[108]=ke,e[109]=D,e[110]=Ke,e[111]=x,e[112]=y,e[113]=qe):qe=e[113],qe}function nn(e){e.delete(`q`),e.delete(`wf`),e.delete(oe),e.delete(j)}function rn(e){return e?.some(an)?3e3:0}function an(e){return e.status===`queued`||e.status===`running`}function on(e){return e.token}function sn(e){return e.language}function cn(){let e=(0,X.c)(2),t=tn(),n;return e[0]===t?n=e[1]:(n=(0,Z.jsx)(Xt,{vm:t}),e[0]=t,e[1]=n),n}function ln(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=ln(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var un={value:()=>{}};function dn(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+``)||r in n||/[\s.]/.test(r))throw Error(`illegal type: `+r);n[r]=[]}return new fn(n)}function fn(e){this._=e}function pn(e,t){return e.trim().split(/^|\s+/).map(function(e){var n=``,r=e.indexOf(`.`);if(r>=0&&(n=e.slice(r+1),e=e.slice(0,r)),e&&!t.hasOwnProperty(e))throw Error(`unknown type: `+e);return{type:e,name:n}})}fn.prototype=dn.prototype={constructor:fn,on:function(e,t){var n=this._,r=pn(e+``,n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=mn(n[i],e.name)))return i;return}if(t!=null&&typeof t!=`function`)throw Error(`invalid callback: `+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=hn(n[i],e.name,t);else if(t==null)for(i in n)n[i]=hn(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new fn(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw Error(`unknown type: `+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function mn(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function hn(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=un,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var gn={svg:`http://www.w3.org/2000/svg`,xhtml:`http://www.w3.org/1999/xhtml`,xlink:`http://www.w3.org/1999/xlink`,xml:`http://www.w3.org/XML/1998/namespace`,xmlns:`http://www.w3.org/2000/xmlns/`};function _n(e){var t=e+=``,n=t.indexOf(`:`);return n>=0&&(t=e.slice(0,n))!==`xmlns`&&(e=e.slice(n+1)),gn.hasOwnProperty(t)?{space:gn[t],local:e}:e}function vn(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===`http://www.w3.org/1999/xhtml`&&t.documentElement.namespaceURI===`http://www.w3.org/1999/xhtml`?t.createElement(e):t.createElementNS(n,e)}}function yn(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function bn(e){var t=_n(e);return(t.local?yn:vn)(t)}function xn(){}function Sn(e){return e==null?xn:function(){return this.querySelector(e)}}function Cn(e){typeof e!=`function`&&(e=Sn(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&(`__data__`in c&&(l.__data__=c.__data__),s[u]=l);return new di(r,this._parents)}function wn(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Tn(){return[]}function En(e){return e==null?Tn:function(){return this.querySelectorAll(e)}}function Dn(e){return function(){return wn(e.apply(this,arguments))}}function On(e){e=typeof e==`function`?Dn(e):En(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new di(r,i)}function kn(e){return function(){return this.matches(e)}}function An(e){return function(t){return t.matches(e)}}var jn=Array.prototype.find;function Mn(e){return function(){return jn.call(this.children,e)}}function Nn(){return this.firstElementChild}function Pn(e){return this.select(e==null?Nn:Mn(typeof e==`function`?e:An(e)))}var Fn=Array.prototype.filter;function In(){return Array.from(this.children)}function Ln(e){return function(){return Fn.call(this.children,e)}}function Rn(e){return this.selectAll(e==null?In:Ln(typeof e==`function`?e:An(e)))}function zn(e){typeof e!=`function`&&(e=kn(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new di(r,this._parents)}function Bn(e){return Array(e.length)}function Vn(){return new di(this._enter||this._groups.map(Bn),this._parents)}function Hn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Hn.prototype={constructor:Hn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Un(e){return function(){return e}}function Wn(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new Hn(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function Gn(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=Array(u),p;for(s=0;s<u;++s)(c=t[s])&&(f[s]=p=o.call(c,c.__data__,s,t)+``,l.has(p)?i[s]=c:l.set(p,c));for(s=0;s<d;++s)p=o.call(e,a[s],s,a)+``,(c=l.get(p))?(r[s]=c,c.__data__=a[s],l.delete(p)):n[s]=new Hn(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function Kn(e){return e.__data__}function qn(e,t){if(!arguments.length)return Array.from(this,Kn);var n=t?Gn:Wn,r=this._parents,i=this._groups;typeof e!=`function`&&(e=Un(e));for(var a=i.length,o=Array(a),s=Array(a),c=Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,p=Jn(e.call(u,u&&u.__data__,l,r)),m=p.length,h=s[l]=Array(m),g=o[l]=Array(m);n(u,d,h,g,c[l]=Array(f),p,t);for(var _=0,v=0,y,b;_<m;++_)if(y=h[_]){for(_>=v&&(v=_+1);!(b=g[v])&&++v<m;);y._next=b||null}}return o=new di(o,r),o._enter=s,o._exit=c,o}function Jn(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function Yn(){return new di(this._exit||this._groups.map(Bn),this._parents)}function Xn(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e==`function`?(r=e(r),r&&=r.selection()):r=r.append(e+``),t!=null&&(i=t(i),i&&=i.selection()),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function Zn(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=Array(d),p,m=0;m<d;++m)(p=l[m]||u[m])&&(f[m]=p);for(;c<i;++c)s[c]=n[c];return new di(s,this._parents)}function Qn(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function $n(e){e||=er;function t(t,n){return t&&n?e(t.__data__,n.__data__):!t-!n}for(var n=this._groups,r=n.length,i=Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new di(i,this._parents).order()}function er(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function tr(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function nr(){return Array.from(this)}function rr(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function ir(){let e=0;for(let t of this)++e;return e}function ar(){return!this.node()}function or(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function sr(e){return function(){this.removeAttribute(e)}}function cr(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lr(e,t){return function(){this.setAttribute(e,t)}}function ur(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function dr(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function fr(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function pr(e,t){var n=_n(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?cr:sr:typeof t==`function`?n.local?fr:dr:n.local?ur:lr)(n,t))}function mr(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function hr(e){return function(){this.style.removeProperty(e)}}function gr(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _r(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function vr(e,t,n){return arguments.length>1?this.each((t==null?hr:typeof t==`function`?_r:gr)(e,t,n??``)):yr(this.node(),e)}function yr(e,t){return e.style.getPropertyValue(t)||mr(e).getComputedStyle(e,null).getPropertyValue(t)}function br(e){return function(){delete this[e]}}function xr(e,t){return function(){this[e]=t}}function Sr(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Cr(e,t){return arguments.length>1?this.each((t==null?br:typeof t==`function`?Sr:xr)(e,t)):this.node()[e]}function wr(e){return e.trim().split(/^|\s+/)}function Tr(e){return e.classList||new Er(e)}function Er(e){this._node=e,this._names=wr(e.getAttribute(`class`)||``)}Er.prototype={add:function(e){this._names.indexOf(e)<0&&(this._names.push(e),this._node.setAttribute(`class`,this._names.join(` `)))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute(`class`,this._names.join(` `)))},contains:function(e){return this._names.indexOf(e)>=0}};function Dr(e,t){for(var n=Tr(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Or(e,t){for(var n=Tr(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function kr(e){return function(){Dr(this,e)}}function Ar(e){return function(){Or(this,e)}}function jr(e,t){return function(){(t.apply(this,arguments)?Dr:Or)(this,e)}}function Mr(e,t){var n=wr(e+``);if(arguments.length<2){for(var r=Tr(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t==`function`?jr:t?kr:Ar)(n,t))}function Nr(){this.textContent=``}function Pr(e){return function(){this.textContent=e}}function Fr(e){return function(){var t=e.apply(this,arguments);this.textContent=t??``}}function Ir(e){return arguments.length?this.each(e==null?Nr:(typeof e==`function`?Fr:Pr)(e)):this.node().textContent}function Lr(){this.innerHTML=``}function Rr(e){return function(){this.innerHTML=e}}function zr(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??``}}function Br(e){return arguments.length?this.each(e==null?Lr:(typeof e==`function`?zr:Rr)(e)):this.node().innerHTML}function Vr(){this.nextSibling&&this.parentNode.appendChild(this)}function Hr(){return this.each(Vr)}function Ur(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Wr(){return this.each(Ur)}function Gr(e){var t=typeof e==`function`?e:bn(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Kr(){return null}function qr(e,t){var n=typeof e==`function`?e:bn(e),r=t==null?Kr:typeof t==`function`?t:Sn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Jr(){var e=this.parentNode;e&&e.removeChild(this)}function Yr(){return this.each(Jr)}function Xr(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Zr(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Qr(e){return this.select(e?Zr:Xr)}function $r(e){return arguments.length?this.property(`__data__`,e):this.node().__data__}function ei(e){return function(t){e.call(this,t,this.__data__)}}function ti(e){return e.trim().split(/^|\s+/).map(function(e){var t=``,n=e.indexOf(`.`);return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function ni(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function ri(e,t,n){return function(){var r=this.__on,i,a=ei(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function ii(e,t,n){var r=ti(e+``),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?ri:ni,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function ai(e,t,n){var r=mr(e),i=r.CustomEvent;typeof i==`function`?i=new i(t,n):(i=r.document.createEvent(`Event`),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function oi(e,t){return function(){return ai(this,e,t)}}function si(e,t){return function(){return ai(this,e,t.apply(this,arguments))}}function ci(e,t){return this.each((typeof t==`function`?si:oi)(e,t))}function*li(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var ui=[null];function di(e,t){this._groups=e,this._parents=t}function fi(){return new di([[document.documentElement]],ui)}function pi(){return this}di.prototype=fi.prototype={constructor:di,select:Cn,selectAll:On,selectChild:Pn,selectChildren:Rn,filter:zn,data:qn,enter:Vn,exit:Yn,join:Xn,merge:Zn,selection:pi,order:Qn,sort:$n,call:tr,nodes:nr,node:rr,size:ir,empty:ar,each:or,attr:pr,style:vr,property:Cr,classed:Mr,text:Ir,html:Br,raise:Hr,lower:Wr,append:Gr,insert:qr,remove:Yr,clone:Qr,datum:$r,on:ii,dispatch:ci,[Symbol.iterator]:li};function mi(e){return typeof e==`string`?new di([[document.querySelector(e)]],[document.documentElement]):new di([[e]],ui)}function hi(e){let t;for(;t=e.sourceEvent;)e=t;return e}function gi(e,t){if(e=hi(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}var _i={passive:!1},vi={capture:!0,passive:!1};function yi(e){e.stopImmediatePropagation()}function bi(e){e.preventDefault(),e.stopImmediatePropagation()}function xi(e){var t=e.document.documentElement,n=mi(e).on(`dragstart.drag`,bi,vi);`onselectstart`in t?n.on(`selectstart.drag`,bi,vi):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect=`none`)}function Si(e,t){var n=e.document.documentElement,r=mi(e).on(`dragstart.drag`,null);t&&(r.on(`click.drag`,bi,vi),setTimeout(function(){r.on(`click.drag`,null)},0)),`onselectstart`in n?r.on(`selectstart.drag`,null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Ci=e=>()=>e;function wi(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}wi.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Ti(e){return!e.ctrlKey&&!e.button}function Ei(){return this.parentNode}function Di(e,t){return t??{x:e.x,y:e.y}}function Oi(){return navigator.maxTouchPoints||`ontouchstart`in this}function ki(){var e=Ti,t=Ei,n=Di,r=Oi,i={},a=dn(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,_i).on(`touchend.drag touchcancel.drag`,v).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!(u||!e.call(this,n,r))){var i=y(this,t.call(this,n,r),n,r,`mouse`);i&&(mi(n.view).on(`mousemove.drag`,m,vi).on(`mouseup.drag`,h,vi),xi(n.view),yi(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(bi(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){mi(e.view).on(`mousemove.drag mouseup.drag`,null),Si(e.view,l),bi(e),i.mouse(`end`,e)}function g(n,r){if(e.call(this,n,r)){var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s,c;for(s=0;s<o;++s)(c=y(this,a,n,r,i[s].identifier,i[s]))&&(yi(n),c(`start`,n,i[s]))}}function _(e){var t=e.changedTouches,n=t.length,r,a;for(r=0;r<n;++r)(a=i[t[r].identifier])&&(bi(e),a(`drag`,e,t[r]))}function v(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(yi(e),a(`end`,e,t[r]))}function y(e,t,r,s,c,l){var u=a.copy(),d=gi(l||r,t),p,m,h;if((h=n.call(e,new wi(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=gi(l||a,t),_=o;break}u.call(r,e,new wi(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:Ci(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:Ci(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:Ci(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:Ci(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}function Ai(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function ji(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Mi(){}var Ni=.7,Pi=1/Ni,Fi=`\\s*([+-]?\\d+)\\s*`,Ii=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*`,Li=`\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*`,Ri=/^#([0-9a-f]{3,8})$/,zi=RegExp(`^rgb\\(${Fi},${Fi},${Fi}\\)$`),Bi=RegExp(`^rgb\\(${Li},${Li},${Li}\\)$`),Vi=RegExp(`^rgba\\(${Fi},${Fi},${Fi},${Ii}\\)$`),Hi=RegExp(`^rgba\\(${Li},${Li},${Li},${Ii}\\)$`),Ui=RegExp(`^hsl\\(${Ii},${Li},${Li}\\)$`),Wi=RegExp(`^hsla\\(${Ii},${Li},${Li},${Ii}\\)$`),Gi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Ai(Mi,Xi,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ki,formatHex:Ki,formatHex8:qi,formatHsl:Ji,formatRgb:Yi,toString:Yi});function Ki(){return this.rgb().formatHex()}function qi(){return this.rgb().formatHex8()}function Ji(){return la(this).formatHsl()}function Yi(){return this.rgb().formatRgb()}function Xi(e){var t,n;return e=(e+``).trim().toLowerCase(),(t=Ri.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Zi(t):n===3?new ta(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Qi(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Qi(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=zi.exec(e))?new ta(t[1],t[2],t[3],1):(t=Bi.exec(e))?new ta(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Vi.exec(e))?Qi(t[1],t[2],t[3],t[4]):(t=Hi.exec(e))?Qi(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Ui.exec(e))?ca(t[1],t[2]/100,t[3]/100,1):(t=Wi.exec(e))?ca(t[1],t[2]/100,t[3]/100,t[4]):Gi.hasOwnProperty(e)?Zi(Gi[e]):e===`transparent`?new ta(NaN,NaN,NaN,0):null}function Zi(e){return new ta(e>>16&255,e>>8&255,e&255,1)}function Qi(e,t,n,r){return r<=0&&(e=t=n=NaN),new ta(e,t,n,r)}function $i(e){return e instanceof Mi||(e=Xi(e)),e?(e=e.rgb(),new ta(e.r,e.g,e.b,e.opacity)):new ta}function ea(e,t,n,r){return arguments.length===1?$i(e):new ta(e,t,n,r??1)}function ta(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Ai(ta,ea,ji(Mi,{brighter(e){return e=e==null?Pi:Pi**+e,new ta(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Ni:Ni**+e,new ta(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ta(oa(this.r),oa(this.g),oa(this.b),aa(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:na,formatHex:na,formatHex8:ra,formatRgb:ia,toString:ia}));function na(){return`#${sa(this.r)}${sa(this.g)}${sa(this.b)}`}function ra(){return`#${sa(this.r)}${sa(this.g)}${sa(this.b)}${sa((isNaN(this.opacity)?1:this.opacity)*255)}`}function ia(){let e=aa(this.opacity);return`${e===1?`rgb(`:`rgba(`}${oa(this.r)}, ${oa(this.g)}, ${oa(this.b)}${e===1?`)`:`, ${e})`}`}function aa(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function oa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function sa(e){return e=oa(e),(e<16?`0`:``)+e.toString(16)}function ca(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new da(e,t,n,r)}function la(e){if(e instanceof da)return new da(e.h,e.s,e.l,e.opacity);if(e instanceof Mi||(e=Xi(e)),!e)return new da;if(e instanceof da)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(o=t===a?(n-r)/s+(n<r)*6:n===a?(r-t)/s+2:(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new da(o,s,c,e.opacity)}function ua(e,t,n,r){return arguments.length===1?la(e):new da(e,t,n,r??1)}function da(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ai(da,ua,ji(Mi,{brighter(e){return e=e==null?Pi:Pi**+e,new da(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Ni:Ni**+e,new da(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new ta(ma(e>=240?e-240:e+120,i,r),ma(e,i,r),ma(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new da(fa(this.h),pa(this.s),pa(this.l),aa(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=aa(this.opacity);return`${e===1?`hsl(`:`hsla(`}${fa(this.h)}, ${pa(this.s)*100}%, ${pa(this.l)*100}%${e===1?`)`:`, ${e})`}`}}));function fa(e){return e=(e||0)%360,e<0?e+360:e}function pa(e){return Math.max(0,Math.min(1,e||0))}function ma(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}var ha=e=>()=>e;function ga(e,t){return function(n){return e+n*t}}function _a(e,t,n){return e**=+n,t=t**+n-e,n=1/n,function(r){return(e+r*t)**+n}}function va(e){return(e=+e)==1?ya:function(t,n){return n-t?_a(t,n,e):ha(isNaN(t)?n:t)}}function ya(e,t){var n=t-e;return n?ga(e,n):ha(isNaN(e)?t:e)}var ba=(function e(t){var n=va(t);function r(e,t){var r=n((e=ea(e)).r,(t=ea(t)).r),i=n(e.g,t.g),a=n(e.b,t.b),o=ya(e.opacity,t.opacity);return function(t){return e.r=r(t),e.g=i(t),e.b=a(t),e.opacity=o(t),e+``}}return r.gamma=e,r})(1);function xa(e,t){t||=[];var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(a){for(i=0;i<n;++i)r[i]=e[i]*(1-a)+t[i]*a;return r}}function Sa(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ca(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=Array(r),a=Array(n),o;for(o=0;o<r;++o)i[o]=Ma(e[o],t[o]);for(;o<n;++o)a[o]=t[o];return function(e){for(o=0;o<r;++o)a[o]=i[o](e);return a}}function wa(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Ta(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ea(e,t){var n={},r={},i;for(i in(typeof e!=`object`||!e)&&(e={}),(typeof t!=`object`||!t)&&(t={}),t)i in e?n[i]=Ma(e[i],t[i]):r[i]=t[i];return function(e){for(i in n)r[i]=n[i](e);return r}}var Da=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oa=new RegExp(Da.source,`g`);function ka(e){return function(){return e}}function Aa(e){return function(t){return e(t)+``}}function ja(e,t){var n=Da.lastIndex=Oa.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e+=``,t+=``;(r=Da.exec(e))&&(i=Oa.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:Ta(r,i)})),n=Oa.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Aa(c[0].x):ka(t):(t=c.length,function(e){for(var n=0,r;n<t;++n)s[(r=c[n]).i]=r.x(e);return s.join(``)})}function Ma(e,t){var n=typeof t,r;return t==null||n===`boolean`?ha(t):(n===`number`?Ta:n===`string`?(r=Xi(t))?(t=r,ba):ja:t instanceof Xi?ba:t instanceof Date?wa:Sa(t)?xa:Array.isArray(t)?Ca:typeof t.valueOf!=`function`&&typeof t.toString!=`function`||isNaN(t)?Ea:Ta)(e,t)}var Na=180/Math.PI,Pa={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Fa(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*Na,skewX:Math.atan(c)*Na,scaleX:o,scaleY:s}}var Ia;function La(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?Pa:Fa(t.a,t.b,t.c,t.d,t.e,t.f)}function Ra(e){return e==null||(Ia||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),Ia.setAttribute(`transform`,e),!(e=Ia.transform.baseVal.consolidate()))?Pa:(e=e.matrix,Fa(e.a,e.b,e.c,e.d,e.e,e.f))}function za(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,o,s){if(e!==i||r!==a){var c=o.push(`translate(`,null,t,null,n);s.push({i:c-4,x:Ta(e,i)},{i:c-2,x:Ta(r,a)})}else (i||a)&&o.push(`translate(`+i+t+a+n)}function o(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:Ta(e,t)}))}function s(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:Ta(e,t)})}function c(e,t,n,r,a,o){if(e!==n||t!==r){var s=a.push(i(a)+`scale(`,null,`,`,null,`)`);o.push({i:s-4,x:Ta(e,n)},{i:s-2,x:Ta(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),o(t.rotate,n.rotate,r,i),s(t.skewX,n.skewX,r,i),c(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var Ba=za(La,`px, `,`px)`,`deg)`),Va=za(Ra,`, `,`)`,`)`),Ha=1e-12;function Ua(e){return((e=Math.exp(e))+1/e)/2}function Wa(e){return((e=Math.exp(e))-1/e)/2}function Ga(e){return((e=Math.exp(2*e))-1)/(e+1)}var Ka=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<Ha)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=Ua(y),c=s/(n*g)*(i*Ga(t*r+y)-Wa(y));return[a+c*d,o+c*f,s*i/Ua(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),qa=0,Ja=0,Ya=0,Xa=1e3,Za,Qa,$a=0,eo=0,to=0,no=typeof performance==`object`&&performance.now?performance:Date,ro=typeof window==`object`&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function io(){return eo||=(ro(ao),no.now()+to)}function ao(){eo=0}function oo(){this._call=this._time=this._next=null}oo.prototype=so.prototype={constructor:oo,restart:function(e,t,n){if(typeof e!=`function`)throw TypeError(`callback is not a function`);n=(n==null?io():+n)+(t==null?0:+t),!this._next&&Qa!==this&&(Qa?Qa._next=this:Za=this,Qa=this),this._call=e,this._time=n,po()},stop:function(){this._call&&(this._call=null,this._time=1/0,po())}};function so(e,t,n){var r=new oo;return r.restart(e,t,n),r}function co(){io(),++qa;for(var e=Za,t;e;)(t=eo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qa}function lo(){eo=($a=no.now())+to,qa=Ja=0;try{co()}finally{qa=0,fo(),eo=0}}function uo(){var e=no.now(),t=e-$a;t>Xa&&(to-=t,$a=e)}function fo(){for(var e,t=Za,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Za=n);Qa=e,po(r)}function po(e){qa||(Ja&&=clearTimeout(Ja),e-eo>24?(e<1/0&&(Ja=setTimeout(lo,e-no.now()-to)),Ya&&=clearInterval(Ya)):(Ya||=($a=no.now(),setInterval(uo,Xa)),qa=1,ro(lo)))}function mo(e,t,n){var r=new oo;return t=t==null?0:+t,r.restart(n=>{r.stop(),e(n+t)},t,n),r}var ho=dn(`start`,`end`,`cancel`,`interrupt`),go=[];function _o(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;xo(e,n,{name:t,index:r,group:i,on:ho,tween:go,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:0})}function vo(e,t){var n=bo(e,t);if(n.state>0)throw Error(`too late; already scheduled`);return n}function yo(e,t){var n=bo(e,t);if(n.state>3)throw Error(`too late; already running`);return n}function bo(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw Error(`transition not found`);return n}function xo(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=so(a,0,n.time);function a(e){n.state=1,n.timer.restart(o,n.delay,n.time),n.delay<=e&&o(e-n.delay)}function o(a){var l,u,d,f;if(n.state!==1)return c();for(l in r)if(f=r[l],f.name===n.name){if(f.state===3)return mo(o);f.state===4?(f.state=6,f.timer.stop(),f.on.call(`interrupt`,e,e.__data__,f.index,f.group),delete r[l]):+l<t&&(f.state=6,f.timer.stop(),f.on.call(`cancel`,e,e.__data__,f.index,f.group),delete r[l])}if(mo(function(){n.state===3&&(n.state=4,n.timer.restart(s,n.delay,n.time),s(a))}),n.state=2,n.on.call(`start`,e,e.__data__,n.index,n.group),n.state===2){for(n.state=3,i=Array(d=n.tween.length),l=0,u=-1;l<d;++l)(f=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(i[++u]=f);i.length=u+1}}function s(t){for(var r=t<n.duration?n.ease.call(null,t/n.duration):(n.timer.restart(c),n.state=5,1),a=-1,o=i.length;++a<o;)i[a].call(e,r);n.state===5&&(n.on.call(`end`,e,e.__data__,n.index,n.group),c())}function c(){for(var i in n.state=6,n.timer.stop(),delete r[t],r)return;delete e.__transition}}function So(e,t){var n=e.__transition,r,i,a=!0,o;if(n){for(o in t=t==null?null:t+``,n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>2&&r.state<5,r.state=6,r.timer.stop(),r.on.call(i?`interrupt`:`cancel`,e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function Co(e){return this.each(function(){So(this,e)})}function wo(e,t){var n,r;return function(){var i=yo(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function To(e,t,n){var r,i;if(typeof n!=`function`)throw Error();return function(){var a=yo(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function Eo(e,t){var n=this._id;if(e+=``,arguments.length<2){for(var r=bo(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?wo:To)(n,e,t))}function Do(e,t,n){var r=e._id;return e.each(function(){var e=yo(this,r);(e.value||={})[t]=n.apply(this,arguments)}),function(e){return bo(e,r).value[t]}}function Oo(e,t){var n;return(typeof t==`number`?Ta:t instanceof Xi?ba:(n=Xi(t))?(t=n,ba):ja)(e,t)}function ko(e){return function(){this.removeAttribute(e)}}function Ao(e){return function(){this.removeAttributeNS(e.space,e.local)}}function jo(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function Mo(e,t,n){var r,i=n+``,a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function No(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Po(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+``,o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function Fo(e,t){var n=_n(e),r=n===`transform`?Va:Oo;return this.attrTween(e,typeof t==`function`?(n.local?Po:No)(n,r,Do(this,`attr.`+e,t)):t==null?(n.local?Ao:ko)(n):(n.local?Mo:jo)(n,r,t))}function Io(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Lo(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Ro(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Lo(e,i)),n}return i._value=t,i}function zo(e,t){var n,r;function i(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&Io(e,i)),n}return i._value=t,i}function Bo(e,t){var n=`attr.`+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!=`function`)throw Error();var r=_n(e);return this.tween(n,(r.local?Ro:zo)(r,t))}function Vo(e,t){return function(){vo(this,e).delay=+t.apply(this,arguments)}}function Ho(e,t){return t=+t,function(){vo(this,e).delay=t}}function Uo(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Vo:Ho)(t,e)):bo(this.node(),t).delay}function Wo(e,t){return function(){yo(this,e).duration=+t.apply(this,arguments)}}function Go(e,t){return t=+t,function(){yo(this,e).duration=t}}function Ko(e){var t=this._id;return arguments.length?this.each((typeof e==`function`?Wo:Go)(t,e)):bo(this.node(),t).duration}function qo(e,t){if(typeof t!=`function`)throw Error();return function(){yo(this,e).ease=t}}function Jo(e){var t=this._id;return arguments.length?this.each(qo(t,e)):bo(this.node(),t).ease}function Yo(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!=`function`)throw Error();yo(this,e).ease=n}}function Xo(e){if(typeof e!=`function`)throw Error();return this.each(Yo(this._id,e))}function Zo(e){typeof e!=`function`&&(e=kn(e));for(var t=this._groups,n=t.length,r=Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Es(r,this._parents,this._name,this._id)}function Qo(e){if(e._id!==this._id)throw Error();for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=Array(u),f,p=0;p<u;++p)(f=c[p]||l[p])&&(d[p]=f);for(;s<r;++s)o[s]=t[s];return new Es(o,this._parents,this._name,this._id)}function $o(e){return(e+``).trim().split(/^|\s+/).every(function(e){var t=e.indexOf(`.`);return t>=0&&(e=e.slice(0,t)),!e||e===`start`})}function es(e,t,n){var r,i,a=$o(t)?vo:yo;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function ts(e,t){var n=this._id;return arguments.length<2?bo(this.node(),n).on.on(e):this.each(es(n,e,t))}function ns(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function rs(){return this.on(`end.remove`,ns(this._id))}function is(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=Sn(e));for(var r=this._groups,i=r.length,a=Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&(`__data__`in u&&(d.__data__=u.__data__),l[f]=d,_o(l[f],t,n,f,l,bo(u,n)));return new Es(a,this._parents,t,n)}function as(e){var t=this._name,n=this._id;typeof e!=`function`&&(e=En(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),p,m=bo(u,n),h=0,g=f.length;h<g;++h)(p=f[h])&&_o(p,t,n,h,f,m);a.push(f),o.push(u)}return new Es(a,o,t,n)}var os=fi.prototype.constructor;function ss(){return new os(this._groups,this._parents)}function cs(e,t){var n,r,i;return function(){var a=yr(this,e),o=(this.style.removeProperty(e),yr(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function ls(e){return function(){this.style.removeProperty(e)}}function us(e,t,n){var r,i=n+``,a;return function(){var o=yr(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function ds(e,t,n){var r,i,a;return function(){var o=yr(this,e),s=n(this),c=s+``;return s??(c=s=(this.style.removeProperty(e),yr(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function fs(e,t){var n,r,i,a=`style.`+t,o=`end.`+a,s;return function(){var c=yo(this,e),l=c.on,u=c.value[a]==null?s||=ls(t):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function ps(e,t,n){var r=(e+=``)==`transform`?Ba:Oo;return t==null?this.styleTween(e,cs(e,r)).on(`end.style.`+e,ls(e)):typeof t==`function`?this.styleTween(e,ds(e,r,Do(this,`style.`+e,t))).each(fs(this._id,e)):this.styleTween(e,us(e,r,t),n).on(`end.style.`+e,null)}function ms(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function hs(e,t,n){var r,i;function a(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&ms(e,a,n)),r}return a._value=t,a}function gs(e,t,n){var r=`style.`+(e+=``);if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!=`function`)throw Error();return this.tween(r,hs(e,t,n??``))}function _s(e){return function(){this.textContent=e}}function vs(e){return function(){var t=e(this);this.textContent=t??``}}function ys(e){return this.tween(`text`,typeof e==`function`?vs(Do(this,`text`,e)):_s(e==null?``:e+``))}function bs(e){return function(t){this.textContent=e.call(this,t)}}function xs(e){var t,n;function r(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&bs(r)),t}return r._value=e,r}function Ss(e){var t=`text`;if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!=`function`)throw Error();return this.tween(t,xs(e))}function Cs(){for(var e=this._name,t=this._id,n=Os(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=bo(c,t);_o(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Es(r,this._parents,e,n)}function ws(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var n=yo(this,r),i=n.on;i!==e&&(t=(e=i).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),n.on=t}),i===0&&a()})}var Ts=0;function Es(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ds(e){return fi().transition(e)}function Os(){return++Ts}var ks=fi.prototype;Es.prototype=Ds.prototype={constructor:Es,select:is,selectAll:as,selectChild:ks.selectChild,selectChildren:ks.selectChildren,filter:Zo,merge:Qo,selection:ss,transition:Cs,call:ks.call,nodes:ks.nodes,node:ks.node,size:ks.size,empty:ks.empty,each:ks.each,on:ts,attr:Fo,attrTween:Bo,style:ps,styleTween:gs,text:ys,textTween:Ss,remove:rs,tween:Eo,delay:Uo,duration:Ko,ease:Jo,easeVarying:Xo,end:ws,[Symbol.iterator]:ks[Symbol.iterator]};function As(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var js={time:null,delay:0,duration:250,ease:As};function Ms(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw Error(`transition ${t} not found`);return n}function Ns(e){var t,n;e instanceof Es?(t=e._id,e=e._name):(t=Os(),(n=js).time=io(),e=e==null?null:e+``);for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&_o(c,e,t,l,o,n||Ms(c,t));return new Es(r,this._parents,e,t)}fi.prototype.interrupt=Co,fi.prototype.transition=Ns;var Ps=e=>()=>e;function Fs(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Is(e,t,n){this.k=e,this.x=t,this.y=n}Is.prototype={constructor:Is,scale:function(e){return e===1?this:new Is(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Is(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return`translate(`+this.x+`,`+this.y+`) scale(`+this.k+`)`}};var Ls=new Is(1,0,0);Rs.prototype=Is.prototype;function Rs(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Ls;return e.__zoom}function zs(e){e.stopImmediatePropagation()}function Bs(e){e.preventDefault(),e.stopImmediatePropagation()}function Vs(e){return(!e.ctrlKey||e.type===`wheel`)&&!e.button}function Hs(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute(`viewBox`)?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Us(){return this.__zoom||Ls}function Ws(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Gs(){return navigator.maxTouchPoints||`ontouchstart`in this}function Ks(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function qs(){var e=Vs,t=Hs,n=Ks,r=Ws,i=Gs,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Ka,l=dn(`start`,`zoom`,`end`),u,d,f,p=500,m=150,h=0,g=10;function _(e){e.property(`__zoom`,Us).on(`wheel.zoom`,w,{passive:!1}).on(`mousedown.zoom`,T).on(`dblclick.zoom`,E).filter(i).on(`touchstart.zoom`,D).on(`touchmove.zoom`,O).on(`touchend.zoom touchcancel.zoom`,k).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}_.transform=function(e,t,n,r){var i=e.selection?e.selection():e;i.property(`__zoom`,Us),e===i?i.interrupt().each(function(){S(this,arguments).event(r).start().zoom(null,typeof t==`function`?t.apply(this,arguments):t).end()}):x(e,t,n,r)},_.scaleBy=function(e,t,n,r){_.scaleTo(e,function(){return this.__zoom.k*(typeof t==`function`?t.apply(this,arguments):t)},n,r)},_.scaleTo=function(e,r,i,a){_.transform(e,function(){var e=t.apply(this,arguments),a=this.__zoom,s=i==null?b(e):typeof i==`function`?i.apply(this,arguments):i,c=a.invert(s),l=typeof r==`function`?r.apply(this,arguments):r;return n(y(v(a,l),s,c),e,o)},i,a)},_.translateBy=function(e,r,i,a){_.transform(e,function(){return n(this.__zoom.translate(typeof r==`function`?r.apply(this,arguments):r,typeof i==`function`?i.apply(this,arguments):i),t.apply(this,arguments),o)},null,a)},_.translateTo=function(e,r,i,a,s){_.transform(e,function(){var e=t.apply(this,arguments),s=this.__zoom,c=a==null?b(e):typeof a==`function`?a.apply(this,arguments):a;return n(Ls.translate(c[0],c[1]).scale(s.k).translate(typeof r==`function`?-r.apply(this,arguments):-r,typeof i==`function`?-i.apply(this,arguments):-i),e,o)},a,s)};function v(e,t){return t=Math.max(a[0],Math.min(a[1],t)),t===e.k?e:new Is(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,i=t[1]-n[1]*e.k;return r===e.x&&i===e.y?e:new Is(e.k,r,i)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,n,r,i){e.on(`start.zoom`,function(){S(this,arguments).event(i).start()}).on(`interrupt.zoom end.zoom`,function(){S(this,arguments).event(i).end()}).tween(`zoom`,function(){var e=this,a=arguments,o=S(e,a).event(i),s=t.apply(e,a),l=r==null?b(s):typeof r==`function`?r.apply(e,a):r,u=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,f=typeof n==`function`?n.apply(e,a):n,p=c(d.invert(l).concat(u/d.k),f.invert(l).concat(u/f.k));return function(e){if(e===1)e=f;else{var t=p(e),n=u/t[2];e=new Is(n,l[0]-t[0]*n,l[1]-t[1]*n)}o.zoom(null,e)}})}function S(e,t,n){return!n&&e.__zooming||new C(e,t)}function C(e,n){this.that=e,this.args=n,this.active=0,this.sourceEvent=null,this.extent=t.apply(e,n),this.taps=0}C.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit(`start`)),this},zoom:function(e,t){return this.mouse&&e!==`mouse`&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&e!==`touch`&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&e!==`touch`&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit(`zoom`),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit(`end`)),this},emit:function(e){var t=mi(this.that).datum();l.call(e,this.that,new Fs(e,{sourceEvent:this.sourceEvent,target:_,type:e,transform:this.that.__zoom,dispatch:l}),t)}};function w(t,...i){if(!e.apply(this,arguments))return;var s=S(this,i).event(t),c=this.__zoom,l=Math.max(a[0],Math.min(a[1],c.k*2**r.apply(this,arguments))),u=gi(t);if(s.wheel)(s.mouse[0][0]!==u[0]||s.mouse[0][1]!==u[1])&&(s.mouse[1]=c.invert(s.mouse[0]=u)),clearTimeout(s.wheel);else if(c.k===l)return;else s.mouse=[u,c.invert(u)],So(this),s.start();Bs(t),s.wheel=setTimeout(d,m),s.zoom(`mouse`,n(y(v(c,l),s.mouse[0],s.mouse[1]),s.extent,o));function d(){s.wheel=null,s.end()}}function T(t,...r){if(f||!e.apply(this,arguments))return;var i=t.currentTarget,a=S(this,r,!0).event(t),s=mi(t.view).on(`mousemove.zoom`,d,!0).on(`mouseup.zoom`,p,!0),c=gi(t,i),l=t.clientX,u=t.clientY;xi(t.view),zs(t),a.mouse=[c,this.__zoom.invert(c)],So(this),a.start();function d(e){if(Bs(e),!a.moved){var t=e.clientX-l,r=e.clientY-u;a.moved=t*t+r*r>h}a.event(e).zoom(`mouse`,n(y(a.that.__zoom,a.mouse[0]=gi(e,i),a.mouse[1]),a.extent,o))}function p(e){s.on(`mousemove.zoom mouseup.zoom`,null),Si(e.view,a.moved),Bs(e),a.event(e).end()}}function E(r,...i){if(e.apply(this,arguments)){var a=this.__zoom,c=gi(r.changedTouches?r.changedTouches[0]:r,this),l=a.invert(c),u=a.k*(r.shiftKey?.5:2),d=n(y(v(a,u),c,l),t.apply(this,i),o);Bs(r),s>0?mi(this).transition().duration(s).call(x,d,c,r):mi(this).call(_.transform,d,c,r)}}function D(t,...n){if(e.apply(this,arguments)){var r=t.touches,i=r.length,a=S(this,n,t.changedTouches.length===i).event(t),o,s,c,l;for(zs(t),s=0;s<i;++s)c=r[s],l=gi(c,this),l=[l,this.__zoom.invert(l),c.identifier],a.touch0?!a.touch1&&a.touch0[2]!==l[2]&&(a.touch1=l,a.taps=0):(a.touch0=l,o=!0,a.taps=1+!!u);u&&=clearTimeout(u),o&&(a.taps<2&&(d=l[0],u=setTimeout(function(){u=null},p)),So(this),a.start())}}function O(e,...t){if(this.__zooming){var r=S(this,t).event(e),i=e.changedTouches,a=i.length,s,c,l,u;for(Bs(e),s=0;s<a;++s)c=i[s],l=gi(c,this),r.touch0&&r.touch0[2]===c.identifier?r.touch0[0]=l:r.touch1&&r.touch1[2]===c.identifier&&(r.touch1[0]=l);if(c=r.that.__zoom,r.touch1){var d=r.touch0[0],f=r.touch0[1],p=r.touch1[0],m=r.touch1[1],h=(h=p[0]-d[0])*h+(h=p[1]-d[1])*h,g=(g=m[0]-f[0])*g+(g=m[1]-f[1])*g;c=v(c,Math.sqrt(h/g)),l=[(d[0]+p[0])/2,(d[1]+p[1])/2],u=[(f[0]+m[0])/2,(f[1]+m[1])/2]}else if(r.touch0)l=r.touch0[0],u=r.touch0[1];else return;r.zoom(`touch`,n(y(c,l,u),r.extent,o))}}function k(e,...t){if(this.__zooming){var n=S(this,t).event(e),r=e.changedTouches,i=r.length,a,o;for(zs(e),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),a=0;a<i;++a)o=r[a],n.touch0&&n.touch0[2]===o.identifier?delete n.touch0:n.touch1&&n.touch1[2]===o.identifier&&delete n.touch1;if(n.touch1&&!n.touch0&&(n.touch0=n.touch1,delete n.touch1),n.touch0)n.touch0[1]=this.__zoom.invert(n.touch0[0]);else if(n.end(),n.taps===2&&(o=gi(o,this),Math.hypot(d[0]-o[0],d[1]-o[1])<g)){var s=mi(this).on(`dblclick.zoom`);s&&s.apply(this,arguments)}}}return _.wheelDelta=function(e){return arguments.length?(r=typeof e==`function`?e:Ps(+e),_):r},_.filter=function(t){return arguments.length?(e=typeof t==`function`?t:Ps(!!t),_):e},_.touchable=function(e){return arguments.length?(i=typeof e==`function`?e:Ps(!!e),_):i},_.extent=function(e){return arguments.length?(t=typeof e==`function`?e:Ps([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),_):t},_.scaleExtent=function(e){return arguments.length?(a[0]=+e[0],a[1]=+e[1],_):[a[0],a[1]]},_.translateExtent=function(e){return arguments.length?(o[0][0]=+e[0][0],o[1][0]=+e[1][0],o[0][1]=+e[0][1],o[1][1]=+e[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(e){return arguments.length?(n=e,_):n},_.duration=function(e){return arguments.length?(s=+e,_):s},_.interpolate=function(e){return arguments.length?(c=e,_):c},_.on=function(){var e=l.on.apply(l,arguments);return e===l?_:e},_.clickDistance=function(e){return arguments.length?(h=(e=+e)*e,_):Math.sqrt(h)},_.tapDistance=function(e){return arguments.length?(g=+e,_):g},_}var Js={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Ys=[[-1/0,-1/0],[1/0,1/0]],Xs=[`Enter`,` `,`Escape`],Zs={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},Qs;(function(e){e.Strict=`strict`,e.Loose=`loose`})(Qs||={});var $s;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})($s||={});var ec;(function(e){e.Partial=`partial`,e.Full=`full`})(ec||={});var tc={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},nc;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(nc||={});var rc;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(rc||={});var Q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(Q||={});var ic={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ac(e){return e===null?null:e?`valid`:`invalid`}var oc=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,sc=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),cc=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),lc=(e,t=[0,0])=>{let{width:n,height:r}=Uc(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},uc=(e,t={nodeOrigin:[0,0]})=>e.length===0?{x:0,y:0,width:0,height:0}:Tc(e.reduce((e,n)=>{let r=typeof n==`string`,i=!t.nodeLookup&&!r?n:void 0;return t.nodeLookup&&(i=r?t.nodeLookup.get(n):cc(n)?n:t.nodeLookup.get(n.id)),Cc(e,i?Dc(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0})},{x:1/0,y:1/0,x2:-1/0,y2:-1/0})),dc=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Cc(n,Dc(e)),r=!0)}),r?Tc(n):{x:0,y:0,width:0,height:0}},fc=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=kc(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},pc=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function mc(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=Uc(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function hc({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Bc(dc(mc(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function gc({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent)if(!s)a?.(`005`,Js.error005());else{let e=s.measured.width,t=s.measured.height;e&&t&&(d=[[c,l],[c+e,l+t]])}else s&&Hc(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Hc(d)?yc(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Js.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function _c({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=pc(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var vc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),yc=(e={x:0,y:0},t,n)=>({x:vc(e.x,t[0][0],t[1][0]-(n?.width??0)),y:vc(e.y,t[0][1],t[1][1]-(n?.height??0))});function bc(e,t,n){let{width:r,height:i}=Uc(n),{x:a,y:o}=n.internals.positionAbsolute;return yc(e,[[a,o],[a+r,o+i]],t)}var xc=(e,t,n)=>e<t?vc(Math.abs(e-t),1,t)/t:e>n?-vc(Math.abs(e-n),1,t)/t:0,Sc=(e,t,n=15,r=40)=>[xc(e.x,r,t.width-r)*n,xc(e.y,r,t.height-r)*n],Cc=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),wc=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Tc=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ec=(e,t=[0,0])=>{let{x:n,y:r}=cc(e)?e.internals.positionAbsolute:lc(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Dc=(e,t=[0,0])=>{let{x:n,y:r}=cc(e)?e.internals.positionAbsolute:lc(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Oc=(e,t)=>Tc(Cc(wc(e),wc(t))),kc=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Ac=(e,t)=>kc(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),jc=e=>Mc(e.width)&&Mc(e.height)&&Mc(e.x)&&Mc(e.y),Mc=e=>!isNaN(e)&&isFinite(e),Nc=(e,t)=>(e,t)=>{},Pc=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Fc=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Pc(s,o):s},Ic=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Lc(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Rc(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Lc(e,n),i=Lc(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Lc(e.top??e.y??0,n),i=Lc(e.bottom??e.y??0,n),a=Lc(e.left??e.x??0,t),o=Lc(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function zc(e,t,n,r,i,a){let{x:o,y:s}=Ic(e,[t,n,r]),{x:c,y:l}=Ic({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Bc=(e,t,n,r,i,a)=>{let o=Rc(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=vc(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=zc(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Vc=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Hc(e){return e!=null&&e!==`parent`}function Uc(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Wc(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Gc(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Kc(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function qc(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Jc(e){return{...Zs,...e||{}}}function Yc(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=tl(e),s=Fc({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Pc(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Xc=e=>({width:e.offsetWidth,height:e.offsetHeight}),Zc=e=>e?.getRootNode?.()||window?.document,Qc=[`INPUT`,`SELECT`,`TEXTAREA`];function $c(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Qc.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var el=e=>`clientX`in e,tl=(e,t)=>{let n=el(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},nl=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Xc(t)}})};function rl({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function il(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function al({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Q.Left:return[t-il(t-r,a),n];case Q.Right:return[t+il(r-t,a),n];case Q.Top:return[t,n-il(n-i,a)];case Q.Bottom:return[t,n+il(i-n,a)]}}function ol({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,curvature:o=.25}){let[s,c]=al({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=al({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=rl({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function sl({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function cl({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function ll({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Cc(Dc(e),Dc(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Ac({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Tc(a))>0}var ul=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,dl=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),fl=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Js.error006()),t;let r=n.getEdgeId||ul,i;return i=oc(e)?{...e}:{...e,id:r(e)},dl(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function pl({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=sl({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var ml={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},hl=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},gl=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function _l({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:i,offset:a,stepPosition:o}){let s=ml[t],c=ml[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=hl({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=sl({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y};return[[e,...x.x!==m[0].x||x.y!==m[0].y?[x]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],h,g,y,b]}function vl(e,t,n,r){let i=Math.min(gl(e,t)/2,gl(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function yl({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=_l({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=vl(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function bl(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function xl(e){let{sourceNode:t,targetNode:n}=e;if(!bl(t)||!bl(n))return null;let r=t.internals.handleBounds||Sl(t.handles),i=n.internals.handleBounds||Sl(n.handles),a=wl(r?.source??[],e.sourceHandle),o=wl(e.connectionMode===Qs.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Js.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||Q.Bottom,c=o?.position||Q.Top,l=Cl(t,a,s),u=Cl(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Sl(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function Cl(e,t,n=Q.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Uc(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case Q.Top:return{x:i+o/2,y:a};case Q.Right:return{x:i+o,y:a+s/2};case Q.Bottom:return{x:i+o/2,y:a+s};case Q.Left:return{x:i,y:a+s/2}}}function wl(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Tl(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function El(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Tl(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Dl=1e3,Ol=10,kl={nodeOrigin:[0,0],nodeExtent:Ys,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Al={...kl,checkEquality:!0};function jl(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Ml(e,t,n){let r=jl(kl,n);for(let n of e.values())if(n.parentId)Ll(n,e,t,r);else{let e=yc(lc(n,r.nodeOrigin),Hc(n.extent)?n.extent:r.nodeExtent,Uc(n));n.internals.positionAbsolute=e}}function Nl(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function Pl(e){return e===`manual`}function Fl(e,t,n,r={}){let i=jl(Al,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Pl(i.zIndexMode)?Dl:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=yc(lc(u,i.nodeOrigin),Hc(u.extent)?u.extent:i.nodeExtent,Uc(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Nl(u,e),z:Rl(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}(e.measured===void 0||e.measured.width===void 0||e.measured.height===void 0)&&!e.hidden&&(c=!1),u.parentId&&Ll(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Il(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ll(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=jl(kl,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Il(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*Ol),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=zl(e,u,o,s,a&&!Pl(c)?Dl:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Rl(e,t,n){let r=Mc(e.zIndex)?e.zIndex:0;return Pl(n)?r:r+(e.selected?t:0)}function zl(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Uc(e),l=lc(e,n),u=Hc(e.extent)?yc(l,e.extent,c):l,d=yc({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=bc(d,c,t));let f=Rl(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Bl(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Oc(a.get(n.parentId)?.expandedRect??Ec(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Uc(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Vl(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=Xc(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Hc(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=bc(h,s,n))}else m&&(h=yc(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:nl(`source`,r.nodeElement,p,d,e.id),target:nl(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&Ll(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:Ec(g,i)}))}}if(f.length>0){let e=Bl(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Hl({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Ul(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Wl(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Ul(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Ul(`target`,s,c,e,i,o),t.set(r.id,r)}}function Gl(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Gl(n,t):!1}function Kl(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function ql(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Gl(o,e))&&(o.draggable||t&&o.draggable===void 0)){let t=e.get(a);t&&i.set(a,{id:a,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return i}function Jl({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function Yl({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Pc(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Xl({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=mi(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?wc(dc(s)):null,x=v&&l?Yl({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Pc(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=gc({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=Jl({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=Sc(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0,(!m||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=Yc(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=ql(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=Jl({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=ki().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Yc(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=tl(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Yc(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=tl(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=tl(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=Jl({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Kl(t,`.${g}`,v))&&(!_||Kl(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Zl(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Ac(i,Ec(e))>0&&r.push(e);return r}var Ql=250;function $l(e,t,n,r){let i=[],a=1/0,o=Zl(e,n,t+Ql);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Cl(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function eu(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Cl(o,c,c.position,!0)}:c}function tu(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function nu(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var ru=()=>!0;function iu(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=ru,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Zc(e.target),E=0,D,{x:O,y:k}=tl(e),A=tu(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=eu(i,A,r,c,t);if(!N)return;let P=tl(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=Sc(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(z)}let B={...N,nodeId:i,type:A,position:N.position},V=c.get(i),H={inProgress:!0,isValid:null,from:Cl(V,B,Q.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:ic[B.position],toNode:null,pointer:P};function U(){M=!0,y(H),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&U();function W(e){if(!M){let{x:t,y:n}=tl(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;U()}if(!x()||!B){G(e);return}let a=b();P=tl(e,j),D=$l(Fc(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=au(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});R=s.handleDomNode,I=s.connection,L=nu(!!D,s.isValid);let u=c.get(i),f=u?Cl(u,B,Q.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ic({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:ic[B.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),H=p}function G(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||R)&&I&&L&&h?.(I);let{inProgress:t,...n}=H,r={...n,toPosition:H.toHandle?H.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,L=!1,I=null,R=null,T.removeEventListener(`mousemove`,W),T.removeEventListener(`mouseup`,G),T.removeEventListener(`touchmove`,W),T.removeEventListener(`touchend`,G)}}T.addEventListener(`mousemove`,W),T.addEventListener(`mouseup`,G),T.addEventListener(`touchmove`,W),T.addEventListener(`touchend`,G)}function au(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=ru,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=tl(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=tu(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===Qs.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=eu(t,e,a,u,n,!0)}return _}var ou={onPointerDown:iu,isValid:au};function su({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=mi(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Vc()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=qs().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:gi}}var cu=e=>({x:e.x,y:e.y,zoom:e.k}),lu=({x:e,y:t,zoom:n})=>Ls.translate(e,t).scale(n),uu=(e,t)=>e.target.closest(`.${t}`),du=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),fu=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,pu=(e,t=0,n=fu,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},mu=e=>{let t=e.ctrlKey&&Vc()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function hu({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(uu(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=gi(u),t=d*2**mu(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===$s.Vertical?0:u.deltaX*f,m=i===$s.Horizontal?0:u.deltaY*f;!Vc()&&u.shiftKey&&i!==$s.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=cu(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function gu({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=uu(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function _u({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=cu(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function vu({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&du(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,cu(a.transform))}}function yu({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&du(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=cu(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function bu({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:a,userSelectionActive:o,noWheelClassName:s,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{let f=e||t,p=n&&d.ctrlKey,m=d.type===`wheel`;if(d.button===1&&d.type===`mousedown`&&(uu(d,`${l}-flow__node`)||uu(d,`${l}-flow__edge`)))return!0;if(!r&&!f&&!i&&!a&&!n||o||u&&!m||uu(d,s)&&m||uu(d,c)&&(!m||i&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type===`touchstart`&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!i&&!p&&m||!r&&(d.type===`mousedown`||d.type===`touchstart`)||Array.isArray(r)&&!r.includes(d.button)&&d.type===`mousedown`)return!1;let h=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&h}}function xu({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=qs().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=mi(e).call(f);y({x:i.x,y:i.y,zoom:vc(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(mu);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?Ma:Ka).transform(pu(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:y,zoomOnScroll:b,zoomOnDoubleClick:x,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&v();let O=i&&!S&&!r;f.clickDistance(D?1/0:!Mc(E)||E<0?0:E);let k=O?hu({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:y,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):gu({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,k,{passive:!1});let A=_u({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,A);let j=vu({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});f.on(`zoom`,j);let M=yu({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,M);let N=bu({zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:y,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});f.filter(N),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function v(){f.on(`zoom`,null)}async function y(e,t,n){let r=lu(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function b(e,t){let n=lu(e);return await g(n,t),n}function x(e){if(p){let t=lu(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function S(){let e=p?Rs(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function C(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?Ma:Ka).scaleTo(pu(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function w(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?Ma:Ka).scaleBy(pu(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function T(e){f?.scaleExtent(e)}function E(e){f?.translateExtent(e)}function D(e){let t=!Mc(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:v,setViewport:b,setViewportConstrained:y,getViewport:S,scaleTo:C,scaleBy:w,setScaleExtent:T,setTranslateExtent:E,syncViewport:x,setClickDistance:D}}var Su;(function(e){e.Line=`line`,e.Handle=`handle`})(Su||={});function Cu({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function wu(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function Tu(e,t){return Math.max(0,t-e)}function Eu(e,t){return Math.max(0,e-t)}function Du(e,t,n){return Math.max(0,t-e,e-n)}function Ou(e,t){return e?!t:t}function ku(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Du(E,h,g),j=Du(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Tu(y+w+O,o[0][0]):!c&&w>0&&(e=Eu(y+E+O,o[1][0])),l&&T<0?t=Tu(b+T+k,o[0][1]):!l&&T>0&&(t=Eu(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=Eu(y+w,s[0][0]):!c&&w<0&&(e=Tu(y+E,s[1][0])),l&&T>0?t=Eu(b+T,s[0][1]):!l&&T<0&&(t=Tu(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Du(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Eu(b+k+E/C,o[1][1])*C:Tu(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?Tu(b+E/C,s[1][1])*C:Eu(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Du(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Eu(y+D*C+O,o[1][0])/C:Tu(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?Tu(y+D*C,s[1][0])/C:Eu(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Ou(c,l)?-w:w)/C:w=(Ou(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Au={width:0,height:0,x:0,y:0},ju={...Au,pointerX:0,pointerY:0,aspectRatio:1};function Mu(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Nu({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=mi(e),o={controlDirection:wu(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Au},h={...ju};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:wu(e)};let g,_=null,v=[],y,b,x,S=!1,C=ki().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Yc(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Hc(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Mu(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Yc(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:C,height:w}=m,T={},E=g.origin??s,{width:D,height:O,x:k,y:A}=ku(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,E,b,x),j=D!==C,M=O!==w,N=k!==u&&j,P=A!==f&&M;if(!N&&!P&&!j&&!M)return;if((N||P||E[0]===1||E[1]===1)&&(T.x=N?k:m.x,T.y=P?A:m.y,m.x=T.x,m.y=T.y,v.length>0)){let e=k-u,t=A-f;for(let n of v)n.position={x:n.position.x-e+E[0]*(D-C),y:n.position.y-t+E[1]*(O-w)},l.push(n)}if((j||M)&&(T.width=j&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?D:m.width,T.height=M&&(!o.resizeDirection||o.resizeDirection===`vertical`)?O:m.height,m.width=T.width,m.height=T.height),y&&g.expandParent){let e=E[0]*(T.width??0);T.x&&T.x<e&&(m.x=e,h.x-=T.x-e);let t=E[1]*(T.height??0);T.y&&T.y<t&&(m.y=t,h.y-=T.y-t)}let F=Cu({width:m.width,prevWidth:C,height:m.height,prevHeight:w,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)!==!1&&(S=!0,d?.(e,I),r(T,l))}).on(`end`,e=>{S&&=(f?.(e,{...m}),i?.({...m}),!1)});a.call(C)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var Pu=e(et(),1),Fu=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Iu=e=>e?Fu(e):Fu,{useDebugValue:Lu}=Y.default,{useSyncExternalStoreWithSelector:Ru}=Pu.default,zu=e=>e;function Bu(e,t=zu,n){let r=Ru(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Lu(r),r}var Vu=(e,t)=>{let n=Iu(e),r=(e,r=t)=>Bu(n,e,r);return Object.assign(r,n),r},Hu=(e,t)=>e?Vu(e,t):Vu;function Uu(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}n();var Wu=(0,Y.createContext)(null),Gu=Wu.Provider,Ku=Js.error001(`react`);function $(e,t){let n=(0,Y.useContext)(Wu);if(n===null)throw Error(Ku);return Bu(n,e,t)}function qu(){let e=(0,Y.useContext)(Wu);if(e===null)throw Error(Ku);return(0,Y.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Ju={display:`none`},Yu={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Xu=`react-flow__node-desc`,Zu=`react-flow__edge-desc`,Qu=`react-flow__aria-live`,$u=e=>e.ariaLiveMessage,ed=e=>e.ariaLabelConfig;function td({rfId:e}){let t=$($u);return(0,Z.jsx)(`div`,{id:`${Qu}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Yu,children:t})}function nd({rfId:e,disableKeyboardA11y:t}){let n=$(ed);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{id:`${Xu}-${e}`,style:Ju,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,Z.jsx)(`div`,{id:`${Zu}-${e}`,style:Ju,children:n[`edge.a11yDescription.default`]}),!t&&(0,Z.jsx)(td,{rfId:e})]})}var rd=(0,Y.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>(0,Z.jsx)(`div`,{className:ln([`react-flow__panel`,n,...`${e}`.split(`-`)]),style:r,ref:a,...i,children:t}));rd.displayName=`Panel`;var id=`https://reactflow.dev?utm_source=attribution`;function ad({proOptions:e,position:t=`bottom-right`}){return e?.hideAttribution?null:(0,Z.jsx)(rd,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${id}`,children:(0,Z.jsx)(`a`,{href:id,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var od=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},sd=e=>e.id;function cd(e,t){return Uu(e.selectedNodes.map(sd),t.selectedNodes.map(sd))&&Uu(e.selectedEdges.map(sd),t.selectedEdges.map(sd))}function ld({onSelectionChange:e}){let t=qu(),{selectedNodes:n,selectedEdges:r}=$(od,cd);return(0,Y.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var ud=e=>!!e.onSelectionChangeHandlers;function dd({onSelectionChange:e}){let t=$(ud);return e||t?(0,Z.jsx)(ld,{onSelectionChange:e}):null}var fd=[0,0],pd={x:0,y:0,zoom:1},md=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],hd=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),gd={translateExtent:Ys,nodeOrigin:fd,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function _d(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=$(hd,Uu),l=qu();(0,Y.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=gd,s()}),[]);let u=(0,Y.useRef)(gd);return(0,Y.useEffect)(()=>{for(let s of md){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Jc(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},md.map(t=>e[t])),null}function vd(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function yd(e){let[t,n]=(0,Y.useState)(e===`system`?null:e);return(0,Y.useEffect)(()=>{if(e!==`system`){n(e);return}let t=vd(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?vd()?.matches?`dark`:`light`:t}var bd=typeof document<`u`?document:null;function xd(e=null,t={target:bd,actInsideInputWithModifier:!0}){let[n,r]=(0,Y.useState)(!1),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(new Set([])),[o,s]=(0,Y.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(`+`,`
|
|
2
|
-
`).replace(`
|
|
3
|
-
|
|
4
|
-
`,`
|
|
5
|
-
+`).split(`
|
|
6
|
-
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,Y.useEffect)(()=>{let n=t?.target??bd,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&$c(e))return!1;let n=Cd(e.code,s);if(a.current.add(e[n]),Sd(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Cd(e.code,s);Sd(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Sd(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Cd(e,t){return t.includes(e)?`code`:`key`}var wd=()=>{let e=qu();return(0,Y.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Bc(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Fc(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Ic(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Td(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Ed(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Ed(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing);break}}function Dd(e,t){return Td(e,t)}function Od(e,t){return Td(e,t)}function kd(e,t){return{id:e,type:`select`,selected:t}}function Ad(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(kd(a.id,e)))}return r}function jd({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Md(e){return{id:e.id,type:`remove`}}var Nd=Nc(`React Flow`,`https://reactflow.dev/`);function Pd(e,t,n={}){return fl(e,t,{...n,onError:n.onError??Nd})}var Fd=e=>sc(e),Id=e=>oc(e);function Ld(e){return(0,Y.forwardRef)(e)}var Rd=typeof window<`u`?Y.useLayoutEffect:Y.useEffect;function zd(e){let[t,n]=(0,Y.useState)(BigInt(0)),[r]=(0,Y.useState)(()=>Bd(()=>n(e=>e+BigInt(1))));return Rd(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Bd(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Vd=(0,Y.createContext)(null);function Hd({children:e}){let t=qu(),n=zd((0,Y.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=jd({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=zd((0,Y.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(jd({items:s,lookup:o}))},[])),i=(0,Y.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,Z.jsx)(Vd.Provider,{value:i,children:e})}function Ud(){let e=(0,Y.useContext)(Vd);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Wd=e=>!!e.panZoom;function Gd(){let e=wd(),t=qu(),n=Ud(),r=$(Wd),i=(0,Y.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Fd(e)?e:n.get(e.id),a=i.parentId?Gc(i.position,i.measured,i.parentId,n,r):i.position;return Ec({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Fd(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Id(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await _c({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Md);o?.(f),c(e)}if(m){let e=d.map(Md);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=jc(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=Ec(s?r:a),l=Ac(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=jc(e)?e:a(e);if(!r)return!1;let i=Ac(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return uc(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??qc();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,Y.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Kd=e=>e.selected,qd=typeof window<`u`?window:void 0;function Jd({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=qu(),{deleteElements:r}=Gd(),i=xd(e,{actInsideInputWithModifier:!1}),a=xd(t,{target:qd});(0,Y.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Kd),edges:e.filter(Kd)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,Y.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Yd(e){let t=qu();(0,Y.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Xc(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Js.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var Xd={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Zd=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Qd({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=$s.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:v,paneClickDistance:y,selectionOnDrag:b}){let x=qu(),S=(0,Y.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=$(Zd,Uu),E=xd(f),D=(0,Y.useRef)();Yd(S);let O=(0,Y.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,Y.useEffect)(()=>{if(S.current){D.current=xu({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,Y.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,Z.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:Xd,children:m})}var $d=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function ef(){let{userSelectionActive:e,userSelectionRect:t}=$($d,Uu);return e&&t?(0,Z.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var tf=(e,t)=>n=>{n.target===t.current&&e?.(n)},nf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function rf({isSelecting:e,selectionKeyPressed:t,selectionMode:n=ec.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,Y.useRef)(0),_=qu(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=$(nf,Uu),C=y&&(e||v),w=(0,Y.useRef)(null),T=(0,Y.useRef)(),E=(0,Y.useRef)(new Set),D=(0,Y.useRef)(new Set),O=(0,Y.useRef)(!1),k=(0,Y.useRef)(!1),A=(0,Y.useRef)({x:0,y:0}),j=(0,Y.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},I=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=tl(n.nativeEvent,T.current),l=Fc({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function L(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Ic(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(fc(a,m,i,n===ec.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}Kc(h,E.current)||c(Ad(a,E.current,!0)),Kc(g,D.current)||l(Ad(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function R(){if(!i||!T.current)return;let[e,t]=Sc(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(R);return}let{x:t,y:n}=A.current;L(t,n),g.current=requestAnimationFrame(R)})}let z=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};return(0,Y.useEffect)(()=>()=>z(),[]),(0,Z.jsxs)(`div`,{className:ln([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:C?void 0:tf(M,w),onContextMenu:tf(N,w),onWheel:tf(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=tl(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Ic({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(R(),!0),L(o,c)}:p,onPointerUp:e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),z())},onPointerCancel:C?e=>{e.target?.releasePointerCapture?.(e.pointerId),z()}:void 0,onPointerDownCapture:C?I:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:Xd,children:[h,(0,Z.jsx)(ef,{})]})}function af({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,Js.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function of({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=qu(),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)();return(0,Y.useEffect)(()=>{if(!t)return u.current=Xl({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{af({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,Y.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var sf=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function cf(){let e=qu();return(0,Y.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=sf(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Pc(t,i));let{position:a,positionAbsolute:s}=gc({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var lf=(0,Y.createContext)(null),uf=lf.Provider;lf.Consumer;var df=()=>(0,Y.useContext)(lf),ff=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),pf=(0,Y.createContext)(null);function mf({children:e}){let t=$(ff,Uu);return(0,Z.jsx)(pf.Provider,{value:t,children:e})}function hf(){let e=(0,Y.useContext)(pf);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var gf={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},_f=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return gf;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===Qs.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function vf({type:e=`source`,position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=qu(),_=df(),{connectOnClick:v,noPanClassName:y,rfId:b}=hf(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=$(_f(_,m,e),Uu);_||g.getState().onError?.(`010`,Js.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Pd(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=el(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();ou.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,Z.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:ln([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=Zc(t.target),h=n||c,{connection:v,isValid:y}=ou.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var yf=(0,Y.memo)(Ld(vf));function bf({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return(0,Z.jsxs)(Z.Fragment,{children:[e?.label,(0,Z.jsx)(yf,{type:`source`,position:n,isConnectable:t})]})}function xf({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yf,{type:`target`,position:n,isConnectable:t}),e?.label,(0,Z.jsx)(yf,{type:`source`,position:r,isConnectable:t})]})}function Sf(){return null}function Cf({data:e,isConnectable:t,targetPosition:n=Q.Top}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yf,{type:`target`,position:n,isConnectable:t}),e?.label]})}var wf={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Tf={input:bf,default:xf,output:Cf,group:Sf};function Ef(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var Df=e=>{let{width:t,height:n,x:r,y:i}=dc(e.nodeLookup,{filter:e=>!!e.selected});return{width:Mc(t)?t:null,height:Mc(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Of({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=qu(),{width:i,height:a,transformString:o,userSelectionActive:s}=$(Df,Uu),c=cf(),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(of({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,Z.jsx)(`div`,{className:ln([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,Z.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(wf,e.key)&&(e.preventDefault(),c({direction:wf[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var kf=typeof window<`u`?window:void 0,Af=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function jf({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:I}){let{nodesSelectionActive:L,userSelectionActive:R}=$(Af,Uu),z=xd(l,{target:kf}),B=xd(h,{target:kf}),V=B||w,H=B||b,U=u&&V!==!0,W=z||R||U;return Jd({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,Z.jsx)(Qd,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:H,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!z&&V,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:I,paneClickDistance:s,selectionOnDrag:U,children:(0,Z.jsxs)(rf,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:V,autoPanOnSelection:T,isSelecting:!!W,selectionMode:d,selectionKeyPressed:z,paneClickDistance:s,selectionOnDrag:U,children:[e,L&&(0,Z.jsx)(Of,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}jf.displayName=`FlowRenderer`;var Mf=(0,Y.memo)(jf),Nf=e=>t=>e?fc(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Pf(e){return $((0,Y.useCallback)(Nf(e),[e]),Uu)}var Ff=e=>e.updateNodeInternals;function If(){let e=$(Ff),[t]=(0,Y.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,Y.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Lf({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=qu(),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(e.sourcePosition),c=(0,Y.useRef)(e.targetPosition),l=(0,Y.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,Y.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,Y.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,Y.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Rf({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=$(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Uu),S=y.type||`default`,C=g?.[S]||Tf[S];C===void 0&&(v?.(`003`,Js.error003(S)),S=`default`,C=g?.default||Tf.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=qu(),k=Wc(y),A=Lf({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=of({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=cf();if(y.hidden)return null;let N=Uc(y),P=Ef(y),F=T||w||t||n||r||i,I=n?e=>n(e,{...b.userNode}):void 0,L=r?e=>r(e,{...b.userNode}):void 0,R=i?e=>i(e,{...b.userNode}):void 0,z=a?e=>a(e,{...b.userNode}):void 0,B=o?e=>o(e,{...b.userNode}):void 0,V=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&af({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},H=t=>{if(!($c(t.nativeEvent)||m)){if(Xs.includes(t.key)&&T)af({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(wf,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:wf[t.key],factor:t.shiftKey?4:1})}}},U=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(fc(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,Z.jsx)(`div`,{className:ln([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:L,onMouseLeave:R,onContextMenu:z,onClick:V,onDoubleClick:B,onKeyDown:D?H:void 0,tabIndex:D?0:void 0,onFocus:D?U:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${Xu}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,Z.jsx)(uf,{value:e,children:(0,Z.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var zf=(0,Y.memo)(Rf),Bf=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Vf(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=$(Bf,Uu),a=Pf(e.onlyRenderVisibleElements),o=If();return(0,Z.jsx)(`div`,{className:`react-flow__nodes`,style:Xd,children:a.map(a=>(0,Z.jsx)(zf,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Vf.displayName=`NodeRenderer`;var Hf=(0,Y.memo)(Vf);function Uf(e){return $((0,Y.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&ll({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Uu)}var Wf=({color:e=`none`,strokeWidth:t=1})=>(0,Z.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Gf=({color:e=`none`,strokeWidth:t=1})=>(0,Z.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),Kf={[rc.Arrow]:Wf,[rc.ArrowClosed]:Gf};function qf(e){let t=qu();return(0,Y.useMemo)(()=>Object.prototype.hasOwnProperty.call(Kf,e)?Kf[e]:(t.getState().onError?.(`009`,Js.error009(e)),null),[e])}var Jf=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=qf(t);return c?(0,Z.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,Z.jsx)(c,{color:n,strokeWidth:o})}):null},Yf=({defaultColor:e,rfId:t})=>{let n=$(e=>e.edges),r=$(e=>e.defaultEdgeOptions),i=(0,Y.useMemo)(()=>El(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,Z.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,Z.jsx)(`defs`,{children:i.map(e=>(0,Z.jsx)(Jf,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Yf.displayName=`MarkerDefinitions`;var Xf=(0,Y.memo)(Yf);function Zf({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,Y.useState)({x:1,y:0,width:0,height:0}),p=ln([`react-flow__edge-textwrapper`,l]),m=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,Z.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,Z.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,Z.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}Zf.displayName=`EdgeText`;var Qf=(0,Y.memo)(Zf);function $f({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{...u,d:e,fill:`none`,className:ln([`react-flow__edge-path`,u.className])}),l?(0,Z.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Mc(t)&&Mc(n)?(0,Z.jsx)(Qf,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function ep({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function tp({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:i,targetPosition:a=Q.Top}){let[o,s]=ep({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=ep({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=rl({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function np(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=tp({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,Z.jsx)($f,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var rp=np({isInternal:!1}),ip=np({isInternal:!0});rp.displayName=`SimpleBezierEdge`,ip.displayName=`SimpleBezierEdgeInternal`;function ap(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Q.Bottom,targetPosition:m=Q.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=yl({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,Z.jsx)($f,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var op=ap({isInternal:!1}),sp=ap({isInternal:!0});op.displayName=`SmoothStepEdge`,sp.displayName=`SmoothStepEdgeInternal`;function cp(e){return(0,Y.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,Z.jsx)(op,{...n,id:r,pathOptions:(0,Y.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var lp=cp({isInternal:!1}),up=cp({isInternal:!0});lp.displayName=`StepEdge`,up.displayName=`StepEdgeInternal`;function dp(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=pl({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,Z.jsx)($f,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var fp=dp({isInternal:!1}),pp=dp({isInternal:!0});fp.displayName=`StraightEdge`,pp.displayName=`StraightEdgeInternal`;function mp(e){return(0,Y.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=Q.Bottom,targetPosition:s=Q.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=ol({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,Z.jsx)($f,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var hp=mp({isInternal:!1}),gp=mp({isInternal:!0});hp.displayName=`BezierEdge`,gp.displayName=`BezierEdgeInternal`;var _p={default:gp,straight:pp,step:up,smoothstep:sp,simplebezier:ip},vp={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},yp=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,bp=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,xp=`react-flow__edgeupdater`;function Sp({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,Z.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:ln([xp,`${xp}-${s}`]),cx:yp(t,r,e),cy:bp(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Cp({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=qu(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;ou.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(e===!0||e===`source`)&&(0,Z.jsx)(Sp,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,Z.jsx)(Sp,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function wp({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=$(t=>t.edgeLookup.get(e)),b=$(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||_p[x];S===void 0&&(_?.(`011`,Js.error011(x)),x=`default`,S=h?.default||_p.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,Y.useRef)(null),[D,O]=(0,Y.useState)(!1),[k,A]=(0,Y.useState)(!1),j=qu(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R}=$((0,Y.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return vp;let i=xl({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=cl({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||vp,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),Uu),z=(0,Y.useMemo)(()=>y.markerStart?`url('#${Tl(y.markerStart,m)}')`:void 0,[y.markerStart,m]),B=(0,Y.useMemo)(()=>y.markerEnd?`url('#${Tl(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||I===null)return null;let V=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},H=a?e=>{a(e,{...y})}:void 0,U=o?e=>{o(e,{...y})}:void 0,W=s?e=>{s(e,{...y})}:void 0,G=c?e=>{c(e,{...y})}:void 0,ee=l?e=>{l(e,{...y})}:void 0;return(0,Z.jsx)(`svg`,{style:{zIndex:M},children:(0,Z.jsxs)(`g`,{className:ln([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:V,onDoubleClick:H,onContextMenu:U,onMouseEnter:W,onMouseMove:G,onMouseLeave:ee,onKeyDown:C?t=>{if(!v&&Xs.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${Zu}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,Z.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:z,markerEnd:B,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,Z.jsx)(Cp,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:I,sourcePosition:L,targetPosition:R,setUpdateHover:O,setReconnecting:A})]})})}var Tp=(0,Y.memo)(wp),Ep=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Dp({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=$(Ep,Uu),b=Uf(t);return(0,Z.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,Z.jsx)(Xf,{defaultColor:e,rfId:n}),b.map(e=>(0,Z.jsx)(Tp,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}Dp.displayName=`EdgeRenderer`;var Op=(0,Y.memo)(Dp),kp=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Ap({children:e}){let t=qu(),n=(0,Y.useRef)(null),[r]=(0,Y.useState)(()=>t.getState().transform);return Rd(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=kp(r)))};return r(),t.subscribe(r)},[t]),(0,Z.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:kp(r)},children:e})}function jp(e){let t=Gd(),n=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Mp=e=>e.panZoom?.syncViewport;function Np(e){let t=$(Mp),n=qu();return(0,Y.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Pp(e){return e.connection.inProgress?{...e.connection,to:Fc(e.connection.to,e.transform)}:{...e.connection}}function Fp(e){return e?t=>e(Pp(t)):Pp}function Ip(e){return $(Fp(e),Uu)}var Lp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Rp({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=$(Lp,Uu);return a&&i&&c?(0,Z.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,Z.jsx)(`g`,{className:ln([`react-flow__connection`,ac(s)]),children:(0,Z.jsx)(zp,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var zp=({style:e,type:t=nc.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Ip();if(!i)return;if(n)return(0,Z.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:ac(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case nc.Bezier:[m]=ol(h);break;case nc.SimpleBezier:[m]=tp(h);break;case nc.Step:[m]=yl({...h,borderRadius:0});break;case nc.SmoothStep:[m]=yl(h);break;default:[m]=pl(h)}return(0,Z.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};zp.displayName=`ConnectionLine`;var Bp={};function Vp(e=Bp){(0,Y.useRef)(e),qu(),(0,Y.useEffect)(()=>{},[e])}function Hp(){qu(),(0,Y.useRef)(!1),(0,Y.useEffect)(()=>{},[])}function Up({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,zoomOnDoubleClick:R,panOnDrag:z,autoPanOnSelection:B,onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:W,onPaneScroll:G,onPaneContextMenu:ee,paneClickDistance:te,nodeClickDistance:ne,onEdgeContextMenu:re,onEdgeMouseEnter:ie,onEdgeMouseMove:K,onEdgeMouseLeave:ae,reconnectRadius:oe,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,noDragClassName:ue,noWheelClassName:de,noPanClassName:q,disableKeyboardA11y:fe,nodeExtent:pe,rfId:me,viewport:he,onViewportChange:ge,nodesDraggable:_e}){return Vp(e),Vp(t),Hp(),jp(n),Np(he),(0,Z.jsx)(Mf,{onPaneClick:V,onPaneMouseEnter:H,onPaneMouseMove:U,onPaneMouseLeave:W,onPaneContextMenu:ee,onPaneScroll:G,paneClickDistance:te,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:R,panOnScroll:F,panOnScrollSpeed:I,panOnScrollMode:L,panOnDrag:z,autoPanOnSelection:B,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ue,noWheelClassName:de,noPanClassName:q,disableKeyboardA11y:fe,onViewportChange:ge,isControlledViewport:!!he,children:(0,Z.jsxs)(Ap,{children:[(0,Z.jsx)(Op,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:se,onReconnectStart:ce,onReconnectEnd:le,onlyRenderVisibleElements:T,onEdgeContextMenu:re,onEdgeMouseEnter:ie,onEdgeMouseMove:K,onEdgeMouseLeave:ae,reconnectRadius:oe,defaultMarkerColor:M,noPanClassName:q,disableKeyboardA11y:fe,rfId:me}),(0,Z.jsx)(Rp,{style:h,type:m,component:g,containerStyle:_}),(0,Z.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,Z.jsx)(Hf,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:ne,onlyRenderVisibleElements:T,noPanClassName:q,noDragClassName:ue,disableKeyboardA11y:fe,nodeExtent:pe,rfId:me,nodesDraggable:_e}),(0,Z.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Up.displayName=`GraphView`;var Wp=(0,Y.memo)(Up),Gp=Nc(`React Flow`,`https://reactflow.dev/`),Kp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Ys;Wl(h,g,_);let{nodesInitialized:x}=Fl(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Bc(dc(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Ys,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Qs.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...tc},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:Gp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:Zs,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},qp=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Hu((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await hc({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Kp({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=Fl(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Wl(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=Vl(e,n,r,i,a,o,l);d&&(Ml(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Cl(e,o.fromHandle,Q.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=Bl(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Dd(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(Od(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>kd(e,!0)));return}i(Ad(r,new Set([...e]),!0)),a(Ad(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>kd(e,!0)));return}a(Ad(n,new Set([...e]))),i(Ad(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(kd(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(kd(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,kd(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,kd(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(Fl(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return Hl({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...tc}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Kp()})}},Object.is);function Jp({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,Y.useState)(()=>qp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,Z.jsx)(Gu,{value:m,children:(0,Z.jsx)(Hd,{children:(0,Z.jsx)(mf,{children:p})})})}function Yp({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,Y.useContext)(Wu)?(0,Z.jsx)(Z.Fragment,{children:e}):(0,Z.jsx)(Jp,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var Xp={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function Zp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:I,connectionMode:L,connectionLineType:R=nc.Bezier,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,deleteKeyCode:H=`Backspace`,selectionKeyCode:U=`Shift`,selectionOnDrag:W=!1,selectionMode:G=ec.Full,panActivationKeyCode:ee=`Space`,multiSelectionKeyCode:te=Vc()?`Meta`:`Control`,zoomActivationKeyCode:ne=Vc()?`Meta`:`Control`,snapToGrid:re,snapGrid:ie,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:ae,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,nodeOrigin:ue=fd,edgesFocusable:de,edgesReconnectable:q,elementsSelectable:fe=!0,defaultViewport:pe=pd,minZoom:me=.5,maxZoom:he=2,translateExtent:ge=Ys,preventScrolling:_e=!0,nodeExtent:ve,defaultMarkerColor:ye=`#b1b1b7`,zoomOnScroll:be=!0,zoomOnPinch:xe=!0,panOnScroll:J=!1,panOnScrollSpeed:Se=.5,panOnScrollMode:Ce=$s.Free,zoomOnDoubleClick:we=!0,panOnDrag:Te=!0,onPaneClick:Ee,onPaneMouseEnter:De,onPaneMouseMove:Oe,onPaneMouseLeave:ke,onPaneScroll:Ae,onPaneContextMenu:je,paneClickDistance:Me=1,nodeClickDistance:Ne=0,children:Pe,onReconnect:Fe,onReconnectStart:Ie,onReconnectEnd:Le,onEdgeContextMenu:Re,onEdgeDoubleClick:ze,onEdgeMouseEnter:Be,onEdgeMouseMove:Ve,onEdgeMouseLeave:He,reconnectRadius:Ue=10,onNodesChange:We,onEdgesChange:Ge,noDragClassName:Ke=`nodrag`,noWheelClassName:qe=`nowheel`,noPanClassName:Je=`nopan`,fitView:Ye,fitViewOptions:Xe,connectOnClick:Ze,attributionPosition:Qe,proOptions:$e,defaultEdgeOptions:et,elevateNodesOnSelect:tt=!0,elevateEdgesOnSelect:nt=!1,disableKeyboardA11y:rt=!1,autoPanOnConnect:it,autoPanOnNodeDrag:X,autoPanOnSelection:at=!0,autoPanSpeed:ot,connectionRadius:st,isValidConnection:ct,onError:lt,style:ut,id:dt,nodeDragThreshold:ft,connectionDragThreshold:pt,viewport:mt,onViewportChange:ht,width:gt,height:_t,colorMode:vt=`light`,debug:yt,onScroll:bt,ariaLabelConfig:xt,zIndexMode:St=`basic`,...Ct},wt){let Tt=dt||`1`,Et=yd(vt),Dt=(0,Y.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),bt?.(e)},[bt]);return(0,Z.jsx)(`div`,{"data-testid":`rf__wrapper`,...Ct,onScroll:Dt,style:{...ut,...Xp},ref:wt,className:ln([`react-flow`,i,Et]),id:dt,role:`application`,children:(0,Z.jsxs)(Yp,{nodes:e,edges:t,width:gt,height:_t,fitView:Ye,fitViewOptions:Xe,minZoom:me,maxZoom:he,nodeOrigin:ue,nodeExtent:ve,zIndexMode:St,children:[(0,Z.jsx)(_d,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:oe,autoPanOnNodeFocus:se,nodesConnectable:ce,nodesFocusable:le,edgesFocusable:de,edgesReconnectable:q,elementsSelectable:fe,elevateNodesOnSelect:tt,elevateEdgesOnSelect:nt,minZoom:me,maxZoom:he,nodeExtent:ve,onNodesChange:We,onEdgesChange:Ge,snapToGrid:re,snapGrid:ie,connectionMode:L,translateExtent:ge,connectOnClick:Ze,defaultEdgeOptions:et,fitView:Ye,fitViewOptions:Xe,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:Je,nodeOrigin:ue,rfId:Tt,autoPanOnConnect:it,autoPanOnNodeDrag:X,autoPanSpeed:ot,onError:lt,connectionRadius:st,isValidConnection:ct,selectNodesOnDrag:ae,nodeDragThreshold:ft,connectionDragThreshold:pt,onBeforeDelete:I,debug:yt,ariaLabelConfig:xt,zIndexMode:St}),(0,Z.jsx)(Wp,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:R,connectionLineStyle:z,connectionLineComponent:B,connectionLineContainerStyle:V,selectionKeyCode:U,selectionOnDrag:W,selectionMode:G,deleteKeyCode:H,multiSelectionKeyCode:te,panActivationKeyCode:ee,zoomActivationKeyCode:ne,onlyRenderVisibleElements:K,defaultViewport:pe,translateExtent:ge,minZoom:me,maxZoom:he,preventScrolling:_e,zoomOnScroll:be,zoomOnPinch:xe,zoomOnDoubleClick:we,panOnScroll:J,panOnScrollSpeed:Se,panOnScrollMode:Ce,panOnDrag:Te,autoPanOnSelection:at,onPaneClick:Ee,onPaneMouseEnter:De,onPaneMouseMove:Oe,onPaneMouseLeave:ke,onPaneScroll:Ae,onPaneContextMenu:je,paneClickDistance:Me,nodeClickDistance:Ne,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Fe,onReconnectStart:Ie,onReconnectEnd:Le,onEdgeContextMenu:Re,onEdgeDoubleClick:ze,onEdgeMouseEnter:Be,onEdgeMouseMove:Ve,onEdgeMouseLeave:He,reconnectRadius:Ue,defaultMarkerColor:ye,noDragClassName:Ke,noWheelClassName:qe,noPanClassName:Je,rfId:Tt,disableKeyboardA11y:rt,nodeExtent:ve,viewport:mt,onViewportChange:ht,nodesDraggable:oe}),(0,Z.jsx)(dd,{onSelectionChange:k}),Pe,(0,Z.jsx)(ad,{proOptions:$e,position:Qe}),(0,Z.jsx)(nd,{rfId:Tt,disableKeyboardA11y:rt})]})})}var Qp=Ld(Zp);function $p(e){let[t,n]=(0,Y.useState)(e);return[t,n,(0,Y.useCallback)(e=>n(t=>Dd(e,t)),[])]}Js.error014();function em({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,Z.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ln([`react-flow__background-pattern`,n,r])})}function tm({radius:e,className:t}){return(0,Z.jsx)(`circle`,{cx:e,cy:e,r:e,className:ln([`react-flow__background-pattern`,`dots`,t])})}var nm;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(nm||={});var rm={[nm.Dots]:1,[nm.Lines]:1,[nm.Cross]:6},im=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function am({id:e,variant:t=nm.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,Y.useRef)(null),{transform:f,patternId:p}=$(im,Uu),m=r||rm[t],h=t===nm.Dots,g=t===nm.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,Z.jsxs)(`svg`,{className:ln([`react-flow__background`,l]),style:{...c,...Xd,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,Z.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,Z.jsx)(tm,{radius:y/2,className:u}):(0,Z.jsx)(em,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,Z.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}am.displayName=`Background`;var om=(0,Y.memo)(am);function sm(){return(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,Z.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function cm(){return(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,Z.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function lm(){return(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,Z.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function um(){return(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Z.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function dm(){return(0,Z.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,Z.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function fm({children:e,className:t,...n}){return(0,Z.jsx)(`button`,{type:`button`,className:ln([`react-flow__controls-button`,t]),...n,children:e})}var pm=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function mm({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=qu(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=$(pm,Uu),{zoomIn:y,zoomOut:b,fitView:x}=Gd();return(0,Z.jsxs)(rd,{className:ln([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(fm,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,Z.jsx)(sm,{})}),(0,Z.jsx)(fm,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,Z.jsx)(cm,{})})]}),n&&(0,Z.jsx)(fm,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,Z.jsx)(lm,{})}),r&&(0,Z.jsx)(fm,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,Z.jsx)(dm,{}):(0,Z.jsx)(um,{})}),u]})}mm.displayName=`Controls`;var hm=(0,Y.memo)(mm);function gm({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,Z.jsx)(`rect`,{className:ln([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var _m=(0,Y.memo)(gm),vm=e=>e.nodes.map(e=>e.id),ym=e=>e instanceof Function?e:()=>e;function bm({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=_m,onClick:o}){let s=$(vm,Uu),c=ym(t),l=ym(e),u=ym(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,Z.jsx)(Z.Fragment,{children:s.map(e=>(0,Z.jsx)(Sm,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function xm({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=$(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Uc(r);return{node:r,x:i,y:a,width:o,height:s}},Uu);return!l||l.hidden||!Wc(l)?null:(0,Z.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var Sm=(0,Y.memo)(xm),Cm=(0,Y.memo)(bm),wm=200,Tm=150,Em=e=>!e.hidden,Dm=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Oc(dc(e.nodeLookup,{filter:Em}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Om=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,km=(e,t)=>Om(e.viewBB,t.viewBB)&&Om(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Am=`react-flow__minimap-desc`;function jm({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=qu(),S=(0,Y.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=$(Dm,km),j=e?.width??wm,M=e?.height??Tm,N=C.width/j,P=C.height/M,F=Math.max(N,P),I=F*j,L=F*M,R=b*F,z=C.x-(I-C.width)/2-R,B=C.y-(L-C.height)/2-R,V=I+R*2,H=L+R*2,U=`${Am}-${T}`,W=(0,Y.useRef)(0),G=(0,Y.useRef)();W.current=F,(0,Y.useEffect)(()=>{if(S.current&&E)return G.current=su({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>W.current}),()=>{G.current?.destroy()}},[E]),(0,Y.useEffect)(()=>{G.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ee=p?e=>{let[t,n]=G.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,te=m?(0,Y.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,ne=_??A[`minimap.ariaLabel`];return(0,Z.jsx)(rd,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:ln([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,Z.jsxs)(`svg`,{width:j,height:M,viewBox:`${z} ${B} ${V} ${H}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":U,ref:S,onClick:ee,children:[ne&&(0,Z.jsx)(`title`,{id:U,children:ne}),(0,Z.jsx)(Cm,{onClick:te,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,Z.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${z-R},${B-R}h${V+R*2}v${H+R*2}h${-V-R*2}z
|
|
7
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}jm.displayName=`MiniMap`,(0,Y.memo)(jm);var Mm=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Nm={[Su.Line]:`right`,[Su.Handle]:`bottom-right`};function Pm({nodeId:e,position:t,variant:n=Su.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=df(),y=typeof e==`string`?e:v,b=qu(),x=(0,Y.useRef)(null),S=n===Su.Handle,C=$((0,Y.useCallback)(Mm(S&&p),[S,p]),Uu),w=(0,Y.useRef)(null),T=t??Nm[n];return(0,Y.useEffect)(()=>{if(!(!x.current||!y))return w.current||=Nu({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Bl([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Gc({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,Z.jsx)(`div`,{className:ln([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,Y.memo)(Pm);function Fm(e,t){let n=new Set(t);if(!n.has(e))return e;for(let t=2;t<1e3;t+=1){let r=`${e}_${t}`;if(!n.has(r))return r}return`${e}_${Date.now()}`}function Im(e){if(!(e instanceof Error))return null;let t=e;if(t.status!==409||!t.body||typeof t.body!=`object`)return null;let n=t.body,r=typeof n.currentRevision==`number`?n.currentRevision:0;return n.code===`WORKFLOW_NAME_EXISTS`&&typeof n.name==`string`&&typeof n.suggestedName==`string`?{code:`WORKFLOW_NAME_EXISTS`,name:n.name,currentRevision:r,suggestedName:n.suggestedName}:n.code===`WORKFLOW_REVISION_CONFLICT`?{code:`WORKFLOW_REVISION_CONFLICT`,currentRevision:r}:null}var Lm={padding:.24,minZoom:.45,maxZoom:1};function Rm({language:e,ownerAgentId:t,saving:n,initialDraft:r,initialName:i,existingNames:a,saveConflict:o,onSave:c,onSaveAndStart:u,onClearSaveConflict:d,onReloadLatest:f}){let p=ih(e),[m,h]=(0,Y.useState)(`my_workflow`),[g,v]=(0,Y.useState)(()=>Xm()),[y,b]=(0,Y.useState)(()=>({title:p.untitled,description:``,tags:[`custom`]})),[x,S]=(0,Y.useState)(`agent-1`),[C,w,T]=$p(g.nodes.map(e=>Jm(e,e.id===`agent-1`))),[E,D]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(null),[F,I]=(0,Y.useState)(null),[L,R]=(0,Y.useState)(!!r),[z,B]=(0,Y.useState)(null),[V,H]=(0,Y.useState)(`idle`),[U,W]=(0,Y.useState)(0),[G,ee]=(0,Y.useState)([]),[ne,re]=(0,Y.useState)(null),ie=(0,Y.useRef)(``),K=(0,Y.useRef)(``),ae=(0,Y.useRef)(void 0),oe=(0,Y.useRef)(void 0),se=(0,Y.useRef)(!1),ce=(0,Y.useRef)(null),[le,de]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{let e=`${r?.mode??`new`}:${r?.name??i}:${r?.baseRevision??0}:${r?.repairPrompt??``}`;ie.current!==e&&(ie.current=e,h(r?.name??i),v(structuredClone(r?.graph??Xm())),de(e=>e+1),b(structuredClone(r?.manifest??{title:p.untitled,description:``,tags:[`custom`]})),S(r?.graph.nodes.find(e=>e.kind===`agent`)?.id??`agent-1`),D(r?.repairPrompt??``),P(null),I(null),R(!!r),A(``),B(null),W(r?.baseRevision??0),ee([]),re(null),ae.current=void 0,oe.current=void 0,H(`idle`))},[p.untitled,r,i]),(0,Y.useEffect)(()=>{r?.mode===`edit`&&ye(r.name).then(ee).catch(()=>ee([]))},[r?.mode,r?.name]),(0,Y.useEffect)(()=>{if(!m.trim())return;let e=window.setTimeout(()=>{te(m,g).then(B).catch(()=>B(null))},350);return()=>window.clearTimeout(e)},[g,m]),(0,Y.useEffect)(()=>{if(!m.trim())return;H(`saving`);let e=window.setTimeout(()=>{Xe({id:ae.current,workflowName:m,graph:g,manifest:y,baseRevision:U,expectedUpdatedAtMs:oe.current}).then(e=>{ae.current=e.id,oe.current=e.updatedAtMs,H(`saved`)}).catch(()=>H(`error`))},900);return()=>window.clearTimeout(e)},[U,g,y,m]);let q=(0,Y.useMemo)(()=>Qm(g,N?.graph??null),[g,N?.graph]),fe=(0,Y.useMemo)(()=>{if(!N)return g;let e=new Set(N.graph.nodes.map(e=>e.id)),t=g.nodes.filter(t=>!e.has(t.id));return{...N.graph,nodes:[...N.graph.nodes,...t]}},[g,N]);(0,Y.useLayoutEffect)(()=>{w(e=>{let t=new Map(e.map(e=>[e.id,e]));return fe.nodes.map(e=>({...t.get(e.id),...Jm(e,e.id===x,q.nodeStates.get(e.id))}))})},[fe.nodes,q.nodeStates,x,w]),(0,Y.useEffect)(()=>{let e=ce.current;if(!e||fe.nodes.length===0)return;let t=window.requestAnimationFrame(()=>{e.fitView(Lm)});return()=>window.cancelAnimationFrame(t)},[fe.nodes.length,le]);let pe=(0,Y.useMemo)(()=>fe.edges.map(Ym),[fe.edges]),he=g.nodes.find(e=>e.id===x)??null,ge=(0,Y.useMemo)(()=>new Set(a),[a]),_e=r?.mode!==`edit`&&ge.has(m),ve=_e?Fm(m,ge):m,xe=z?.valid===!0&&!_e&&!n&&!j,Se=(0,Y.useCallback)(e=>{v(t=>{let n=t.nodes.map(t=>t.id!==e.id||t.position.x===e.position.x&&t.position.y===e.position.y?t:{...t,position:e.position});return n.some((e,n)=>e!==t.nodes[n])?{...t,nodes:n}:t})},[]),we=(0,Y.useCallback)(e=>{let t=e.filter(e=>e.type!==`select`);t.length!==0&&v(e=>({...e,edges:Od(t,e.edges.map(Ym)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),Te=(0,Y.useCallback)(e=>{!e.source||!e.target||v(t=>({...t,edges:Pd({...e,id:`edge-${crypto.randomUUID()}`},t.edges.map(Ym)).map(e=>({id:e.id,source:e.source,target:e.target,sourcePort:e.sourceHandle===`true`||e.sourceHandle===`false`?e.sourceHandle:void 0}))}))},[]),Ee=(0,Y.useCallback)((e,t)=>{v(n=>({...n,nodes:n.nodes.map(n=>n.id===e?t(n):n)}))},[]),De=e=>{let t=`${e}-${crypto.randomUUID().slice(0,8)}`,n=Zm(e,t,g.nodes.length);v(e=>{let r=e.nodes.find(e=>e.id===x&&e.kind!==`output`),i=r?[{id:`edge-${crypto.randomUUID()}`,source:r.id,target:t}]:[];return{...e,nodes:[...e.nodes,n],edges:[...e.edges,...i]}}),de(e=>e+1),S(t)},Oe=()=>{!he||he.kind===`input`||he.kind===`output`||(v(e=>({...e,nodes:e.nodes.filter(e=>e.id!==he.id),edges:e.edges.filter(e=>e.source!==he.id&&e.target!==he.id)})),de(e=>e+1),S(``))},Me=(0,Y.useCallback)(async()=>{if(E.trim()){M(!0);try{let n=await Ae({prompt:E,agentId:t,language:e===`zh`?`zh`:`en`,mode:r||g.nodes.length>3?`improve`:`create`,existingGraph:g}),i=r?.mode===`edit`?r.name:Fm(n.name,ge);I(i===n.name?null:n.name),P(i===n.name?n:{...n,name:i}),R(!0),de(e=>e+1),S(n.graph.nodes.find(e=>e.kind===`agent`)?.id??``)}finally{M(!1)}}},[E,ge,g,r,e,t]);(0,Y.useEffect)(()=>{let e=r?.repairPrompt?.trim();!e||E.trim()!==e||j||N||K.current===e||(K.current=e,Me())},[E,Me,j,r?.repairPrompt,N]);let Pe=()=>{P(null),I(null),S(g.nodes.find(e=>e.kind===`agent`)?.id??``),de(e=>e+1)},Fe=async()=>{if(!(!N||n||se.current)){se.current=!0;try{let e=await c({name:N.name,graph:N.graph,manifest:N.manifest,expectedRevision:U});if(!e)return;h(e.name),v(structuredClone(e.graph)),b(rh(e)),B(N.validation),W(e.revision),P(null),I(null),D(``),S(e.graph.nodes.find(e=>e.kind===`agent`)?.id??``),ae.current&&await Ke(ae.current).catch(()=>void 0)}catch{}finally{se.current=!1}}},Ie=async e=>{if(!xe||se.current)return;se.current=!0;let t={name:m,graph:g,manifest:y,expectedRevision:U};try{if(e)await u({...t,goal:k.trim()||y.description||m});else{let e=await c(t);if(!e)return;W(e.revision)}ae.current&&await Ke(ae.current).catch(()=>void 0)}catch{return}finally{se.current=!1}},Le=async e=>{if(!(ne!==null||r?.mode!==`edit`)){re(e);try{let t=await Qe(r.name,e,U);v(t.graph),de(e=>e+1),b(rh(t)),W(t.revision),S(t.graph.nodes.find(e=>e.kind===`agent`)?.id??``),ee(await ye(r.name))}finally{re(null)}}};return(0,Z.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`header`,{className:`flex shrink-0 items-center gap-3 border-b border-edge px-4 py-3`,children:[(0,Z.jsx)(s,{to:`/workflows`,className:l(`inline-flex size-9 shrink-0 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,ke.focusRingPanel),"aria-label":e===`zh`?`返回工作流`:`Back to workflows`,children:(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:r?.mode===`edit`?p.editTitle:p.createTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:p.subtitle})]}),(0,Z.jsx)(`span`,{className:l(`text-xs`,V===`error`?`text-danger`:`text-fg-subtle`),children:V===`saving`?p.savingDraft:V===`saved`?p.savedDraft:V===`error`?p.draftError:``})]}),o?(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:o.code===`WORKFLOW_NAME_EXISTS`?e===`zh`?`内部名称“${o.name}”已被使用。`:`The internal name “${o.name}” is already in use.`:e===`zh`?`这个工作流已更新到版本 ${o.currentRevision}。`:`This workflow has changed to revision ${o.currentRevision}.`}),o.code===`WORKFLOW_NAME_EXISTS`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(J,{variant:`secondary`,className:`h-8`,onClick:()=>{h(o.suggestedName),d()},children:e===`zh`?`使用 ${o.suggestedName}`:`Use ${o.suggestedName}`}),(0,Z.jsx)(s,{className:`text-sm font-medium text-accent-fg hover:underline`,to:`/workflows/${encodeURIComponent(o.name)}`,children:e===`zh`?`打开已有工作流`:`Open existing`})]}):(0,Z.jsx)(J,{variant:`secondary`,className:`h-8`,onClick:f,children:e===`zh`?`加载最新版本`:`Load latest`})]}):null,!o&&_e?(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-warning/30 bg-warning/5 px-4 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 flex-1`,children:e===`zh`?`内部名称“${m}”已被使用。`:`The internal name “${m}” is already in use.`}),(0,Z.jsx)(J,{variant:`secondary`,className:`h-8`,onClick:()=>h(ve),children:e===`zh`?`使用 ${ve}`:`Use ${ve}`})]}):null,!o&&!_e&&F&&N?(0,Z.jsx)(`div`,{className:`shrink-0 border-b border-accent/20 bg-accent/5 px-4 py-2 text-sm text-fg-muted`,children:e===`zh`?`“${F}”已存在,方案将保存为“${N.name}”。`:`“${F}” already exists. This proposal will be saved as “${N.name}”.`}):null,L?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto lg:flex-row lg:overflow-hidden`,children:[(0,Z.jsxs)(`section`,{className:`flex min-h-[32rem] min-w-0 flex-1 flex-col bg-surface-base lg:min-h-0`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-edge px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`mr-2 min-w-36`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:p.flowTitle}),(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:p.stepCount(g.nodes.length)})]}),(0,Z.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!N,onClick:()=>De(`agent`),children:[(0,Z.jsx)(me,{className:`size-3.5`}),p.addAgent]}),(0,Z.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!N,onClick:()=>De(`decision`),children:[(0,Z.jsx)(je,{className:`size-3.5`}),p.addDecision]}),(0,Z.jsxs)(J,{variant:`secondary`,className:`h-8 rounded-lg text-xs`,disabled:!!N,onClick:()=>De(`merge`),children:[(0,Z.jsx)(_,{className:`size-3.5`}),p.addMerge]}),(0,Z.jsx)(`span`,{className:`ml-auto text-xs text-fg-subtle`,children:p.canvasHint})]}),(0,Z.jsx)(`div`,{className:`relative min-h-72 flex-1`,children:g.nodes.length>0?(0,Z.jsxs)(Qp,{"aria-label":p.flowAria,nodes:C,edges:pe,nodeTypes:Gm,onNodesChange:T,onEdgesChange:we,onConnect:Te,nodesDraggable:!N,nodesConnectable:!N,onNodeClick:(e,t)=>S(t.id),onNodeDragStart:(e,t)=>S(t.id),onNodeDragStop:(e,t)=>Se(t),onInit:e=>{ce.current=e,window.requestAnimationFrame(()=>{e.fitView(Lm)})},fitView:!0,fitViewOptions:Lm,minZoom:.25,maxZoom:1.5,deleteKeyCode:null,proOptions:{hideAttribution:!0},children:[(0,Z.jsx)(om,{color:`var(--color-edge)`,gap:22,size:1}),(0,Z.jsx)(hm,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`})]}):(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center px-6 text-center text-sm text-fg-muted`,children:p.emptyFlow})})]}),(0,Z.jsx)(`aside`,{className:`flex w-full shrink-0 flex-col border-t border-edge bg-surface-panel lg:w-[22rem] lg:border-l lg:border-t-0`,children:(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:N?(0,Z.jsx)(Bm,{proposal:N,diff:q,copy:p,saving:n,onAccept:()=>void Fe(),onReject:Pe}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-fg`,htmlFor:`workflow-title`,children:p.humanTitle}),(0,Z.jsx)(`input`,{id:`workflow-title`,value:y.title??``,onChange:e=>b(t=>({...t,title:e.target.value})),className:qm}),(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-description`,children:p.outcome}),(0,Z.jsx)(`textarea`,{id:`workflow-description`,value:y.description??``,onChange:e=>b(t=>({...t,description:e.target.value})),className:`${qm} min-h-20 resize-y`}),(0,Z.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:p.advanced}),(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`workflow-name`,children:p.workflowName}),(0,Z.jsx)(`input`,{id:`workflow-name`,value:m,onChange:e=>h(th(e.target.value)),className:qm}),_e?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-danger`,children:e===`zh`?`该内部名称已被使用,请换一个名称。`:`This internal name is already in use.`}):null,r?.mode===`edit`&&G.length>0?(0,Z.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Z.jsx)(He,{className:`size-3.5`}),p.versions,` · v`,U]}),(0,Z.jsx)(`div`,{className:`mt-2 space-y-1`,children:G.map(t=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg px-2 py-1.5 hover:bg-surface-hover`,children:[(0,Z.jsxs)(`span`,{className:`min-w-0 text-xs text-fg-muted`,children:[`v`,t.revision,` · `,new Intl.DateTimeFormat(e,{dateStyle:`medium`,timeStyle:`short`}).format(t.createdAtMs)]}),t.revision===U?(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:p.currentVersion}):(0,Z.jsxs)(J,{variant:`ghost`,className:`h-7 shrink-0 px-2 text-xs`,disabled:ne!==null,onClick:()=>void Le(t.revision),children:[(0,Z.jsx)(Ne,{className:`size-3`}),ne===t.revision?p.restoring:p.restore]})]},t.revision))})]}):null]})]}),(0,Z.jsx)(`div`,{className:`my-4 border-t border-edge`}),he?(0,Z.jsx)(Km,{node:he,copy:p,updateNode:Ee,onDelete:Oe}):(0,Z.jsx)(`div`,{className:`py-8 text-center text-sm text-fg-muted`,children:p.selectNode}),z&&!z.valid?(0,Z.jsxs)(`section`,{className:`mt-4 rounded-lg border border-danger/30 bg-danger/5 p-3`,children:[(0,Z.jsx)(`h3`,{className:`text-xs font-medium text-danger`,children:p.needsAttention}),(0,Z.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs text-danger`,children:z.errors.slice(0,5).map((e,t)=>(0,Z.jsxs)(`li`,{children:[`• `,e.message]},`${e.code}-${t}`))})]}):null]})})})]}),(0,Z.jsx)(`footer`,{className:`shrink-0 border-t border-edge bg-surface-panel p-3`,children:(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,Z.jsx)(O,{className:`size-4 shrink-0 text-accent-fg`}),(0,Z.jsx)(`input`,{value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Me()},placeholder:p.aiPlaceholder,className:`${qm} mt-0 flex-1`}),(0,Z.jsx)(J,{variant:`secondary`,className:`h-10 shrink-0`,disabled:!!N||j||!E.trim(),onClick:()=>void Me(),children:j?p.designing:p.applyWithAi})]}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`input`,{value:k,onChange:e=>A(e.target.value),placeholder:p.testGoal,className:`${qm} mt-0 w-52`}),(0,Z.jsxs)(J,{variant:`secondary`,disabled:!xe,onClick:()=>void Ie(!1),children:[(0,Z.jsx)(Ce,{className:`size-4`}),p.publish]}),(0,Z.jsxs)(J,{variant:`primary`,disabled:!xe,onClick:()=>void Ie(!0),children:[(0,Z.jsx)(ue,{className:`size-4`}),p.publishAndRun]})]})]})})]}):(0,Z.jsx)(zm,{copy:p,prompt:E,generating:j,onPromptChange:D,onGenerate:()=>void Me(),onManual:()=>R(!0)})]})}function zm(e){let t=(0,X.c)(38),{copy:n,prompt:r,generating:i,onPromptChange:a,onGenerate:o,onManual:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-2xl bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(O,{className:`size-5`})}),t[0]=c):c=t[0];let l;t[1]===n.introTitle?l=t[2]:(l=(0,Z.jsx)(`h2`,{className:`mt-5 text-2xl font-semibold text-fg`,children:n.introTitle}),t[1]=n.introTitle,t[2]=l);let u;t[3]===n.introDescription?u=t[4]:(u=(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:n.introDescription}),t[3]=n.introDescription,t[4]=u);let d;t[5]===a?d=t[6]:(d=e=>a(e.target.value),t[5]=a,t[6]=d);let f;t[7]!==n.introPlaceholder||t[8]!==r||t[9]!==d?(f=(0,Z.jsx)(`textarea`,{autoFocus:!0,value:r,onChange:d,placeholder:n.introPlaceholder,className:`${qm} mt-6 h-auto min-h-32 resize-y py-3 text-base leading-6`}),t[7]=n.introPlaceholder,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p;if(t[11]!==n.examples||t[12]!==a){let e;t[14]===a?e=t[15]:(e=e=>(0,Z.jsx)(`button`,{type:`button`,className:`rounded-full border border-edge bg-surface-panel px-3 py-1.5 text-xs text-fg-muted hover:bg-surface-hover hover:text-fg`,onClick:()=>a(e),children:e},e),t[14]=a,t[15]=e),p=n.examples.map(e),t[11]=n.examples,t[12]=a,t[13]=p}else p=t[13];let m;t[16]===p?m=t[17]:(m=(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:p}),t[16]=p,t[17]=m);let h;t[18]!==i||t[19]!==r?(h=!r.trim()||i,t[18]=i,t[19]=r,t[20]=h):h=t[20];let g;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(O,{className:`size-4`}),t[21]=g):g=t[21];let _=i?n.designing:n.designWorkflow,v;t[22]!==o||t[23]!==_||t[24]!==h?(v=(0,Z.jsxs)(J,{variant:`primary`,disabled:h,onClick:o,children:[g,_]}),t[22]=o,t[23]=_,t[24]=h,t[25]=v):v=t[25];let y;t[26]!==n.manualStart||t[27]!==s?(y=(0,Z.jsx)(J,{variant:`ghost`,onClick:s,children:n.manualStart}),t[26]=n.manualStart,t[27]=s,t[28]=y):y=t[28];let b;t[29]!==v||t[30]!==y?(b=(0,Z.jsxs)(`div`,{className:`mt-6 flex flex-wrap items-center gap-3`,children:[v,y]}),t[29]=v,t[30]=y,t[31]=b):b=t[31];let x;return t[32]!==b||t[33]!==l||t[34]!==u||t[35]!==f||t[36]!==m?(x=(0,Z.jsx)(`section`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-y-auto bg-surface-base px-5 py-10`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-2xl`,children:[c,l,u,f,m,b]})}),t[32]=b,t[33]=l,t[34]=u,t[35]=f,t[36]=m,t[37]=x):x=t[37],x}function Bm(e){let t=(0,X.c)(74),{proposal:n,diff:r,copy:i,saving:a,onAccept:o,onReject:s}=e,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Z.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Z.jsx)(O,{className:`size-4`})}),t[0]=c):c=t[0];let l;t[1]===i.proposalTitle?l=t[2]:(l=(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:i.proposalTitle}),t[1]=i.proposalTitle,t[2]=l);let d;t[3]===i.proposalHint?d=t[4]:(d=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.proposalHint}),t[3]=i.proposalHint,t[4]=d);let f;t[5]!==l||t[6]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[c,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[l,d]})]}),t[5]=l,t[6]=d,t[7]=f):f=t[7];let p=n.manifest.title||n.name,m;t[8]===p?m=t[9]:(m=(0,Z.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:p}),t[8]=p,t[9]=m);let h=n.explanation||n.manifest.description,g;t[10]===h?g=t[11]:(g=(0,Z.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:h}),t[10]=h,t[11]=g);let _;t[12]===i.added?_=t[13]:(_=(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.added}),t[12]=i.added,t[13]=_);let v;t[14]===r.addedIds.length?v=t[15]:(v=(0,Z.jsx)(`dd`,{className:`mt-1 font-semibold text-success`,children:r.addedIds.length}),t[14]=r.addedIds.length,t[15]=v);let y;t[16]!==v||t[17]!==_?(y=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-success-soft px-2 py-2`,children:[_,v]}),t[16]=v,t[17]=_,t[18]=y):y=t[18];let b;t[19]===i.changed?b=t[20]:(b=(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.changed}),t[19]=i.changed,t[20]=b);let x=r.changedIds.length+r.connectionChanges,S;t[21]===x?S=t[22]:(S=(0,Z.jsx)(`dd`,{className:`mt-1 font-semibold text-accent-fg`,children:x}),t[21]=x,t[22]=S);let C;t[23]!==b||t[24]!==S?(C=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-accent-soft px-2 py-2`,children:[b,S]}),t[23]=b,t[24]=S,t[25]=C):C=t[25];let w;t[26]===i.removed?w=t[27]:(w=(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:i.removed}),t[26]=i.removed,t[27]=w);let T;t[28]===r.removedIds.length?T=t[29]:(T=(0,Z.jsx)(`dd`,{className:`mt-1 font-semibold text-danger`,children:r.removedIds.length}),t[28]=r.removedIds.length,t[29]=T);let E;t[30]!==w||t[31]!==T?(E=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-danger/5 px-2 py-2`,children:[w,T]}),t[30]=w,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==y||t[34]!==C||t[35]!==E?(D=(0,Z.jsxs)(`dl`,{className:`mt-3 grid grid-cols-3 gap-2 text-center text-xs`,children:[y,C,E]}),t[33]=y,t[34]=C,t[35]=E,t[36]=D):D=t[36];let k;t[37]!==D||t[38]!==m||t[39]!==g?(k=(0,Z.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base/50 p-3`,children:[m,g,D]}),t[37]=D,t[38]=m,t[39]=g,t[40]=k):k=t[40];let A;t[41]!==i.assumptions||t[42]!==n.assumptions?(A=n.assumptions.length?(0,Z.jsx)(Hm,{title:i.assumptions,items:n.assumptions}):null,t[41]=i.assumptions,t[42]=n.assumptions,t[43]=A):A=t[43];let j;t[44]!==i.risks||t[45]!==n.risks?(j=n.risks.length?(0,Z.jsx)(Hm,{title:i.risks,items:n.risks}):null,t[44]=i.risks,t[45]=n.risks,t[46]=j):j=t[46];let M;t[47]!==i.permissions||t[48]!==n.permissionsSummary?(M=n.permissionsSummary.length?(0,Z.jsx)(Hm,{title:i.permissions,items:n.permissionsSummary}):null,t[47]=i.permissions,t[48]=n.permissionsSummary,t[49]=M):M=t[49];let N;t[50]!==n.validation.errors||t[51]!==n.validation.valid?(N=n.validation.valid?null:(0,Z.jsx)(`div`,{className:`mt-4 rounded-xl border border-danger/30 bg-danger/5 p-3 text-xs text-danger`,children:n.validation.errors.slice(0,4).map(Vm)}),t[50]=n.validation.errors,t[51]=n.validation.valid,t[52]=N):N=t[52];let P=a||!n.validation.valid,F;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,Z.jsx)(u,{className:`size-4`}),t[53]=F):F=t[53];let I=a?i.savingProposal:i.acceptAndSave,L;t[54]!==o||t[55]!==P||t[56]!==I?(L=(0,Z.jsxs)(J,{variant:`primary`,disabled:P,onClick:o,children:[F,I]}),t[54]=o,t[55]=P,t[56]=I,t[57]=L):L=t[57];let R;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(Ze,{className:`size-4`}),t[58]=R):R=t[58];let z;t[59]!==i.rejectProposal||t[60]!==s||t[61]!==a?(z=(0,Z.jsxs)(J,{variant:`ghost`,disabled:a,onClick:s,children:[R,i.rejectProposal]}),t[59]=i.rejectProposal,t[60]=s,t[61]=a,t[62]=z):z=t[62];let B;t[63]!==L||t[64]!==z?(B=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[L,z]}),t[63]=L,t[64]=z,t[65]=B):B=t[65];let V;return t[66]!==k||t[67]!==A||t[68]!==j||t[69]!==M||t[70]!==N||t[71]!==B||t[72]!==f?(V=(0,Z.jsxs)(`section`,{children:[f,k,A,j,M,N,B]}),t[66]=k,t[67]=A,t[68]=j,t[69]=M,t[70]=N,t[71]=B,t[72]=f,t[73]=V):V=t[73],V}function Vm(e){return(0,Z.jsxs)(`p`,{children:[`• `,e.message]},`${e.code}:${e.message}`)}function Hm(e){let t=(0,X.c)(9),{title:n,items:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,4).map(Um),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,Z.jsx)(`ul`,{className:`mt-2 space-y-1 text-xs leading-5 text-fg-muted`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,Z.jsxs)(`section`,{className:`mt-4`,children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function Um(e){return(0,Z.jsxs)(`li`,{children:[`• `,e]},e)}function Wm(e){let t=(0,X.c)(34),{data:n,selected:r}=e,i=n.workflowNode,a=n.diffState,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,Z.jsx)(ze,{}):i.kind===`agent`?(0,Z.jsx)(me,{}):i.kind===`decision`?(0,Z.jsx)(je,{}):i.kind===`merge`?(0,Z.jsx)(_,{}):(0,Z.jsx)(ue,{}),t[0]=i.kind,t[1]=o);let s=o,c=r?`border-accent ring-2 ring-accent/20`:`border-edge`,u=a===`added`&&`border-success ring-2 ring-success/15`,d=a===`changed`&&`border-accent ring-2 ring-accent/15`,f=a===`removed`&&`border-dashed border-danger opacity-55`,p;t[2]!==c||t[3]!==u||t[4]!==d||t[5]!==f?(p=l(`w-52 rounded-xl border bg-surface-panel px-3 py-3 shadow-surface transition-colors`,c,u,d,f),t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=p):p=t[6];let m;t[7]===i.kind?m=t[8]:(m=i.kind===`input`?null:(0,Z.jsx)(yf,{type:`target`,position:Q.Left,className:`!size-2.5 !border-2 !border-surface-panel !bg-fg-subtle`}),t[7]=i.kind,t[8]=m);let h;t[9]===s?h=t[10]:(h=(0,Z.jsx)(`span`,{className:`mt-0.5 [&>svg]:size-4 text-accent-fg`,children:s}),t[9]=s,t[10]=h);let g;t[11]===i.title?g=t[12]:(g=(0,Z.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[11]=i.title,t[12]=g);let v;t[13]!==i.description||t[14]!==i.kind?(v=i.description||nh(i.kind),t[13]=i.description,t[14]=i.kind,t[15]=v):v=t[15];let y;t[16]===v?y=t[17]:(y=(0,Z.jsx)(`span`,{className:`mt-1 block line-clamp-2 text-xs leading-4 text-fg-muted`,children:v}),t[16]=v,t[17]=y);let b;t[18]!==y||t[19]!==g?(b=(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[g,y]}),t[18]=y,t[19]=g,t[20]=b):b=t[20];let x;t[21]===a?x=t[22]:(x=a?(0,Z.jsx)(`span`,{className:l(`rounded-full px-1.5 py-0.5 text-[10px] font-medium`,a===`added`?`bg-success-soft text-success`:a===`removed`?`bg-danger/10 text-danger`:`bg-accent-soft text-accent-fg`),children:a===`added`?`+`:a===`removed`?`−`:`Δ`}):null,t[21]=a,t[22]=x);let S;t[23]!==b||t[24]!==x||t[25]!==h?(S=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[h,b,x]}),t[23]=b,t[24]=x,t[25]=h,t[26]=S):S=t[26];let C;t[27]===i.kind?C=t[28]:(C=i.kind===`decision`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yf,{id:`true`,type:`source`,position:Q.Right,style:{top:`38%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-success`}),(0,Z.jsx)(yf,{id:`false`,type:`source`,position:Q.Right,style:{top:`70%`},className:`!size-2.5 !border-2 !border-surface-panel !bg-danger`})]}):i.kind===`output`?null:(0,Z.jsx)(yf,{type:`source`,position:Q.Right,className:`!size-2.5 !border-2 !border-surface-panel !bg-accent`}),t[27]=i.kind,t[28]=C);let w;return t[29]!==S||t[30]!==C||t[31]!==p||t[32]!==m?(w=(0,Z.jsxs)(`div`,{className:p,children:[m,S,C]}),t[29]=S,t[30]=C,t[31]=p,t[32]=m,t[33]=w):w=t[33],w}var Gm={workflow:Wm};function Km(e){let t=(0,X.c)(71),{node:n,copy:r,updateNode:i,onDelete:a}=e,o;t[0]!==n.id||t[1]!==i?(o=e=>i(n.id,t=>({...t,...e})),t[0]=n.id,t[1]=i,t[2]=o):o=t[2];let s=o,c;t[3]!==n.id||t[4]!==i?(c=e=>i(n.id,t=>({...t,config:{...t.config,...e}})),t[3]=n.id,t[4]=i,t[5]=c):c=t[5];let l=c,u;t[6]===r.stepSettings?u=t[7]:(u=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.stepSettings}),t[6]=r.stepSettings,t[7]=u);let d;t[8]!==r.remove||t[9]!==n.kind||t[10]!==a?(d=n.kind!==`input`&&n.kind!==`output`?(0,Z.jsxs)(J,{variant:`ghost`,className:`h-8 px-2 text-danger`,onClick:a,children:[(0,Z.jsx)(Ee,{className:`size-3.5`}),r.remove]}):null,t[8]=r.remove,t[9]=n.kind,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.stepName?p=t[16]:(p=(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-title`,children:r.stepName}),t[15]=r.stepName,t[16]=p);let m;t[17]===s?m=t[18]:(m=e=>s({title:e.target.value}),t[17]=s,t[18]=m);let h;t[19]!==n.title||t[20]!==m?(h=(0,Z.jsx)(`input`,{id:`node-title`,value:n.title,onChange:m,className:qm}),t[19]=n.title,t[20]=m,t[21]=h):h=t[21];let g;t[22]===r.stepPurpose?g=t[23]:(g=(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-description`,children:r.stepPurpose}),t[22]=r.stepPurpose,t[23]=g);let _=n.description??``,v;t[24]===s?v=t[25]:(v=e=>s({description:e.target.value}),t[24]=s,t[25]=v);let y;t[26]!==_||t[27]!==v?(y=(0,Z.jsx)(`textarea`,{id:`node-description`,value:_,onChange:v,className:`${qm} min-h-16 resize-y`}),t[26]=_,t[27]=v,t[28]=y):y=t[28];let b;t[29]!==r.advanced||t[30]!==r.defaultModel||t[31]!==r.instructions||t[32]!==r.model||t[33]!==n.config||t[34]!==n.kind||t[35]!==l?(b=n.kind===`agent`?(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsxs)(`details`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:r.advanced}),(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-prompt`,children:r.instructions}),(0,Z.jsx)(`textarea`,{id:`node-prompt`,value:String(n.config.prompt??``),onChange:e=>l({prompt:e.target.value}),className:`${qm} min-h-36 resize-y`}),(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`node-model`,children:r.model}),(0,Z.jsx)(`input`,{id:`node-model`,value:String(n.config.model??``),onChange:e=>l({model:e.target.value||void 0}),placeholder:r.defaultModel,className:qm})]})}):null,t[29]=r.advanced,t[30]=r.defaultModel,t[31]=r.instructions,t[32]=r.model,t[33]=n.config,t[34]=n.kind,t[35]=l,t[36]=b):b=t[36];let x;t[37]!==r.compareValue||t[38]!==r.condition||t[39]!==r.contains||t[40]!==r.equals||t[41]!==r.exists||t[42]!==r.notEquals||t[43]!==r.valuePath||t[44]!==n.config||t[45]!==n.kind||t[46]!==l?(x=n.kind===`decision`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-path`,children:r.valuePath}),(0,Z.jsx)(`input`,{id:`decision-path`,value:n.config.rule?.path??``,onChange:e=>l({rule:{...n.config.rule??{operator:`exists`},path:e.target.value}}),placeholder:`result.approved`,className:qm}),(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`decision-operator-label`,children:r.condition}),(0,Z.jsx)(K,{value:n.config.rule?.operator??`exists`,placeholder:r.condition,allowEmpty:!1,ariaLabelledBy:`decision-operator-label`,options:[{value:`exists`,label:r.exists},{value:`equals`,label:r.equals},{value:`not_equals`,label:r.notEquals},{value:`contains`,label:r.contains}],onChange:e=>l({rule:{...n.config.rule??{path:``},operator:e}})}),n.config.rule?.operator===`exists`?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`decision-value`,children:r.compareValue}),(0,Z.jsx)(`input`,{id:`decision-value`,value:String(n.config.rule?.value??``),onChange:e=>l({rule:{...n.config.rule,value:e.target.value}}),className:qm})]})]}):null,t[37]=r.compareValue,t[38]=r.condition,t[39]=r.contains,t[40]=r.equals,t[41]=r.exists,t[42]=r.notEquals,t[43]=r.valuePath,t[44]=n.config,t[45]=n.kind,t[46]=l,t[47]=x):x=t[47];let S;t[48]!==r.combineAs||t[49]!==r.listResults||t[50]!==r.namedResults||t[51]!==n.config||t[52]!==n.kind||t[53]!==l?(S=n.kind===`merge`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,id:`merge-mode-label`,children:r.combineAs}),(0,Z.jsx)(K,{value:String(n.config.mode??`object`),placeholder:r.combineAs,allowEmpty:!1,ariaLabelledBy:`merge-mode-label`,options:[{value:`object`,label:r.namedResults},{value:`array`,label:r.listResults}],onChange:e=>l({mode:e})})]}):null,t[48]=r.combineAs,t[49]=r.listResults,t[50]=r.namedResults,t[51]=n.config,t[52]=n.kind,t[53]=l,t[54]=S):S=t[54];let C;t[55]!==r.autoSummary||t[56]!==r.summaryTemplate||t[57]!==n.config||t[58]!==n.kind||t[59]!==l?(C=n.kind===`output`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`mt-3 block text-xs font-medium text-fg`,htmlFor:`output-summary`,children:r.summaryTemplate}),(0,Z.jsx)(`textarea`,{id:`output-summary`,value:String(n.config.summary??``),onChange:e=>l({summary:e.target.value||void 0}),placeholder:r.autoSummary,className:`${qm} min-h-20 resize-y`})]}):null,t[55]=r.autoSummary,t[56]=r.summaryTemplate,t[57]=n.config,t[58]=n.kind,t[59]=l,t[60]=C):C=t[60];let w;return t[61]!==y||t[62]!==b||t[63]!==x||t[64]!==S||t[65]!==C||t[66]!==f||t[67]!==p||t[68]!==h||t[69]!==g?(w=(0,Z.jsxs)(`section`,{children:[f,p,h,g,y,b,x,S,C]}),t[61]=y,t[62]=b,t[63]=x,t[64]=S,t[65]=C,t[66]=f,t[67]=p,t[68]=h,t[69]=g,t[70]=w):w=t[70],w}var qm=`mt-1 block h-10 w-full rounded-lg border border-edge bg-surface-subtle px-3 text-sm text-fg outline-none placeholder:text-fg-subtle focus:border-edge-strong`;function Jm(e,t=!1,n){return{id:e.id,type:`workflow`,position:e.position,selected:t,data:{workflowNode:e,diffState:n}}}function Ym(e){return{id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:rc.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}}function Xm(){return{schemaVersion:1,nodes:[{id:`input`,kind:`input`,title:`Input`,description:`What the user provides`,position:{x:0,y:120},config:{}},{id:`agent-1`,kind:`agent`,title:`Do the work`,description:`Understand and complete the request`,phaseId:`work`,position:{x:300,y:120},config:{prompt:`Complete this goal: {{goal}}
|
|
8
|
-
|
|
9
|
-
User input:
|
|
10
|
-
{{input}}`,maxIterations:12}},{id:`output`,kind:`output`,title:`Result`,description:`A clear answer for the user`,position:{x:620,y:120},config:{}}],edges:[{id:`input-agent`,source:`input`,target:`agent-1`},{id:`agent-output`,source:`agent-1`,target:`output`}]}}function Zm(e,t,n){let r={x:280+n%3*280,y:80+Math.floor(n/3)*180};return e===`agent`?{id:t,kind:e,title:`New AI step`,description:`Describe what this step should accomplish`,phaseId:`work`,position:r,config:{prompt:`Use the previous results to complete this step:
|
|
11
|
-
{{predecessors}}`,maxIterations:12}}:e===`decision`?{id:t,kind:e,title:`Check a condition`,description:`Choose what happens next`,position:r,config:{rule:{path:``,operator:`exists`}}}:{id:t,kind:e,title:`Combine results`,description:`Bring parallel work together`,position:r,config:{mode:`object`}}}function Qm(e,t){let n=new Map;if(!t)return{addedIds:[],changedIds:[],removedIds:[],connectionChanges:0,nodeStates:n};let r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map(t.nodes.map(e=>[e.id,e])),a=t.nodes.filter(e=>!r.has(e.id)).map(e=>e.id),o=e.nodes.filter(e=>!i.has(e.id)).map(e=>e.id),s=t.nodes.filter(e=>{let t=r.get(e.id);return t?$m(t)!==$m(e):!1}).map(e=>e.id);a.forEach(e=>n.set(e,`added`)),s.forEach(e=>n.set(e,`changed`)),o.forEach(e=>n.set(e,`removed`));let c=new Set(e.edges.map(eh)),l=new Set(t.edges.map(eh));return{addedIds:a,changedIds:s,removedIds:o,connectionChanges:e.edges.filter(e=>!l.has(eh(e))).length+t.edges.filter(e=>!c.has(eh(e))).length,nodeStates:n}}function $m(e){let{position:t,...n}=e;return JSON.stringify(n)}function eh(e){return`${e.source}:${e.sourcePort??``}->${e.target}`}function th(e){return e.toLowerCase().replace(/[^a-z0-9_-]+/g,`_`).replace(/^_+/,``)}function nh(e){return{input:`User input`,agent:`AI step`,decision:`Decision`,merge:`Combine`,output:`User result`}[e]}function rh(e){return{title:e.title,description:e.description,version:e.version,inputSchema:e.inputSchema,outputSchema:e.outputSchema,defaults:e.defaults,tags:e.metadata.tags,whenToUse:e.metadata.whenToUse,estimatedAgents:e.metadata.estimatedAgents,permissions:e.permissions,resources:e.resources}}function ih(e){return e===`zh`?{untitled:`未命名工作流`,editTitle:`编辑工作流`,createTitle:`创建工作流`,subtitle:`描述目标、确认方案,然后用示例测试。无需编写代码。`,close:`关闭`,savingDraft:`正在保存草稿…`,savedDraft:`草稿已保存`,draftError:`草稿保存失败`,flowTitle:`工作流步骤图`,flowAria:`可编辑的工作流步骤图`,stepCount:e=>`${e} 个步骤 · 点击步骤可编辑`,emptyFlow:`还没有步骤。添加一个 AI 步骤开始设计。`,addAgent:`添加 AI 步骤`,addDecision:`添加判断`,addMerge:`合并结果`,canvasHint:`拖动步骤并连接圆点`,workflowName:`内部名称`,humanTitle:`用户看到的名称`,outcome:`这个工作流最终帮用户得到什么?`,versions:`版本记录`,currentVersion:`当前`,restore:`恢复为新版本`,restoring:`恢复中…`,selectNode:`选择一个步骤来编辑`,needsAttention:`发布前需要处理`,stepSettings:`步骤设置`,remove:`删除`,stepName:`步骤名称`,stepPurpose:`这一步的作用`,instructions:`告诉 AI 要做什么`,advanced:`高级设置`,model:`模型(可选)`,defaultModel:`使用智能默认值`,valuePath:`要检查的值`,condition:`判断条件`,exists:`存在`,equals:`等于`,notEquals:`不等于`,contains:`包含`,compareValue:`比较值`,combineAs:`合并方式`,namedResults:`按步骤名称组织`,listResults:`按列表组织`,summaryTemplate:`结果摘要(可选)`,autoSummary:`留空则自动生成`,aiPlaceholder:`例如:增加一个风险评审步骤,并与方案分析并行`,designing:`正在设计…`,applyWithAi:`让 AI 提出修改`,testGoal:`用什么例子测试?`,publish:`保存`,publishAndRun:`保存并测试`,introTitle:`你希望这个工作流持续帮你完成什么?`,introDescription:`直接描述最终目标。AI 会先给出一份可理解的步骤方案,只有你确认后才会保存。`,introPlaceholder:`例如:每周整理项目进展,识别风险,并生成一份可以发给团队的周报。`,examples:[`研究一个主题并给出可靠结论`,`评审需求并生成实现计划`,`分析问题、定位原因并给出修复建议`],designWorkflow:`生成方案`,manualStart:`高级:手动搭建`,proposalTitle:`AI 提出的方案`,proposalHint:`绿色是新增,蓝色是修改,红色虚线是删除。确认前不会改变现有工作流。`,added:`新增`,changed:`修改`,removed:`删除`,assumptions:`方案假设`,risks:`需要留意`,permissions:`需要的权限`,acceptAndSave:`采用并保存`,savingProposal:`正在保存…`,rejectProposal:`不采用,返回修改`}:{untitled:`Untitled workflow`,editTitle:`Edit workflow`,createTitle:`Create workflow`,subtitle:`Describe the outcome, review the plan, then test it with an example. No code required.`,close:`Close`,savingDraft:`Saving draft…`,savedDraft:`Draft saved`,draftError:`Draft could not be saved`,flowTitle:`Workflow map`,flowAria:`Editable workflow step map`,stepCount:e=>`${e} steps · select a step to edit`,emptyFlow:`No steps yet. Add an AI step to start designing.`,addAgent:`Add AI step`,addDecision:`Add decision`,addMerge:`Combine results`,canvasHint:`Drag steps and connect the dots`,workflowName:`Internal name`,humanTitle:`Name users see`,outcome:`What will this workflow help the user achieve?`,versions:`Version history`,currentVersion:`Current`,restore:`Restore as new`,restoring:`Restoring…`,selectNode:`Select a step to edit it`,needsAttention:`Needs attention before publishing`,stepSettings:`Step settings`,remove:`Remove`,stepName:`Step name`,stepPurpose:`Purpose of this step`,instructions:`Tell the AI what to do`,advanced:`Advanced settings`,model:`Model (optional)`,defaultModel:`Use smart default`,valuePath:`Value to check`,condition:`Condition`,exists:`Exists`,equals:`Equals`,notEquals:`Does not equal`,contains:`Contains`,compareValue:`Compare with`,combineAs:`Combine as`,namedResults:`Named results`,listResults:`List of results`,summaryTemplate:`Result summary (optional)`,autoSummary:`Leave blank to generate automatically`,aiPlaceholder:`For example: add a risk review in parallel with solution analysis`,designing:`Designing…`,applyWithAi:`Ask AI to propose changes`,testGoal:`What example should we test?`,publish:`Save`,publishAndRun:`Save & test`,introTitle:`What should this workflow keep doing for you?`,introDescription:`Describe the outcome in plain language. AI will propose an understandable plan and will not save anything until you approve it.`,introPlaceholder:`For example: summarize project progress every week, identify risks, and produce a team-ready update.`,examples:[`Research a topic and deliver a reliable conclusion`,`Review a request and produce an implementation plan`,`Analyze an issue, find the cause, and recommend a fix`],designWorkflow:`Generate plan`,manualStart:`Advanced: build manually`,proposalTitle:`AI proposal`,proposalHint:`Green is added, blue is changed, and dashed red is removed. Nothing changes until you approve.`,added:`Added`,changed:`Changed`,removed:`Removed`,assumptions:`Assumptions`,risks:`Things to check`,permissions:`Required access`,acceptAndSave:`Accept & save`,savingProposal:`Saving…`,rejectProposal:`Reject and revise`}}function ah(e){let t=(0,X.c)(54),{graph:n,language:r,className:i}=e,a;t[0]===r?a=t[1]:(a=uh(r),t[0]=r,t[1]=a);let o=a,[s,c]=(0,Y.useState)(n.nodes.find(oh)?.id??n.nodes[0]?.id),u;if(t[2]!==o.kind||t[3]!==n.nodes){let e;t[5]===o.kind?e=t[6]:(e=e=>({id:e.id,type:`definitionNode`,position:e.position,data:{definitionNode:e,kindLabel:o.kind[e.kind]}}),t[5]=o.kind,t[6]=e),u=n.nodes.map(e),t[2]=o.kind,t[3]=n.nodes,t[4]=u}else u=t[4];let d=u,f;if(t[7]!==o.no||t[8]!==o.yes||t[9]!==n.edges){let e;t[11]!==o.no||t[12]!==o.yes?(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,label:e.sourcePort===`true`?o.yes:e.sourcePort===`false`?o.no:void 0,labelStyle:{fill:`var(--color-fg-subtle)`,fontSize:10},labelBgStyle:{fill:`var(--color-surface-panel)`,fillOpacity:.9},markerEnd:{type:rc.ArrowClosed},style:{stroke:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[11]=o.no,t[12]=o.yes,t[13]=e):e=t[13],f=n.edges.map(e),t[7]=o.no,t[8]=o.yes,t[9]=n.edges,t[10]=f}else f=t[10];let p=f,m=n.nodes,h,g,_,v,y,b;if(t[14]!==i||t[15]!==o.ariaLabel||t[16]!==o.empty||t[17]!==o.kind||t[18]!==o.selectHint||t[19]!==p||t[20]!==n.nodes||t[21]!==d||t[22]!==s){h=Symbol.for(`react.early_return_sentinel`);bb0:{let e;t[29]===s?e=t[30]:(e=e=>e.id===s,t[29]=s,t[30]=e);let r=m.find(e);if(n.nodes.length===0){let e;t[31]===i?e=t[32]:(e=l(`flex min-h-72 items-center justify-center bg-surface-base/40 px-6 text-center text-sm text-fg-muted`,i),t[31]=i,t[32]=e);let n;t[33]!==o.empty||t[34]!==e?(n=(0,Z.jsx)(`div`,{className:e,children:o.empty}),t[33]=o.empty,t[34]=e,t[35]=n):n=t[35],h=n;break bb0}t[36]===i?v=t[37]:(v=l(`overflow-hidden bg-surface-base/45`,i),t[36]=i,t[37]=v),y=o.ariaLabel;let a;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(a=(e,t)=>c(t.id),t[38]=a):a=t[38];let u;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(u={padding:.24,minZoom:.45,maxZoom:1},t[39]=u):u=t[39];let f,x,S;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(f={hideAttribution:!0},x=(0,Z.jsx)(om,{color:`var(--color-edge)`,gap:22,size:1}),S=(0,Z.jsx)(hm,{showInteractive:!1,className:`!border-edge !bg-surface-panel !shadow-surface`}),t[40]=f,t[41]=x,t[42]=S):(f=t[40],x=t[41],S=t[42]),t[43]!==p||t[44]!==d?(b=(0,Z.jsx)(`div`,{className:`h-[22rem] min-h-72`,children:(0,Z.jsxs)(Qp,{nodes:d,edges:p,nodeTypes:lh,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:a,fitView:!0,fitViewOptions:u,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:f,children:[x,S]})}),t[43]=p,t[44]=d,t[45]=b):b=t[45],g=`flex min-h-16 items-start gap-3 border-t border-edge bg-surface-panel px-4 py-3`,_=r?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:ch(r.kind)}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`strong`,{className:`block text-sm font-medium text-fg`,children:r.title}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:r.description||o.kind[r.kind]})]})]}):(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:o.selectHint})}t[14]=i,t[15]=o.ariaLabel,t[16]=o.empty,t[17]=o.kind,t[18]=o.selectHint,t[19]=p,t[20]=n.nodes,t[21]=d,t[22]=s,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y,t[28]=b}else h=t[23],g=t[24],_=t[25],v=t[26],y=t[27],b=t[28];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let x;t[46]!==g||t[47]!==_?(x=(0,Z.jsx)(`div`,{className:g,children:_}),t[46]=g,t[47]=_,t[48]=x):x=t[48];let S;return t[49]!==x||t[50]!==v||t[51]!==y||t[52]!==b?(S=(0,Z.jsxs)(`section`,{className:v,"aria-label":y,children:[b,x]}),t[49]=x,t[50]=v,t[51]=y,t[52]=b,t[53]=S):S=t[53],S}function oh(e){return e.kind===`agent`}function sh(e){let t=(0,X.c)(25),{data:n,selected:r}=e,i=n.definitionNode,a=r?`border-accent ring-2 ring-accent/20`:`border-edge`,o;t[0]===a?o=t[1]:(o=l(`w-48 rounded-xl border bg-surface-panel px-3 py-3 shadow-surface transition-colors`,a),t[0]=a,t[1]=o);let s;t[2]===i.kind?s=t[3]:(s=i.kind===`input`?null:(0,Z.jsx)(yf,{type:`target`,position:Q.Left,className:`!invisible`}),t[2]=i.kind,t[3]=s);let c;t[4]===i.kind?c=t[5]:(c=ch(i.kind),t[4]=i.kind,t[5]=c);let u;t[6]===c?u=t[7]:(u=(0,Z.jsx)(`span`,{className:`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg bg-accent-soft text-accent-fg`,children:c}),t[6]=c,t[7]=u);let d;t[8]===i.title?d=t[9]:(d=(0,Z.jsx)(`strong`,{className:`block truncate text-sm font-medium text-fg`,children:i.title}),t[8]=i.title,t[9]=d);let f;t[10]===n.kindLabel?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:n.kindLabel}),t[10]=n.kindLabel,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;t[15]!==u||t[16]!==p?(m=(0,Z.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[u,p]}),t[15]=u,t[16]=p,t[17]=m):m=t[17];let h;t[18]===i.kind?h=t[19]:(h=i.kind===`decision`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yf,{id:`true`,type:`source`,position:Q.Right,style:{top:`38%`},className:`!invisible`}),(0,Z.jsx)(yf,{id:`false`,type:`source`,position:Q.Right,style:{top:`70%`},className:`!invisible`})]}):i.kind===`output`?null:(0,Z.jsx)(yf,{type:`source`,position:Q.Right,className:`!invisible`}),t[18]=i.kind,t[19]=h);let g;return t[20]!==h||t[21]!==o||t[22]!==s||t[23]!==m?(g=(0,Z.jsxs)(`div`,{className:o,children:[s,m,h]}),t[20]=h,t[21]=o,t[22]=s,t[23]=m,t[24]=g):g=t[24],g}function ch(e){return e===`input`?(0,Z.jsx)(ze,{className:`size-4`,"aria-hidden":!0}):e===`agent`?(0,Z.jsx)(me,{className:`size-4`,"aria-hidden":!0}):e===`decision`?(0,Z.jsx)(je,{className:`size-4`,"aria-hidden":!0}):e===`merge`?(0,Z.jsx)(_,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(ue,{className:`size-4`,"aria-hidden":!0})}var lh={definitionNode:sh};function uh(e){return e===`zh`?{ariaLabel:`工作流步骤图`,empty:`这个工作流还没有可展示的步骤。`,selectHint:`点击步骤查看它的作用。`,yes:`是`,no:`否`,kind:{input:`任务输入`,agent:`AI 执行`,decision:`条件判断`,merge:`汇总结果`,output:`最终结果`}}:{ariaLabel:`Workflow step map`,empty:`This workflow has no steps to display yet.`,selectHint:`Select a step to see what it does.`,yes:`Yes`,no:`No`,kind:{input:`Task input`,agent:`AI work`,decision:`Decision`,merge:`Combine results`,output:`Final result`}}}function dh(e){let t=(0,X.c)(54),{graph:n,view:r,language:i,onRepair:a}=e,[o,s]=(0,Y.useState)(),c=(0,Y.useRef)(null),d=(0,Y.useRef)(void 0),f;t[0]===i?f=t[1]:(f=bh(i),t[0]=i,t[1]=f);let p=f,m;t[2]===r.nodes?m=t[3]:(m=new Map(r.nodes.map(gh)),t[2]=r.nodes,t[3]=m);let h=m,g;if(t[4]!==n.nodes||t[5]!==h){let e;t[7]===h?e=t[8]:(e=e=>({id:e.id,type:`runNode`,position:e.position,data:{definitionNode:e,runNode:h.get(e.id)}}),t[7]=h,t[8]=e),g=n.nodes.map(e),t[4]=n.nodes,t[5]=h,t[6]=g}else g=t[6];let _=g,v;if(t[9]!==n.edges||t[10]!==h){let e;t[12]===h?e=t[13]:(e=e=>({id:e.id,source:e.source,target:e.target,sourceHandle:e.sourcePort===`true`||e.sourcePort===`false`?e.sourcePort:void 0,markerEnd:{type:rc.ArrowClosed},animated:h.get(e.source)?.status===`running`,style:{stroke:h.get(e.source)?.status===`done`?`var(--color-success)`:`var(--color-fg-subtle)`,strokeWidth:1.5}}),t[12]=h,t[13]=e),v=n.edges.map(e),t[9]=n.edges,t[10]=h,t[11]=v}else v=t[11];let y=v,x;t[14]!==o||t[15]!==h?(x=o?h.get(o):void 0,t[14]=o,t[15]=h,t[16]=x):x=t[16];let S=x,C;t[17]!==n.nodes||t[18]!==o?(C=o?n.nodes.find(e=>e.id===o):void 0,t[17]=n.nodes,t[18]=o,t[19]=C):C=t[19];let w=C,T;t[20]===r.nodes?T=t[21]:(T=r.nodes.some(hh),t[20]=r.nodes,t[21]=T);let E=T,D,O;t[22]===r.nodes?(D=t[23],O=t[24]):(D=()=>{let e=r.nodes.find(mh)??r.nodes.find(ph)??[...r.nodes].reverse().find(fh);if(!e||d.current===e.id)return;d.current=e.id,s(e.id);let t=window.requestAnimationFrame(()=>{c.current?.fitView({nodes:[{id:e.id}],padding:1.4,minZoom:.65,maxZoom:1,duration:300})});return()=>window.cancelAnimationFrame(t)},O=[r.nodes],t[22]=r.nodes,t[23]=D,t[24]=O),(0,Y.useEffect)(D,O);let k;t[25]===p.title?k=t[26]:(k=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:p.title}),t[25]=p.title,t[26]=k);let A;t[27]===p.hint?A=t[28]:(A=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:p.hint}),t[27]=p.hint,t[28]=A);let j;t[29]!==k||t[30]!==A?(j=(0,Z.jsxs)(`div`,{children:[k,A]}),t[29]=k,t[30]=A,t[31]=j):j=t[31];let M;t[32]!==p.repair||t[33]!==E||t[34]!==a?(M=E&&a?(0,Z.jsxs)(J,{variant:`secondary`,className:`h-8 text-xs`,onClick:a,children:[(0,Z.jsx)(Ne,{className:`size-3.5`}),p.repair]}):null,t[32]=p.repair,t[33]=E,t[34]=a,t[35]=M):M=t[35];let N;t[36]!==j||t[37]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-edge px-4 py-3`,children:[j,M]}),t[36]=j,t[37]=M,t[38]=N):N=t[38];let P,F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(P=(e,t)=>s(t.id),F=e=>{c.current=e},t[39]=P,t[40]=F):(P=t[39],F=t[40]);let I,L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(I={hideAttribution:!0},L=(0,Z.jsx)(om,{color:`var(--color-edge)`,gap:22,size:1}),t[41]=I,t[42]=L):(I=t[41],L=t[42]);let R;t[43]!==y||t[44]!==_?(R=(0,Z.jsx)(`div`,{className:`h-[28rem]`,children:(0,Z.jsx)(Qp,{nodes:_,edges:y,nodeTypes:yh,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,onNodeClick:P,onInit:F,fitView:!0,minZoom:.3,maxZoom:1.25,panOnScroll:!0,zoomOnDoubleClick:!1,proOptions:I,children:L})}),t[43]=y,t[44]=_,t[45]=R):R=t[45];let z;t[46]!==p.status||t[47]!==S||t[48]!==w?(z=S?(0,Z.jsxs)(`div`,{className:l(`flex items-start gap-2 border-t border-edge px-4 py-3 text-xs`,S.status===`error`?`text-danger`:`text-fg-muted`),children:[S.status===`error`?(0,Z.jsx)(b,{className:`mt-0.5 size-3.5 shrink-0`}):S.status===`done`?(0,Z.jsx)(u,{className:`mt-0.5 size-3.5 shrink-0 text-success`}):null,(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`strong`,{className:`font-medium text-fg`,children:S.title}),w?.description?(0,Z.jsx)(`span`,{className:`block pt-0.5 text-fg-subtle`,children:w.description}):null,(0,Z.jsx)(`span`,{className:`block pt-1`,children:S.error||S.resultPreview||p.status[S.status]})]})]}):null,t[46]=p.status,t[47]=S,t[48]=w,t[49]=z):z=t[49];let B;return t[50]!==N||t[51]!==R||t[52]!==z?(B=(0,Z.jsxs)(`section`,{className:`mt-5 overflow-hidden rounded-2xl border border-edge bg-surface-base/35`,children:[N,R,z]}),t[50]=N,t[51]=R,t[52]=z,t[53]=B):B=t[53],B}function fh(e){return e.status===`done`}function ph(e){return e.status===`error`}function mh(e){return e.status===`running`}function hh(e){return e.status===`error`}function gh(e){return[e.id,e]}function _h(e){let t=(0,X.c)(30),{data:n,selected:r}=e,i=n.definitionNode,a=n.runNode?.status??`pending`,o;t[0]===i.kind?o=t[1]:(o=i.kind===`input`?(0,Z.jsx)(ze,{}):i.kind===`agent`?(0,Z.jsx)(me,{}):i.kind===`decision`?(0,Z.jsx)(je,{}):i.kind===`merge`?(0,Z.jsx)(_,{}):(0,Z.jsx)(ue,{}),t[0]=i.kind,t[1]=o);let s=o,c=a===`running`&&`border-accent ring-2 ring-accent/20`,u=a===`done`&&`border-success/50`,d=a===`error`&&`border-danger ring-2 ring-danger/15`,f=(a===`pending`||a===`skipped`)&&`border-edge opacity-70`,p=r&&`ring-2 ring-accent/25`,m;t[2]!==c||t[3]!==u||t[4]!==d||t[5]!==f||t[6]!==p?(m=l(`w-48 rounded-xl border bg-surface-panel px-3 py-2.5 shadow-surface`,c,u,d,f,p),t[2]=c,t[3]=u,t[4]=d,t[5]=f,t[6]=p,t[7]=m):m=t[7];let h;t[8]===i.kind?h=t[9]:(h=i.kind===`input`?null:(0,Z.jsx)(yf,{type:`target`,position:Q.Left,className:`!invisible`}),t[8]=i.kind,t[9]=h);let g;t[10]===s?g=t[11]:(g=(0,Z.jsx)(`span`,{className:`[&>svg]:size-4 text-fg-subtle`,children:s}),t[10]=s,t[11]=g);let v;t[12]===i.title?v=t[13]:(v=(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-fg`,children:i.title}),t[12]=i.title,t[13]=v);let y;t[14]===a?y=t[15]:(y=(0,Z.jsx)(vh,{status:a}),t[14]=a,t[15]=y);let b;t[16]!==v||t[17]!==y||t[18]!==g?(b=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[g,v,y]}),t[16]=v,t[17]=y,t[18]=g,t[19]=b):b=t[19];let x;t[20]===i.description?x=t[21]:(x=i.description?(0,Z.jsx)(`p`,{className:`mt-1.5 line-clamp-2 text-xs leading-4 text-fg-muted`,children:i.description}):null,t[20]=i.description,t[21]=x);let S;t[22]===i.kind?S=t[23]:(S=i.kind===`decision`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(yf,{id:`true`,type:`source`,position:Q.Right,className:`!invisible`}),(0,Z.jsx)(yf,{id:`false`,type:`source`,position:Q.Right,className:`!invisible`})]}):i.kind===`output`?null:(0,Z.jsx)(yf,{type:`source`,position:Q.Right,className:`!invisible`}),t[22]=i.kind,t[23]=S);let C;return t[24]!==b||t[25]!==x||t[26]!==S||t[27]!==m||t[28]!==h?(C=(0,Z.jsxs)(`div`,{className:m,children:[h,b,x,S]}),t[24]=b,t[25]=x,t[26]=S,t[27]=m,t[28]=h,t[29]=C):C=t[29],C}function vh(e){let t=(0,X.c)(4),{status:n}=e;if(n===`done`){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-success`,children:(0,Z.jsx)(u,{className:`size-3`})}),t[0]=e):e=t[0],e}if(n===`error`){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-danger/10 text-danger`,children:(0,Z.jsx)(b,{className:`size-3`})}),t[1]=e):e=t[1],e}if(n===`running`){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,Z.jsx)(`span`,{className:`size-2.5 animate-pulse rounded-full bg-accent motion-reduce:animate-none`}),t[2]=e):e=t[2],e}let r;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Z.jsx)(`span`,{className:`size-2 rounded-full bg-edge-strong`}),t[3]=r):r=t[3],r}var yh={runNode:_h};function bh(e){return e===`zh`?{title:`运行过程`,hint:`点选步骤查看当前结果;画布会随着执行自动更新。`,repair:`修复这个工作流`,status:{pending:`等待中`,running:`执行中`,done:`已完成`,error:`失败`,skipped:`已跳过`}}:{title:`Live workflow`,hint:`Select a step to inspect it. The canvas updates as work progresses.`,repair:`Repair workflow`,status:{pending:`Waiting`,running:`Running`,done:`Completed`,error:`Failed`,skipped:`Skipped`}}}function xh(e,t){return t.status[e]??e}function Sh(e,t){return t.phaseStatus[e]??e}function Ch(e,t){let{run:n}=e;return n.status===`succeeded`?I(t.runSummarySucceeded,{agents:n.metrics.doneAgentCount,artifacts:n.metrics.artifactCount}):n.status===`failed`||n.status===`timeout`?n.error?.message??t.runSummaryFailedFallback:n.status===`cancelled`?t.runSummaryCancelled:I(t.runSummaryActive,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}function wh(e,t){let{run:n}=e;return n.status===`failed`?t.diagnosticFailedHint:n.status===`timeout`?t.diagnosticTimeoutHint:n.status===`cancelled`?t.diagnosticCancelledHint:n.status===`succeeded`&&n.metrics.errorAgentCount>0?t.diagnosticPartialHint:null}function Th(e){return B(e)}function Eh({view:e,comparison:t,loading:n,language:r,localeTag:i,activeTab:a,onTabChange:s,onCancel:c,onRetry:p,onReplay:m,onOpenRunId:h,ownerAgentId:_,onRepairWorkflow:v}){let b=f(r).workflows,S=C(r),w=o(),[T,E]=(0,Y.useState)(!1),[D,O]=(0,Y.useState)(!1),[A,j]=(0,Y.useState)(null),[M,N]=(0,Y.useState)(!1),[F,B]=(0,Y.useState)(null),[H,G]=(0,Y.useState)(null),[,ee]=(0,Y.useState)(0),te=e?.run.status,ne=te?x.has(te):!1;(0,Y.useEffect)(()=>{e?.run.id&&(E(!1),B(null))},[e?.run.id,ne,te,e?.run.metrics.errorAgentCount]),(0,Y.useEffect)(()=>{if(!ne)return;let e=window.setInterval(()=>ee(e=>e+1),1e3);return()=>window.clearInterval(e)},[ne]);let re=(0,Y.useMemo)(()=>e?U(e):null,[e]),ie=(0,Y.useMemo)(()=>re?Be(re):{phases:[],unphased:null},[re]),K=(0,Y.useMemo)(()=>A==null||!re?null:re.agents.find(e=>e.id===A)??null,[A,re]);(0,Y.useEffect)(()=>{re?.runId&&j((re.agents.find(e=>e.status===`error`||e.status===`skipped`)??re.agents.find(e=>e.status===`running`)??null)?.id??null)},[re?.runId]);let ae=(0,Y.useCallback)(e=>{j(e.id)},[]),oe=(0,Y.useMemo)(()=>e?z(e):[],[e]),se=e?L(e.run.result):void 0,ce=se?Jh(se):null,le=se?P(se):``,ue=!!se,de=(0,Y.useCallback)(async()=>{ue&&await d(le)&&(N(!0),window.setTimeout(()=>N(!1),1500))},[ue,le]),fe=(0,Y.useCallback)(()=>{if(!ue||!e)return;let t=new Blob([le],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`${e.run.definitionId}-${e.run.id.slice(0,8)}.md`,r.click(),URL.revokeObjectURL(n)},[ue,le,e]),pe=(0,Y.useCallback)(()=>{if(!e)return;let t=Th(e);t&&w($e(t))},[w,e]),me=(0,Y.useCallback)(async t=>{if(e){B(null),G(t.id);try{Kh(await he(e.run.id,t.id,{ownerAgentId:_}),t.name||t.id)}catch(e){B(e instanceof Error?e.message:String(e))}finally{G(null)}}},[_,e]),ge=(0,Y.useCallback)(t=>{if(!e||!t.prompt)return;let n=Th(e);if(!n){d(t.prompt);return}w($e(n,t.prompt))},[w,e]),_e=(0,Y.useCallback)(e=>{if(e.kind===`copy_result`){de();return}if(e.kind===`open_artifact`){let t=Xh(e.payload),n=ce?.artifacts.find(e=>e.id===t||e.name===t);n&&me(n);return}let t=Xh(e.payload),n=ce?.followUps.find(e=>e.id===t);if(n?.prompt){ge(n);return}let r=Zh(e.payload);r&&ge({id:e.id,title:e.label,prompt:r})},[de,me,ge,ce?.artifacts,ce?.followUps]),ve=(0,Y.useCallback)(t=>{if(!e||t==null)return;let n=String(t),r=e.agents.findIndex(e=>String(e.id)===n);if(r<0)return;let i=Number.parseInt(n,10);j(Number.isFinite(i)?i:r+1)},[e]),ye=e?Th(e):null,be=ce?.actions.filter(e=>Qh(e,ce))??[],xe=be.some(e=>e.kind===`copy_result`);if(n)return(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel p-5`,children:(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,"aria-busy":!0,children:[(0,Z.jsx)(q,{className:`h-8 w-72 max-w-full`}),(0,Z.jsx)(q,{className:`mt-4 h-28 rounded-2xl`}),(0,Z.jsx)(q,{className:`mt-5 h-[28rem] rounded-2xl`})]})});if(!e||!re)return null;let{run:Se}=e,Ce=e.controls.canCancel&&ne,Ee=ne&&Se.startedAtMs!=null?y(Date.now()-Se.startedAtMs):y(Se.metrics.durationMs??void 0),De=Ch(e,b),Oe=wh(e,b),ke=e.controls.canRetry&&e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.prompt?.trim()),Ae=e.controls.canRetry&&(e.phases.some(t=>t.status===`failed`&&e.agents.some(e=>e.phaseId===t.id&&e.prompt?.trim()))||e.agents.some(e=>(e.status===`error`||e.status===`skipped`)&&e.phaseId&&e.prompt?.trim())),je=Se.goal?.trim()||Se.title,Me=e.nodes.find(e=>e.status===`running`)??e.nodes.find(e=>e.status===`error`)??[...e.nodes].reverse().find(e=>e.status===`done`),Pe=Me?Me.error||Me.resultPreview||(r===`zh`?`${Me.status===`running`?`正在执行`:Me.status===`done`?`刚刚完成`:`需要处理`}:${Me.title}`:`${Me.status===`running`?`Working on`:Me.status===`done`?`Just completed`:`Needs attention`}: ${Me.title}`):De,Fe=oe.length>0||!!Oe,Ie=(Se.status===`failed`||Se.status===`timeout`)&&!!v,Re=!!ye||Ce||Ie,ze=e.controls.canRetry||ke||Ae,Ve=ue,He=Re||ze||Ve,Ue=a===`diagnostics`||a===`debug`?`process`:a;return(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,Z.jsxs)(`section`,{className:`mx-auto w-full max-w-6xl p-5`,children:[(0,Z.jsxs)(`header`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,Z.jsx)(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`,children:(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-semibold leading-7 text-fg`,children:je}),(0,Z.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs font-medium`,k(Se.status)),children:xh(Se.status,b)})]}),(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[Se.title,` · `,Se.definitionId]}),(0,Z.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:De}),Oe?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:Oe}):null,(0,Z.jsxs)(`div`,{className:l(`mt-4 rounded-xl border px-3 py-2.5`,Me?.status===`error`?`border-danger/30 bg-danger/5`:`border-accent/20 bg-accent-soft/50`),children:[(0,Z.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:r===`zh`?`当前状态`:`Current status`}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm font-medium text-fg`,children:Pe})]})]})}),(0,Z.jsxs)(`dl`,{className:`mt-4 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,Z.jsx)(rg,{label:b.metrics.startedAt,value:we(Se.startedAtMs??Se.createdAtMs,i)}),(0,Z.jsx)(rg,{label:b.metrics.duration,value:Ee}),(0,Z.jsx)(rg,{label:b.metrics.agents,value:I(b.agentProgress,{done:Se.metrics.doneAgentCount,total:Se.metrics.agentCount})}),(0,Z.jsx)(rg,{label:b.metrics.artifacts,value:String(Se.metrics.artifactCount)})]})]}),(0,Z.jsx)(Oh,{activeTab:Ue,onChange:s,labels:b,artifactCount:ce?.artifacts.length??e.artifacts.length}),Ue===`result`?(0,Z.jsxs)(`section`,{className:`mt-5 space-y-4`,children:[ue?(0,Z.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base/50 p-3`,children:(0,Z.jsx)(g,{result:se,labels:S.result})}):Se.status!==`failed`&&Se.status!==`timeout`?(0,Z.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:b.noResult}):null,Se.status===`failed`||Se.status===`timeout`?(0,Z.jsx)(zh,{view:e,language:r}):null,ce?(0,Z.jsx)(Gh,{outcome:ce,labels:b,downloadingArtifactId:H,downloadError:F,onCopyText:e=>void d(e),onDownloadArtifact:e=>void me(e),onStartFollowUp:ge,compact:!0}):null,He?(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:[(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:b.nextActionsTitle}),(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-3`,children:[Re?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-fg-subtle`,children:b.primaryActionsTitle}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(Se.status===`failed`||Se.status===`timeout`)&&v?(0,Z.jsxs)(J,{variant:`primary`,onClick:v,children:[(0,Z.jsx)(W,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`让 AI 修复`:`Fix with AI`]}):null,ye?(0,Z.jsxs)(J,{variant:`primary`,onClick:pe,children:[(0,Z.jsx)(R,{className:`size-4`,"aria-hidden":!0}),b.continueInChat]}):null,Ce?(0,Z.jsxs)(J,{variant:`secondary`,onClick:c,className:`text-red-600 dark:text-red-300`,children:[(0,Z.jsx)(Le,{className:`size-4`,"aria-hidden":!0}),b.cancel]}):null]})]}):null,ze?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-fg-subtle`,children:b.recoveryActionsTitle}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[ke?(0,Z.jsxs)(J,{variant:`secondary`,onClick:()=>m(`failed_agents`),children:[(0,Z.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}),b.replayFailedAgents]}):null,Ae?(0,Z.jsxs)(J,{variant:`secondary`,onClick:()=>m(`failed_phases`),children:[(0,Z.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}),b.replayFailedPhases]}):null,e.controls.canRetry?(0,Z.jsxs)(J,{variant:`secondary`,onClick:p,children:[(0,Z.jsx)(Ne,{className:`size-4`,"aria-hidden":!0}),b.rerun]}):null]})]}):null,Ve?(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h4`,{className:`text-xs font-medium text-fg-subtle`,children:b.resultActionsTitle}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[be.map(e=>(0,Z.jsx)(J,{variant:`secondary`,onClick:()=>_e(e),children:e.label},e.id)),xe?null:(0,Z.jsxs)(J,{variant:`secondary`,onClick:de,children:[M?(0,Z.jsx)(u,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(V,{className:`size-4`,"aria-hidden":!0}),M?b.copied:b.copyResult]}),(0,Z.jsxs)(J,{variant:`secondary`,onClick:fe,children:[(0,Z.jsx)(Te,{className:`size-4`,"aria-hidden":!0}),b.exportResult]})]})]}):null]})]}):null,Fe?(0,Z.jsx)(Dh,{diagnostics:oe,labels:b,hint:Oe,onOpenAgent:ve}):null,(0,Z.jsx)(Fh,{view:e,comparison:t,labels:b,onOpenRunId:h}),(0,Z.jsx)(Ih,{view:e,labels:b})]}):null,Ue===`process`?(0,Z.jsxs)(Z.Fragment,{children:[e.run.metadata?.definition.graph?(0,Z.jsx)(dh,{graph:e.run.metadata.definition.graph,view:e,language:r,onRepair:v}):null,Fe?(0,Z.jsx)(Dh,{diagnostics:oe,labels:b,hint:Oe,onOpenAgent:ve}):null,(0,Z.jsx)(kh,{snapshot:re,rollup:ie,view:e,labels:b,cardLabels:S,isActive:ne,processExpanded:T,logsExpanded:D,selectedAgentId:A,selectedAgent:K,durationText:Ee,onToggleProcess:()=>E(e=>!e),onToggleLogs:()=>O(e=>!e),onSelectAgent:ae})]}):null,Ue===`artifacts`?(0,Z.jsx)(Gh,{outcome:ce,labels:b,downloadingArtifactId:H,downloadError:F,onCopyText:e=>void d(e),onDownloadArtifact:e=>void me(e),onStartFollowUp:ge}):null]})})}function Dh(e){let t=(0,X.c)(13),{diagnostics:n,labels:r,hint:i,onOpenAgent:a}=e;if(n.length===0&&!i)return null;let o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,Z.jsx)(`div`,{className:`rounded-xl bg-rose-500/10 p-2 text-rose-700 dark:text-rose-300`,children:(0,Z.jsx)(b,{className:`size-4`,"aria-hidden":!0})}),t[0]=o):o=t[0];let s;t[1]===r.reliabilityTitle?s=t[2]:(s=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.reliabilityTitle}),t[1]=r.reliabilityTitle,t[2]=s);let c=i??r.reliabilityHint,l;t[3]===c?l=t[4]:(l=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r||t[7]!==a?(u=n.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:n.slice(0,5).map(e=>(0,Z.jsx)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-panel px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:Ph(e,r)}),e.message?(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs leading-5 text-fg-muted`,children:e.message}):null,e.detail?(0,Z.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-subtle`,children:e.detail}):null]}),e.agentId==null?null:(0,Z.jsx)(J,{type:`button`,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,onClick:()=>a(e.agentId),children:r.openAgentDetails})]})},e.key))}):null,t[5]=n,t[6]=r,t[7]=a,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==l||t[11]!==u?(d=(0,Z.jsx)(`section`,{className:`mt-5 rounded-2xl border border-rose-500/20 bg-rose-500/5 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex items-start gap-3`,children:[o,(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,l,u]})]})}),t[9]=s,t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Oh(e){let t=(0,X.c)(16),{activeTab:n,onChange:r,labels:i,artifactCount:a}=e,o;t[0]===i.resultTitle?o=t[1]:(o={id:`result`,label:i.resultTitle},t[0]=i.resultTitle,t[1]=o);let s;t[2]===i.process?s=t[3]:(s={id:`process`,label:i.process},t[2]=i.process,t[3]=s);let c=a||void 0,l;t[4]!==i.outcomeArtifacts||t[5]!==c?(l={id:`artifacts`,label:i.outcomeArtifacts,count:c},t[4]=i.outcomeArtifacts,t[5]=c,t[6]=l):l=t[6];let u;t[7]!==o||t[8]!==s||t[9]!==l?(u=[o,s,l],t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10];let d=u,f;return t[11]!==n||t[12]!==i.taskActionsAria||t[13]!==r||t[14]!==d?(f=(0,Z.jsx)(`div`,{className:`mt-5 flex overflow-x-auto border-b border-edge pb-2`,children:(0,Z.jsx)(tt,{items:d,activeTab:n,onChange:r,ariaLabel:i.taskActionsAria})}),t[11]=n,t[12]=i.taskActionsAria,t[13]=r,t[14]=d,t[15]=f):f=t[15],f}function kh(e){let t=(0,X.c)(37),{snapshot:n,rollup:r,view:i,labels:a,cardLabels:o,isActive:s,processExpanded:c,logsExpanded:u,selectedAgentId:d,selectedAgent:f,durationText:p,onToggleProcess:m,onToggleLogs:h,onSelectAgent:g}=e,_;t[0]===a.process?_=t[1]:(_=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.process}),t[0]=a.process,t[1]=_);let v;t[2]!==a.agentProgress||t[3]!==i.run.metrics.agentCount||t[4]!==i.run.metrics.doneAgentCount?(v=I(a.agentProgress,{done:i.run.metrics.doneAgentCount,total:i.run.metrics.agentCount}),t[2]=a.agentProgress,t[3]=i.run.metrics.agentCount,t[4]=i.run.metrics.doneAgentCount,t[5]=v):v=t[5];let y;t[6]!==p||t[7]!==v?(y=(0,Z.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[v,` · `,p]}),t[6]=p,t[7]=v,t[8]=y):y=t[8];let b;t[9]!==_||t[10]!==y?(b=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[_,y]}),t[9]=_,t[10]=y,t[11]=b):b=t[11];let x=c?`rotate-180`:null,S;t[12]===x?S=t[13]:(S=l(`size-4 shrink-0 text-fg-subtle transition-transform`,x),t[12]=x,t[13]=S);let C;t[14]===S?C=t[15]:(C=(0,Z.jsx)(Ge,{className:S,"aria-hidden":!0}),t[14]=S,t[15]=C);let w;t[16]!==m||t[17]!==c||t[18]!==b||t[19]!==C?(w=(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-4 px-4 py-3 text-left`,onClick:m,"aria-expanded":c,children:[b,C]}),t[16]=m,t[17]=c,t[18]=b,t[19]=C,t[20]=w):w=t[20];let T;t[21]!==o||t[22]!==s||t[23]!==a||t[24]!==u||t[25]!==g||t[26]!==h||t[27]!==c||t[28]!==r||t[29]!==f||t[30]!==d||t[31]!==n||t[32]!==i.phases?(T=c?(0,Z.jsx)(`div`,{className:`border-t border-edge px-4 pb-4 pt-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_minmax(20rem,26rem)]`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[s?(0,Z.jsx)(We,{snapshot:n,labels:o,logsExpanded:u,onToggleLogs:h,selectedAgentId:d,onSelectAgent:g}):(0,Z.jsx)(ge,{rollup:r,currentPhase:n.currentPhase,labels:o.phase,recentLogs:n.logs,recentLogsHeading:o.recentLogsHeading,showAllLogsLabel:o.showAllLogs,logsExpanded:u,onToggleLogs:h,selectedAgentId:d,onSelectAgent:g}),i.phases.length>0?(0,Z.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:i.phases.map(e=>(0,Z.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:Sh(e.status,a)})]})},e.id))}):null]}),(0,Z.jsx)(Ah,{agent:f,snapshot:n,labels:a,cardLabels:o})]})}):null,t[21]=o,t[22]=s,t[23]=a,t[24]=u,t[25]=g,t[26]=h,t[27]=c,t[28]=r,t[29]=f,t[30]=d,t[31]=n,t[32]=i.phases,t[33]=T):T=t[33];let E;return t[34]!==w||t[35]!==T?(E=(0,Z.jsxs)(`div`,{className:`mt-5 rounded-2xl border border-edge bg-surface-base/35`,children:[w,T]}),t[34]=w,t[35]=T,t[36]=E):E=t[36],E}function Ah(e){let t=(0,X.c)(57),{agent:n,snapshot:r,labels:i,cardLabels:a}=e,[o,s]=(0,Y.useState)(!1),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s(!1)},t[0]=c):c=t[0];let u=n?.id,d;if(t[1]===u?d=t[2]:(d=[u],t[1]=u,t[2]=d),(0,Y.useEffect)(c,d),!n){let e;return t[3]===i.noSubagents?e=t[4]:(e=(0,Z.jsx)(`aside`,{className:`min-w-0 rounded-2xl border border-dashed border-edge bg-surface-panel/45 p-4 text-sm text-fg-muted`,children:i.noSubagents}),t[3]=i.noSubagents,t[4]=e),e}let f;t[5]===n?f=t[6]:(f=Me(n),t[5]=n,t[6]=f);let p=f,m=n.error||n.resultPreview||n.currentStep||a.checkDetail.runningPlaceholder,h;t[7]===n.label?h=t[8]:(h=(0,Z.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.label}),t[7]=n.label,t[8]=h);let g=n.phase||i.process,_;t[9]!==p||t[10]!==g?(_=[g,p].filter(Boolean),t[9]=p,t[10]=g,t[11]=_):_=t[11];let v=_.join(` · `),y;t[12]===v?y=t[13]:(y=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:v}),t[12]=v,t[13]=y);let b;t[14]!==h||t[15]!==y?(b=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[h,y]}),t[14]=h,t[15]=y,t[16]=b):b=t[16];let x;t[17]===n.status?x=t[18]:(x=l(`rounded-full px-2 py-0.5 text-xs font-medium`,ng(n.status)),t[17]=n.status,t[18]=x);let S=i.agentStatus[n.status]??n.status,C;t[19]!==x||t[20]!==S?(C=(0,Z.jsx)(`span`,{className:x,children:S}),t[19]=x,t[20]=S,t[21]=C):C=t[21];let w;t[22]!==b||t[23]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[b,C]}),t[22]=b,t[23]=C,t[24]=w):w=t[24];let T;t[25]===i.agentOutputHeading?T=t[26]:(T=(0,Z.jsx)(`h4`,{className:`text-xs font-semibold text-fg`,children:i.agentOutputHeading}),t[25]=i.agentOutputHeading,t[26]=T);let E=n.error?`font-mono text-rose-600 dark:text-rose-400`:`text-fg-muted`,D;t[27]===E?D=t[28]:(D=l(`mt-2 max-h-72 overflow-auto whitespace-pre-wrap wrap-break-word text-sm leading-6`,E),t[27]=E,t[28]=D);let O;t[29]!==m||t[30]!==D?(O=(0,Z.jsx)(`div`,{className:D,children:m}),t[29]=m,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==T||t[33]!==O?(k=(0,Z.jsxs)(`section`,{className:`mt-4 rounded-xl border border-edge-subtle bg-surface-base/60 p-3`,children:[T,O]}),t[32]=T,t[33]=O,t[34]=k):k=t[34];let A;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>s(Nh),t[35]=A):A=t[35];let j=i.debugDetailsTitle,M=o&&`rotate-180`,N;t[36]===M?N=t[37]:(N=l(`size-4 shrink-0 text-fg-subtle transition-transform`,M),t[36]=M,t[37]=N);let P;t[38]===N?P=t[39]:(P=(0,Z.jsx)(Ge,{className:N,"aria-hidden":!0}),t[38]=N,t[39]=P);let F;t[40]!==o||t[41]!==i.debugDetailsTitle||t[42]!==P?(F=(0,Z.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-xs font-semibold text-fg`,onClick:A,"aria-expanded":o,children:[j,P]}),t[40]=o,t[41]=i.debugDetailsTitle,t[42]=P,t[43]=F):F=t[43];let I;t[44]!==o||t[45]!==n||t[46]!==a||t[47]!==i||t[48]!==r?(I=o?(0,Z.jsxs)(`div`,{className:`space-y-3 border-t border-edge-subtle p-3`,children:[n.steps?.length?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.checkDetail.stepsHeading}),(0,Z.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.steps.slice(0,8).map(Mh)})]}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:i.agentInputHeading}),(0,Z.jsx)(`pre`,{className:`mt-1 max-h-44 overflow-auto whitespace-pre-wrap wrap-break-word rounded-lg bg-surface-panel p-2 font-mono text-xs leading-5 text-fg-muted`,children:n.prompt||`—`})]}),(0,Z.jsx)($h,{agent:n,labels:i}),r.logs.length>0?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:a.recentLogsHeading}),(0,Z.jsx)(`div`,{className:`mt-1 max-h-36 space-y-0.5 overflow-auto rounded-lg bg-surface-panel p-2 font-mono text-xs text-fg-subtle`,children:r.logs.map(jh)})]}):null]}):null,t[44]=o,t[45]=n,t[46]=a,t[47]=i,t[48]=r,t[49]=I):I=t[49];let L;t[50]!==F||t[51]!==I?(L=(0,Z.jsxs)(`section`,{className:`mt-3 rounded-xl border border-edge-subtle bg-surface-base/40`,children:[F,I]}),t[50]=F,t[51]=I,t[52]=L):L=t[52];let R;return t[53]!==w||t[54]!==k||t[55]!==L?(R=(0,Z.jsxs)(`aside`,{className:`min-w-0 rounded-2xl border border-edge bg-surface-panel p-4`,children:[w,k,L]}),t[53]=w,t[54]=k,t[55]=L,t[56]=R):R=t[56],R}function jh(e){return(0,Z.jsx)(`div`,{className:`wrap-break-word`,children:e},e)}function Mh(e){return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-2.5 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-fg`,children:e.label}),(0,Z.jsx)(`span`,{className:`shrink-0 text-[10px] text-fg-subtle`,children:e.status})]}),e.detail||e.resultPreview||e.error?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.error||e.resultPreview||e.detail}):null]},e.id)}function Nh(e){return!e}function Ph(e,t){return e.kind===`run_error`?e.code?I(t.diagnosticsRunErrorWithCode,{code:e.code}):t.diagnosticsRunError:e.kind===`agent_error`?I(t.diagnosticsAgentError,{agent:e.agentLabel??String(e.agentId??`—`)}):e.kind===`step_error`?I(t.diagnosticsStepError,{agent:e.agentLabel??String(e.agentId??`—`),step:e.stepLabel??e.stepId??`—`}):I(t.diagnosticsAgentSkipped,{agent:e.agentLabel??String(e.agentId??`—`)})}function Fh(e){let t=(0,X.c)(36),{view:n,comparison:r,labels:i,onOpenRunId:a}=e,o=n.run.metadata?.replay;if(!o)return null;let s;t[0]===i.replayLineageTitle?s=t[1]:(s=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.replayLineageTitle}),t[0]=i.replayLineageTitle,t[1]=s);let c;t[2]!==i||t[3]!==o.scope||t[4]!==o.targetCount?(c=I(i.replayLineageSummary,{scope:Rh(o.scope,i),count:o.targetCount}),t[2]=i,t[3]=o.scope,t[4]=o.targetCount,t[5]=c):c=t[5];let l;t[6]===c?l=t[7]:(l=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:c}),t[6]=c,t[7]=l);let u;t[8]!==i.replaySourceRun||t[9]!==o.sourceRunId?(u=(0,Z.jsx)(ig,{label:i.replaySourceRun,value:o.sourceRunId}),t[8]=i.replaySourceRun,t[9]=o.sourceRunId,t[10]=u):u=t[10];let d=i.replayTargetAgents,f;t[11]===o.agentIds?f=t[12]:(f=o.agentIds.join(`, `),t[11]=o.agentIds,t[12]=f);let p;t[13]!==i.replayTargetAgents||t[14]!==f?(p=(0,Z.jsx)(ig,{label:d,value:f}),t[13]=i.replayTargetAgents,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-2`,children:[u,p]}),t[16]=u,t[17]=p,t[18]=m):m=t[18];let h;t[19]!==r||t[20]!==i.replayDurationDelta||t[21]!==i.replayFixedAgents||t[22]!==i.replayStillFailingAgents?(h=r?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(rg,{label:i.replayFixedAgents,value:String(r.fixedAgentIds.length)}),(0,Z.jsx)(rg,{label:i.replayStillFailingAgents,value:String(r.stillFailingAgentIds.length)}),(0,Z.jsx)(rg,{label:i.replayDurationDelta,value:Lh(r.durationDeltaMs)})]}):null,t[19]=r,t[20]=i.replayDurationDelta,t[21]=i.replayFixedAgents,t[22]=i.replayStillFailingAgents,t[23]=h):h=t[23];let g;t[24]!==s||t[25]!==l||t[26]!==m||t[27]!==h?(g=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[s,l,m,h]}),t[24]=s,t[25]=l,t[26]=m,t[27]=h,t[28]=g):g=t[28];let _;t[29]!==i.replayOpenSource||t[30]!==a||t[31]!==o.sourceRunId?(_=a?(0,Z.jsx)(J,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>a(o.sourceRunId),children:i.replayOpenSource}):null,t[29]=i.replayOpenSource,t[30]=a,t[31]=o.sourceRunId,t[32]=_):_=t[32];let v;return t[33]!==g||t[34]!==_?(v=(0,Z.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[g,_]})}),t[33]=g,t[34]=_,t[35]=v):v=t[35],v}function Ih(e){let t=(0,X.c)(36),{view:n,labels:r}=e,i;t[0]===n.run.metadata?.contextRefs?i=t[1]:(i=n.run.metadata?.contextRefs??[],t[0]=n.run.metadata?.contextRefs,t[1]=i);let a=i,o;t[2]===n.run.metadata?.writebackPolicy?.targets?o=t[3]:(o=n.run.metadata?.writebackPolicy?.targets??[],t[2]=n.run.metadata?.writebackPolicy?.targets,t[3]=o);let s=o;if(!a.length&&!s.length)return null;let c;t[4]===r.contextRefsTitle?c=t[5]:(c=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.contextRefsTitle}),t[4]=r.contextRefsTitle,t[5]=c);let l;t[6]===r.contextRefsHint?l=t[7]:(l=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.contextRefsHint}),t[6]=r.contextRefsHint,t[7]=l);let u;t[8]!==r.contextRefKinds||t[9]!==r.noContextRefs||t[10]!==a?(u=a.length?a.map(e=>(0,Z.jsx)(ig,{label:r.contextRefKinds[e.kind]??e.kind,value:[e.title||e.id,e.role].filter(Boolean).join(` · `)},`${e.kind}:${e.id}:${e.role??``}`)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noContextRefs}),t[8]=r.contextRefKinds,t[9]=r.noContextRefs,t[10]=a,t[11]=u):u=t[11];let d;t[12]===u?d=t[13]:(d=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:u}),t[12]=u,t[13]=d);let f;t[14]!==c||t[15]!==l||t[16]!==d?(f=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[c,l,d]}),t[14]=c,t[15]=l,t[16]=d,t[17]=f):f=t[17];let p;t[18]===r.writebackTitle?p=t[19]:(p=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.writebackTitle}),t[18]=r.writebackTitle,t[19]=p);let m;t[20]===r.writebackHint?m=t[21]:(m=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-subtle`,children:r.writebackHint}),t[20]=r.writebackHint,t[21]=m);let h;t[22]!==r.noWritebackTargets||t[23]!==r.writebackModes||t[24]!==r.writebackTargetKinds||t[25]!==s?(h=s.length?s.map(e=>(0,Z.jsx)(ig,{label:r.writebackTargetKinds[e.kind]??e.kind,value:`${e.id} · ${r.writebackModes[e.mode]??e.mode}`},`${e.kind}:${e.id}:${e.mode}`)):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.noWritebackTargets}),t[22]=r.noWritebackTargets,t[23]=r.writebackModes,t[24]=r.writebackTargetKinds,t[25]=s,t[26]=h):h=t[26];let g;t[27]===h?g=t[28]:(g=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:h}),t[27]=h,t[28]=g);let _;t[29]!==g||t[30]!==p||t[31]!==m?(_=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[p,m,g]}),t[29]=g,t[30]=p,t[31]=m,t[32]=_):_=t[32];let v;return t[33]!==_||t[34]!==f?(v=(0,Z.jsx)(`section`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/35 p-4`,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[f,_]})}),t[33]=_,t[34]=f,t[35]=v):v=t[35],v}function Lh(e){return e==null?`—`:`${e>0?`+`:e<0?`-`:``}${y(Math.abs(e))}`}function Rh(e,t){return e===`failed_phases`?t.replayScopeFailedPhases:t.replayScopeFailedAgents}function zh(e){let t=(0,X.c)(8),{view:n,language:r}=e,i=n.nodes,a,o;if(t[0]!==r||t[1]!==n.nodes){o=Symbol.for(`react.early_return_sentinel`);bb0:{let e=i.filter(Wh),s=n.nodes.filter(Uh);if(e.length===0&&s.length===0){o=null;break bb0}let c=r===`zh`?`已保留的阶段结果`:`Work completed before the failure`,l;t[4]===c?l=t[5]:(l=(0,Z.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c}),t[4]=c,t[5]=l);let u=r===`zh`?`失败不会清空已经完成的工作。你可以先使用这些结果,再让 AI 修复剩余步骤。`:`Completed work is preserved. You can use it now and ask AI to repair the remaining steps.`,d;t[6]===u?d=t[7]:(d=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:u}),t[6]=u,t[7]=d),a=(0,Z.jsxs)(`section`,{className:`rounded-2xl border border-amber-500/25 bg-amber-500/5 p-4`,children:[l,d,e.length>0?(0,Z.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(Hh)}):null,s.length>0?(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-danger`,children:r===`zh`?`待修复:${s.map(Vh).join(`、`)}`:`Needs repair: ${s.map(Bh).join(`, `)}`}):null]})}t[0]=r,t[1]=n.nodes,t[2]=a,t[3]=o}else a=t[2],o=t[3];return o===Symbol.for(`react.early_return_sentinel`)?a:o}function Bh(e){return e.title}function Vh(e){return e.title}function Hh(e){return(0,Z.jsxs)(`li`,{className:`rounded-xl border border-edge-subtle bg-surface-base/60 px-3 py-2.5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Z.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-xs leading-5 text-fg-muted`,children:e.resultPreview})]},e.id)}function Uh(e){return e.status===`error`}function Wh(e){return e.status===`done`&&e.resultPreview?.trim()}function Gh(e){let t=(0,X.c)(23),{outcome:n,labels:r,downloadingArtifactId:i,downloadError:a,onCopyText:o,onDownloadArtifact:s,onStartFollowUp:c,compact:u}=e,d=u===void 0?!1:u;if(!n||!n.artifacts.length&&!n.followUps.length&&n.structuredOutput===void 0){if(d)return null;let e;return t[0]===r.noArtifacts?e=t[1]:(e=(0,Z.jsx)(`section`,{className:`mt-5 rounded-xl border border-dashed border-edge p-4 text-sm text-fg-muted`,children:r.noArtifacts}),t[0]=r.noArtifacts,t[1]=e),e}let f=!d&&`mt-5`,p;t[2]===f?p=t[3]:(p=l(`grid gap-3 lg:grid-cols-3`,f),t[2]=f,t[3]=p);let m;t[4]!==a||t[5]!==i||t[6]!==r||t[7]!==s||t[8]!==n.artifacts?(m=n.artifacts.length>0?(0,Z.jsxs)(qh,{title:r.outcomeArtifacts,children:[(0,Z.jsx)(`ul`,{className:`space-y-2`,children:n.artifacts.map(e=>(0,Z.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,title:e.title??e.name,children:e.title??e.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-subtle`,children:e.mimeType}),(0,Z.jsxs)(`button`,{type:`button`,className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline disabled:cursor-wait disabled:opacity-60`,disabled:i===e.id,onClick:()=>s(e),children:[(0,Z.jsx)(Te,{className:`size-3`,"aria-hidden":!0}),i===e.id?r.downloadingArtifact:r.downloadArtifact]})]},e.id))}),a?(0,Z.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-rose-600 dark:text-rose-400`,children:a}):null]}):null,t[4]=a,t[5]=i,t[6]=r,t[7]=s,t[8]=n.artifacts,t[9]=m):m=t[9];let h;t[10]!==r||t[11]!==o||t[12]!==c||t[13]!==n.followUps?(h=n.followUps.length>0?(0,Z.jsx)(qh,{title:r.outcomeFollowUps,children:(0,Z.jsx)(`ul`,{className:`space-y-2`,children:n.followUps.map(e=>(0,Z.jsxs)(`li`,{className:`rounded-lg bg-surface-base px-2.5 py-2`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.title}),e.prompt?(0,Z.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-2`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-accent-fg hover:underline`,onClick:()=>c(e),children:r.startFollowUp}),(0,Z.jsx)(`button`,{type:`button`,className:`text-xs font-medium text-fg-subtle hover:text-fg`,onClick:()=>o(e.prompt??``),children:r.copyPrompt})]}):null]},e.id))})}):null,t[10]=r,t[11]=o,t[12]=c,t[13]=n.followUps,t[14]=h):h=t[14];let g;t[15]!==r||t[16]!==n.structuredOutput?(g=n.structuredOutput===void 0?null:(0,Z.jsx)(qh,{title:r.outcomeStructuredOutput,className:`lg:col-span-3`,children:(0,Z.jsxs)(`details`,{className:`rounded-lg bg-surface-base`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer px-3 py-2 text-xs font-medium text-fg-muted hover:text-fg`,children:r.outcomeStructuredOutput}),(0,Z.jsx)(`pre`,{className:`max-h-[28rem] min-w-0 overflow-auto whitespace-pre-wrap break-words border-t border-edge-subtle p-3 font-mono text-xs leading-5 text-fg-muted`,children:P(n.structuredOutput)})]})}),t[15]=r,t[16]=n.structuredOutput,t[17]=g):g=t[17];let _;return t[18]!==p||t[19]!==m||t[20]!==h||t[21]!==g?(_=(0,Z.jsxs)(`div`,{className:p,children:[m,h,g]}),t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_):_=t[22],_}function Kh(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function qh(e){let t=(0,X.c)(10),{title:n,children:r,className:i}=e,a;t[0]===i?a=t[1]:(a=l(`min-w-0 rounded-xl border border-edge-subtle bg-surface-base/35 p-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,Z.jsx)(`h4`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,Z.jsx)(`div`,{className:`mt-2`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`section`,{className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function Jh(e){if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e,n=Array.isArray(t.actions)?t.actions:[],r=Array.isArray(t.artifacts)?t.artifacts:[],i=Array.isArray(t.followUps)?t.followUps:[];return n.length===0&&r.length===0&&i.length===0&&t.structuredOutput===void 0?null:{actions:n,artifacts:r,followUps:i,structuredOutput:t.structuredOutput}}function Yh(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function Xh(e){if(typeof e==`string`)return e.trim()||null;let t=Yh(e);if(!t)return null;for(let e of[`artifactId`,`followUpId`,`id`,`name`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Zh(e){let t=Yh(e);if(!t)return null;for(let e of[`prompt`,`message`,`text`])if(typeof t[e]==`string`&&t[e].trim())return t[e].trim();return null}function Qh(e,t){if(e.kind===`copy_result`)return!0;let n=Xh(e.payload);return e.kind===`open_artifact`?!!(n&&t.artifacts.some(e=>e.id===n||e.name===n)):e.kind===`start_followup`?!!(Zh(e.payload)||n&&t.followUps.some(e=>e.id===n&&e.prompt)):!!Zh(e.payload)}function $h(e){let t=(0,X.c)(21),{agent:n,labels:r}=e,i=n.invocation;if(!i)return null;let a=i.resolvedModelRef??i.modelRef,o;t[0]!==r.agentInvocationModel||t[1]!==a?(o={label:r.agentInvocationModel,value:a},t[0]=r.agentInvocationModel,t[1]=a,t[2]=o):o=t[2];let s;t[3]===i.toolset?s=t[4]:(s=i.toolset?.join(`, `),t[3]=i.toolset,t[4]=s);let c;t[5]!==r.agentInvocationTools||t[6]!==s?(c={label:r.agentInvocationTools,value:s},t[5]=r.agentInvocationTools,t[6]=s,t[7]=c):c=t[7];let l=i.maxIterations==null?void 0:String(i.maxIterations),u;t[8]!==r.agentInvocationIterations||t[9]!==l?(u={label:r.agentInvocationIterations,value:l},t[8]=r.agentInvocationIterations,t[9]=l,t[10]=u):u=t[10];let d=i.schema?r.agentInvocationSchemaPresent:void 0,f;t[11]!==r.agentInvocationSchema||t[12]!==d?(f={label:r.agentInvocationSchema,value:d},t[11]=r.agentInvocationSchema,t[12]=d,t[13]=f):f=t[13];let p;t[14]!==o||t[15]!==c||t[16]!==u||t[17]!==f?(p=[o,c,u,f].filter(tg),t[14]=o,t[15]=c,t[16]=u,t[17]=f,t[18]=p):p=t[18];let m=p;if(m.length===0)return null;let h;return t[19]===m?h=t[20]:(h=(0,Z.jsx)(`dl`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 text-xs sm:grid-cols-2 lg:grid-cols-4`,children:m.map(eg)}),t[19]=m,t[20]=h),h}function eg(e){return(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`dt`,{className:`text-fg-subtle`,children:e.label}),(0,Z.jsx)(`dd`,{className:`mt-0.5 truncate font-medium text-fg-muted`,title:e.value,children:e.value})]},e.label)}function tg(e){return!!e.value}function ng(e){return e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`error`?`bg-rose-500/10 text-rose-700 dark:text-rose-300`:e===`running`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-subtle`}function rg(e){let t=(0,X.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`dt`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`dd`,{className:`mt-1 text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base/40 p-3`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ig(e){let t=(0,X.c)(7),{label:n,value:r}=e,i;t[0]===n?i=t[1]:(i=(0,Z.jsx)(`div`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=(0,Z.jsx)(`div`,{className:`mt-1 truncate text-sm font-medium text-fg`,title:r,children:r}),t[2]=r,t[3]=a);let o;return t[4]!==i||t[5]!==a?(o=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[i,a]}),t[4]=i,t[5]=a,t[6]=o):o=t[6],o}function ag(){let e=(0,X.c)(8),t=m(og),[n]=a(),r;e[0]===n?r=e[1]:(r=n.get(`agentId`)?.trim()||void 0,e[0]=n,e[1]=r);let i=r,o;e[2]===t?o=e[3]:(o=t?[`workflow-route-agents`,t]:null,e[2]=t,e[3]=o);let s;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},e[4]=s):s=e[4];let c=h(o,ae,s),l=i??c.data?.defaultId,u;return e[5]!==c.isLoading||e[6]!==l?(u={ownerAgentId:l,loading:c.isLoading},e[5]=c.isLoading,e[6]=l,e[7]=u):u=e[7],u}function og(e){return e.token}function sg(e){let t=(0,X.c)(19),n=m(cg),r;t[0]===n?r=t[1]:(r=n?[`workflow-route-definitions`,n]:null,t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i={revalidateOnFocus:!1},t[2]=i):i=t[2];let a=h(r,Se,i),o;t[3]!==e||t[4]!==a.data?(o=a.data?.find(t=>t.id===e||t.name===e),t[3]=e,t[4]=a.data,t[5]=o):o=t[5];let s=o,c;t[6]===a?c=t[7]:(c=async e=>{await a.mutate(t=>[...(t??[]).filter(t=>t.id!==e.id&&t.name!==e.name),e],{revalidate:!1})},t[6]=a,t[7]=c);let l=c,u;t[8]===a?u=t[9]:(u=async()=>{await a.mutate()},t[8]=a,t[9]=u);let d=u,f;t[10]===a.data?f=t[11]:(f=a.data??[],t[10]=a.data,t[11]=f);let p;return t[12]!==s||t[13]!==a.error||t[14]!==a.isLoading||t[15]!==d||t[16]!==f||t[17]!==l?(p={definition:s,definitions:f,loading:a.isLoading,error:a.error,upsertDefinition:l,refreshDefinitions:d},t[12]=s,t[13]=a.error,t[14]=a.isLoading,t[15]=d,t[16]=f,t[17]=l,t[18]=p):p=t[18],p}function cg(e){return e.token}var lg=()=>({goal:``,argValues:{},schemaInput:{},concurrency:``,maxSubagents:``});function ug(){let{definitionId:e}=c(),[t]=a(),n=o(),r=p(e=>e.language),i=f(r).workflows,l=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:u}=ag(),d=t.get(`projectId`)?.trim()||void 0,{definition:m,loading:g,error:_}=sg(e),v=h(u?[`workflow-detail-runs`,u,e,d??``]:null,()=>de(100,{ownerAgentId:u,projectId:d}),{revalidateOnFocus:!1}),[y,b]=(0,Y.useState)(lg),[x,S]=(0,Y.useState)(!1),[C,w]=(0,Y.useState)(null),E=(0,Y.useMemo)(()=>(v.data??[]).filter(e=>e.definitionId===m?.id).slice(0,6),[m?.id,v.data]),D=rt(m,y),O=m?H(m,r):null,k=(0,Y.useCallback)(async()=>{if(!(!m||!D.valid||x)){S(!0),w(null);try{n(`/workflows/runs/${(await Je({definitionId:m.id,goal:y.goal.trim()||O?.description||m.title,input:nt(m,y),agentId:u,projectId:d,concurrency:y.concurrency.trim()?Number(y.concurrency):void 0,maxSubagents:y.maxSubagents.trim()?Number(y.maxSubagents):void 0})).runId}${u?`?agentId=${encodeURIComponent(u)}`:``}`)}catch(e){w(e instanceof Error?e.message:i.startFailed)}finally{S(!1)}}},[m,D.valid,i.startFailed,O?.description,n,u,d,y,x]);if(g)return(0,Z.jsx)(hg,{});if(!m||!O)return(0,Z.jsx)(gg,{message:_?.message??(r===`zh`?`没有找到这个工作流`:`Workflow not found`)});let A=new URLSearchParams;u&&A.set(`agentId`,u),d&&A.set(`projectId`,d),m.metadata.source!==`user`&&A.set(`copy`,m.id);let j=`${m.metadata.source===`user`?`/workflows/${m.id}/edit`:`/workflows/new`}${A.size?`?${A.toString()}`:``}`;return(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-y-auto bg-surface-panel`,children:(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl px-4 py-5 sm:px-6`,children:[(0,Z.jsxs)(s,{to:`/workflows`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-fg-muted hover:text-fg`,children:[(0,Z.jsx)(be,{className:`size-4`,"aria-hidden":!0}),r===`zh`?`返回工作流`:`Back to workflows`]}),(0,Z.jsxs)(`header`,{className:`mt-4 flex flex-col gap-4 border-b border-edge pb-5 lg:flex-row lg:items-start lg:justify-between`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{children:m.metadata.source===`user`?i.badgeUser:i.badgeBuiltin}),(0,Z.jsx)(`span`,{children:`·`}),(0,Z.jsx)(`span`,{children:r===`zh`?`版本 ${m.revision}`:`Version ${m.revision}`})]}),(0,Z.jsx)(`h1`,{className:`mt-2 text-2xl font-semibold text-fg`,children:m.title}),(0,Z.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:O.description})]}),(0,Z.jsx)(J,{asChild:!0,variant:`secondary`,className:`shrink-0`,children:(0,Z.jsxs)(s,{to:j,children:[m.metadata.source===`user`?(0,Z.jsx)(Ye,{className:`size-4`,"aria-hidden":!0}):(0,Z.jsx)(T,{className:`size-4`,"aria-hidden":!0}),m.metadata.source===`user`?i.editWorkflow:i.copyAndEditWorkflow]})})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-5 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,Z.jsxs)(`section`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`它会怎样完成任务`:`How it completes the task`}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r===`zh`?`点击步骤查看职责;运行后这里会显示实时状态。`:`Select a step to understand its role. Live status appears here while running.`}),(0,Z.jsx)(ah,{graph:m.graph,language:r,className:`mt-3 h-[28rem] rounded-xl border border-edge`})]}),(0,Z.jsxs)(`aside`,{className:`rounded-xl border border-edge bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`开始一次运行`:`Start a run`}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-fg-muted`,children:O.whenToUse||O.description}),(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(it,{definition:m,language:r,value:y,onChange:b,mode:`manual`,badgeLabel:i.readyToStart,aiAssist:{context:{surface:`workflow-start`,workflowId:m.id,workflowName:m.name,workflowTitle:m.title,workflowDescription:O.description}}})}),C?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:C}):null,(0,Z.jsxs)(J,{variant:`primary`,className:`mt-4 w-full`,disabled:!D.valid||x,onClick:()=>void k(),children:[(0,Z.jsx)(ue,{className:`size-4`,"aria-hidden":!0}),x?i.starting:i.runWorkflow]})]})]}),(0,Z.jsxs)(`section`,{className:`mt-6 border-t border-edge pt-5`,children:[(0,Z.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:r===`zh`?`最近运行`:`Recent runs`}),E.length?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-2 xl:grid-cols-3`,children:E.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`rounded-xl border border-edge bg-surface-base/40 p-3 text-left hover:bg-surface-hover`,onClick:()=>n(`/workflows/runs/${e.id}${u?`?agentId=${encodeURIComponent(u)}`:``}`),children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,Z.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:i.status[e.status]})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:new Intl.DateTimeFormat(l,{dateStyle:`medium`,timeStyle:`short`}).format(e.createdAtMs)})]},e.id))}):(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r===`zh`?`还没有运行记录。`:`No runs yet.`})]})]})})}function dg(){let{definitionId:e}=c(),[t]=a(),n=o(),r=p(e=>e.language),{ownerAgentId:i}=ag(),s=t.get(`copy`)?.trim()||void 0,l=t.get(`repairRun`)?.trim()||void 0,{definition:u,definitions:d,loading:f,upsertDefinition:m,refreshDefinitions:g}=sg(e??s),_=h(l&&i?[`workflow-repair-run`,l,i]:null,()=>_e(l,{ownerAgentId:i}),{revalidateOnFocus:!1}),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),w=(0,Y.useMemo)(()=>d.map(e=>e.name),[d]),T=(0,Y.useMemo)(()=>Fm(`my_workflow`,w),[w]),E=(0,Y.useMemo)(()=>{if(!u)return null;let t=e&&u.metadata.source===`user`?`edit`:`copy`,n=(_.data?.nodes.filter(e=>e.status===`error`)??[]).map(e=>r===`zh`?`${e.title}:${e.error??`执行失败`}`:`${e.title}: ${e.error??`execution failed`}`).join(r===`zh`?`;`:`; `)||_.data?.run.error?.message||void 0,i=l&&_.data?r===`zh`?`修复这次运行中的失败步骤,并保持原始目标不变:${n??`请根据运行记录定位失败原因`}`:`Repair the failed steps from this run while preserving the original goal: ${n??`use the run record to identify the failure`}`:void 0;return{mode:t,name:t===`edit`?u.name:mg(u.name,d),graph:structuredClone(u.graph),manifest:rh(u),baseRevision:t===`edit`?u.revision:0,sourceTitle:u.title,repairPrompt:i}},[u,e,d,r,_.data?.nodes,l]),D=(0,Y.useCallback)(async e=>{y(!0),x(null),C(null);try{let t=await G(e.name,e.graph,e.manifest,e.expectedRevision);return await m(t),n(`/workflows/${t.id}/edit`,{replace:!0}),t}catch(e){let t=Im(e);C(t),t||x(e instanceof Error?e.message:String(e))}finally{y(!1)}},[n,m]),O=(0,Y.useCallback)(async e=>{y(!0),x(null),C(null);try{let t=await G(e.name,e.graph,e.manifest,e.expectedRevision);await m(t),n(`/workflows/runs/${(await Je({definitionId:t.id,goal:e.goal,input:{goal:e.goal},agentId:i})).runId}${i?`?agentId=${encodeURIComponent(i)}`:``}`)}catch(e){let t=Im(e);throw C(t),t||x(e instanceof Error?e.message:String(e)),e}finally{y(!1)}},[n,i,m]);return f?(0,Z.jsx)(hg,{}):e&&!u?(0,Z.jsx)(gg,{message:r===`zh`?`没有找到这个工作流`:`Workflow not found`}):(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[b?(0,Z.jsx)(`div`,{className:`border-b border-danger/30 bg-danger/5 px-4 py-2 text-sm text-danger`,children:b}):null,(0,Z.jsx)(Rm,{language:r,ownerAgentId:i,saving:v,initialDraft:E,initialName:T,existingNames:w,saveConflict:S,onSave:D,onSaveAndStart:O,onClearSaveConflict:()=>C(null),onReloadLatest:()=>{C(null),x(null),g()}})]})}function fg(){let e=(0,X.c)(53),{runId:t}=c(),n=o(),r=p(pg),i=r===`zh`?`zh-CN`:`en-US`,{ownerAgentId:a}=ag(),s;e[0]===a?s=e[1]:(s={ownerAgentId:a},e[0]=a,e[1]=s);let l=ve(t,s),[u,d]=(0,Y.useState)(`process`),f=(0,Y.useRef)(!0),m;e[2]!==l.view?.run.metadata?.replay||e[3]!==a||e[4]!==t?(m=l.view?.run.metadata?.replay&&t?[`workflow-run-page-comparison`,t,a]:null,e[2]=l.view?.run.metadata?.replay,e[3]=a,e[4]=t,e[5]=m):m=e[5];let g;e[6]!==a||e[7]!==t?(g=()=>Fe(t,{ownerAgentId:a}),e[6]=a,e[7]=t,e[8]=g):g=e[8];let _;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!1},e[9]=_):_=e[9];let v=h(m,g,_),y;e[10]===l.view?y=e[11]:(y=l.view?x.has(l.view.run.status):!0,e[10]=l.view,e[11]=y);let b=y,S,C;e[12]===b?(S=e[13],C=e[14]):(S=()=>{f.current&&!b&&d(`result`),f.current=b},C=[b],e[12]=b,e[13]=S,e[14]=C),(0,Y.useEffect)(S,C);let w;e[15]!==n||e[16]!==a?(w=e=>{n(`/workflows/runs/${e}${a?`?agentId=${encodeURIComponent(a)}`:``}`)},e[15]=n,e[16]=a,e[17]=w):w=e[17];let T=w,E;e[18]!==T||e[19]!==a||e[20]!==t?(E=async()=>{t&&T((await fe(t,{ownerAgentId:a})).runId)},e[18]=T,e[19]=a,e[20]=t,e[21]=E):E=e[21];let D=E,O;e[22]!==T||e[23]!==a||e[24]!==t?(O=async e=>{t&&T((await qe(t,e,{ownerAgentId:a})).runId)},e[22]=T,e[23]=a,e[24]=t,e[25]=O):O=e[25];let k=O;if(!l.loading&&!l.view){let t=l.error instanceof Error?l.error.message:r===`zh`?`没有找到这次运行`:`Workflow run not found`,n;return e[26]===t?n=e[27]:(n=(0,Z.jsx)(gg,{message:t}),e[26]=t,e[27]=n),n}let A;e[28]!==l||e[29]!==a||e[30]!==t?(A=()=>t&&void pe(t,{ownerAgentId:a}).then(()=>l.mutate()),e[28]=l,e[29]=a,e[30]=t,e[31]=A):A=e[31];let j;e[32]===D?j=e[33]:(j=()=>void D(),e[32]=D,e[33]=j);let M;e[34]===k?M=e[35]:(M=e=>void k(e),e[34]=k,e[35]=M);let N;e[36]!==l.view||e[37]!==n||e[38]!==a?(N=l.view?()=>n(`/workflows/${l.view.run.definitionId}/edit?repairRun=${encodeURIComponent(l.view.run.id)}${a?`&agentId=${encodeURIComponent(a)}`:``}`):void 0,e[36]=l.view,e[37]=n,e[38]=a,e[39]=N):N=e[39];let P;return e[40]!==u||e[41]!==v.data||e[42]!==r||e[43]!==l.loading||e[44]!==l.view||e[45]!==i||e[46]!==T||e[47]!==a||e[48]!==A||e[49]!==j||e[50]!==M||e[51]!==N?(P=(0,Z.jsx)(Eh,{view:l.view,comparison:v.data,loading:l.loading,language:r,localeTag:i,activeTab:u,onTabChange:d,onCancel:A,onRetry:j,onReplay:M,onOpenRunId:T,ownerAgentId:a,onRepairWorkflow:N}),e[40]=u,e[41]=v.data,e[42]=r,e[43]=l.loading,e[44]=l.view,e[45]=i,e[46]=T,e[47]=a,e[48]=A,e[49]=j,e[50]=M,e[51]=N,e[52]=P):P=e[52],P}function pg(e){return e.language}function mg(e,t){let n=new Set(t.map(e=>e.name)),r=`${e}_copy`;if(!n.has(r))return r;for(let e=2;e<100;e+=1){let t=`${r}_${e}`;if(!n.has(t))return t}return`${r}_${Date.now()}`}function hg(){let e=(0,X.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Z.jsx)(`main`,{className:`min-h-0 flex-1 overflow-auto bg-surface-panel p-5`,"aria-busy":!0,children:(0,Z.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl`,children:[(0,Z.jsx)(q,{className:`h-5 w-36`}),(0,Z.jsx)(q,{className:`mt-5 h-9 w-80 max-w-full`}),(0,Z.jsx)(q,{className:`mt-4 h-[28rem] rounded-xl`})]})}),e[0]=t):t=e[0],t}function gg(e){let t=(0,X.c)(5),{message:n}=e,r;t[0]===n?r=t[1]:(r=(0,Z.jsx)(`p`,{className:`text-sm text-danger`,children:n}),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Z.jsx)(J,{asChild:!0,variant:`secondary`,className:`mt-4`,children:(0,Z.jsxs)(s,{to:`/workflows`,children:[(0,Z.jsx)(be,{className:`size-4`}),`Back`]})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Z.jsx)(`main`,{className:`flex min-h-0 flex-1 items-center justify-center bg-surface-panel p-6 text-center`,children:(0,Z.jsxs)(`div`,{children:[r,i]})}),t[3]=r,t[4]=a),a}export{ug as WorkflowDetailPage,dg as WorkflowEditorPage,fg as WorkflowRunPage,cn as WorkflowsPage};
|