repo-harness 0.26.5 → 0.26.6

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 (152) hide show
  1. package/README.md +1 -1
  2. package/assets/reference-configs/herdr-notify.md +11 -0
  3. package/assets/reference-configs/hook-operations.md +8 -1
  4. package/assets/skill-version.json +2 -2
  5. package/dist/hook-entry.js +11 -6
  6. package/dist/oar-review-host.js +4 -4
  7. package/dist/operator-ui/assets/{ArchitectureWorkspace-MI67sbfJ.js → ArchitectureWorkspace-D8LE-XjF.js} +1 -1
  8. package/dist/operator-ui/assets/{DocsPage-DXsq7ksr.js → DocsPage-DSdLctNT.js} +3 -3
  9. package/dist/operator-ui/assets/{abnfDiagram-VCTEODGH-Du4Qptlr.js → abnfDiagram-VCTEODGH-DfMDS2Lp.js} +1 -1
  10. package/dist/operator-ui/assets/architecture-7GRP2DOG-BgSLPpA1.js +1 -0
  11. package/dist/operator-ui/assets/{architectureDiagram-5GKGNRK7-DiMthM0w.js → architectureDiagram-5GKGNRK7-DPcsBDdu.js} +1 -1
  12. package/dist/operator-ui/assets/{blockDiagram-I7D4REHJ-D_QqPUr7.js → blockDiagram-I7D4REHJ-C6EZpBYV.js} +1 -1
  13. package/dist/operator-ui/assets/{c4Diagram-7LVT6UL2-pj_bu4Nh.js → c4Diagram-7LVT6UL2-DzR6nhre.js} +1 -1
  14. package/dist/operator-ui/assets/channel-B-mW7McF.js +1 -0
  15. package/dist/operator-ui/assets/{chunk-4HAMMTFA-xtIZzskX.js → chunk-4HAMMTFA-CIMhC59u.js} +1 -1
  16. package/dist/operator-ui/assets/{chunk-75Z2AOVW-Bzfo0VHT.js → chunk-75Z2AOVW-CSfYGhNA.js} +1 -1
  17. package/dist/operator-ui/assets/{chunk-DU6HZSFF-CfBOd2gP.js → chunk-DU6HZSFF-x7L88tMK.js} +1 -1
  18. package/dist/operator-ui/assets/{chunk-F27PBJKO-Cieq95Sy.js → chunk-F27PBJKO-D9CDMJ3K.js} +1 -1
  19. package/dist/operator-ui/assets/{chunk-GMAD6QVW-dV76sYzG.js → chunk-GMAD6QVW-0JYSnCZR.js} +1 -1
  20. package/dist/operator-ui/assets/{chunk-GVQU2GXP-DqJfKzYX.js → chunk-GVQU2GXP-BkyS7eBn.js} +1 -1
  21. package/dist/operator-ui/assets/{chunk-IMKFNOWR-BLEt4XiE.js → chunk-IMKFNOWR-UlgE8I96.js} +1 -1
  22. package/dist/operator-ui/assets/{chunk-L3NEJ4N5-C1TuP2gY.js → chunk-L3NEJ4N5-C7-4NM1T.js} +1 -1
  23. package/dist/operator-ui/assets/{chunk-OSK3NFVY-04DOmJKL.js → chunk-OSK3NFVY-BU0mlY5x.js} +1 -1
  24. package/dist/operator-ui/assets/{chunk-P2QGCYS3-Ch9B4-1u.js → chunk-P2QGCYS3-D6_cpwRO.js} +1 -1
  25. package/dist/operator-ui/assets/{chunk-POPQ4Y6H-DUoQ4ozJ.js → chunk-POPQ4Y6H-yDTSJccE.js} +1 -1
  26. package/dist/operator-ui/assets/{chunk-PWAF6VOD-BXK8Z81N.js → chunk-PWAF6VOD-BhZe2vwA.js} +1 -1
  27. package/dist/operator-ui/assets/{chunk-SHT3W25Y-CVa8q6ek.js → chunk-SHT3W25Y-B659Jmy9.js} +1 -1
  28. package/dist/operator-ui/assets/{chunk-SVP7TREG-CGGZ6y5s.js → chunk-SVP7TREG-4j1CtJJq.js} +1 -1
  29. package/dist/operator-ui/assets/{chunk-TICWLB2K-BH1pgrbg.js → chunk-TICWLB2K-BimIfkEM.js} +1 -1
  30. package/dist/operator-ui/assets/classDiagram-ZZMXUADV-VMwuztF3.js +1 -0
  31. package/dist/operator-ui/assets/classDiagram-v2-VYDZK3BY-VMwuztF3.js +1 -0
  32. package/dist/operator-ui/assets/{cynefin-OW5HDTMX-lm799lgu.js → cynefin-OW5HDTMX-DAMHK0c0.js} +1 -1
  33. package/dist/operator-ui/assets/{cynefinDiagram-5FMLGOSQ-DcyIvKnj.js → cynefinDiagram-5FMLGOSQ-Bxh92BVi.js} +1 -1
  34. package/dist/operator-ui/assets/{dagre-GXQ25YYZ-bRL4S7AL.js → dagre-GXQ25YYZ-DTL5yR1u.js} +1 -1
  35. package/dist/operator-ui/assets/{diagram-S7CK7UJ4-CyYH5boW.js → diagram-S7CK7UJ4-CoiWkjHb.js} +1 -1
  36. package/dist/operator-ui/assets/{diagram-UQ7AKVKN-DRnugtrH.js → diagram-UQ7AKVKN-BWP0Cbdb.js} +1 -1
  37. package/dist/operator-ui/assets/{diagram-VSXAHHWV-2yZScVoc.js → diagram-VSXAHHWV-2h1zz_Ua.js} +1 -1
  38. package/dist/operator-ui/assets/{diagram-VX7I27RA-MR2zXJL1.js → diagram-VX7I27RA-BqfEHdTD.js} +1 -1
  39. package/dist/operator-ui/assets/{diagram-Z3DM3KII-vHNWHp-b.js → diagram-Z3DM3KII-DZXmwLMt.js} +1 -1
  40. package/dist/operator-ui/assets/{ebnfDiagram-PWID7BFC-TKyEWOyO.js → ebnfDiagram-PWID7BFC-Blb4A7C3.js} +1 -1
  41. package/dist/operator-ui/assets/{erDiagram-RLTQ6QDP-De_iHG1O.js → erDiagram-RLTQ6QDP-BqsgGP_M.js} +1 -1
  42. package/dist/operator-ui/assets/eventmodeling-NTZA5JFV-BgE8UgeA.js +1 -0
  43. package/dist/operator-ui/assets/flowDiagram-HODETNUW-MIzGGbeU.js +1 -0
  44. package/dist/operator-ui/assets/{ganttDiagram-EL5Y4UJY-Di7nGDCD.js → ganttDiagram-EL5Y4UJY-UxVDVpGp.js} +1 -1
  45. package/dist/operator-ui/assets/{gitGraph-4MIJSDKK-Cw2GFgKj.js → gitGraph-4MIJSDKK-tgZ11cXV.js} +1 -1
  46. package/dist/operator-ui/assets/{gitGraphDiagram-WWUBYQGX-CgQatyhO.js → gitGraphDiagram-WWUBYQGX-WhG8HTrQ.js} +1 -1
  47. package/dist/operator-ui/assets/{index-D68hqwj8.js → index-Fcy-xiIk.js} +9 -9
  48. package/dist/operator-ui/assets/{info-A6RAGUB7-DzNzoaIn.js → info-A6RAGUB7-DkRbWrsD.js} +1 -1
  49. package/dist/operator-ui/assets/{infoDiagram-27XIBGKW-adi3SvmF.js → infoDiagram-27XIBGKW-VQalCtES.js} +1 -1
  50. package/dist/operator-ui/assets/{ishikawaDiagram-5VMMS53U-Da3Dnf0N.js → ishikawaDiagram-5VMMS53U-D7eREjkZ.js} +1 -1
  51. package/dist/operator-ui/assets/{journeyDiagram-3NMN7TZE-YOPJowfS.js → journeyDiagram-3NMN7TZE-sq6r1yfQ.js} +1 -1
  52. package/dist/operator-ui/assets/{kanban-definition-UXKFOSKX-CQibnj3V.js → kanban-definition-UXKFOSKX-xLS7cLVC.js} +1 -1
  53. package/dist/operator-ui/assets/{line-BJ_prgs5.js → line-DSEexTxI.js} +1 -1
  54. package/dist/operator-ui/assets/{mermaid-parser.core-CVtuUAl1.js → mermaid-parser.core-eHRL0p-V.js} +3 -3
  55. package/dist/operator-ui/assets/{mermaid.core-CUo84mNY.js → mermaid.core-5QKPbk__.js} +4 -4
  56. package/dist/operator-ui/assets/{mindmap-definition-YA3MSWOX-Bla7EjkG.js → mindmap-definition-YA3MSWOX-Bj8_GgoF.js} +1 -1
  57. package/dist/operator-ui/assets/{packet-AYTQ26CC-C3WOhu-H.js → packet-AYTQ26CC-BFDJ7WnH.js} +1 -1
  58. package/dist/operator-ui/assets/{pegDiagram-XKGWAZYB-QqctIBnz.js → pegDiagram-XKGWAZYB-BCE9YZTv.js} +1 -1
  59. package/dist/operator-ui/assets/{pie-WAS4IAKB-C_KpF3n5.js → pie-WAS4IAKB-BiKTFpfV.js} +1 -1
  60. package/dist/operator-ui/assets/{pieDiagram-E7YTZNPT-DIR4CkgL.js → pieDiagram-E7YTZNPT-DxDYHn8T.js} +1 -1
  61. package/dist/operator-ui/assets/{quadrantDiagram-AXDQQJYC-ElbTkAxO.js → quadrantDiagram-AXDQQJYC-CbIKAxKj.js} +1 -1
  62. package/dist/operator-ui/assets/{radar-RG4KPBEZ-CCsk9Y_6.js → radar-RG4KPBEZ-B-gdC3sE.js} +1 -1
  63. package/dist/operator-ui/assets/{railroad-74A4TZTK-DuZi_c43.js → railroad-74A4TZTK-CPhKfCOo.js} +1 -1
  64. package/dist/operator-ui/assets/railroad-abnf-HS5TGJTU-d0JEC-DD.js +1 -0
  65. package/dist/operator-ui/assets/railroad-ebnf-LZEXJU2U-C6EPurrP.js +1 -0
  66. package/dist/operator-ui/assets/railroad-peg-WCYAUIDC-oJasS-4i.js +1 -0
  67. package/dist/operator-ui/assets/{railroadDiagram-O6MQD6OU-iU4HU0w7.js → railroadDiagram-O6MQD6OU-DLzKmpVQ.js} +1 -1
  68. package/dist/operator-ui/assets/{requirementDiagram-BXWQKSXE-BlbfNq-y.js → requirementDiagram-BXWQKSXE-DXVYIbBr.js} +1 -1
  69. package/dist/operator-ui/assets/{sankeyDiagram-P5KCCOFB-jsIDIGSQ.js → sankeyDiagram-P5KCCOFB-n7h6z0_-.js} +1 -1
  70. package/dist/operator-ui/assets/{sequenceDiagram-WJ2MYXX4-DYUYs68X.js → sequenceDiagram-WJ2MYXX4--h5c7-SR.js} +1 -1
  71. package/dist/operator-ui/assets/{stateDiagram-D77RDMKH-DwUSx-Cr.js → stateDiagram-D77RDMKH-DKMwKjre.js} +1 -1
  72. package/dist/operator-ui/assets/stateDiagram-v2-MP3YSRHH-BFpB5NXy.js +1 -0
  73. package/dist/operator-ui/assets/{swimlanes-42K2YHIH-DUxSnyH8.js → swimlanes-42K2YHIH-BDL9jgR-.js} +1 -1
  74. package/dist/operator-ui/assets/swimlanesDiagram-VR7AAH4N-DokZACZv.js +8 -0
  75. package/dist/operator-ui/assets/{timeline-definition-24CTP7MA-CcMwI1LW.js → timeline-definition-24CTP7MA-CIQpGoRj.js} +1 -1
  76. package/dist/operator-ui/assets/{treeView-Q6P3EWNA-DBtbVup8.js → treeView-Q6P3EWNA-Btq_7U7g.js} +1 -1
  77. package/dist/operator-ui/assets/{treemap-WGGIJYW6-B4wdkJ-s.js → treemap-WGGIJYW6-CW0DP3MN.js} +1 -1
  78. package/dist/operator-ui/assets/{vennDiagram-4TSXK5OY-Ch-g-ngd.js → vennDiagram-4TSXK5OY-CmLMLbIW.js} +1 -1
  79. package/dist/operator-ui/assets/{wardley-WFR3VGLG-DyY3tyw-.js → wardley-WFR3VGLG-BNXyPxq3.js} +1 -1
  80. package/dist/operator-ui/assets/{wardleyDiagram-VM6X3IG4-2xKWsc63.js → wardleyDiagram-VM6X3IG4-CeL-Ktes.js} +1 -1
  81. package/dist/operator-ui/assets/{xychartDiagram-S5SC5T6Z-BUc2TE0l.js → xychartDiagram-S5SC5T6Z-DPqbR-N1.js} +1 -1
  82. package/dist/operator-ui/index.html +1 -1
  83. package/package.json +2 -2
  84. package/scripts/check-tarball-install-smoke.sh +65 -3
  85. package/scripts/contract-worktree-runtime.ts +20 -5
  86. package/scripts/create-project-dirs.sh +0 -1
  87. package/scripts/init-project.sh +1 -2
  88. package/scripts/lib/ci-run-tests.sh +2 -5
  89. package/scripts/lib/project-init-lib.sh +1 -601
  90. package/src/cli/commands/doctor.ts +23 -5
  91. package/src/cli/commands/events-actions.ts +155 -0
  92. package/src/cli/commands/events.ts +3 -148
  93. package/src/cli/commands/global-runtime.ts +2 -8
  94. package/src/cli/commands/herdr-actions.ts +127 -0
  95. package/src/cli/commands/herdr.ts +8 -145
  96. package/src/cli/commands/init-hook.ts +4 -2
  97. package/src/cli/commands/operator.ts +3 -3
  98. package/src/cli/commands/review.ts +3 -2
  99. package/src/cli/commands/security.ts +14 -3
  100. package/src/cli/commands/status.ts +4 -3
  101. package/src/cli/index.ts +20 -16
  102. package/src/cli/installer/architecture-selection.ts +13 -7
  103. package/src/cli/installer/install-profile.ts +9 -9
  104. package/src/cli/installer/managed-entries.ts +48 -10
  105. package/src/cli/installer/targets/claude.ts +3 -8
  106. package/src/core/board/advisor-seat.ts +27 -7
  107. package/src/core/board/attention.ts +5 -2
  108. package/src/core/board/board.ts +13 -6
  109. package/src/core/board/desk.ts +16 -5
  110. package/src/core/board/parents.ts +4 -4
  111. package/src/core/board/summary.ts +1 -1
  112. package/src/core/publication/publication-writes.ts +18 -0
  113. package/src/core/setup/decode.ts +2 -1
  114. package/src/core/setup/projection.ts +3 -1
  115. package/src/core/setup/types.ts +1 -0
  116. package/src/core/skill-surface/plugin-manifest.ts +6 -3
  117. package/src/core/terminal/hc-address.ts +10 -0
  118. package/src/effects/adoption/standard-plan.ts +14 -12
  119. package/src/effects/board/claude-agent-types.ts +15 -4
  120. package/src/effects/operator/runtime-status.ts +7 -2
  121. package/src/effects/operator/server.ts +6 -3
  122. package/src/effects/publication/app-hook-config.ts +25 -0
  123. package/src/effects/review-runner/task-oar-host.ts +3 -2
  124. package/src/effects/review-runner/task-review-runner.ts +3 -2
  125. package/src/effects/terminal/herdr-core.ts +16 -15
  126. package/src/effects/terminal/native-task-session.ts +1 -1
  127. package/src/effects/terminal/runtime-closeout.ts +346 -0
  128. package/src/effects/terminal/task-runtime-observation.ts +2 -2
  129. package/src/effects/terminal/task-session.ts +9 -339
  130. package/src/operator-web/BoardOffice.tsx +13 -8
  131. package/src/operator-web/board-office.ts +16 -7
  132. package/src/operator-web/fixtures/board-1474.json +5 -1
  133. package/src/operator-web/fixtures/board-parents.json +4 -1
  134. package/src/operator-web/fixtures/bots.ts +1 -1
  135. package/src/operator-web/fixtures/office.ts +9 -9
  136. package/src/operator-web/fixtures/setup.ts +4 -4
  137. package/src/operator-web/i18n/board.ts +22 -0
  138. package/src/operator-web/office-scene.ts +20 -7
  139. package/src/pi/compat.ts +1 -1
  140. package/dist/operator-ui/assets/architecture-7GRP2DOG-DDLdiURO.js +0 -1
  141. package/dist/operator-ui/assets/channel-EdTftRwl.js +0 -1
  142. package/dist/operator-ui/assets/classDiagram-ZZMXUADV-CUXZx1Vw.js +0 -1
  143. package/dist/operator-ui/assets/classDiagram-v2-VYDZK3BY-CUXZx1Vw.js +0 -1
  144. package/dist/operator-ui/assets/eventmodeling-NTZA5JFV-B98h4u3B.js +0 -1
  145. package/dist/operator-ui/assets/flowDiagram-HODETNUW-D0E7KaF5.js +0 -1
  146. package/dist/operator-ui/assets/railroad-abnf-HS5TGJTU-CADr6Cfa.js +0 -1
  147. package/dist/operator-ui/assets/railroad-ebnf-LZEXJU2U-CquXxbT1.js +0 -1
  148. package/dist/operator-ui/assets/railroad-peg-WCYAUIDC-CVM2y0el.js +0 -1
  149. package/dist/operator-ui/assets/stateDiagram-v2-MP3YSRHH-Bnciowwt.js +0 -1
  150. package/dist/operator-ui/assets/swimlanesDiagram-VR7AAH4N-BUXVnUoD.js +0 -8
  151. package/src/effects/terminal/herdr.ts +0 -69
  152. package/src/effects/terminal/task-worktree-runtime.ts +0 -27
package/README.md CHANGED
@@ -331,6 +331,6 @@ None of these are bundled dependencies; see
331
331
 
332
332
  ## Release & license
333
333
 
334
- - npm: `repo-harness@0.26.5` · workflow stamp `repo-harness@0.26.5+template@0.26.5`
334
+ - npm: `repo-harness@0.26.6` · workflow stamp `repo-harness@0.26.6+template@0.26.6`
335
335
  - History: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
336
336
  - License: MIT — see [`LICENSE`](LICENSE)
@@ -1,5 +1,16 @@
1
1
  # Herdr dispatch and notify
2
2
 
3
+ `repo-harness herdr`, `events`, and `review round|status|close|cancel` need
4
+ `peer-runtime` in the recorded plugin set. Their help stays open. An absent
5
+ plugin exits 1 with empty stdout and `install_plugin_unavailable` before any
6
+ prompt, credential read or process start. Run the printed repair: for `all`,
7
+ `repo-harness update`; for an explicit list, add `peer-runtime` with
8
+ `repo-harness install --plugins <your plugins>,peer-runtime`. No migration runs.
9
+ The plugin is available on every target; its portal skill installs on Claude
10
+ only. `hc`, the Herdr skill, fleet files, worktree closeout and doctor stay in
11
+ core. The hidden Operator cleanup-investigation job also needs `peer-runtime`;
12
+ the server records `host_failed` when the guard refuses that child.
13
+
3
14
  ## Herdr Dispatch
4
15
 
5
16
  - Claude, Codex and Pi peers run in herdr-core terminals that Herdr.app shows as panes. Start them with `herdr-app do` and talk to them with `hc` ([Runtime commands](#runtime-commands)). Receipt-bearing acceptance uses `repo-harness review round`; its OAR host runs the reviewer. Select Pi with `--harness pi`. Never call a vendor CLI directly for acceptance.
@@ -158,9 +158,16 @@ marks a capture older than 30 minutes `unknown`.
158
158
  `~/.claude/settings.json` has no `statusLine`:
159
159
 
160
160
  ```json
161
- "statusLine": { "type": "command", "command": ": repo-harness-managed-hook-v1; exec repo-harness-hook statusline" }
161
+ "statusLine": { "type": "command", "command": ": repo-harness-managed-hook-v1; exec '/absolute/path/to/bun' '/absolute/bun/install/global/node_modules/repo-harness/dist/hook-entry.js' statusline" }
162
162
  ```
163
163
 
164
+ Install resolves the Bun runtime from `process.execPath` and the bundle from
165
+ `<bunGlobalPackageRoot(env)>/dist/hook-entry.js`. It quotes both absolute paths.
166
+ The bundle comes from the global install, including when install runs through
167
+ `bunx` or a task worktree. A missing global bundle stops installation before
168
+ host configuration writes. Repair it with `bun add -g repo-harness`, then rerun
169
+ `repo-harness install --location global`.
170
+
164
171
  The managed tag is the ownership proof, as for the managed hook commands.
165
172
  Install refreshes the entry only while its command has the tag, and uninstall
166
173
  removes it only then. A user edit removes the tag, so the entry is then the
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.26.5",
3
- "templateVersion": "0.26.5",
2
+ "version": "0.26.6",
3
+ "templateVersion": "0.26.6",
4
4
  "skillName": "repo-harness",
5
5
  "contractId": "tasks-first-harness-v1",
6
6
  "compatibility": {
@@ -2555,10 +2555,10 @@ function createFileExclusiveDurably(path, content, mode = 384) {
2555
2555
  var init_atomic_append = () => {};
2556
2556
 
2557
2557
  // package.json
2558
- var version = "0.26.5", dependencies;
2558
+ var version = "0.26.6", dependencies;
2559
2559
  var init_package = __esm(() => {
2560
2560
  dependencies = {
2561
- "@botiverse/oar": "0.88.0",
2561
+ "@botiverse/oar": "0.91.0",
2562
2562
  "@modelcontextprotocol/sdk": "^1.31.0",
2563
2563
  archctx: "0.11.3",
2564
2564
  "archctx-contracts": "0.11.3",
@@ -10528,6 +10528,7 @@ var SURFACE_OWNERS = ["core", ...PLUGIN_IDS];
10528
10528
  function isPluginId(value) {
10529
10529
  return typeof value === "string" && PLUGIN_IDS.includes(value);
10530
10530
  }
10531
+ var UPDATE_COMMAND = "repo-harness update";
10531
10532
  function installSelectionCommand(selection) {
10532
10533
  if (selection === "all")
10533
10534
  return "repo-harness install";
@@ -10652,7 +10653,7 @@ function readRecordedInstallState(env = process.env) {
10652
10653
  function readRecordedSelection(env = process.env) {
10653
10654
  try {
10654
10655
  const state = readRecordedInstallState(env);
10655
- return state === null ? { status: "none" } : { status: "recorded", plugins: enabledPlugins(state) };
10656
+ return state === null ? { status: "none" } : { status: "recorded", selection: state.selection, plugins: enabledPlugins(state) };
10656
10657
  } catch (error) {
10657
10658
  if (error instanceof InstallStateError)
10658
10659
  return { status: "unreadable", error };
@@ -10662,11 +10663,15 @@ function readRecordedSelection(env = process.env) {
10662
10663
  function pluginSelected(selection, id) {
10663
10664
  return selection.status === "recorded" && selection.plugins.includes(id);
10664
10665
  }
10665
- function pluginRepair(added, plugins) {
10666
- return plugins === null ? installSelectionCommand("all") : installSelectionCommand(PLUGIN_IDS.filter((id) => plugins.includes(id) || id === added));
10666
+ function pluginRepair(added, selection) {
10667
+ if (selection === null)
10668
+ return installSelectionCommand("all");
10669
+ if (selection === "all")
10670
+ return UPDATE_COMMAND;
10671
+ return installSelectionCommand(PLUGIN_IDS.filter((id) => selection.includes(id) || id === added));
10667
10672
  }
10668
10673
  function notSelectedMessage(selection, id) {
10669
- return `the ${id} plugin is not selected; run: ${pluginRepair(id, selection.status === "recorded" ? selection.plugins : null)}`;
10674
+ return `the ${id} plugin is not selected; run: ${pluginRepair(id, selection.status === "recorded" ? selection.selection : null)}`;
10670
10675
  }
10671
10676
  function architectureSelectionReport(selection) {
10672
10677
  if (pluginSelected(selection, "architecture"))
@@ -1400,8 +1400,8 @@ async function promptWithOarObservation(session, kind, request, host, input, opt
1400
1400
  const run = await promptAndWait(session, input, { ...options, inputId: request.request_id });
1401
1401
  snapshot.control = run.result.kind;
1402
1402
  snapshot.rejection = run.kind === "rejected" ? run.code : null;
1403
- snapshot.outcome = run.kind === "rejected" ? null : run.outcome.kind;
1404
- snapshot.failure = run.kind !== "rejected" && run.outcome.kind === "failed" ? run.outcome.failure : null;
1403
+ snapshot.outcome = run.kind !== "rejected" && run.kind !== "handled" ? run.outcome.kind : null;
1404
+ snapshot.failure = run.kind !== "rejected" && run.kind !== "handled" && run.outcome.kind === "failed" ? run.outcome.failure : null;
1405
1405
  snapshot.actual_model = oarActualModel(kind, session);
1406
1406
  return run;
1407
1407
  } finally {
@@ -1518,12 +1518,12 @@ ${inbox}`, { ...request, host: started.provider }, (snapshot) => {
1518
1518
  observation: snapshot
1519
1519
  });
1520
1520
  }, spec.timeoutMs);
1521
- if (run.kind !== "rejected" && run.outcome.kind === "failed" && run.outcome.failure === "auth")
1521
+ if (run.kind !== "rejected" && run.kind !== "handled" && run.outcome.kind === "failed" && run.outcome.failure === "auth")
1522
1522
  throw new Error("OAR_REVIEW_AUTH_STOP");
1523
1523
  const observation = {
1524
1524
  request_id: request.request_id,
1525
1525
  kind: run.kind,
1526
- outcome: run.kind === "rejected" ? null : run.outcome.kind,
1526
+ outcome: run.kind !== "rejected" && run.kind !== "handled" ? run.outcome.kind : null,
1527
1527
  actual_model: host.model(spec.kind)
1528
1528
  };
1529
1529
  writeSessionArtifact(join6(spec.controlDirectory, `observed-${request.round}.json`), observation);
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,S as n,a as r,b as i,d as a,h as o,m as s,n as c,o as l,p as u,s as d,v as f}from"./index-D68hqwj8.js";import{C as p,S as m,T as h,_ as g,b as _,i as v,n as y,r as b,t as x,v as S,w as C,x as w,y as T}from"./src-B-DeWB10.js";import{t as E}from"./value-DcGlvoTp.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=h(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,v).filter(r).on(`touchstart.drag`,x).on(`touchmove.drag`,E,_).on(`touchend.drag touchcancel.drag`,N).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function v(n,r){if(!u&&e.call(this,n,r)){var i=P(this,t.call(this,n,r),n,r,`mouse`);i&&(C(n.view).on(`mousemove.drag`,y,w).on(`mouseup.drag`,b,w),g(n.view),m(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function y(e){if(T(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function b(e){C(e.view).on(`mousemove.drag mouseup.drag`,null),S(e.view,l),T(e),i.mouse(`end`,e)}function x(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=P(this,a,n,r,i[s].identifier,i[s]))&&(m(n),c(`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])&&(T(e),a(`drag`,e,t[r]))}function N(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(m(e),a(`end`,e,t[r]))}function P(e,t,r,s,c,l){var u=a.copy(),d=p(l||r,t),m,h,g;if((g=n.call(e,new O(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return m=g.x-d[0]||0,h=g.y-d[1]||0,function n(r,a,l){var _=d,v;switch(r){case`start`:i[c]=n,v=o++;break;case`end`:delete i[c],--o;case`drag`:d=p(l||a,t),v=o}u.call(r,e,new O(r,{sourceEvent:a,subject:g,target:f,identifier:c,active:v,x:d[0]+m,y:d[1]+h,dx:d[0]-_[0],dy:d[1]-_[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:D(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:D(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:D(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:D(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var P=e(t(),1);function ee(e){return e.kind===`group`}var F=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,te=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,I=e=>typeof e==`string`,L=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,R=e=>L(e)&&e>0,ne=e=>typeof e==`boolean`,re=e=>t=>I(t)&&e.test(t),z=(...e)=>t=>e.includes(t),ie=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},ae=re(/^[0-9a-f]{64}$/),oe=re(te),se=re(F),ce=e=>I(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),le=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),ue=V({id:I,from:I,to:I,label:I,evidence:V({entrypointId:I,sourceSymbol:I,sinkId:I})}),de=e=>V({id:I,capabilityId:se,name:I,applicability:z(`not-applicable`),rationale:I})(e)||V({id:I,capabilityId:se,name:I,applicability:z(`required`),participants:B(V({id:I,nodeId:I})),steps:B(ue),outcomes:B(V({id:I,kind:z(`success`,`error`),label:I,steps:B(ue),terminal:V({participant:I,label:I})}))})(e),fe=e=>typeof e==`string`&&e.length>0&&e!==`group`,pe=V({include:B(I),exclude:B(I)}),me=e=>V({id:I,kind:fe,name:I,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:I,kind:z(`group`),role:z(`caller`,`callee`),count:R,members:B(V({id:I,name:I}))})(e),he=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:oe,modules:B(V({id:se,domain:I,name:I,status:I,components:L,state:le}))}),ge=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:oe,module:V({id:se,name:I,status:I,summary:I,responsibilities:B(I),notes:B(I),source:pe,verification:B(I),entrypoints:B(V({id:I,path:ce,symbols:B(V({name:I,sinks:B(V({id:I,path:ce,symbol:I}))}))})),components:B(V({id:I,kind:fe,name:I,summary:I,source:pe}))}),graph:V({center:se,nodes:B(me),edges:B(V({source:I,target:I,intent:I,relation_kind:I,direction:z(`directed`)}))}),flows:B(de),section3:ie(I),linked_docs:B(V({path:ce,kind:z(`contract`,`plan`),status:ie(I)})),state:le}),_e=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:I,package_version:I,repository_id:re(/^repo_[0-9a-f]{16}$/),capability_id:se,commit:oe,mode:z(`module`,`diff`),base:ie(oe),head:ie(oe),worktree_dirty_paths:B(ce),dirty_content_sha256:ie(ae),model_sha256:ae,doc_sha256:ie(ae),sources:B(V({path:ce,sha256:ae,bytes:L,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:R,used_bytes:L,incomplete:ne,omitted_sections:B(I)}),shard:V({index:R,count:R,bytes:L}),full_prompt_sha256:ae,prompt:I,digest:ae});function ve(e){if(!he(e))throw Error(`architecture_module_index_invalid`);return e}function ye(e){if(!ge(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>ee(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function be(e){if(!_e(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}var H=i();function U(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=U(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var xe={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.`},Se=[[-1/0,-1/0],[1/0,1/0]],Ce=[`Enter`,` `,`Escape`],we={"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`},Te;(function(e){e.Strict=`strict`,e.Loose=`loose`})(Te||={});var Ee;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Ee||={});var De;(function(e){e.Partial=`partial`,e.Full=`full`})(De||={});var Oe={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ke;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ke||={});var Ae;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Ae||={});var W;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(W||={});var je={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Me=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),Pe=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Fe=(e,t=[0,0])=>{let{width:n,height:r}=ht(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Ie=(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):Pe(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ye(e,$e(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ze(r):{x:0,y:0,width:0,height:0}},Le=(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=Ye(n,$e(e)),r=!0)}),r?Ze(n):{x:0,y:0,width:0,height:0}},Re=(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=tt(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},ze=(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 Be(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}=ht(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 Ve({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=ft(Le(Be(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 He({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`,xe.error005());else{let{width:e,height:t}=ht(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&mt(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=mt(d)?Ge(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,xe.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 Ue({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=ze(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 We=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:We(e.x,t[0][0],t[1][0]-(n?.width??0)),y:We(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ke(e,t,n){let{width:r,height:i}=ht(n),{x:a,y:o}=n.internals.positionAbsolute;return Ge(e,[[a,o],[a+r,o+i]],t)}var qe=(e,t,n)=>e<t?We(Math.abs(e-t),1,t)/t:e>n?-We(Math.abs(e-n),1,t)/t:0,Je=(e,t,n=15,r=40)=>[qe(e.x,r,t.width-r)*n,qe(e.y,r,t.height-r)*n],Ye=(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)}),Xe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ze=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Qe=(e,t=[0,0])=>{let{x:n,y:r}=Pe(e)?e.internals.positionAbsolute:Fe(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}},$e=(e,t=[0,0])=>{let{x:n,y:r}=Pe(e)?e.internals.positionAbsolute:Fe(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)}},et=(e,t)=>Ze(Ye(Xe(e),Xe(t))),tt=(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)},nt=(e,t)=>tt(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),rt=e=>it(e.width)&&it(e.height)&&it(e.x)&&it(e.y),it=e=>!isNaN(e)&&isFinite(e),at=(e,t)=>(e,t)=>{},ot=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),st=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?ot(s,o):s},ct=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function lt(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 ut(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=lt(e,n),i=lt(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=lt(e.top??e.y??0,n),i=lt(e.bottom??e.y??0,n),a=lt(e.left??e.x??0,t),o=lt(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 dt(e,t,n,r,i,a){let{x:o,y:s}=ct(e,[t,n,r]),{x:c,y:l}=ct({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 ft=(e,t,n,r,i,a)=>{let o=ut(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=We(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=dt(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}},pt=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function mt(e){return e!=null&&e!==`parent`}function ht(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gt(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function _t(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 vt(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function yt(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function bt(e){return{...we,...e||{}}}function xt(e){return e===null?null:e?`valid`:`invalid`}function St(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Ot(e),s=st({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?ot(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Ct=e=>({width:e.offsetWidth,height:e.offsetHeight}),wt=e=>e?.getRootNode?.()||window?.document,Tt=[`INPUT`,`SELECT`,`TEXTAREA`];function Et(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Tt.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Dt=e=>`clientX`in e,Ot=(e,t)=>{let n=Dt(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)}},kt=(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,...Ct(t)}})};function At({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 jt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Mt({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case W.Left:return[t-jt(t-r,a),n];case W.Right:return[t+jt(r-t,a),n];case W.Top:return[t,n-jt(n-i,a)];case W.Bottom:return[t,n+jt(i-n,a)]}}function Nt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,curvature:o=.25}){let[s,c]=Mt({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Mt({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=At({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 Pt({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 Ft({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 It({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ye($e(e),$e(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),nt({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Ze(a))>0}var Lt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Rt=(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)),zt=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,xe.error006()),t;let r=n.getEdgeId||Lt,i;return i=Me(e)?{...e}:{...e,id:r(e)},Rt(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Bt({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Pt({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Vt={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Ht=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},Ut=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Wt({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:i,offset:a,stepPosition:o}){let s=Vt[t],c=Vt[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=Ht({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]=Pt({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 Gt(e,t,n,r){let i=Math.min(Ut(e,t)/2,Ut(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 Kt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Wt({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+=Gt(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 qt(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Jt(e){let{sourceNode:t,targetNode:n}=e;if(!qt(t)||!qt(n))return null;let r=t.internals.handleBounds||Yt(t.handles),i=n.internals.handleBounds||Yt(n.handles),a=Zt(r?.source??[],e.sourceHandle),o=Zt(e.connectionMode===Te.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,xe.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||W.Bottom,c=o?.position||W.Top,l=Xt(t,a,s),u=Xt(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Yt(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 Xt(e,t,n=W.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??ht(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case W.Top:return{x:i+o/2,y:a};case W.Right:return{x:i+o,y:a+s/2};case W.Bottom:return{x:i+o/2,y:a+s};case W.Left:return{x:i,y:a+s/2}}}function Zt(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Qt(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function $t(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=Qt(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 en=1e3,tn=10,nn={nodeOrigin:[0,0],nodeExtent:Se,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},rn={...nn,checkEquality:!0};function an(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function on(e,t,n){let r=an(nn,n);for(let n of e.values())if(n.parentId)dn(n,e,t,r);else{let e=Ge(Fe(n,r.nodeOrigin),mt(n.extent)?n.extent:r.nodeExtent,ht(n));n.internals.positionAbsolute=e}}function sn(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 cn(e){return e===`manual`}function ln(e,t,n,r={}){let i=an(rn,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!cn(i.zIndexMode)?en: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=Ge(Fe(u,i.nodeOrigin),mt(u.extent)?u.extent:i.nodeExtent,ht(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:sn(u,e),z:fn(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&&dn(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function un(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 dn(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=an(nn,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}un(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*tn),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=pn(e,u,o,s,a&&!cn(c)?en: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 fn(e,t,n){let r=it(e.zIndex)?e.zIndex:0;return cn(n)?r:r+(e.selected?t:0)}function pn(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ht(e),l=Fe(e,n),u=mt(e.extent)?Ge(l,e.extent,c):l,d=Ge({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Ke(d,c,t));let f=fn(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function mn(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=et(a.get(n.parentId)?.expandedRect??Qe(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=ht(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 hn(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=Ct(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=mt(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Ke(h,s,n))}else m&&(h=Ge(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:kt(`source`,r.nodeElement,p,d,e.id),target:kt(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&dn(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:Qe(g,i)}))}}if(f.length>0){let e=mn(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function gn({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 _n(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 vn(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}`;_n(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),_n(`target`,s,c,e,i,o),t.set(r.id,r)}}function yn(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:yn(n,t):!1}function bn(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 xn(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!yn(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 Sn({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 Cn({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=ot(a,t);return{x:o.x-a.x,y:o.y-a.y}}function wn({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=C(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Xe(Le(s)):null,x=v&&l?Cn({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:ot(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}=He({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=Sn({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||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]=Je(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(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||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=St(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=xn(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=Sn({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let E=N().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&T(e),a=St(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Ot(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=St(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,w()),!d){let t=Ot(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=Ot(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=Sn({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!bn(t,`.${g}`,v))&&(!_||bn(t,_,v))});f.call(E)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Tn(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())nt(i,Qe(e))>0&&r.push(e);return r}var En=250;function Dn(e,t,n,r){let i=[],a=1/0,o=Tn(e,n,t+En);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}=Xt(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 On(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,...Xt(o,c,c.position,!0)}:c}function kn(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function An(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var jn=()=>!0;function Mn(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:_=jn,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=wt(e.target),E=0,D,{x:O,y:k}=Ot(e),A=kn(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=On(i,A,r,c,t);if(!N)return;let P=Ot(e,j),ee=!1,F=null,te=!1,I=null;function L(){if(!u||!j)return;let[e,t]=Je(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(L)}let R={...N,nodeId:i,type:A,position:N.position},ne=c.get(i),re={inProgress:!0,isValid:null,from:Xt(ne,R,W.Left,!0),fromHandle:R,fromPosition:R.position,fromNode:ne,to:P,toHandle:null,toPosition:je[R.position],toNode:null,pointer:P};function z(){M=!0,y(re),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&z();function ie(e){if(!M){let{x:t,y:n}=Ot(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;z()}if(!x()||!R){B(e);return}let a=b();P=Ot(e,j),D=Dn(st(P,a,!1,[1,1]),n,c,R),ee||=(L(),!0);let s=Nn(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});I=s.handleDomNode,F=s.connection,te=An(!!D,s.isValid);let u=c.get(i),f=u?Xt(u,R,W.Left,!0):re.from,p={...re,from:f,isValid:te,to:s.toHandle&&te?ct({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:te&&s.toHandle?s.toHandle.position:je[R.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),re=p}function B(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||I)&&F&&te&&h?.(F);let{inProgress:t,...n}=re,r={...n,toPosition:re.toHandle?re.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ee=!1,te=!1,F=null,I=null,T.removeEventListener(`mousemove`,ie),T.removeEventListener(`mouseup`,B),T.removeEventListener(`touchmove`,ie),T.removeEventListener(`touchend`,B)}}T.addEventListener(`mousemove`,ie),T.addEventListener(`mouseup`,B),T.addEventListener(`touchmove`,ie),T.addEventListener(`touchend`,B)}function Nn(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=jn,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}=Ot(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=kn(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===Te.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=On(t,e,a,u,n,!0)}return _}var Pn={onPointerDown:Mn,isValid:Nn};function Fn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=C(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&&pt()?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=x().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:p}}var In=e=>({x:e.x,y:e.y,zoom:e.k}),Ln=({x:e,y:t,zoom:n})=>y.translate(e,t).scale(n),Rn=(e,t)=>e.target.closest(`.${t}`),zn=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Bn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Vn=(e,t=0,n=Bn,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Hn=e=>{let t=e.ctrlKey&&pt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Un({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Rn(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=p(u),t=d*2**Hn(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,m=i===Ee.Vertical?0:u.deltaX*f,h=i===Ee.Horizontal?0:u.deltaY*f;!pt()&&u.shiftKey&&i!==Ee.Vertical&&(m=u.deltaY*f,h=0),r.translateBy(n,-(m/d)*a,-(h/d)*a,{internal:!0});let g=In(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,g):(e.isPanScrolling=!0,s?.(u,g)),e.panScrollTimeout=setTimeout(()=>{l?.(u,g),e.isPanScrolling=!1},150)}}function Wn({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 Gn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=In(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 Kn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&zn(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,In(a.transform))}}function qn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&zn(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=In(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Jn({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 Yn({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=x().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=C(e).call(f);S({x:i.x,y:i.y,zoom:We(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(Hn);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).transform(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:v,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&y();let k=i&&!C&&!r;f.clickDistance(O?1/0:!it(D)||D<0?0:D);let A=k?Un({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Wn({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=Gn({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=Kn({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=qn({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=Jn({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:v,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function y(){f.on(`zoom`,null)}async function S(e,t,n){let r=Ln(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function w(e,t){let n=Ln(e);return await g(n,t),n}function T(e){if(p){let t=Ln(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function D(){let e=p?b(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).scaleTo(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function k(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).scaleBy(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){f?.scaleExtent(e)}function j(e){f?.translateExtent(e)}function M(e){let t=!it(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:y,setViewport:w,setViewportConstrained:S,getViewport:D,scaleTo:O,scaleBy:k,setScaleExtent:A,setTranslateExtent:j,syncViewport:T,setClickDistance:M}}var Xn;(function(e){e.Line=`line`,e.Handle=`handle`})(Xn||={});function Zn({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 Qn(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 $n(e,t){return Math.max(0,t-e)}function er(e,t){return Math.max(0,e-t)}function tr(e,t,n){return Math.max(0,t-e,e-n)}function nr(e,t){return e?!t:t}function rr(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=tr(E,h,g),j=tr(D,_,v);if(o){let e=0,t=0;c&&w<0?e=$n(y+w+O,o[0][0]):!c&&w>0&&(e=er(y+E+O,o[1][0])),l&&T<0?t=$n(b+T+k,o[0][1]):!l&&T>0&&(t=er(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=er(y+w,s[0][0]):!c&&w<0&&(e=$n(y+E,s[1][0])),l&&T>0?t=er(b+T,s[0][1]):!l&&T<0&&(t=$n(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=tr(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?er(b+k+E/C,o[1][1])*C:$n(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?$n(b+E/C,s[1][1])*C:er(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=tr(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?er(y+D*C+O,o[1][0])/C:$n(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?$n(y+D*C,s[1][0])/C:er(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=(nr(c,l)?-w:w)/C:w=(nr(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 ir={width:0,height:0,x:0,y:0},ar={...ir,pointerX:0,pointerY:0,aspectRatio:1};function or(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 sr({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=C(e),o={controlDirection:Qn(`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={...ir},h={...ar};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Qn(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}=St(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=mt(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=or(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=St(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}=rr(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 ee=Zn({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),F={...m,direction:ee};if(p?.(e,F)===!1){m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position});return}d?.(e,F),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 cr=e(f(),1),lr=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},ur=e=>e?lr(e):lr,{useDebugValue:dr}=P.default,{useSyncExternalStoreWithSelector:fr}=cr.default,pr=e=>e;function mr(e,t=pr,n){let r=fr(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return dr(r),r}var hr=(e,t)=>{let n=ur(e),r=(e,r=t)=>mr(n,e,r);return Object.assign(r,n),r},gr=(e,t)=>e?hr(e,t):hr;function G(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}n();var _r=(0,P.createContext)(null),vr=_r.Provider,yr=xe.error001(`react`);function K(e,t){let n=(0,P.useContext)(_r);if(n===null)throw Error(yr);return mr(n,e,t)}function q(){let e=(0,P.useContext)(_r);if(e===null)throw Error(yr);return(0,P.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var br={display:`none`},xr={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Sr=`react-flow__node-desc`,Cr=`react-flow__edge-desc`,wr=`react-flow__aria-live`,Tr=e=>e.ariaLiveMessage,Er=e=>e.ariaLabelConfig;function Dr({rfId:e}){let t=K(Tr);return(0,H.jsx)(`div`,{id:`${wr}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:xr,children:t})}function Or({rfId:e,disableKeyboardA11y:t}){let n=K(Er);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{id:`${Sr}-${e}`,style:br,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,H.jsx)(`div`,{id:`${Cr}-${e}`,style:br,children:n[`edge.a11yDescription.default`]}),!t&&(0,H.jsx)(Dr,{rfId:e})]})}var kr=(0,P.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,H.jsx)(`div`,{className:U([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});kr.displayName=`Panel`;var Ar=`https://reactflow.dev?utm_source=attribution`;function jr({proOptions:e,position:t=`bottom-right`}){return(0,P.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,H.jsx)(kr,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ar}`,children:(0,H.jsx)(`a`,{href:Ar,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Mr=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}},Nr=e=>e.id;function Pr(e,t){return G(e.selectedNodes.map(Nr),t.selectedNodes.map(Nr))&&G(e.selectedEdges.map(Nr),t.selectedEdges.map(Nr))}function Fr({onSelectionChange:e}){let t=q(),{selectedNodes:n,selectedEdges:r}=K(Mr,Pr);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 Lr({onSelectionChange:e}){let t=K(Ir);return e||t?(0,H.jsx)(Fr,{onSelectionChange:e}):null}var Rr=[0,0],zr={x:0,y:0,zoom:1},Br=[...`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`],Vr=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}),Hr={translateExtent:Se,nodeOrigin:Rr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ur(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=K(Vr,G),l=q();(0,P.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Hr,s()}),[]);let u=(0,P.useRef)(Hr);return(0,P.useEffect)(()=>{for(let s of Br){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:bt(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Br.map(t=>e[t])),null}function Wr(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Gr(e){let[t,n]=(0,P.useState)(e===`system`?null:e);return(0,P.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Wr(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Wr()?.matches?`dark`:`light`:t}var Kr=typeof document<`u`?document:null;function qr(e=null,t={target:Kr,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{r as e}from"./rolldown-runtime-hePW80VL.js";import{C as t,S as n,a as r,b as i,d as a,h as o,m as s,n as c,o as l,p as u,s as d,v as f}from"./index-Fcy-xiIk.js";import{C as p,S as m,T as h,_ as g,b as _,i as v,n as y,r as b,t as x,v as S,w as C,x as w,y as T}from"./src-B-DeWB10.js";import{t as E}from"./value-DcGlvoTp.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=h(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,v).filter(r).on(`touchstart.drag`,x).on(`touchmove.drag`,E,_).on(`touchend.drag touchcancel.drag`,N).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function v(n,r){if(!u&&e.call(this,n,r)){var i=P(this,t.call(this,n,r),n,r,`mouse`);i&&(C(n.view).on(`mousemove.drag`,y,w).on(`mouseup.drag`,b,w),g(n.view),m(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function y(e){if(T(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function b(e){C(e.view).on(`mousemove.drag mouseup.drag`,null),S(e.view,l),T(e),i.mouse(`end`,e)}function x(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=P(this,a,n,r,i[s].identifier,i[s]))&&(m(n),c(`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])&&(T(e),a(`drag`,e,t[r]))}function N(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(m(e),a(`end`,e,t[r]))}function P(e,t,r,s,c,l){var u=a.copy(),d=p(l||r,t),m,h,g;if((g=n.call(e,new O(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return m=g.x-d[0]||0,h=g.y-d[1]||0,function n(r,a,l){var _=d,v;switch(r){case`start`:i[c]=n,v=o++;break;case`end`:delete i[c],--o;case`drag`:d=p(l||a,t),v=o}u.call(r,e,new O(r,{sourceEvent:a,subject:g,target:f,identifier:c,active:v,x:d[0]+m,y:d[1]+h,dx:d[0]-_[0],dy:d[1]-_[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:D(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:D(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:D(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:D(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var P=e(t(),1);function ee(e){return e.kind===`group`}var F=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,te=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,I=e=>typeof e==`string`,L=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,R=e=>L(e)&&e>0,ne=e=>typeof e==`boolean`,re=e=>t=>I(t)&&e.test(t),z=(...e)=>t=>e.includes(t),ie=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},ae=re(/^[0-9a-f]{64}$/),oe=re(te),se=re(F),ce=e=>I(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),le=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),ue=V({id:I,from:I,to:I,label:I,evidence:V({entrypointId:I,sourceSymbol:I,sinkId:I})}),de=e=>V({id:I,capabilityId:se,name:I,applicability:z(`not-applicable`),rationale:I})(e)||V({id:I,capabilityId:se,name:I,applicability:z(`required`),participants:B(V({id:I,nodeId:I})),steps:B(ue),outcomes:B(V({id:I,kind:z(`success`,`error`),label:I,steps:B(ue),terminal:V({participant:I,label:I})}))})(e),fe=e=>typeof e==`string`&&e.length>0&&e!==`group`,pe=V({include:B(I),exclude:B(I)}),me=e=>V({id:I,kind:fe,name:I,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:I,kind:z(`group`),role:z(`caller`,`callee`),count:R,members:B(V({id:I,name:I}))})(e),he=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:oe,modules:B(V({id:se,domain:I,name:I,status:I,components:L,state:le}))}),ge=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:oe,module:V({id:se,name:I,status:I,summary:I,responsibilities:B(I),notes:B(I),source:pe,verification:B(I),entrypoints:B(V({id:I,path:ce,symbols:B(V({name:I,sinks:B(V({id:I,path:ce,symbol:I}))}))})),components:B(V({id:I,kind:fe,name:I,summary:I,source:pe}))}),graph:V({center:se,nodes:B(me),edges:B(V({source:I,target:I,intent:I,relation_kind:I,direction:z(`directed`)}))}),flows:B(de),section3:ie(I),linked_docs:B(V({path:ce,kind:z(`contract`,`plan`),status:ie(I)})),state:le}),_e=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:I,package_version:I,repository_id:re(/^repo_[0-9a-f]{16}$/),capability_id:se,commit:oe,mode:z(`module`,`diff`),base:ie(oe),head:ie(oe),worktree_dirty_paths:B(ce),dirty_content_sha256:ie(ae),model_sha256:ae,doc_sha256:ie(ae),sources:B(V({path:ce,sha256:ae,bytes:L,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:R,used_bytes:L,incomplete:ne,omitted_sections:B(I)}),shard:V({index:R,count:R,bytes:L}),full_prompt_sha256:ae,prompt:I,digest:ae});function ve(e){if(!he(e))throw Error(`architecture_module_index_invalid`);return e}function ye(e){if(!ge(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>ee(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function be(e){if(!_e(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}var H=i();function U(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=U(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var xe={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.`},Se=[[-1/0,-1/0],[1/0,1/0]],Ce=[`Enter`,` `,`Escape`],we={"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`},Te;(function(e){e.Strict=`strict`,e.Loose=`loose`})(Te||={});var Ee;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(Ee||={});var De;(function(e){e.Partial=`partial`,e.Full=`full`})(De||={});var Oe={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ke;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ke||={});var Ae;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(Ae||={});var W;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(W||={});var je={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Me=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),Pe=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Fe=(e,t=[0,0])=>{let{width:n,height:r}=ht(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Ie=(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):Pe(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ye(e,$e(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ze(r):{x:0,y:0,width:0,height:0}},Le=(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=Ye(n,$e(e)),r=!0)}),r?Ze(n):{x:0,y:0,width:0,height:0}},Re=(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=tt(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},ze=(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 Be(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}=ht(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 Ve({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=ft(Le(Be(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 He({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`,xe.error005());else{let{width:e,height:t}=ht(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&mt(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=mt(d)?Ge(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,xe.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 Ue({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=ze(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 We=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:We(e.x,t[0][0],t[1][0]-(n?.width??0)),y:We(e.y,t[0][1],t[1][1]-(n?.height??0))});function Ke(e,t,n){let{width:r,height:i}=ht(n),{x:a,y:o}=n.internals.positionAbsolute;return Ge(e,[[a,o],[a+r,o+i]],t)}var qe=(e,t,n)=>e<t?We(Math.abs(e-t),1,t)/t:e>n?-We(Math.abs(e-n),1,t)/t:0,Je=(e,t,n=15,r=40)=>[qe(e.x,r,t.width-r)*n,qe(e.y,r,t.height-r)*n],Ye=(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)}),Xe=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ze=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Qe=(e,t=[0,0])=>{let{x:n,y:r}=Pe(e)?e.internals.positionAbsolute:Fe(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}},$e=(e,t=[0,0])=>{let{x:n,y:r}=Pe(e)?e.internals.positionAbsolute:Fe(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)}},et=(e,t)=>Ze(Ye(Xe(e),Xe(t))),tt=(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)},nt=(e,t)=>tt(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),rt=e=>it(e.width)&&it(e.height)&&it(e.x)&&it(e.y),it=e=>!isNaN(e)&&isFinite(e),at=(e,t)=>(e,t)=>{},ot=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),st=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?ot(s,o):s},ct=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function lt(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 ut(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=lt(e,n),i=lt(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=lt(e.top??e.y??0,n),i=lt(e.bottom??e.y??0,n),a=lt(e.left??e.x??0,t),o=lt(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 dt(e,t,n,r,i,a){let{x:o,y:s}=ct(e,[t,n,r]),{x:c,y:l}=ct({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 ft=(e,t,n,r,i,a)=>{let o=ut(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=We(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=dt(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}},pt=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function mt(e){return e!=null&&e!==`parent`}function ht(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gt(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function _t(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 vt(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function yt(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function bt(e){return{...we,...e||{}}}function xt(e){return e===null?null:e?`valid`:`invalid`}function St(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=Ot(e),s=st({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?ot(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var Ct=e=>({width:e.offsetWidth,height:e.offsetHeight}),wt=e=>e?.getRootNode?.()||window?.document,Tt=[`INPUT`,`SELECT`,`TEXTAREA`];function Et(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?Tt.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var Dt=e=>`clientX`in e,Ot=(e,t)=>{let n=Dt(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)}},kt=(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,...Ct(t)}})};function At({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 jt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Mt({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case W.Left:return[t-jt(t-r,a),n];case W.Right:return[t+jt(r-t,a),n];case W.Top:return[t,n-jt(n-i,a)];case W.Bottom:return[t,n+jt(i-n,a)]}}function Nt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,curvature:o=.25}){let[s,c]=Mt({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=Mt({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=At({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 Pt({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 Ft({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 It({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ye($e(e),$e(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),nt({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Ze(a))>0}var Lt=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Rt=(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)),zt=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,xe.error006()),t;let r=n.getEdgeId||Lt,i;return i=Me(e)?{...e}:{...e,id:r(e)},Rt(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Bt({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Pt({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var Vt={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Ht=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},Ut=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2);function Wt({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:i,offset:a,stepPosition:o}){let s=Vt[t],c=Vt[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=Ht({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]=Pt({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 Gt(e,t,n,r){let i=Math.min(Ut(e,t)/2,Ut(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 Kt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Wt({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+=Gt(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 qt(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Jt(e){let{sourceNode:t,targetNode:n}=e;if(!qt(t)||!qt(n))return null;let r=t.internals.handleBounds||Yt(t.handles),i=n.internals.handleBounds||Yt(n.handles),a=Zt(r?.source??[],e.sourceHandle),o=Zt(e.connectionMode===Te.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,xe.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||W.Bottom,c=o?.position||W.Top,l=Xt(t,a,s),u=Xt(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Yt(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 Xt(e,t,n=W.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??ht(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case W.Top:return{x:i+o/2,y:a};case W.Right:return{x:i+o,y:a+s/2};case W.Bottom:return{x:i+o/2,y:a+s};case W.Left:return{x:i,y:a+s/2}}}function Zt(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Qt(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function $t(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=Qt(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 en=1e3,tn=10,nn={nodeOrigin:[0,0],nodeExtent:Se,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},rn={...nn,checkEquality:!0};function an(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function on(e,t,n){let r=an(nn,n);for(let n of e.values())if(n.parentId)dn(n,e,t,r);else{let e=Ge(Fe(n,r.nodeOrigin),mt(n.extent)?n.extent:r.nodeExtent,ht(n));n.internals.positionAbsolute=e}}function sn(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 cn(e){return e===`manual`}function ln(e,t,n,r={}){let i=an(rn,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!cn(i.zIndexMode)?en: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=Ge(Fe(u,i.nodeOrigin),mt(u.extent)?u.extent:i.nodeExtent,ht(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:sn(u,e),z:fn(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&&dn(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function un(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 dn(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=an(nn,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}un(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*tn),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=pn(e,u,o,s,a&&!cn(c)?en: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 fn(e,t,n){let r=it(e.zIndex)?e.zIndex:0;return cn(n)?r:r+(e.selected?t:0)}function pn(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=ht(e),l=Fe(e,n),u=mt(e.extent)?Ge(l,e.extent,c):l,d=Ge({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Ke(d,c,t));let f=fn(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function mn(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=et(a.get(n.parentId)?.expandedRect??Qe(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=ht(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 hn(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=Ct(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=mt(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Ke(h,s,n))}else m&&(h=Ge(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:kt(`source`,r.nodeElement,p,d,e.id),target:kt(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&dn(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:Qe(g,i)}))}}if(f.length>0){let e=mn(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function gn({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 _n(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 vn(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}`;_n(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),_n(`target`,s,c,e,i,o),t.set(r.id,r)}}function yn(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:yn(n,t):!1}function bn(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 xn(e,t,n,r){let i=new Map;for(let[a,o]of e)if((o.selected||o.id===r)&&(!o.parentId||!yn(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 Sn({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 Cn({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=ot(a,t);return{x:o.x-a.x,y:o.y-a.y}}function wn({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=C(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Xe(Le(s)):null,x=v&&l?Cn({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:ot(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}=He({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=Sn({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||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]=Je(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(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||!y)&&!o&&b&&(i.get(b)?.selected||_()),y&&m&&b&&e?.(b);let v=St(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=v,s=xn(i,c,v,b),s.size>0&&(n||h||!b&&g)){let[e,t]=Sn({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let E=N().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&T(e),a=St(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=Ot(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=St(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,w()),!d){let t=Ot(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=Ot(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p){p&&s.size>0&&t().updateNodePositions(s,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=Sn({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!bn(t,`.${g}`,v))&&(!_||bn(t,_,v))});f.call(E)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function Tn(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())nt(i,Qe(e))>0&&r.push(e);return r}var En=250;function Dn(e,t,n,r){let i=[],a=1/0,o=Tn(e,n,t+En);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}=Xt(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 On(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,...Xt(o,c,c.position,!0)}:c}function kn(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function An(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var jn=()=>!0;function Mn(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:_=jn,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=wt(e.target),E=0,D,{x:O,y:k}=Ot(e),A=kn(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=On(i,A,r,c,t);if(!N)return;let P=Ot(e,j),ee=!1,F=null,te=!1,I=null;function L(){if(!u||!j)return;let[e,t]=Je(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(L)}let R={...N,nodeId:i,type:A,position:N.position},ne=c.get(i),re={inProgress:!0,isValid:null,from:Xt(ne,R,W.Left,!0),fromHandle:R,fromPosition:R.position,fromNode:ne,to:P,toHandle:null,toPosition:je[R.position],toNode:null,pointer:P};function z(){M=!0,y(re),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&z();function ie(e){if(!M){let{x:t,y:n}=Ot(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;z()}if(!x()||!R){B(e);return}let a=b();P=Ot(e,j),D=Dn(st(P,a,!1,[1,1]),n,c,R),ee||=(L(),!0);let s=Nn(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});I=s.handleDomNode,F=s.connection,te=An(!!D,s.isValid);let u=c.get(i),f=u?Xt(u,R,W.Left,!0):re.from,p={...re,from:f,isValid:te,to:s.toHandle&&te?ct({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:te&&s.toHandle?s.toHandle.position:je[R.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),re=p}function B(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||I)&&F&&te&&h?.(F);let{inProgress:t,...n}=re,r={...n,toPosition:re.toHandle?re.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ee=!1,te=!1,F=null,I=null,T.removeEventListener(`mousemove`,ie),T.removeEventListener(`mouseup`,B),T.removeEventListener(`touchmove`,ie),T.removeEventListener(`touchend`,B)}}T.addEventListener(`mousemove`,ie),T.addEventListener(`mouseup`,B),T.addEventListener(`touchmove`,ie),T.addEventListener(`touchend`,B)}function Nn(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=jn,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}=Ot(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=kn(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===Te.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=On(t,e,a,u,n,!0)}return _}var Pn={onPointerDown:Mn,isValid:Nn};function Fn({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=C(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&&pt()?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=x().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:p}}var In=e=>({x:e.x,y:e.y,zoom:e.k}),Ln=({x:e,y:t,zoom:n})=>y.translate(e,t).scale(n),Rn=(e,t)=>e.target.closest(`.${t}`),zn=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Bn=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Vn=(e,t=0,n=Bn,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Hn=e=>{let t=e.ctrlKey&&pt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Un({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Rn(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=p(u),t=d*2**Hn(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,m=i===Ee.Vertical?0:u.deltaX*f,h=i===Ee.Horizontal?0:u.deltaY*f;!pt()&&u.shiftKey&&i!==Ee.Vertical&&(m=u.deltaY*f,h=0),r.translateBy(n,-(m/d)*a,-(h/d)*a,{internal:!0});let g=In(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,g):(e.isPanScrolling=!0,s?.(u,g)),e.panScrollTimeout=setTimeout(()=>{l?.(u,g),e.isPanScrolling=!1},150)}}function Wn({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 Gn({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=In(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 Kn({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&zn(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,In(a.transform))}}function qn({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&zn(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=In(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Jn({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 Yn({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null)?.observe(e);let f=x().extent(()=>d).scaleExtent([t,n]).translateExtent(r),p=C(e).call(f);S({x:i.x,y:i.y,zoom:We(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let m=p.on(`wheel.zoom`),h=p.on(`dblclick.zoom`);f.wheelDelta(Hn);async function g(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).transform(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function _({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:g,preventScrolling:_,zoomOnPinch:v,zoomOnScroll:b,zoomOnDoubleClick:x,panActivationKeyPressed:S=!1,zoomActivationKeyPressed:C,lib:w,onTransformChange:T,connectionInProgress:E,paneClickDistance:D,selectionOnDrag:O}){r&&!l.isZoomingOrPanning&&y();let k=i&&!C&&!r;f.clickDistance(O?1/0:!it(D)||D<0?0:D);let A=k?Un({zoomPanValues:l,noWheelClassName:e,d3Selection:p,d3Zoom:f,panOnScrollMode:d,panOnScrollSpeed:g,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Wn({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:m});p.on(`wheel.zoom`,A,{passive:!1});let j=Gn({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});f.on(`start`,j);let M=Kn({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:T});f.on(`zoom`,M);let N=qn({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});f.on(`end`,N);let P=Jn({panActivationKeyPressed:S,zoomActivationKeyPressed:C,panOnDrag:u,zoomOnScroll:b,panOnScroll:i,zoomOnDoubleClick:x,zoomOnPinch:v,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:w,connectionInProgress:E});f.filter(P),x?p.on(`dblclick.zoom`,h):p.on(`dblclick.zoom`,null)}function y(){f.on(`zoom`,null)}async function S(e,t,n){let r=Ln(e),i=f?.constrain()(r,t,n);return i&&await g(i),i}async function w(e,t){let n=Ln(e);return await g(n,t),n}function T(e){if(p){let t=Ln(e),n=p.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&f?.transform(p,t,null,{sync:!0})}}function D(){let e=p?b(p.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).scaleTo(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function k(e,t){return p?new Promise(n=>{f?.interpolate(t?.interpolate===`linear`?E:v).scaleBy(Vn(p,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){f?.scaleExtent(e)}function j(e){f?.translateExtent(e)}function M(e){let t=!it(e)||e<0?0:e;f?.clickDistance(t)}return{update:_,destroy:y,setViewport:w,setViewportConstrained:S,getViewport:D,scaleTo:O,scaleBy:k,setScaleExtent:A,setTranslateExtent:j,syncViewport:T,setClickDistance:M}}var Xn;(function(e){e.Line=`line`,e.Handle=`handle`})(Xn||={});function Zn({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 Qn(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 $n(e,t){return Math.max(0,t-e)}function er(e,t){return Math.max(0,e-t)}function tr(e,t,n){return Math.max(0,t-e,e-n)}function nr(e,t){return e?!t:t}function rr(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=tr(E,h,g),j=tr(D,_,v);if(o){let e=0,t=0;c&&w<0?e=$n(y+w+O,o[0][0]):!c&&w>0&&(e=er(y+E+O,o[1][0])),l&&T<0?t=$n(b+T+k,o[0][1]):!l&&T>0&&(t=er(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=er(y+w,s[0][0]):!c&&w<0&&(e=$n(y+E,s[1][0])),l&&T>0?t=er(b+T,s[0][1]):!l&&T<0&&(t=$n(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=tr(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?er(b+k+E/C,o[1][1])*C:$n(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?$n(b+E/C,s[1][1])*C:er(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=tr(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?er(y+D*C+O,o[1][0])/C:$n(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?$n(y+D*C,s[1][0])/C:er(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=(nr(c,l)?-w:w)/C:w=(nr(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 ir={width:0,height:0,x:0,y:0},ar={...ir,pointerX:0,pointerY:0,aspectRatio:1};function or(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 sr({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=C(e),o={controlDirection:Qn(`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={...ir},h={...ar};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Qn(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}=St(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=mt(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=or(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=St(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}=rr(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 ee=Zn({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),F={...m,direction:ee};if(p?.(e,F)===!1){m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position});return}d?.(e,F),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 cr=e(f(),1),lr=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},ur=e=>e?lr(e):lr,{useDebugValue:dr}=P.default,{useSyncExternalStoreWithSelector:fr}=cr.default,pr=e=>e;function mr(e,t=pr,n){let r=fr(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return dr(r),r}var hr=(e,t)=>{let n=ur(e),r=(e,r=t)=>mr(n,e,r);return Object.assign(r,n),r},gr=(e,t)=>e?hr(e,t):hr;function G(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}n();var _r=(0,P.createContext)(null),vr=_r.Provider,yr=xe.error001(`react`);function K(e,t){let n=(0,P.useContext)(_r);if(n===null)throw Error(yr);return mr(n,e,t)}function q(){let e=(0,P.useContext)(_r);if(e===null)throw Error(yr);return(0,P.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var br={display:`none`},xr={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},Sr=`react-flow__node-desc`,Cr=`react-flow__edge-desc`,wr=`react-flow__aria-live`,Tr=e=>e.ariaLiveMessage,Er=e=>e.ariaLabelConfig;function Dr({rfId:e}){let t=K(Tr);return(0,H.jsx)(`div`,{id:`${wr}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:xr,children:t})}function Or({rfId:e,disableKeyboardA11y:t}){let n=K(Er);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{id:`${Sr}-${e}`,style:br,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,H.jsx)(`div`,{id:`${Cr}-${e}`,style:br,children:n[`edge.a11yDescription.default`]}),!t&&(0,H.jsx)(Dr,{rfId:e})]})}var kr=(0,P.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,H.jsx)(`div`,{className:U([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});kr.displayName=`Panel`;var Ar=`https://reactflow.dev?utm_source=attribution`;function jr({proOptions:e,position:t=`bottom-right`}){return(0,P.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,H.jsx)(kr,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Ar}`,children:(0,H.jsx)(`a`,{href:Ar,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Mr=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}},Nr=e=>e.id;function Pr(e,t){return G(e.selectedNodes.map(Nr),t.selectedNodes.map(Nr))&&G(e.selectedEdges.map(Nr),t.selectedEdges.map(Nr))}function Fr({onSelectionChange:e}){let t=q(),{selectedNodes:n,selectedEdges:r}=K(Mr,Pr);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 Lr({onSelectionChange:e}){let t=K(Ir);return e||t?(0,H.jsx)(Fr,{onSelectionChange:e}):null}var Rr=[0,0],zr={x:0,y:0,zoom:1},Br=[...`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`],Vr=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}),Hr={translateExtent:Se,nodeOrigin:Rr,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Ur(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=K(Vr,G),l=q();(0,P.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Hr,s()}),[]);let u=(0,P.useRef)(Hr);return(0,P.useEffect)(()=>{for(let s of Br){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:bt(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Br.map(t=>e[t])),null}function Wr(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Gr(e){let[t,n]=(0,P.useState)(e===`system`?null:e);return(0,P.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Wr(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Wr()?.matches?`dark`:`light`:t}var Kr=typeof document<`u`?document:null;function qr(e=null,t={target:Kr,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
  `,`