@cuongtran001/kanna 1.97.0 → 1.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/client/assets/{BoardsPage-D3TlgAZ_.js → BoardsPage-DnaQWbzp.js} +1 -1
  2. package/dist/client/assets/{BoardsRoutePage-VkxV-IFk.js → BoardsRoutePage-DmOwWLci.js} +1 -1
  3. package/dist/client/assets/{ChatPage-Dscf_7rF.js → ChatPage-k3TqHkXQ.js} +7 -7
  4. package/dist/client/assets/{CronJobsPage-CRkUkXat.js → CronJobsPage-DVHuxrYY.js} +1 -1
  5. package/dist/client/assets/{FilePreviewSheet-DeowWf5y.js → FilePreviewSheet-BoLr9WcJ.js} +1 -1
  6. package/dist/client/assets/{FlowSurface-CWsaGLfa.js → FlowSurface-B_DV7uxh.js} +1 -1
  7. package/dist/client/assets/{GenUIBlock-Bv-OFgT5.js → GenUIBlock-BKFWGRt3.js} +2 -2
  8. package/dist/client/assets/{InboundHandlerFields-Bz-crPWC.js → InboundHandlerFields-CydmPZnR.js} +1 -1
  9. package/dist/client/assets/InboxPage-DEZGMwaM.js +1 -0
  10. package/dist/client/assets/{LocalProjectsPage-Lx4uBsJV.js → LocalProjectsPage-B4_oDIwv.js} +1 -1
  11. package/dist/client/assets/SettingsPage-2kslBZYC.js +17 -0
  12. package/dist/client/assets/{StackBoardsRoutePage-Uy6E-3Gl.js → StackBoardsRoutePage-B5OmiXfm.js} +1 -1
  13. package/dist/client/assets/{ToolCallMessage-DEfxdq5H.js → ToolCallMessage-DWDXqIxN.js} +1 -1
  14. package/dist/client/assets/{VChartSurface-UFK0UlX-.js → VChartSurface-Cno4to2v.js} +1 -1
  15. package/dist/client/assets/{WebhooksPage-6ALLVh_l.js → WebhooksPage-CDi0sjp_.js} +1 -1
  16. package/dist/client/assets/{WorkflowsPage-1i5hmCxm.js → WorkflowsPage-B7dDRnom.js} +1 -1
  17. package/dist/client/assets/{appSettingsStore-DhpIEBz2.js → appSettingsStore-CTO4ww2r.js} +1 -1
  18. package/dist/client/assets/{arrow-left-Bto85Swe.js → arrow-left-DY159_z6.js} +1 -1
  19. package/dist/client/assets/{beacon-alias-HmDCskK6.js → beacon-alias-Ck8eEBJd.js} +3 -3
  20. package/dist/client/assets/{code-xml-DVVP_fVN.js → code-xml-B8fqYkTN.js} +1 -1
  21. package/dist/client/assets/{commandFeedback-2cA8d_WY.js → commandFeedback-CS3oraa4.js} +1 -1
  22. package/dist/client/assets/{contextWindow-B9Tu0rKj.js → contextWindow-CZxN8wf7.js} +1 -1
  23. package/dist/client/assets/{copyFeedbackStore-CNP3tyq0.js → copyFeedbackStore-D9RGdNO2.js} +1 -1
  24. package/dist/client/assets/{createScopedStore-jAn6kJBy.js → createScopedStore-kwtX2Lxk.js} +1 -1
  25. package/dist/client/assets/{cronJobsStore-OUyVs58Z.js → cronJobsStore-D5PZ7m75.js} +1 -1
  26. package/dist/client/assets/{file-plus-corner-DY_1K1Ne.js → file-plus-corner-By8hvvBQ.js} +1 -1
  27. package/dist/client/assets/inboxStore-BRxIHKG-.js +1 -0
  28. package/dist/client/assets/{index-DUJdXxNz.js → index-Cj9-ngio.js} +14 -14
  29. package/dist/client/assets/index-QA9eWHUp.css +1 -0
  30. package/dist/client/assets/{info-BcA9_4Qg.js → info-DsAB2UYg.js} +1 -1
  31. package/dist/client/assets/{input-DbE6EzUB.js → input-CqI_XUed.js} +1 -1
  32. package/dist/client/assets/{log-CFGrfkV1.js → log-BIDtX3w_.js} +1 -1
  33. package/dist/client/assets/minus-BGJNC3Ic.js +1 -0
  34. package/dist/client/assets/{monitor-Bd61vIbY.js → monitor-CwxYaMWD.js} +1 -1
  35. package/dist/client/assets/{pencil-Kx3rEkBI.js → pencil-BYKvQLYj.js} +1 -1
  36. package/dist/client/assets/{pendingActionsStore-C6o78Bki.js → pendingActionsStore-CwpO00OX.js} +1 -1
  37. package/dist/client/assets/{plus-D5yDJAY3.js → plus-CMObx8HU.js} +1 -1
  38. package/dist/client/assets/{refresh-cw-CxKjA56k.js → refresh-cw-CfJKJFhW.js} +1 -1
  39. package/dist/client/assets/runDetached-Bhk-au-L.js +1 -0
  40. package/dist/client/assets/{search-mHZVZKtE.js → search-OIXiWxsb.js} +1 -1
  41. package/dist/client/assets/{searchable-select-B47fAmOU.js → searchable-select-CUXvl9dS.js} +1 -1
  42. package/dist/client/assets/{segmented-control--alEtfTe.js → segmented-control-DOAxfKHm.js} +1 -1
  43. package/dist/client/assets/{select-BO0FDRBe.js → select-DwkFJBAi.js} +1 -1
  44. package/dist/client/assets/{settings-header-button-j3Rd0uOx.js → settings-header-button-jFUsXQeP.js} +1 -1
  45. package/dist/client/assets/{state-mark-Wim8WKu4.js → state-mark-CvNhMI9T.js} +1 -1
  46. package/dist/client/assets/{terminal-BLkQOd9o.js → terminal-NlVH8D6Q.js} +1 -1
  47. package/dist/client/assets/{timer.adapter-DTTP0Zuq.js → timer.adapter-Bj98pz1I.js} +1 -1
  48. package/dist/client/assets/{tools-BxqpIPAt.js → tools-CiQVf6uy.js} +1 -1
  49. package/dist/client/assets/{triangle-alert-B3zlPujO.js → triangle-alert-0j3N0C0M.js} +1 -1
  50. package/dist/client/assets/{useAppGlobalState-BkMT4XZb.js → useAppGlobalState-0b_GMkje.js} +1 -1
  51. package/dist/client/assets/{useProviderCatalog-BlO4bNcc.js → useProviderCatalog-B-Vb7xM1.js} +1 -1
  52. package/dist/client/assets/{useTheme-DqpsYqBt.js → useTheme-bl0TpEGW.js} +1 -1
  53. package/dist/client/index.html +32 -32
  54. package/package.json +1 -1
  55. package/src/server/inbound/inbox-reply.test.ts +1 -1
  56. package/src/server/inbound/referenced-chat-ids.test.ts +55 -0
  57. package/src/server/inbound/referenced-chat-ids.ts +22 -0
  58. package/src/server/inbox/inbox-boot.test.ts +64 -1
  59. package/src/server/inbox/inbox-boot.ts +24 -4
  60. package/src/server/inbox/inbox-outbox.test.ts +229 -0
  61. package/src/server/inbox/inbox-outbox.ts +107 -0
  62. package/src/server/inbox/inbox-projection.ts +32 -0
  63. package/src/server/inbox/inbox-registry.ts +56 -2
  64. package/src/server/mcp-sources/mcp-source-client.adapter.test.ts +38 -1
  65. package/src/server/mcp-sources/mcp-source-client.adapter.ts +13 -7
  66. package/src/server/mcp-sources/mcp-source-runner.test.ts +69 -0
  67. package/src/server/mcp-sources/mcp-source-runner.ts +67 -12
  68. package/src/server/mcp-sources/mcp-sources-boot.test.ts +11 -0
  69. package/src/server/mcp-sources/mcp-sources-boot.ts +6 -1
  70. package/src/server/mcp-sources-settings.test.ts +42 -1
  71. package/src/server/mcp-sources-settings.ts +25 -10
  72. package/src/server/push/push-manager.test.ts +1 -0
  73. package/src/server/server.ts +11 -2
  74. package/src/server/ws-router-abandoned-chat.test.ts +17 -1
  75. package/src/server/ws-router-broadcast.ts +3 -1
  76. package/src/server/ws-router-command-results.test.ts +6 -2
  77. package/src/server/ws-router-inbox.ts +41 -13
  78. package/src/server/ws-router.ts +7 -6
  79. package/src/shared/commands/inbox.ts +10 -2
  80. package/src/shared/commands/results/inbox.ts +8 -0
  81. package/src/shared/inbound/reply-args.test.ts +45 -0
  82. package/src/shared/inbound/reply-args.ts +48 -0
  83. package/src/shared/inbound/template.ts +9 -0
  84. package/src/shared/inbox/events.ts +38 -1
  85. package/src/shared/inbox/policy.test.ts +1 -0
  86. package/src/shared/inbox/policy.ts +23 -1
  87. package/src/shared/inbox/types.schema.ts +15 -0
  88. package/src/shared/inbox/types.ts +24 -0
  89. package/src/shared/mcp-sources/presets.ts +10 -2
  90. package/src/shared/mcp-sources/types.schema.ts +15 -1
  91. package/src/shared/mcp-sources/types.ts +17 -0
  92. package/src/shared/mcp-sources/validate.test.ts +9 -0
  93. package/src/shared/mcp-sources/validate.ts +39 -2
  94. package/dist/client/assets/InboxPage-Cx2I-D9G.js +0 -1
  95. package/dist/client/assets/SettingsPage-QUQTA-qY.js +0 -17
  96. package/dist/client/assets/inboxStore-q-JHTh--.js +0 -1
  97. package/dist/client/assets/index-D_XO3fZ-.css +0 -1
  98. package/dist/client/assets/minus-jIhdwm1f.js +0 -1
  99. package/dist/client/assets/runDetached-138oevj9.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{n as i}from"./pathUtils-DTWwEzHK.js";import{_ as a}from"./state-mark-Wim8WKu4.js";import{t as o}from"./cronJobsStore-OUyVs58Z.js";import{Kt as s,ln as c,mn as l}from"./index-DUJdXxNz.js";import{o as u}from"./ChatPage-Dscf_7rF.js";var d=e(t(),1),f=e(r(),1);function p(){let e=o(e=>e.rows),t=(0,d.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{projectPath:n.projectPath,rows:[]};e.rows.push(n),t.set(n.projectId,e)}return[...t.values()]},[e]);return(0,f.jsx)(`div`,{className:s,children:(0,f.jsxs)(`div`,{className:`mx-auto w-full max-w-[900px] px-4 py-8`,children:[(0,f.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-lg font-semibold text-foreground`,children:[(0,f.jsx)(l,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),`Cron jobs`,(0,f.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground tabular-nums`,children:[e.length,` armed`]})]}),e.length===0?(0,f.jsxs)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:[`No cron jobs armed anywhere. Arm one from any chat with`,` `,(0,f.jsx)(`code`,{className:`font-mono text-xs`,children:`/cron <instruction> inline|spawn <schedule>`}),`.`]}):(0,f.jsx)(`div`,{className:`mt-6 space-y-6`,children:t.map(e=>(0,f.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,f.jsxs)(`h2`,{className:`border-b border-border bg-card p-3 px-4 text-sm font-medium text-foreground`,children:[i(e.projectPath),(0,f.jsx)(`span`,{className:`ml-2 font-mono text-xs font-normal text-muted-foreground`,children:e.projectPath})]}),(0,f.jsx)(`div`,{children:e.rows.map((t,r)=>(0,f.jsx)(u,{job:t.job,chatId:t.chatId,divider:r<e.rows.length-1,trailing:(0,f.jsxs)(n,{to:a(t.chatId),className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,f.jsx)(c,{className:`h-3 w-3`,"aria-hidden":`true`}),t.chatTitle||`Open chat`]})},`${t.chatId} ${t.job.jobId}`))})]},e.projectPath))})]})})}export{p as CronJobsPage};
1
+ import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{n}from"./chunk-6KYCQHYJ-C0N1h4Su.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{n as i}from"./pathUtils-DTWwEzHK.js";import{_ as a}from"./state-mark-CvNhMI9T.js";import{t as o}from"./cronJobsStore-D5PZ7m75.js";import{Yt as s,_n as c,fn as l}from"./index-Cj9-ngio.js";import{o as u}from"./ChatPage-k3TqHkXQ.js";var d=e(t(),1),f=e(r(),1);function p(){let e=o(e=>e.rows),t=(0,d.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{projectPath:n.projectPath,rows:[]};e.rows.push(n),t.set(n.projectId,e)}return[...t.values()]},[e]);return(0,f.jsx)(`div`,{className:s,children:(0,f.jsxs)(`div`,{className:`mx-auto w-full max-w-[900px] px-4 py-8`,children:[(0,f.jsxs)(`h1`,{className:`flex items-center gap-2.5 text-lg font-semibold text-foreground`,children:[(0,f.jsx)(c,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),`Cron jobs`,(0,f.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground tabular-nums`,children:[e.length,` armed`]})]}),e.length===0?(0,f.jsxs)(`p`,{className:`mt-6 text-sm text-muted-foreground`,children:[`No cron jobs armed anywhere. Arm one from any chat with`,` `,(0,f.jsx)(`code`,{className:`font-mono text-xs`,children:`/cron <instruction> inline|spawn <schedule>`}),`.`]}):(0,f.jsx)(`div`,{className:`mt-6 space-y-6`,children:t.map(e=>(0,f.jsxs)(`div`,{className:`rounded-2xl border border-border overflow-hidden`,children:[(0,f.jsxs)(`h2`,{className:`border-b border-border bg-card p-3 px-4 text-sm font-medium text-foreground`,children:[i(e.projectPath),(0,f.jsx)(`span`,{className:`ml-2 font-mono text-xs font-normal text-muted-foreground`,children:e.projectPath})]}),(0,f.jsx)(`div`,{children:e.rows.map((t,r)=>(0,f.jsx)(u,{job:t.job,chatId:t.chatId,divider:r<e.rows.length-1,trailing:(0,f.jsxs)(n,{to:a(t.chatId),className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,f.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),t.chatTitle||`Open chat`]})},`${t.chatId} ${t.job.jobId}`))})]},e.projectPath))})]})})}export{p as CronJobsPage};
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-p9MbdTIm.js","assets/preload-helper-BLdHbfdN.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BGvpoTgt.js","assets/rolldown-runtime-BCiCTKAo.js","assets/src-C_gRsKqw.js","assets/chunk-DSNLSHJZ-D5Iibx2y.js","assets/chunk-7S6XSTFO-pfhMrhA0.js","assets/dist-DGs_yUrP.js","assets/chunk-YZO67HFG-asNK6fGE.js","assets/chunk-AQDTSKZB-Mur9zlR5.js","assets/chunk-DUW6YSOI-Dgx8z5s3.js","assets/chunk-UHW7PFBP-Dyj--6BQ.js","assets/chunk-HAGFOTED--TH6w7Tu.js","assets/chunk-J5ZVWO5B-oDCd-gWO.js","assets/rough.esm-Dy-Kn_BL.js","assets/chunk-ZAUX2LTX-9rUW8M31.js","assets/chunk-WQQL4CDK-Qu-ToZ1a.js","assets/line-BwNeh2p4.js","assets/path-fybaL0A-.js","assets/array-BifhSqXX.js","assets/chunk-HNE4Q36P-pxtEEFeh.js"])))=>i.map(i=>d[i]);
2
- import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{t as n}from"./react-dom-2r3XOwTS.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{f as i,h as a,l as o,n as s,r as c,t as l}from"./pendingActionsStore-C6o78Bki.js";import{Ct as u,L as d,_ as f,b as p,c as m,d as h,f as g,g as _,h as v,j as y,l as b,o as x,p as S,s as ee,t as te,u as ne,v as re,vt as C,wt as ie,y as ae}from"./beacon-alias-HmDCskK6.js";import{a as w,i as oe,o as T,r as se}from"./copyFeedbackStore-CNP3tyq0.js";import{n as ce,t as le}from"./code-xml-DVVP_fVN.js";import{t as ue}from"./minus-jIhdwm1f.js";import{t as de}from"./plus-D5yDJAY3.js";import{t as fe}from"./refresh-cw-CxKjA56k.js";import{t as pe}from"./triangle-alert-B3zlPujO.js";import{a as me,g as he,i as ge,n as _e,t as ve,u as ye}from"./timer.adapter-DTTP0Zuq.js";import{a as be,i as xe}from"./log-CFGrfkV1.js";import{n as E,t as D}from"./createScopedStore-jAn6kJBy.js";import{t as Se}from"./preload-helper-BLdHbfdN.js";import{r as Ce}from"./useTheme-DqpsYqBt.js";import{c as we,f as Te,i as Ee,n as De,r as Oe,t as ke,u as Ae}from"./pathUtils-DTWwEzHK.js";import{t as O}from"./runDetached-138oevj9.js";import{t as k}from"./dom.adapter-C26vNdMA.js";import"./storage.adapter-DafyA8In.js";var je={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};je.node;var Me=a(je),Ne={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};Ne.node;var Pe=a(Ne),Fe={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};Fe.node;var Ie=a(Fe),Le={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};Le.node;var Re=a(Le),ze={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};ze.node;var Be=a(ze),Ve={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};Ve.node;var He=a(Ve),Ue={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Ue.node;var We=a(Ue),Ge={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Ge.node;var Ke=a(Ge),qe={name:`file-video-camera`,size:24,node:[[`path`,{d:`M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2`,key:`jrl274`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m10 17.843 3.033-1.755a.64.64 0 0 1 .967.56v4.704a.65.65 0 0 1-.967.56L10 20.157`,key:`17aeo9`}],[`rect`,{width:`7`,height:`6`,x:`3`,y:`16`,rx:`1`,key:`s27ndx`}]],aliases:[`file-video-2`]};qe.node;var Je=a(qe),Ye={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Ye.node;var Xe=a(Ye),Ze={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};Ze.node;var Qe=a(Ze),$e={name:`receipt-text`,size:24,node:[[`path`,{d:`M13 16H8`,key:`wsln4y`}],[`path`,{d:`M14 8H8`,key:`1l3xfs`}],[`path`,{d:`M16 12H8`,key:`1fr5h0`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};$e.node;var et=a($e),tt={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};tt.node;var nt=a(tt),rt={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};rt.node;var it=a(rt),at={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};at.node;var ot=a(at),st={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};st.node;var ct=a(st);async function lt(e,t={}){let n=t.http??u;try{let r=await n.head(e,{signal:t.signal});return r.ok?{kind:`ready`,mimeType:r.headers[`content-type`]?.split(`;`)[0]?.trim()??`application/octet-stream`,size:Number.parseInt(r.headers[`content-length`]??`0`,10)||0}:r.status===404?{kind:`missing`}:{kind:`error`}}catch{return{kind:`error`}}}async function ut(e,t){let[n=``]=e.split(`?`),r=Te(Ae.uploadContent.path,n);if(!r)throw Error(`Not an upload content URL: ${e}`);if(!t)throw Error(`Not connected to the server`);await t.command({type:`upload.delete`,projectId:r.projectId,storedName:r.storedName})}async function dt(e,t,n={}){let{body:r,ok:i,status:a}=await(n.http??u).streamBytes(e,{signal:n.signal,headers:{Accept:`text/plain, text/markdown, application/json, text/csv, text/tab-separated-values, */*`}});if(!i)throw Error(`Preview request failed with status ${a}`);if(!r)return{content:``,truncated:!1};let o=r.getReader(),s=[],c=0,l=!1;for(;;){let{done:e,value:n}=await o.read();if(e)break;if(!n)continue;let r=t-c;if(r<=0){l=!0,await o.cancel();break}if(n.byteLength>r){s.push(n.slice(0,r)),c+=r,l=!0,await o.cancel();break}s.push(n),c+=n.byteLength}let d=new Uint8Array(c),f=0;for(let e of s)d.set(e,f),f+=e.byteLength;return{content:new TextDecoder().decode(d),truncated:l}}var ft=1048576,pt=new Set(`.c,.cc,.cfg,.conf,.cpp,.cs,.css,.env,.go,.graphql,.h,.hpp,.html,.ini,.java,.js,.jsonc,.jsx,.kt,.lua,.mjs,.php,.pl,.properties,.py,.rb,.rs,.scss,.sh,.sql,.swift,.toml,.ts,.tsx,.txt,.vue,.xml,.yaml,.yml,.zsh`.split(`,`)),mt=new Set([`.7z`,`.bz2`,`.gz`,`.rar`,`.tar`,`.tgz`,`.xz`,`.zip`]),ht=new Set([`.aac`,`.flac`,`.m4a`,`.mp3`,`.ogg`,`.wav`]),gt=new Set([`.avi`,`.m4v`,`.mov`,`.mp4`,`.mkv`,`.webm`]);function A(e){let t=e.mimeType.toLowerCase(),n=N(e.displayName);return t.startsWith(`image/`)?{kind:`image`,openInNewTab:!1}:t===`application/pdf`?{kind:`pdf`,openInNewTab:!1}:t===`application/json`?(e.size??0)<=262144?{kind:`json`,openInNewTab:!1}:{kind:`external`,openInNewTab:!0}:Et(e)?{kind:`markdown`,openInNewTab:!1}:t===`text/csv`||t===`text/tab-separated-values`?{kind:`table`,openInNewTab:!1}:t.startsWith(`audio/`)||ht.has(n)?{kind:`audio`,openInNewTab:!1}:t.startsWith(`video/`)||gt.has(n)?{kind:`video`,openInNewTab:!1}:t.startsWith(`text/`)||pt.has(n)?{kind:`text`,openInNewTab:!1}:{kind:`external`,openInNewTab:!0}}var _t={image:`Image`,pdf:`PDF`,markdown:`Markdown`,json:`JSON`,table:`Table`,code:`Source`,text:`Text`,archive:`Archive`,audio:`Audio`,video:`Video`,file:`File`,mermaid:`Diagram`};function vt(e,t){if(e===`archive`&&t){if(t.includes(`zip`))return`ZIP archive`;if(t.includes(`gzip`))return`Gzip archive`;if(t.includes(`x-tar`))return`Tar archive`}if(e===`image`&&t){let e=t.split(`/`)[1]?.split(`;`)[0]?.toUpperCase();if(e)return`${e} image`}return _t[e]}function j(e){let t=M(e);return{iconKind:t,friendlyType:vt(t,e.mimeType),sizeLabel:e.size!==void 0&&e.size>0?x(e.size):null}}function yt(e,t,n){return[e,t,n.friendlyType,n.sizeLabel].filter(e=>!!e).join(`, `)}function M(e){let t=e.mimeType.toLowerCase(),n=N(e.displayName);return t.startsWith(`image/`)?`image`:t===`application/pdf`||n===`.pdf`?`pdf`:t===`application/json`||n===`.json`||n===`.jsonc`?`json`:Et(e)?`markdown`:t===`text/csv`||t===`text/tab-separated-values`||n===`.csv`||n===`.tsv`?`table`:t.startsWith(`audio/`)||ht.has(n)?`audio`:t.startsWith(`video/`)||gt.has(n)?`video`:t.includes(`zip`)||t.includes(`archive`)||mt.has(n)?`archive`:Ot(e)?`mermaid`:pt.has(n)?n===`.txt`?`text`:`code`:t.startsWith(`text/`)?`text`:`file`}async function bt(e,t,n={}){let r=n.dom??k,i=n.timer??ve,a=typeof AbortController<`u`?new AbortController:null,o=a?i.setTimeout(()=>a.abort(`preview-timeout`),15e3):null;try{return await dt(r.resolveUrl(e),t,{signal:a?.signal,http:n.http})}catch(e){throw kt(be(e))?Error(`Preview request timed out`,{cause:e}):e}finally{o!==null&&i.clearTimeout(o)}}function xt(e){try{return`${JSON.stringify(JSON.parse(e),null,2)}\n`}catch{return e}}function St(e,t){let n=At(e,t),r=n.length,i=n.reduce((e,t)=>Math.max(e,t.length),0),a=r>200,o=i>20;return{rows:n.slice(0,200).map(e=>e.slice(0,20)),rowCount:r,columnCount:i,truncatedRows:a,truncatedColumns:o}}function N(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Ct(e){return e.split(`;`)[0]?.trim().toLowerCase()??``}function wt(e){return[N(e.displayName),N(e.relativePath??``)]}var Tt=new Set([`text/markdown`,`text/x-markdown`]);function Et(e){return Tt.has(Ct(e.mimeType))?!0:wt(e).includes(`.md`)}var Dt=new Set([`.mmd`,`.mermaid`]);function Ot(e){return Ct(e.mimeType)===`text/vnd.mermaid`||wt(e).some(e=>Dt.has(e))}function kt(e){return e instanceof DOMException&&e.name===`AbortError`||e.message===`preview-timeout`}function At(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;o<e.length;o+=1){let s=e[o],c=e[o+1];s===`"`?a&&c===`"`?(i+=`"`,o+=1):a=!a:!a&&s===t?(r.push(i),i=``):!a&&(s===`
2
+ import{o as e}from"./rolldown-runtime-BCiCTKAo.js";import{t}from"./react-BWPDF9mI.js";import{t as n}from"./react-dom-2r3XOwTS.js";import{t as r}from"./jsx-runtime-BB9-612F.js";import{f as i,h as a,l as o,n as s,r as c,t as l}from"./pendingActionsStore-CwpO00OX.js";import{Ct as u,L as d,_ as f,b as p,c as m,d as h,f as g,g as _,h as v,j as y,l as b,o as x,p as S,s as ee,t as te,u as ne,v as re,vt as C,wt as ie,y as ae}from"./beacon-alias-Ck8eEBJd.js";import{a as w,i as oe,o as T,r as se}from"./copyFeedbackStore-D9RGdNO2.js";import{n as ce,t as le}from"./code-xml-B8fqYkTN.js";import{t as ue}from"./minus-BGJNC3Ic.js";import{t as de}from"./plus-CMObx8HU.js";import{t as fe}from"./refresh-cw-CfJKJFhW.js";import{t as pe}from"./triangle-alert-0j3N0C0M.js";import{a as me,g as he,i as ge,n as _e,t as ve,u as ye}from"./timer.adapter-Bj98pz1I.js";import{a as be,i as xe}from"./log-BIDtX3w_.js";import{n as E,t as D}from"./createScopedStore-kwtX2Lxk.js";import{t as Se}from"./preload-helper-BLdHbfdN.js";import{r as Ce}from"./useTheme-bl0TpEGW.js";import{c as we,f as Te,i as Ee,n as De,r as Oe,t as ke,u as Ae}from"./pathUtils-DTWwEzHK.js";import{t as O}from"./runDetached-Bhk-au-L.js";import{t as k}from"./dom.adapter-C26vNdMA.js";import"./storage.adapter-DafyA8In.js";var je={name:`download`,size:24,node:[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]};je.node;var Me=a(je),Ne={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};Ne.node;var Pe=a(Ne),Fe={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};Fe.node;var Ie=a(Fe),Le={name:`file-code-corner`,size:24,node:[[`path`,{d:`M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35`,key:`1wthlu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m5 16-3 3 3 3`,key:`331omg`}],[`path`,{d:`m9 22 3-3-3-3`,key:`lsp7cz`}]],aliases:[`file-code-2`]};Le.node;var Re=a(Le),ze={name:`file-headphone`,size:24,node:[[`path`,{d:`M4 6.835V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-.343`,key:`1vfytu`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M2 19a2 2 0 0 1 4 0v1a2 2 0 0 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 0 1-4 0v-1a2 2 0 0 1 4 0`,key:`1etmh7`}]],aliases:[`file-audio`,`file-audio-2`]};ze.node;var Be=a(ze),Ve={name:`file-image`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`10`,cy:`12`,r:`2`,key:`737tya`}],[`path`,{d:`m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22`,key:`wt3hpn`}]]};Ve.node;var He=a(Ve),Ue={name:`file-spreadsheet`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 13h2`,key:`yr2amv`}],[`path`,{d:`M14 13h2`,key:`un5t4a`}],[`path`,{d:`M8 17h2`,key:`2yhykz`}],[`path`,{d:`M14 17h2`,key:`10kma7`}]]};Ue.node;var We=a(Ue),Ge={name:`file-text`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]};Ge.node;var Ke=a(Ge),qe={name:`file-video-camera`,size:24,node:[[`path`,{d:`M4 12V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2`,key:`jrl274`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m10 17.843 3.033-1.755a.64.64 0 0 1 .967.56v4.704a.65.65 0 0 1-.967.56L10 20.157`,key:`17aeo9`}],[`rect`,{width:`7`,height:`6`,x:`3`,y:`16`,rx:`1`,key:`s27ndx`}]],aliases:[`file-video-2`]};qe.node;var Je=a(qe),Ye={name:`file`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]};Ye.node;var Xe=a(Ye),Ze={name:`maximize-2`,size:24,node:[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]};Ze.node;var Qe=a(Ze),$e={name:`receipt-text`,size:24,node:[[`path`,{d:`M13 16H8`,key:`wsln4y`}],[`path`,{d:`M14 8H8`,key:`1l3xfs`}],[`path`,{d:`M16 12H8`,key:`1fr5h0`}],[`path`,{d:`M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z`,key:`ycz6yz`}]]};$e.node;var et=a($e),tt={name:`rotate-ccw`,size:24,node:[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]};tt.node;var nt=a(tt),rt={name:`scroll-text`,size:24,node:[[`path`,{d:`M15 12h-5`,key:`r7krc0`}],[`path`,{d:`M15 8h-5`,key:`1khuty`}],[`path`,{d:`M19 17V5a2 2 0 0 0-2-2H4`,key:`zz82l3`}],[`path`,{d:`M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3`,key:`1ph1d7`}]]};rt.node;var it=a(rt),at={name:`share-2`,size:24,node:[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]};at.node;var ot=a(at),st={name:`wrench`,size:24,node:[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]};st.node;var ct=a(st);async function lt(e,t={}){let n=t.http??u;try{let r=await n.head(e,{signal:t.signal});return r.ok?{kind:`ready`,mimeType:r.headers[`content-type`]?.split(`;`)[0]?.trim()??`application/octet-stream`,size:Number.parseInt(r.headers[`content-length`]??`0`,10)||0}:r.status===404?{kind:`missing`}:{kind:`error`}}catch{return{kind:`error`}}}async function ut(e,t){let[n=``]=e.split(`?`),r=Te(Ae.uploadContent.path,n);if(!r)throw Error(`Not an upload content URL: ${e}`);if(!t)throw Error(`Not connected to the server`);await t.command({type:`upload.delete`,projectId:r.projectId,storedName:r.storedName})}async function dt(e,t,n={}){let{body:r,ok:i,status:a}=await(n.http??u).streamBytes(e,{signal:n.signal,headers:{Accept:`text/plain, text/markdown, application/json, text/csv, text/tab-separated-values, */*`}});if(!i)throw Error(`Preview request failed with status ${a}`);if(!r)return{content:``,truncated:!1};let o=r.getReader(),s=[],c=0,l=!1;for(;;){let{done:e,value:n}=await o.read();if(e)break;if(!n)continue;let r=t-c;if(r<=0){l=!0,await o.cancel();break}if(n.byteLength>r){s.push(n.slice(0,r)),c+=r,l=!0,await o.cancel();break}s.push(n),c+=n.byteLength}let d=new Uint8Array(c),f=0;for(let e of s)d.set(e,f),f+=e.byteLength;return{content:new TextDecoder().decode(d),truncated:l}}var ft=1048576,pt=new Set(`.c,.cc,.cfg,.conf,.cpp,.cs,.css,.env,.go,.graphql,.h,.hpp,.html,.ini,.java,.js,.jsonc,.jsx,.kt,.lua,.mjs,.php,.pl,.properties,.py,.rb,.rs,.scss,.sh,.sql,.swift,.toml,.ts,.tsx,.txt,.vue,.xml,.yaml,.yml,.zsh`.split(`,`)),mt=new Set([`.7z`,`.bz2`,`.gz`,`.rar`,`.tar`,`.tgz`,`.xz`,`.zip`]),ht=new Set([`.aac`,`.flac`,`.m4a`,`.mp3`,`.ogg`,`.wav`]),gt=new Set([`.avi`,`.m4v`,`.mov`,`.mp4`,`.mkv`,`.webm`]);function A(e){let t=e.mimeType.toLowerCase(),n=N(e.displayName);return t.startsWith(`image/`)?{kind:`image`,openInNewTab:!1}:t===`application/pdf`?{kind:`pdf`,openInNewTab:!1}:t===`application/json`?(e.size??0)<=262144?{kind:`json`,openInNewTab:!1}:{kind:`external`,openInNewTab:!0}:Et(e)?{kind:`markdown`,openInNewTab:!1}:t===`text/csv`||t===`text/tab-separated-values`?{kind:`table`,openInNewTab:!1}:t.startsWith(`audio/`)||ht.has(n)?{kind:`audio`,openInNewTab:!1}:t.startsWith(`video/`)||gt.has(n)?{kind:`video`,openInNewTab:!1}:t.startsWith(`text/`)||pt.has(n)?{kind:`text`,openInNewTab:!1}:{kind:`external`,openInNewTab:!0}}var _t={image:`Image`,pdf:`PDF`,markdown:`Markdown`,json:`JSON`,table:`Table`,code:`Source`,text:`Text`,archive:`Archive`,audio:`Audio`,video:`Video`,file:`File`,mermaid:`Diagram`};function vt(e,t){if(e===`archive`&&t){if(t.includes(`zip`))return`ZIP archive`;if(t.includes(`gzip`))return`Gzip archive`;if(t.includes(`x-tar`))return`Tar archive`}if(e===`image`&&t){let e=t.split(`/`)[1]?.split(`;`)[0]?.toUpperCase();if(e)return`${e} image`}return _t[e]}function j(e){let t=M(e);return{iconKind:t,friendlyType:vt(t,e.mimeType),sizeLabel:e.size!==void 0&&e.size>0?x(e.size):null}}function yt(e,t,n){return[e,t,n.friendlyType,n.sizeLabel].filter(e=>!!e).join(`, `)}function M(e){let t=e.mimeType.toLowerCase(),n=N(e.displayName);return t.startsWith(`image/`)?`image`:t===`application/pdf`||n===`.pdf`?`pdf`:t===`application/json`||n===`.json`||n===`.jsonc`?`json`:Et(e)?`markdown`:t===`text/csv`||t===`text/tab-separated-values`||n===`.csv`||n===`.tsv`?`table`:t.startsWith(`audio/`)||ht.has(n)?`audio`:t.startsWith(`video/`)||gt.has(n)?`video`:t.includes(`zip`)||t.includes(`archive`)||mt.has(n)?`archive`:Ot(e)?`mermaid`:pt.has(n)?n===`.txt`?`text`:`code`:t.startsWith(`text/`)?`text`:`file`}async function bt(e,t,n={}){let r=n.dom??k,i=n.timer??ve,a=typeof AbortController<`u`?new AbortController:null,o=a?i.setTimeout(()=>a.abort(`preview-timeout`),15e3):null;try{return await dt(r.resolveUrl(e),t,{signal:a?.signal,http:n.http})}catch(e){throw kt(be(e))?Error(`Preview request timed out`,{cause:e}):e}finally{o!==null&&i.clearTimeout(o)}}function xt(e){try{return`${JSON.stringify(JSON.parse(e),null,2)}\n`}catch{return e}}function St(e,t){let n=At(e,t),r=n.length,i=n.reduce((e,t)=>Math.max(e,t.length),0),a=r>200,o=i>20;return{rows:n.slice(0,200).map(e=>e.slice(0,20)),rowCount:r,columnCount:i,truncatedRows:a,truncatedColumns:o}}function N(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t).toLowerCase():``}function Ct(e){return e.split(`;`)[0]?.trim().toLowerCase()??``}function wt(e){return[N(e.displayName),N(e.relativePath??``)]}var Tt=new Set([`text/markdown`,`text/x-markdown`]);function Et(e){return Tt.has(Ct(e.mimeType))?!0:wt(e).includes(`.md`)}var Dt=new Set([`.mmd`,`.mermaid`]);function Ot(e){return Ct(e.mimeType)===`text/vnd.mermaid`||wt(e).some(e=>Dt.has(e))}function kt(e){return e instanceof DOMException&&e.name===`AbortError`||e.message===`preview-timeout`}function At(e,t){let n=[],r=[],i=``,a=!1;for(let o=0;o<e.length;o+=1){let s=e[o],c=e[o+1];s===`"`?a&&c===`"`?(i+=`"`,o+=1):a=!a:!a&&s===t?(r.push(i),i=``):!a&&(s===`
3
3
  `||s===`\r`)?(s===`\r`&&c===`
4
4
  `&&(o+=1),r.push(i),n.push(r),r=[],i=``):i+=s}return(i.length>0||r.length>0)&&(r.push(i),n.push(r)),n}var P=e(r(),1),F=18,jt=3,I=2*Math.PI*F,L=42;function Mt({progress:e,onCancel:t,size:n=`md`,className:r,cancelLabel:a=`Cancel upload`}){let o=e==null,s=o?0:Math.min(1,Math.max(0,e)),c=o?null:Math.round(s*100),l=I*(1-s),u=n===`sm`?36:48;return(0,P.jsx)(`div`,{className:i(`pointer-events-auto absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-background/85`,r),role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":c??void 0,"aria-label":o?`Uploading`:`Uploading, ${c}%`,children:(0,P.jsxs)(`div`,{className:i(`group/overlay relative inline-flex items-center justify-center`,o&&`motion-safe:animate-spin`),style:{width:u,height:u},children:[(0,P.jsxs)(`svg`,{viewBox:`0 0 ${L} ${L}`,width:u,height:u,className:`absolute inset-0 -rotate-90`,"aria-hidden":`true`,children:[(0,P.jsx)(`circle`,{cx:L/2,cy:L/2,r:F,stroke:`currentColor`,strokeWidth:jt,fill:`none`,className:`text-border`}),(0,P.jsx)(`circle`,{cx:L/2,cy:L/2,r:F,stroke:`currentColor`,strokeWidth:jt,fill:`none`,strokeLinecap:`round`,strokeDasharray:I,strokeDashoffset:o?I*.75:l,className:i(`motion-safe:transition-[stroke-dashoffset] motion-safe:duration-150 motion-safe:ease-out`,t?`text-foreground group-hover/overlay:text-destructive`:`text-foreground`)})]}),c===null?null:(0,P.jsxs)(`span`,{className:i(`pointer-events-none select-none font-mono tabular-nums text-foreground transition-opacity`,`text-xs`,t&&`group-hover/overlay:opacity-0`),children:[c,`%`]}),t?(0,P.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},className:i(`absolute inset-0 flex items-center justify-center rounded-full text-destructive transition-opacity`,c===null?``:`opacity-0 group-hover/overlay:opacity-100`,`focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive`),"aria-label":a,children:(0,P.jsx)(he,{className:n===`sm`?`h-3.5 w-3.5`:`h-4 w-4`})}):null]})})}function R(e){return D(e,e=>t=>({value:e,set:e=>t({value:e})}))}var z=e(t(),1),B=R(`ExpandableRow`),Nt=()=>{},Pt=(0,z.createContext)(Nt);function Ft({children:e,onOpenLocalLink:t}){return(0,P.jsx)(Pt.Provider,{value:t??Nt,children:e})}function It({icon:e,className:t}){return(0,P.jsx)(e,{className:t})}function Lt({children:e,className:t}){return(0,P.jsx)(`div`,{className:i(`flex gap-3 justify-start items-center`,t),children:e})}function Rt({children:e,className:t}){return(0,P.jsx)(`div`,{className:i(`flex items-center gap-1.5 text-xs`,t),children:e})}function zt({children:e,className:t}){return(0,P.jsx)(`span`,{className:i(`font-medium text-foreground/80`,t),children:e})}function Bt({children:e}){return(0,P.jsx)(`span`,{className:`text-muted-foreground`,children:e})}function Vt({children:e,className:t}){return(0,P.jsxs)(Lt,{className:i(`px-0.5 text-xs tracking-wide`,t),children:[(0,P.jsx)(`div`,{className:`w-full h-[1px] bg-border`}),(0,P.jsx)(zt,{className:`whitespace-nowrap text-xs tracking-widest text-muted-foreground/60 flex-shrink-0`,children:e}),(0,P.jsx)(`div`,{className:`w-full h-[1px] bg-border`})]})}function Ht({children:e,expandedContent:t}){let n=B.useScopedStore(e=>e.value),r=B.useScopedStore(e=>e.set);return(0,P.jsxs)(`div`,{className:`flex flex-col w-full`,children:[(0,P.jsxs)(`button`,{onClick:()=>r(!n),className:`group/expandable-row cursor-pointer grid grid-cols-[auto_1fr] items-center gap-1 text-sm ${n?``:`hover:opacity-60 transition-opacity`}`,children:[(0,P.jsx)(`div`,{className:`grid grid-cols-[auto_1fr] items-center gap-1.5`,children:e}),(0,P.jsx)(ce,{className:`h-4.5 w-4.5 text-muted-icon translate-y-[0.5px] transition-[transform,opacity] motion-reduce:transition-none duration-200 opacity-0 group-hover/expandable-row:opacity-100 ${n?`rotate-90 opacity-100`:``}`})]}),n&&t]})}function Ut({children:e,expandedContent:t,defaultExpanded:n=!1}){return(0,P.jsx)(B.Provider,{init:n,children:(0,P.jsx)(Ht,{expandedContent:t,children:e})})}function Wt({label:e,children:t,copyText:n,ports:r}){let{copied:a,copy:s}=se(r),c=n??V(t),l=(0,z.useCallback)(()=>{O(`copy code`,s(c))},[s,c]);return(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`font-medium text-muted-foreground`,children:e}),(0,P.jsxs)(`div`,{className:`relative group/codeblock`,children:[(0,P.jsx)(`pre`,{className:`my-1 text-xs font-mono whitespace-no-wrap break-all bg-muted border border-border rounded-lg p-2 max-h-64 overflow-auto w-full`,children:t}),(0,P.jsx)(o,{variant:`ghost`,size:`icon`,"aria-label":a?`Copied`:`Copy code`,className:i(`absolute top-[4px] right-[4px] z-10 h-11 w-11 md:h-6.5 md:w-6.5 rounded-sm text-muted-foreground opacity-100 md:opacity-0 md:group-hover/codeblock:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100`,!a&&`hover:text-foreground`,a&&`hover:!bg-transparent hover:!border-transparent`),onClick:l,children:a?(0,P.jsx)(T,{className:`h-3.5 w-3.5 text-success-text`}):(0,P.jsx)(w,{className:`h-4 w-4`})})]})]})}function Gt({children:e,icon:t,className:n}){return(0,P.jsxs)(`span`,{className:i(`inline-flex items-center gap-1 px-2 py-1 bg-muted border border-border rounded-full`,n),children:[t&&(0,P.jsx)(t,{className:`h-3 w-3 text-muted-foreground`}),e]})}function Kt({children:e,className:t}){return(0,P.jsxs)(`div`,{className:i(`grid grid-cols-[auto_1fr] gap-2 min-w-0`,t),children:[(0,P.jsx)(`div`,{className:` min-w-5 flex flex-col relative items-center justify-center`,children:(0,P.jsx)(`div`,{className:`min-h-full w-[1px] bg-muted-foreground/20`})}),(0,P.jsx)(`div`,{className:`-ml-[1px] min-w-0 overflow-hidden`,children:e})]})}function qt(e){return typeof e==`object`&&!!e&&`props`in e}function V(e){return typeof e==`string`?e:typeof e==`number`?String(e):Array.isArray(e)?e.map(V).join(``):qt(e)?V(e.props.children):``}function Jt({children:e,ports:t,copyText:n,...r}){let{copied:a,copy:s}=se(t),c=n??V(e),l=()=>{O(`copy code`,s(c))};return(0,P.jsxs)(`div`,{className:`relative overflow-x-auto max-w-full min-w-0 no-code-highlight group/pre`,children:[(0,P.jsx)(`pre`,{className:`min-w-0 rounded-xl py-2.5 px-3.5 [.no-pre-highlight_&]:bg-background`,...r,children:e}),(0,P.jsx)(o,{variant:`ghost`,size:`icon`,"aria-label":a?`Copied`:`Copy code`,className:i(`absolute top-[35px] -translate-y-[50%] -translate-x-[1px] rounded-md right-1.5 h-11 w-11 md:h-8 md:w-8 text-muted-foreground opacity-100 md:opacity-0 md:group-hover/pre:opacity-100 transition-opacity [@media(hover:none)]:!opacity-100`,!a&&`hover:text-foreground`,a&&`hover:!bg-transparent hover:!border-transparent`),onClick:l,children:a?(0,P.jsx)(T,{className:`h-4 w-4 text-success-text`}):(0,P.jsx)(w,{className:`h-4 w-4`})})]})}function H({source:e,ports:t,highlightLine:n}){return n===void 0?(0,P.jsx)(Jt,{ports:t,children:(0,P.jsx)(`code`,{className:`block text-xs whitespace-pre language-mermaid`,children:e})}):(0,P.jsx)(Jt,{ports:t,copyText:e,children:(0,P.jsx)(`code`,{className:`grid grid-cols-[auto_1fr] text-xs language-mermaid`,children:e.split(`
5
5
  `).flatMap((e,t)=>{let r=t+1,a=r===n;return[(0,P.jsx)(`span`,{"aria-hidden":`true`,className:i(`select-none pr-3 text-right tabular-nums`,a?`bg-muted font-medium text-destructive`:`text-muted-foreground/60`),children:r},`gutter-${r}`),(0,P.jsx)(`span`,{className:i(`whitespace-pre`,a&&`bg-muted text-destructive`),children:e.length>0?e:` `},`line-${r}`)]})})})}function Yt({description:e}){return(0,P.jsxs)(P.Fragment,{children:[e.friendlyType,e.sizeLabel?(0,P.jsxs)(P.Fragment,{children:[` · `,(0,P.jsx)(`span`,{className:`tabular-nums`,children:e.sizeLabel})]}):null]})}function Xt({attachment:e,previewUrl:t,onClick:n,onRemove:r,className:a,size:o=`transcript`,uploadProgress:s,onCancelUpload:c}){let l=e.contentUrl||t,u=o===`composer`,d=s!==void 0;return(0,P.jsxs)(`div`,{className:i(`group relative flex flex-row items-end`,a),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:n,className:i(`group/image relative overflow-hidden rounded-xl border border-border/80 bg-background shadow-sm`,u?`min-w-[80px]`:`min-w-[200px]`),children:[l?(0,P.jsx)(`img`,{src:l,alt:e.displayName,className:i(`rounded-xl object-contain bg-muted`,u?`min-h-[50px] min-w-[80px] max-h-[120px] max-w-[200px]`:`min-h-[100px] min-w-[200px] max-h-[300px] max-w-[300px]`)}):(0,P.jsx)(`div`,{className:i(`flex items-center justify-center rounded-xl bg-muted text-muted-foreground`,u?`min-h-[64px] min-w-[80px]`:`min-h-[160px] min-w-[200px]`),children:(0,P.jsx)(He,{className:i(u?`size-6`:`size-8`)})}),(0,P.jsxs)(`div`,{className:i(`pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/75 via-black/30 to-transparent text-left opacity-0 transition-opacity duration-200 group-hover/image:opacity-100`,u?`px-2.5 pb-2 pt-6`:`px-4 pb-3 pt-10`),children:[(0,P.jsx)(`div`,{className:i(`truncate font-medium text-white`,u?`text-xs`:`text-sm`),children:e.displayName}),(0,P.jsxs)(`div`,{className:`truncate text-xs text-white/80`,children:[e.mimeType,` · `,x(e.size)]})]})]}),d?(0,P.jsx)(Mt,{progress:s??null,onCancel:c,size:u?`sm`:`md`,cancelLabel:`Cancel upload of ${e.displayName}`}):null,r&&!d?(0,P.jsx)(Zt,{displayName:e.displayName,onRemove:r}):null]})}function U({attachment:e,onClick:t,onRemove:n,className:r,uploadProgress:a,onCancelUpload:o,href:s,download:c,meta:l,ariaLabel:u,disabledReason:d}){let f=Qt(e.kind===`mention`?`text`:M(e)),p=e.kind===`mention`,m=p?De(e.displayName):e.displayName,h=p?Oe(e.displayName):``,g=a!==void 0,_=!!d,v=i(`flex w-[200px] items-center gap-2 rounded-xl border border-border bg-background p-1 pr-3 text-left transition-colors`,_?`cursor-not-allowed opacity-60`:`hover:bg-accent/50`),y;y=p?(0,P.jsx)(`div`,{className:`max-w-[150px] truncate text-xs text-muted-foreground`,children:h?`@${h}`:`@mention`}):d?(0,P.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:d}):l===void 0?(0,P.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.mimeType,` · `,x(e.size)]}):(0,P.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:l});let b=(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`flex min-h-10 min-w-10 items-center justify-center rounded-lg border border-border bg-muted text-muted-foreground`,children:(0,P.jsx)(It,{icon:f,className:`size-5`})}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`div`,{className:i(`max-w-[150px] truncate text-13 font-medium`,_?`text-muted-foreground line-through`:`text-foreground`),children:m}),y]})]});return(0,P.jsxs)(`div`,{className:i(`group relative`,r),children:[s&&!_?(0,P.jsx)(`a`,{href:s,download:c,rel:`noopener`,"aria-label":u,className:v,children:b}):(0,P.jsx)(`button`,{type:`button`,onClick:_?void 0:t,"aria-label":u,"aria-disabled":_||void 0,disabled:_,className:v,children:b}),g?(0,P.jsx)(Mt,{progress:a??null,onCancel:o,size:`sm`,cancelLabel:`Cancel upload of ${e.displayName}`}):null,n&&!g?(0,P.jsx)(Zt,{displayName:e.displayName,onRemove:n}):null]})}function Zt({displayName:e,onRemove:t}){return(0,P.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 rounded-full bg-background/90 p-1 text-muted-foreground shadow-sm transition hover:bg-muted hover:text-foreground`,onClick:e=>{e.preventDefault(),e.stopPropagation(),t()},"aria-label":`Remove ${e}`,children:(0,P.jsx)(he,{className:`h-3.5 w-3.5`})})}function Qt(e){switch(e){case`image`:return He;case`pdf`:return et;case`markdown`:return it;case`json`:return Ie;case`table`:return We;case`code`:return Re;case`text`:return Ke;case`archive`:return Pe;case`audio`:return Be;case`video`:return Je;default:return Xe}}function $t({source:e}){return(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center overflow-auto`,children:(0,P.jsx)(`img`,{src:e.contentUrl,alt:e.altText??e.displayName,className:`max-h-[80dvh] w-auto max-w-full rounded-2xl object-contain`,style:{touchAction:`pinch-zoom`}})})}function en({source:e}){return(0,P.jsxs)(`div`,{className:`flex h-full flex-col gap-2`,children:[(0,P.jsx)(`iframe`,{src:e.contentUrl,title:e.displayName,sandbox:``,className:`hidden md:block h-[75dvh] w-full rounded-xl border border-border bg-background`}),(0,P.jsx)(`a`,{href:e.contentUrl,target:`_blank`,rel:`noopener noreferrer`,className:`md:hidden inline-flex items-center justify-center rounded-xl border border-border bg-muted px-3 py-2 text-sm`,children:`Open PDF externally`})]})}var tn=/<thinking>([\s\S]*?)<\/thinking>/gi;function nn(e){let t=[],n=0;tn.lastIndex=0;let r;for(;(r=tn.exec(e))!==null;){if(r.index>n){let i=e.slice(n,r.index);i.length>0&&t.push({kind:`text`,content:i})}t.push({kind:`thinking`,content:r[1]??``}),n=r.index+r[0].length}let i=e.slice(n),a=i.search(/<thinking>/i);if(a!==-1){let e=i.slice(0,a);e.length>0&&t.push({kind:`text`,content:e});let n=i.slice(a+10);t.push({kind:`thinking`,content:n})}else i.length>0&&t.push({kind:`text`,content:i});return rn(t)}function rn(e){let t=[];for(let n of e){let e=t[t.length-1];n.kind===`text`&&e&&e.kind===`text`?e.content+=n.content:t.push(n)}return t}var an=/^[ \t]*(`{3,}|~{3,})/,on=/https?:\/\/[^\s<>)\]'"]+/g,sn=/(?<![a-zA-Z0-9_])((?:PR|pull\s+request|merge\s+request|MR|issue|fix(?:es|ed)?|close[sd]?|resolve[sd]?|bug|task|ticket|story)\s+)?#(\d+)/gi,cn=/[.,;:!?)\]]+$/;function ln(e){if(!e.includes(`#`)||!e.includes(`http`))return e;let t=e.split(`
@@ -1,4 +1,4 @@
1
- import{o as e,t}from"./rolldown-runtime-BCiCTKAo.js";import{t as n}from"./react-BWPDF9mI.js";import{t as r}from"./react-dom-2r3XOwTS.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{f as a}from"./pendingActionsStore-C6o78Bki.js";import{n as o}from"./useTheme-DqpsYqBt.js";import"./index-DUJdXxNz.js";import{C as s,S as c,T as l,_ as u,b as d,i as f,n as p,r as m,t as h,v as g,w as _,x as v,y}from"./src-C_gRsKqw.js";import{t as b}from"./value-CHmTzbgv.js";import{t as x}from"./shim-IYZxwmPZ.js";import{a as S,i as C,n as w,r as T,s as E}from"./GenUIBlock-Bv-OFgT5.js";var D=e=>()=>e;function O(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}})}O.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function k(e){return!e.ctrlKey&&!e.button}function A(){return this.parentNode}function j(e,t){return t??{x:e.x,y:e.y}}function M(){return navigator.maxTouchPoints||`ontouchstart`in this}function N(){var e=k,t=A,n=j,r=M,i={},a=l(`start`,`drag`,`end`),o=0,f,p,m,h,b=0;function x(e){e.on(`mousedown.drag`,S).filter(r).on(`touchstart.drag`,T).on(`touchmove.drag`,E,d).on(`touchend.drag touchcancel.drag`,N).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function S(n,r){if(!h&&e.call(this,n,r)){var i=P(this,t.call(this,n,r),n,r,`mouse`);i&&(_(n.view).on(`mousemove.drag`,C,v).on(`mouseup.drag`,w,v),u(n.view),c(n),m=!1,f=n.clientX,p=n.clientY,i(`start`,n))}}function C(e){if(y(e),!m){var t=e.clientX-f,n=e.clientY-p;m=t*t+n*n>b}i.mouse(`drag`,e)}function w(e){_(e.view).on(`mousemove.drag mouseup.drag`,null),g(e.view,m),y(e),i.mouse(`end`,e)}function T(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,l;s<o;++s)(l=P(this,a,n,r,i[s].identifier,i[s]))&&(c(n),l(`start`,n,i[s]))}function E(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(y(e),a(`drag`,e,t[r]))}function N(e){var t=e.changedTouches,n=t.length,r,a;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(c(e),a(`end`,e,t[r]))}function P(e,t,r,c,l,u){var d=a.copy(),f=s(u||r,t),p,m,h;if((h=n.call(e,new O(`beforestart`,{sourceEvent:r,target:x,identifier:l,active:o,x:f[0],y:f[1],dx:0,dy:0,dispatch:d}),c))!=null)return p=h.x-f[0]||0,m=h.y-f[1]||0,function n(r,a,u){var g=f,_;switch(r){case`start`:i[l]=n,_=o++;break;case`end`:delete i[l],--o;case`drag`:f=s(u||a,t),_=o}d.call(r,e,new O(r,{sourceEvent:a,subject:h,target:x,identifier:l,active:_,x:f[0]+p,y:f[1]+m,dx:f[0]-g[0],dy:f[1]-g[1],dispatch:d}),c)}}return x.filter=function(t){return arguments.length?(e=typeof t==`function`?t:D(!!t),x):e},x.container=function(e){return arguments.length?(t=typeof e==`function`?e:D(e),x):t},x.subject=function(e){return arguments.length?(n=typeof e==`function`?e:D(e),x):n},x.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:D(!!e),x):r},x.on=function(){var e=a.on.apply(a,arguments);return e===a?x:e},x.clickDistance=function(e){return arguments.length?(b=(e=+e)*e,x):Math.sqrt(b)},x}var P=e(n(),1),F=e(i());function I(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=I(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var L={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.`},R=[[-1/0,-1/0],[1/0,1/0]],z=[`Enter`,` `,`Escape`],B={"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`},V;(function(e){e.Strict=`strict`,e.Loose=`loose`})(V||={});var H;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(H||={});var U;(function(e){e.Partial=`partial`,e.Full=`full`})(U||={});var W={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},G;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(G||={});var K;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(K||={});var q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(q||={});var ee={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top},te=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,ne=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),re=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),ie=(e,t=[0,0])=>{let{width:n,height:r}=Y(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},ae=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):re(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,ve(e,Se(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?be(r):{x:0,y:0,width:0,height:0}},oe=(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=ve(n,Se(e)),r=!0)}),r?be(n):{x:0,y:0,width:0,height:0}},se=(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=we(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},ce=(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 le(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}=Y(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 ue({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Pe(oe(le(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 de({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`,L.error005());else{let{width:e,height:t}=Y(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Ie(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=Ie(d)?me(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,L.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 fe({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=ce(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 pe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),me=(e={x:0,y:0},t,n)=>({x:pe(e.x,t[0][0],t[1][0]-(n?.width??0)),y:pe(e.y,t[0][1],t[1][1]-(n?.height??0))});function he(e,t,n){let{width:r,height:i}=Y(n),{x:a,y:o}=n.internals.positionAbsolute;return me(e,[[a,o],[a+r,o+i]],t)}var ge=(e,t,n)=>e<t?pe(Math.abs(e-t),1,t)/t:e>n?-pe(Math.abs(e-n),1,t)/t:0,_e=(e,t,n=15,r=40)=>[ge(e.x,r,t.width-r)*n,ge(e.y,r,t.height-r)*n],ve=(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)}),ye=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),be=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),xe=(e,t=[0,0])=>{let{x:n,y:r}=re(e)?e.internals.positionAbsolute:ie(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}},Se=(e,t=[0,0])=>{let{x:n,y:r}=re(e)?e.internals.positionAbsolute:ie(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)}},Ce=(e,t)=>be(ve(ye(e),ye(t))),we=(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)},Te=(e,t)=>we(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ee=e=>J(e.width)&&J(e.height)&&J(e.x)&&J(e.y),J=e=>!isNaN(e)&&isFinite(e),De=(e,t)=>(e,t)=>{},Oe=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ke=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Oe(s,o):s},Ae=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function je(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 Me(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=je(e,n),i=je(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=je(e.top??e.y??0,n),i=je(e.bottom??e.y??0,n),a=je(e.left??e.x??0,t),o=je(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 Ne(e,t,n,r,i,a){let{x:o,y:s}=Ae(e,[t,n,r]),{x:c,y:l}=Ae({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 Pe=(e,t,n,r,i,a)=>{let o=Me(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=pe(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=Ne(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}},Fe=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Ie(e){return e!=null&&e!==`parent`}function Y(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Le(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Re(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 ze(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Be(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ve(e){return{...B,...e||{}}}function He(e){return e===null?null:e?`valid`:`invalid`}function Ue(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=X(e),s=ke({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Oe(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var We=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ge=e=>e?.getRootNode?.()||window?.document,Ke=[`INPUT`,`SELECT`,`TEXTAREA`];function qe(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Ke.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Je=e=>`clientX`in e,X=(e,t)=>{let n=Je(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)}},Ye=(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,...We(t)}})};function Xe({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 Ze(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Qe({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case q.Left:return[t-Ze(t-r,a),n];case q.Right:return[t+Ze(r-t,a),n];case q.Top:return[t,n-Ze(n-i,a)];case q.Bottom:return[t,n+Ze(i-n,a)]}}function $e({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:i,targetPosition:a=q.Top,curvature:o=.25}){let[s,c]=Qe({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Qe({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Xe({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 et({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 tt({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 nt({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=ve(Se(e),Se(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Te({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},be(a))>0}var rt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,it=(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)),at=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,L.error006()),t;let r=n.getEdgeId||rt,i;return i=te(e)?{...e}:{...e,id:r(e)},it(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function ot({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=et({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var st={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},ct=({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},lt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function ut({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:i,offset:a,stepPosition:o}){let s=st[t],c=st[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=ct({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]=et({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 dt(e,t,n,r){let i=Math.min(lt(e,t)/2,lt(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 ft({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]=ut({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+=dt(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 pt(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mt(e){let{sourceNode:t,targetNode:n}=e;if(!pt(t)||!pt(n))return null;let r=t.internals.handleBounds||ht(t.handles),i=n.internals.handleBounds||ht(n.handles),a=_t(r?.source??[],e.sourceHandle),o=_t(e.connectionMode===V.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,L.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=gt(t,a,s),u=gt(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function ht(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 gt(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??Y(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 _t(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function vt(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function yt(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=vt(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 bt=1e3,xt=10,St={nodeOrigin:[0,0],nodeExtent:R,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Ct={...St,checkEquality:!0};function wt(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Tt(e,t,n){let r=wt(St,n);for(let n of e.values())if(n.parentId)At(n,e,t,r);else{let e=me(ie(n,r.nodeOrigin),Ie(n.extent)?n.extent:r.nodeExtent,Y(n));n.internals.positionAbsolute=e}}function Et(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 Dt(e){return e===`manual`}function Ot(e,t,n,r={}){let i=wt(Ct,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Dt(i.zIndexMode)?bt: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=me(ie(u,i.nodeOrigin),Ie(u.extent)?u.extent:i.nodeExtent,Y(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Et(u,e),z:jt(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&&At(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function kt(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 At(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=wt(St,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}kt(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*xt),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Mt(e,u,o,s,a&&!Dt(c)?bt: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 jt(e,t,n){let r=J(e.zIndex)?e.zIndex:0;return Dt(n)?r:r+(e.selected?t:0)}function Mt(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Y(e),l=ie(e,n),u=Ie(e.extent)?me(l,e.extent,c):l,d=me({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=he(d,c,t));let f=jt(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Nt(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=Ce(a.get(n.parentId)?.expandedRect??xe(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=Y(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 Pt(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=We(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=Ie(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=he(h,s,n))}else m&&(h=me(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Ye(`source`,r.nodeElement,p,d,e.id),target:Ye(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&At(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:xe(g,i)}))}}if(f.length>0){let e=Nt(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Ft({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 It(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 Lt(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}`;It(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),It(`target`,s,c,e,i,o),t.set(r.id,r)}}function Rt(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Rt(n,t):!1}function zt(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 Bt(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Rt(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 Vt({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 Ht({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=Oe(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Ut({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:v,domNode:y,isSelectable:b,nodeId:x,nodeClickDistance:S=0}){f=_(y);function C({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?ye(oe(s)):null,b=v&&l?Ht({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=b?{x:Math.round(a.x+b.x),y:Math.round(a.y+b.y)}:Oe(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}=de({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||!x&&f))){let[e,t]=Vt({nodeId:x,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),x||f?.(h,t)}}async function w(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=_e(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})&&C(a)),o=requestAnimationFrame(w)}function T(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&&b||o||!x||i.get(x)?.selected||_(),b&&m&&x&&e?.(x);let v=Ue(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Bt(i,c,v,x),s.size>0&&(n||h||!x&&g)){let[e,t]=Vt({nodeId:x,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),x||g?.(r.sourceEvent,t)}}let E=N().clickDistance(S).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&&T(e),a=Ue(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=X(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Ue(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||x&&!m.has(x))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,w()),!d){let t=X(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&T(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=X(e.sourceEvent,u),C(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else 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||!x&&o){let[t,r]=Vt({nodeId:x,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),x||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!zt(t,`.${g}`,y))&&(!v||zt(t,v,y))});f.call(E)}function v(){f?.on(`.drag`,null)}return{update:g,destroy:v}}function Wt(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())Te(i,xe(e))>0&&r.push(e);return r}var Gt=250;function Kt(e,t,n,r){let i=[],a=1/0,o=Wt(e,n,t+Gt);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}=gt(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 qt(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,...gt(o,c,c.position,!0)}:c}function Jt(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Yt(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Xt=()=>!0;function Zt(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:_=Xt,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Ge(e.target),E=0,D,{x:O,y:k}=X(e),A=Jt(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=qt(i,A,r,c,t);if(!N)return;let P=X(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=_e(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:gt(V,B,q.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:ee[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}=X(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=X(e,j),D=Kt(ke(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Qt(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=Yt(!!D,s.isValid);let u=c.get(i),f=u?gt(u,B,q.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ae({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:ee[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 Qt(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Xt,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}=X(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=Jt(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===V.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=qt(t,e,a,u,n,!0)}return _}var $t={onPointerDown:Zt,isValid:Qt};function en({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=_(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&&Fe()?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=h().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:s}}var tn=e=>({x:e.x,y:e.y,zoom:e.k}),nn=({x:e,y:t,zoom:n})=>p.translate(e,t).scale(n),rn=(e,t)=>e.target.closest(`.${t}`),an=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),on=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sn=(e,t=0,n=on,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},cn=e=>{let t=e.ctrlKey&&Fe()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ln({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(rn(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();let f=n.property(`__zoom`).k||1;if(d.ctrlKey&&o){let e=s(d),t=f*2**cn(d);r.scaleTo(n,t,e,d);return}let p=d.deltaMode===1?20:1,m=i===H.Vertical?0:d.deltaX*p,h=i===H.Horizontal?0:d.deltaY*p;!Fe()&&d.shiftKey&&i!==H.Vertical&&(m=d.deltaY*p,h=0),r.translateBy(n,-(m/f)*a,-(h/f)*a,{internal:!0});let g=tn(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(d,g):(e.isPanScrolling=!0,c?.(d,g)),e.panScrollTimeout=setTimeout(()=>{u?.(d,g),e.isPanScrolling=!1},150)}}function un({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=rn(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function dn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=tn(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 fn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&an(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,tn(a.transform))}}function pn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&an(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=tn(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function mn({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(rn(f,`${u}-flow__node`)||rn(f,`${u}-flow__edge`)||rn(f,`${u}-flow__selection`)||rn(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||rn(f,c)&&h||rn(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function hn({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 p=h().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=_(e).call(p);w({x:i.x,y:i.y,zoom:pe(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let v=g.on(`wheel.zoom`),y=g.on(`dblclick.zoom`);p.wheelDelta(cn);async function x(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).transform(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function S({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:f,preventScrolling:m,zoomOnPinch:h,zoomOnScroll:_,zoomOnDoubleClick:b,panActivationKeyPressed:x=!1,zoomActivationKeyPressed:S,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&C();let k=i&&!S&&!r;p.clickDistance(O?1/0:!J(D)||D<0?0:D);let A=k?ln({zoomPanValues:l,noWheelClassName:e,d3Selection:g,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:h,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):un({noWheelClassName:e,preventScrolling:m,d3ZoomHandler:v});g.on(`wheel.zoom`,A,{passive:!1});let j=dn({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,j);let M=fn({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});p.on(`zoom`,M);let N=pn({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,N);let P=mn({panActivationKeyPressed:x,zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:_,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:h,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});p.filter(P),b?g.on(`dblclick.zoom`,y):g.on(`dblclick.zoom`,null)}function C(){p.on(`zoom`,null)}async function w(e,t,n){let r=nn(e),i=p?.constrain()(r,t,n);return i&&await x(i),i}async function T(e,t){let n=nn(e);return await x(n,t),n}function E(e){if(g){let t=nn(e),n=g.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&p?.transform(g,t,null,{sync:!0})}}function D(){let e=g?m(g.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).scaleTo(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function k(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).scaleBy(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){p?.scaleExtent(e)}function j(e){p?.translateExtent(e)}function M(e){let t=!J(e)||e<0?0:e;p?.clickDistance(t)}return{update:S,destroy:C,setViewport:T,setViewportConstrained:w,getViewport:D,scaleTo:O,scaleBy:k,setScaleExtent:A,setTranslateExtent:j,syncViewport:E,setClickDistance:M}}var gn;(function(e){e.Line=`line`,e.Handle=`handle`})(gn||={});function _n({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 vn(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 yn(e,t){return Math.max(0,t-e)}function bn(e,t){return Math.max(0,e-t)}function xn(e,t,n){return Math.max(0,t-e,e-n)}function Sn(e,t){return e?!t:t}function Cn(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=xn(E,h,g),j=xn(D,_,v);if(o){let e=0,t=0;c&&w<0?e=yn(y+w+O,o[0][0]):!c&&w>0&&(e=bn(y+E+O,o[1][0])),l&&T<0?t=yn(b+T+k,o[0][1]):!l&&T>0&&(t=bn(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=bn(y+w,s[0][0]):!c&&w<0&&(e=yn(y+E,s[1][0])),l&&T>0?t=bn(b+T,s[0][1]):!l&&T<0&&(t=yn(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=xn(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?bn(b+k+E/C,o[1][1])*C:yn(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?yn(b+E/C,s[1][1])*C:bn(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=xn(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?bn(y+D*C+O,o[1][0])/C:yn(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?yn(y+D*C,s[1][0])/C:bn(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=(Sn(c,l)?-w:w)/C:w=(Sn(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 wn={width:0,height:0,x:0,y:0},Tn={...wn,pointerX:0,pointerY:0,aspectRatio:1};function En(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 Dn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=_(e),o={controlDirection:vn(`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={...wn},h={...Tn};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:vn(e)};let g,_=null,v=[],y,b,x,S=N().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}=Ue(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=Ie(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=En(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=Ue(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=Cn(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=_n({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,I),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var On=t((e=>{var t=n(),r=x();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),kn=e(t(((e,t)=>{t.exports=On()}))(),1),An=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},jn=e=>e?An(e):An,{useDebugValue:Mn}=P.default,{useSyncExternalStoreWithSelector:Nn}=kn.default,Pn=e=>e;function Fn(e,t=Pn,n){let r=Nn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Mn(r),r}var In=(e,t)=>{let n=jn(e),r=(e,r=t)=>Fn(n,e,r);return Object.assign(r,n),r},Ln=(e,t)=>e?In(e,t):In;function Z(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}var Rn=e(r()),zn=(0,P.createContext)(null),Bn=zn.Provider,Vn=L.error001(`react`);function Q(e,t){let n=(0,P.useContext)(zn);if(n===null)throw Error(Vn);return Fn(n,e,t)}function $(){let e=(0,P.useContext)(zn);if(e===null)throw Error(Vn);return(0,P.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Hn={display:`none`},Un={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Wn=`react-flow__node-desc`,Gn=`react-flow__edge-desc`,Kn=`react-flow__aria-live`,qn=e=>e.ariaLiveMessage,Jn=e=>e.ariaLabelConfig;function Yn({rfId:e}){let t=Q(qn);return(0,F.jsx)(`div`,{id:`${Kn}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Un,children:t})}function Xn({rfId:e,disableKeyboardA11y:t}){let n=Q(Jn);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{id:`${Wn}-${e}`,style:Hn,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,F.jsx)(`div`,{id:`${Gn}-${e}`,style:Hn,children:n[`edge.a11yDescription.default`]}),!t&&(0,F.jsx)(Yn,{rfId:e})]})}var Zn=(0,P.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,F.jsx)(`div`,{className:I([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});Zn.displayName=`Panel`;var Qn=`https://reactflow.dev?utm_source=attribution`;function $n({proOptions:e,position:t=`bottom-right`}){return(0,P.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,F.jsx)(Zn,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Qn}`,children:(0,F.jsx)(`a`,{href:Qn,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var er=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}},tr=e=>e.id;function nr(e,t){return Z(e.selectedNodes.map(tr),t.selectedNodes.map(tr))&&Z(e.selectedEdges.map(tr),t.selectedEdges.map(tr))}function rr({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(er,nr);return(0,P.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var ir=e=>!!e.onSelectionChangeHandlers;function ar({onSelectionChange:e}){let t=Q(ir);return e||t?(0,F.jsx)(rr,{onSelectionChange:e}):null}var or=[0,0],sr={x:0,y:0,zoom:1},cr=[...`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`],lr=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}),ur={translateExtent:R,nodeOrigin:or,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function dr(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(lr,Z),l=$();(0,P.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=ur,s()}),[]);let u=(0,P.useRef)(ur);return(0,P.useEffect)(()=>{for(let s of cr){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:Ve(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},cr.map(t=>e[t])),null}function fr(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function pr(e){let[t,n]=(0,P.useState)(e===`system`?null:e);return(0,P.useEffect)(()=>{if(e!==`system`){n(e);return}let t=fr(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?fr()?.matches?`dark`:`light`:t}var mr=typeof document<`u`?document:null;function hr(e=null,t={target:mr,actInsideInputWithModifier:!0}){let[n,r]=(0,P.useState)(!1),i=(0,P.useRef)(!1),a=(0,P.useRef)(new Set([])),[o,s]=(0,P.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
1
+ import{o as e,t}from"./rolldown-runtime-BCiCTKAo.js";import{t as n}from"./react-BWPDF9mI.js";import{t as r}from"./react-dom-2r3XOwTS.js";import{t as i}from"./jsx-runtime-BB9-612F.js";import{f as a}from"./pendingActionsStore-CwpO00OX.js";import{n as o}from"./useTheme-bl0TpEGW.js";import"./index-Cj9-ngio.js";import{C as s,S as c,T as l,_ as u,b as d,i as f,n as p,r as m,t as h,v as g,w as _,x as v,y}from"./src-C_gRsKqw.js";import{t as b}from"./value-CHmTzbgv.js";import{t as x}from"./shim-IYZxwmPZ.js";import{a as S,i as C,n as w,r as T,s as E}from"./GenUIBlock-BKFWGRt3.js";var D=e=>()=>e;function O(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}})}O.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function k(e){return!e.ctrlKey&&!e.button}function A(){return this.parentNode}function j(e,t){return t??{x:e.x,y:e.y}}function M(){return navigator.maxTouchPoints||`ontouchstart`in this}function N(){var e=k,t=A,n=j,r=M,i={},a=l(`start`,`drag`,`end`),o=0,f,p,m,h,b=0;function x(e){e.on(`mousedown.drag`,S).filter(r).on(`touchstart.drag`,T).on(`touchmove.drag`,E,d).on(`touchend.drag touchcancel.drag`,N).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function S(n,r){if(!h&&e.call(this,n,r)){var i=P(this,t.call(this,n,r),n,r,`mouse`);i&&(_(n.view).on(`mousemove.drag`,C,v).on(`mouseup.drag`,w,v),u(n.view),c(n),m=!1,f=n.clientX,p=n.clientY,i(`start`,n))}}function C(e){if(y(e),!m){var t=e.clientX-f,n=e.clientY-p;m=t*t+n*n>b}i.mouse(`drag`,e)}function w(e){_(e.view).on(`mousemove.drag mouseup.drag`,null),g(e.view,m),y(e),i.mouse(`end`,e)}function T(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,l;s<o;++s)(l=P(this,a,n,r,i[s].identifier,i[s]))&&(c(n),l(`start`,n,i[s]))}function E(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(y(e),a(`drag`,e,t[r]))}function N(e){var t=e.changedTouches,n=t.length,r,a;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(c(e),a(`end`,e,t[r]))}function P(e,t,r,c,l,u){var d=a.copy(),f=s(u||r,t),p,m,h;if((h=n.call(e,new O(`beforestart`,{sourceEvent:r,target:x,identifier:l,active:o,x:f[0],y:f[1],dx:0,dy:0,dispatch:d}),c))!=null)return p=h.x-f[0]||0,m=h.y-f[1]||0,function n(r,a,u){var g=f,_;switch(r){case`start`:i[l]=n,_=o++;break;case`end`:delete i[l],--o;case`drag`:f=s(u||a,t),_=o}d.call(r,e,new O(r,{sourceEvent:a,subject:h,target:x,identifier:l,active:_,x:f[0]+p,y:f[1]+m,dx:f[0]-g[0],dy:f[1]-g[1],dispatch:d}),c)}}return x.filter=function(t){return arguments.length?(e=typeof t==`function`?t:D(!!t),x):e},x.container=function(e){return arguments.length?(t=typeof e==`function`?e:D(e),x):t},x.subject=function(e){return arguments.length?(n=typeof e==`function`?e:D(e),x):n},x.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:D(!!e),x):r},x.on=function(){var e=a.on.apply(a,arguments);return e===a?x:e},x.clickDistance=function(e){return arguments.length?(b=(e=+e)*e,x):Math.sqrt(b)},x}var P=e(n(),1),F=e(i());function I(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=I(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var L={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.`},R=[[-1/0,-1/0],[1/0,1/0]],z=[`Enter`,` `,`Escape`],B={"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`},V;(function(e){e.Strict=`strict`,e.Loose=`loose`})(V||={});var H;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(H||={});var U;(function(e){e.Partial=`partial`,e.Full=`full`})(U||={});var W={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},G;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(G||={});var K;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(K||={});var q;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(q||={});var ee={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top},te=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,ne=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),re=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),ie=(e,t=[0,0])=>{let{width:n,height:r}=Y(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},ae=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):re(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,ve(e,Se(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?be(r):{x:0,y:0,width:0,height:0}},oe=(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=ve(n,Se(e)),r=!0)}),r?be(n):{x:0,y:0,width:0,height:0}},se=(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=we(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},ce=(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 le(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}=Y(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 ue({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Pe(oe(le(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 de({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`,L.error005());else{let{width:e,height:t}=Y(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Ie(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=Ie(d)?me(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,L.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 fe({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=ce(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 pe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),me=(e={x:0,y:0},t,n)=>({x:pe(e.x,t[0][0],t[1][0]-(n?.width??0)),y:pe(e.y,t[0][1],t[1][1]-(n?.height??0))});function he(e,t,n){let{width:r,height:i}=Y(n),{x:a,y:o}=n.internals.positionAbsolute;return me(e,[[a,o],[a+r,o+i]],t)}var ge=(e,t,n)=>e<t?pe(Math.abs(e-t),1,t)/t:e>n?-pe(Math.abs(e-n),1,t)/t:0,_e=(e,t,n=15,r=40)=>[ge(e.x,r,t.width-r)*n,ge(e.y,r,t.height-r)*n],ve=(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)}),ye=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),be=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),xe=(e,t=[0,0])=>{let{x:n,y:r}=re(e)?e.internals.positionAbsolute:ie(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}},Se=(e,t=[0,0])=>{let{x:n,y:r}=re(e)?e.internals.positionAbsolute:ie(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)}},Ce=(e,t)=>be(ve(ye(e),ye(t))),we=(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)},Te=(e,t)=>we(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ee=e=>J(e.width)&&J(e.height)&&J(e.x)&&J(e.y),J=e=>!isNaN(e)&&isFinite(e),De=(e,t)=>(e,t)=>{},Oe=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),ke=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Oe(s,o):s},Ae=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function je(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 Me(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=je(e,n),i=je(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=je(e.top??e.y??0,n),i=je(e.bottom??e.y??0,n),a=je(e.left??e.x??0,t),o=je(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 Ne(e,t,n,r,i,a){let{x:o,y:s}=Ae(e,[t,n,r]),{x:c,y:l}=Ae({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 Pe=(e,t,n,r,i,a)=>{let o=Me(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=pe(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=Ne(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}},Fe=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Ie(e){return e!=null&&e!==`parent`}function Y(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Le(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Re(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 ze(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Be(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Ve(e){return{...B,...e||{}}}function He(e){return e===null?null:e?`valid`:`invalid`}function Ue(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=X(e),s=ke({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Oe(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var We=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ge=e=>e?.getRootNode?.()||window?.document,Ke=[`INPUT`,`SELECT`,`TEXTAREA`];function qe(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Ke.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Je=e=>`clientX`in e,X=(e,t)=>{let n=Je(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)}},Ye=(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,...We(t)}})};function Xe({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 Ze(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Qe({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case q.Left:return[t-Ze(t-r,a),n];case q.Right:return[t+Ze(r-t,a),n];case q.Top:return[t,n-Ze(n-i,a)];case q.Bottom:return[t,n+Ze(i-n,a)]}}function $e({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:r,targetY:i,targetPosition:a=q.Top,curvature:o=.25}){let[s,c]=Qe({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Qe({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=Xe({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 et({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 tt({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 nt({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=ve(Se(e),Se(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Te({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},be(a))>0}var rt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,it=(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)),at=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,L.error006()),t;let r=n.getEdgeId||rt,i;return i=te(e)?{...e}:{...e,id:r(e)},it(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function ot({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=et({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var st={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},ct=({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},lt=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function ut({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:r=q.Top,center:i,offset:a,stepPosition:o}){let s=st[t],c=st[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=ct({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]=et({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 dt(e,t,n,r){let i=Math.min(lt(e,t)/2,lt(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 ft({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]=ut({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+=dt(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 pt(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function mt(e){let{sourceNode:t,targetNode:n}=e;if(!pt(t)||!pt(n))return null;let r=t.internals.handleBounds||ht(t.handles),i=n.internals.handleBounds||ht(n.handles),a=_t(r?.source??[],e.sourceHandle),o=_t(e.connectionMode===V.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,L.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=gt(t,a,s),u=gt(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function ht(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 gt(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??Y(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 _t(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function vt(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function yt(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=vt(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 bt=1e3,xt=10,St={nodeOrigin:[0,0],nodeExtent:R,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Ct={...St,checkEquality:!0};function wt(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Tt(e,t,n){let r=wt(St,n);for(let n of e.values())if(n.parentId)At(n,e,t,r);else{let e=me(ie(n,r.nodeOrigin),Ie(n.extent)?n.extent:r.nodeExtent,Y(n));n.internals.positionAbsolute=e}}function Et(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 Dt(e){return e===`manual`}function Ot(e,t,n,r={}){let i=wt(Ct,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Dt(i.zIndexMode)?bt: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=me(ie(u,i.nodeOrigin),Ie(u.extent)?u.extent:i.nodeExtent,Y(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Et(u,e),z:jt(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&&At(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function kt(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 At(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=wt(St,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}kt(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*xt),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Mt(e,u,o,s,a&&!Dt(c)?bt: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 jt(e,t,n){let r=J(e.zIndex)?e.zIndex:0;return Dt(n)?r:r+(e.selected?t:0)}function Mt(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Y(e),l=ie(e,n),u=Ie(e.extent)?me(l,e.extent,c):l,d=me({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=he(d,c,t));let f=jt(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Nt(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=Ce(a.get(n.parentId)?.expandedRect??xe(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=Y(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 Pt(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=We(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=Ie(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=he(h,s,n))}else m&&(h=me(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:Ye(`source`,r.nodeElement,p,d,e.id),target:Ye(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&At(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:xe(g,i)}))}}if(f.length>0){let e=Nt(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function Ft({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 It(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 Lt(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}`;It(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),It(`target`,s,c,e,i,o),t.set(r.id,r)}}function Rt(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Rt(n,t):!1}function zt(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 Bt(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!Rt(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 Vt({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 Ht({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=Oe(a,t);return{x:o.x-a.x,y:o.y-a.y}}function Ut({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:v,domNode:y,isSelectable:b,nodeId:x,nodeClickDistance:S=0}){f=_(y);function C({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?ye(oe(s)):null,b=v&&l?Ht({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=b?{x:Math.round(a.x+b.x),y:Math.round(a.y+b.y)}:Oe(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}=de({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||!x&&f))){let[e,t]=Vt({nodeId:x,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),x||f?.(h,t)}}async function w(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=_e(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})&&C(a)),o=requestAnimationFrame(w)}function T(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&&b||o||!x||i.get(x)?.selected||_(),b&&m&&x&&e?.(x);let v=Ue(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=Bt(i,c,v,x),s.size>0&&(n||h||!x&&g)){let[e,t]=Vt({nodeId:x,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),x||g?.(r.sourceEvent,t)}}let E=N().clickDistance(S).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&&T(e),a=Ue(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=X(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Ue(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||x&&!m.has(x))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,w()),!d){let t=X(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&T(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=X(e.sourceEvent,u),C(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else 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||!x&&o){let[t,r]=Vt({nodeId:x,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),x||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!zt(t,`.${g}`,y))&&(!v||zt(t,v,y))});f.call(E)}function v(){f?.on(`.drag`,null)}return{update:g,destroy:v}}function Wt(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())Te(i,xe(e))>0&&r.push(e);return r}var Gt=250;function Kt(e,t,n,r){let i=[],a=1/0,o=Wt(e,n,t+Gt);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}=gt(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 qt(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,...gt(o,c,c.position,!0)}:c}function Jt(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function Yt(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var Xt=()=>!0;function Zt(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:_=Xt,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=Ge(e.target),E=0,D,{x:O,y:k}=X(e),A=Jt(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=qt(i,A,r,c,t);if(!N)return;let P=X(e,j),F=!1,I=null,L=!1,R=null;function z(){if(!u||!j)return;let[e,t]=_e(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:gt(V,B,q.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:V,to:P,toHandle:null,toPosition:ee[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}=X(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=X(e,j),D=Kt(ke(P,a,!1,[1,1]),n,c,B),F||=(z(),!0);let s=Qt(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=Yt(!!D,s.isValid);let u=c.get(i),f=u?gt(u,B,q.Left,!0):H.from,p={...H,from:f,isValid:L,to:s.toHandle&&L?Ae({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:L&&s.toHandle?s.toHandle.position:ee[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 Qt(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=Xt,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}=X(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=Jt(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===V.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=qt(t,e,a,u,n,!0)}return _}var $t={onPointerDown:Zt,isValid:Qt};function en({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=_(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&&Fe()?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=h().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:s}}var tn=e=>({x:e.x,y:e.y,zoom:e.k}),nn=({x:e,y:t,zoom:n})=>p.translate(e,t).scale(n),rn=(e,t)=>e.target.closest(`.${t}`),an=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),on=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sn=(e,t=0,n=on,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},cn=e=>{let t=e.ctrlKey&&Fe()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function ln({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:u}){return d=>{if(rn(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();let f=n.property(`__zoom`).k||1;if(d.ctrlKey&&o){let e=s(d),t=f*2**cn(d);r.scaleTo(n,t,e,d);return}let p=d.deltaMode===1?20:1,m=i===H.Vertical?0:d.deltaX*p,h=i===H.Horizontal?0:d.deltaY*p;!Fe()&&d.shiftKey&&i!==H.Vertical&&(m=d.deltaY*p,h=0),r.translateBy(n,-(m/f)*a,-(h/f)*a,{internal:!0});let g=tn(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?l?.(d,g):(e.isPanScrolling=!0,c?.(d,g)),e.panScrollTimeout=setTimeout(()=>{u?.(d,g),e.isPanScrolling=!1},150)}}function un({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=rn(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function dn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=tn(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 fn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&an(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,tn(a.transform))}}function pn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&an(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=tn(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function mn({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(rn(f,`${u}-flow__node`)||rn(f,`${u}-flow__edge`)||rn(f,`${u}-flow__selection`)||rn(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||rn(f,c)&&h||rn(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function hn({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 p=h().extent(()=>d).scaleExtent([t,n]).translateExtent(r),g=_(e).call(p);w({x:i.x,y:i.y,zoom:pe(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let v=g.on(`wheel.zoom`),y=g.on(`dblclick.zoom`);p.wheelDelta(cn);async function x(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).transform(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function S({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:f,preventScrolling:m,zoomOnPinch:h,zoomOnScroll:_,zoomOnDoubleClick:b,panActivationKeyPressed:x=!1,zoomActivationKeyPressed:S,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&C();let k=i&&!S&&!r;p.clickDistance(O?1/0:!J(D)||D<0?0:D);let A=k?ln({zoomPanValues:l,noWheelClassName:e,d3Selection:g,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:h,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):un({noWheelClassName:e,preventScrolling:m,d3ZoomHandler:v});g.on(`wheel.zoom`,A,{passive:!1});let j=dn({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,j);let M=fn({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});p.on(`zoom`,M);let N=pn({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,N);let P=mn({panActivationKeyPressed:x,zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:_,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:h,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});p.filter(P),b?g.on(`dblclick.zoom`,y):g.on(`dblclick.zoom`,null)}function C(){p.on(`zoom`,null)}async function w(e,t,n){let r=nn(e),i=p?.constrain()(r,t,n);return i&&await x(i),i}async function T(e,t){let n=nn(e);return await x(n,t),n}function E(e){if(g){let t=nn(e),n=g.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&p?.transform(g,t,null,{sync:!0})}}function D(){let e=g?m(g.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).scaleTo(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function k(e,t){return g?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?b:f).scaleBy(sn(g,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){p?.scaleExtent(e)}function j(e){p?.translateExtent(e)}function M(e){let t=!J(e)||e<0?0:e;p?.clickDistance(t)}return{update:S,destroy:C,setViewport:T,setViewportConstrained:w,getViewport:D,scaleTo:O,scaleBy:k,setScaleExtent:A,setTranslateExtent:j,syncViewport:E,setClickDistance:M}}var gn;(function(e){e.Line=`line`,e.Handle=`handle`})(gn||={});function _n({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 vn(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 yn(e,t){return Math.max(0,t-e)}function bn(e,t){return Math.max(0,e-t)}function xn(e,t,n){return Math.max(0,t-e,e-n)}function Sn(e,t){return e?!t:t}function Cn(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=xn(E,h,g),j=xn(D,_,v);if(o){let e=0,t=0;c&&w<0?e=yn(y+w+O,o[0][0]):!c&&w>0&&(e=bn(y+E+O,o[1][0])),l&&T<0?t=yn(b+T+k,o[0][1]):!l&&T>0&&(t=bn(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=bn(y+w,s[0][0]):!c&&w<0&&(e=yn(y+E,s[1][0])),l&&T>0?t=bn(b+T,s[0][1]):!l&&T<0&&(t=yn(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=xn(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?bn(b+k+E/C,o[1][1])*C:yn(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?yn(b+E/C,s[1][1])*C:bn(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=xn(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?bn(y+D*C+O,o[1][0])/C:yn(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?yn(y+D*C,s[1][0])/C:bn(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=(Sn(c,l)?-w:w)/C:w=(Sn(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 wn={width:0,height:0,x:0,y:0},Tn={...wn,pointerX:0,pointerY:0,aspectRatio:1};function En(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 Dn({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=_(e),o={controlDirection:vn(`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={...wn},h={...Tn};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:vn(e)};let g,_=null,v=[],y,b,x,S=N().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}=Ue(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=Ie(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=En(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=Ue(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=Cn(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=_n({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),I={...m,direction:F};p?.(e,I)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,I),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var On=t((e=>{var t=n(),r=x();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=r.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),kn=e(t(((e,t)=>{t.exports=On()}))(),1),An=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},jn=e=>e?An(e):An,{useDebugValue:Mn}=P.default,{useSyncExternalStoreWithSelector:Nn}=kn.default,Pn=e=>e;function Fn(e,t=Pn,n){let r=Nn(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Mn(r),r}var In=(e,t)=>{let n=jn(e),r=(e,r=t)=>Fn(n,e,r);return Object.assign(r,n),r},Ln=(e,t)=>e?In(e,t):In;function Z(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}var Rn=e(r()),zn=(0,P.createContext)(null),Bn=zn.Provider,Vn=L.error001(`react`);function Q(e,t){let n=(0,P.useContext)(zn);if(n===null)throw Error(Vn);return Fn(n,e,t)}function $(){let e=(0,P.useContext)(zn);if(e===null)throw Error(Vn);return(0,P.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Hn={display:`none`},Un={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Wn=`react-flow__node-desc`,Gn=`react-flow__edge-desc`,Kn=`react-flow__aria-live`,qn=e=>e.ariaLiveMessage,Jn=e=>e.ariaLabelConfig;function Yn({rfId:e}){let t=Q(qn);return(0,F.jsx)(`div`,{id:`${Kn}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Un,children:t})}function Xn({rfId:e,disableKeyboardA11y:t}){let n=Q(Jn);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{id:`${Wn}-${e}`,style:Hn,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,F.jsx)(`div`,{id:`${Gn}-${e}`,style:Hn,children:n[`edge.a11yDescription.default`]}),!t&&(0,F.jsx)(Yn,{rfId:e})]})}var Zn=(0,P.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,F.jsx)(`div`,{className:I([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});Zn.displayName=`Panel`;var Qn=`https://reactflow.dev?utm_source=attribution`;function $n({proOptions:e,position:t=`bottom-right`}){return(0,P.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,F.jsx)(Zn,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Qn}`,children:(0,F.jsx)(`a`,{href:Qn,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var er=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}},tr=e=>e.id;function nr(e,t){return Z(e.selectedNodes.map(tr),t.selectedNodes.map(tr))&&Z(e.selectedEdges.map(tr),t.selectedEdges.map(tr))}function rr({onSelectionChange:e}){let t=$(),{selectedNodes:n,selectedEdges:r}=Q(er,nr);return(0,P.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var ir=e=>!!e.onSelectionChangeHandlers;function ar({onSelectionChange:e}){let t=Q(ir);return e||t?(0,F.jsx)(rr,{onSelectionChange:e}):null}var or=[0,0],sr={x:0,y:0,zoom:1},cr=[...`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`],lr=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}),ur={translateExtent:R,nodeOrigin:or,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function dr(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=Q(lr,Z),l=$();(0,P.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=ur,s()}),[]);let u=(0,P.useRef)(ur);return(0,P.useEffect)(()=>{for(let s of cr){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:Ve(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},cr.map(t=>e[t])),null}function fr(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function pr(e){let[t,n]=(0,P.useState)(e===`system`?null:e);return(0,P.useEffect)(()=>{if(e!==`system`){n(e);return}let t=fr(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?fr()?.matches?`dark`:`light`:t}var mr=typeof document<`u`?document:null;function hr(e=null,t={target:mr,actInsideInputWithModifier:!0}){let[n,r]=(0,P.useState)(!1),i=(0,P.useRef)(!1),a=(0,P.useRef)(new Set([])),[o,s]=(0,P.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
2
2
  `).replace(`
3
3
 
4
4
  `,`