@aiderdesk/aiderdesk 0.61.0-dev → 0.61.1

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 (196) hide show
  1. package/out/renderer/assets/__vite-browser-external-2447137e-DYxpcVy9.js +4 -0
  2. package/out/renderer/assets/{_baseUniq-Z8t1Ab1g.js → _baseUniq-BPF2Herp.js} +21 -197
  3. package/out/renderer/assets/{arc-CwESpVYE.js → arc-DfPLteHF.js} +1 -1
  4. package/out/renderer/assets/{architectureDiagram-2XIMDMQ5-C490EQr5.js → architectureDiagram-Q4EWVU46-Bw0u-sSH.js} +34 -20
  5. package/out/renderer/assets/{blockDiagram-WCTKOSBZ-DbHssxrQ.js → blockDiagram-DXYQGD6D-CkfB9if8.js} +21 -8
  6. package/out/renderer/assets/{c4Diagram-IC4MRINW-BxE3GUKu.js → c4Diagram-AHTNJAMY-DweK9Liz.js} +31 -35
  7. package/out/renderer/assets/{channel-C9hJq_Xr.js → channel-C5wwrRof.js} +1 -1
  8. package/out/renderer/assets/{chunk-4BX2VUAB-ChcKNpL6.js → chunk-4BX2VUAB-0KM14cFd.js} +1 -1
  9. package/out/renderer/assets/{chunk-WL4C6EOR-vhby2fZi.js → chunk-4TB4RGXK-CmVtCVL4.js} +121 -82
  10. package/out/renderer/assets/{chunk-55IACEB6-oLT9lXTt.js → chunk-55IACEB6-BzVYZvBM.js} +1 -1
  11. package/out/renderer/assets/{chunk-KX2RTZJC-D32tV7H-.js → chunk-EDXVE4YY-BryQl5Kv.js} +1 -1
  12. package/out/renderer/assets/{chunk-FMBD7UC4-B5k8rETe.js → chunk-FMBD7UC4-CRiLea_e.js} +1 -1
  13. package/out/renderer/assets/{chunk-NQ4KR5QH-Bmqo2FpL.js → chunk-OYMX7WX6-Cpi4N3NO.js} +32 -15
  14. package/out/renderer/assets/{chunk-QZHKN3VN-8BpGifjS.js → chunk-QZHKN3VN-BT8kABWC.js} +1 -1
  15. package/out/renderer/assets/{chunk-JSJVCQXG-DtjSx6Cj.js → chunk-YZCP3GAM-OLZV_Sef.js} +1 -1
  16. package/out/renderer/assets/{classDiagram-VBA2DB6C-BxRSSb9e.js → classDiagram-6PBFFD2Q-VdE6G90i.js} +6 -6
  17. package/out/renderer/assets/{classDiagram-v2-RAHNMMFH-BxRSSb9e.js → classDiagram-v2-HSJHXN6E-VdE6G90i.js} +6 -6
  18. package/out/renderer/assets/{clone-D9a-uIZa.js → clone-DwQZ86nS.js} +1 -1
  19. package/out/renderer/assets/{cose-bilkent-S5V4N54A-CUqqQ-6R.js → cose-bilkent-S5V4N54A-BEcAKM9H.js} +1 -1
  20. package/out/renderer/assets/{dagre-KLK3FWXG-ORIwMMhq.js → dagre-KV5264BT-BcFQYL1M.js} +6 -6
  21. package/out/renderer/assets/diagram-5BDNPKRD-GrUNdC1u.js +171 -0
  22. package/out/renderer/assets/{diagram-E7M64L7V-bS9HcoDQ.js → diagram-G4DWMVQ6-CG4S-ov5.js} +15 -13
  23. package/out/renderer/assets/{diagram-IFDJBPK2-BRlTIR0J.js → diagram-MMDJMWI5-9ogY3MRC.js} +5 -6
  24. package/out/renderer/assets/{diagram-P4PSJMXO-jsjGwH-p.js → diagram-TYMM5635-Ck7mI1bS.js} +5 -6
  25. package/out/renderer/assets/{erDiagram-INFDFZHY-DGlgjHOQ.js → erDiagram-SMLLAGMA-Dvf_c-7M.js} +81 -35
  26. package/out/renderer/assets/{flowDiagram-PKNHOUZH-CzLC87bM.js → flowDiagram-DWJPFMVM-CPDjOXYp.js} +27 -45
  27. package/out/renderer/assets/{ganttDiagram-A5KZAMGK-BbDv36wT.js → ganttDiagram-T4ZO3ILL-B4dJrK-3.js} +17 -8
  28. package/out/renderer/assets/{gitGraphDiagram-K3NZZRJ6-CBQnBjEi.js → gitGraphDiagram-UUTBAWPF-De2eCfMN.js} +244 -67
  29. package/out/renderer/assets/{graph-Dl5N6maZ.js → graph-BFn23kR_.js} +175 -3
  30. package/out/renderer/assets/{index-MDHavDF9.js → index-BL-57WPa.js} +15877 -20787
  31. package/out/renderer/assets/{index-CDCy_DhA.css → index-BkntVzTm.css} +114 -301
  32. package/out/renderer/assets/{infoDiagram-LFFYTUFH-GtEDBEmz.js → infoDiagram-42DDH7IO-BIt9B6mQ.js} +5 -6
  33. package/out/renderer/assets/{ishikawaDiagram-PHBUUO56-Uj90gr3I.js → ishikawaDiagram-UXIWVN3A-CXZs0KGV.js} +3 -3
  34. package/out/renderer/assets/{journeyDiagram-4ABVD52K-DekFuOwS.js → journeyDiagram-VCZTEJTY-B-EXuj5b.js} +14 -13
  35. package/out/renderer/assets/{kanban-definition-K7BYSVSG-Hfz2L6NS.js → kanban-definition-6JOO6SKY-ByvN0qaD.js} +5 -2
  36. package/out/renderer/assets/{layout-B9K2VT39.js → layout-BpybWUv6.js} +117 -4
  37. package/out/renderer/assets/min-DB8ixvoT.js +41 -0
  38. package/out/renderer/assets/{mindmap-definition-YRQLILUH-DDcS7_GH.js → mindmap-definition-QFDTVHPH-Do-I-At8.js} +69 -13
  39. package/out/renderer/assets/{pieDiagram-SKSYHLDU-DwjEcJ0Q.js → pieDiagram-DEJITSTG-Cnpf6Gt6.js} +20 -13
  40. package/out/renderer/assets/{quadrantDiagram-337W2JSQ-CpGqN7vo.js → quadrantDiagram-34T5L4WZ-VcOb1qLd.js} +1 -1
  41. package/out/renderer/assets/{requirementDiagram-Z7DCOOCP-qDRUf1ip.js → requirementDiagram-MS252O5E-VJs9Hpaw.js} +42 -11
  42. package/out/renderer/assets/{sankeyDiagram-WA2Y5GQK-DRKS8C1H.js → sankeyDiagram-XADWPNL6-BoXxgLvi.js} +1 -1
  43. package/out/renderer/assets/{sequenceDiagram-2WXFIKYE-DhVN2ug2.js → sequenceDiagram-FGHM5R23-b69hQjSp.js} +446 -220
  44. package/out/renderer/assets/{stateDiagram-RAJIS63D-BpP4eSqu.js → stateDiagram-FHFEXIEX-BK7E-REm.js} +10 -9
  45. package/out/renderer/assets/{stateDiagram-v2-FVOUBMTO-B_qQJqra.js → stateDiagram-v2-QKLJ7IA2-Cd2wfCQu.js} +4 -4
  46. package/out/renderer/assets/{timeline-definition-YZTLITO2-UoWXE_76.js → timeline-definition-GMOUNBTQ-Bl-MTfK5.js} +445 -71
  47. package/out/renderer/assets/{vennDiagram-LZ73GAT5-Dp1FZ609.js → vennDiagram-DHZGUBPP-DNmr1k2L.js} +1 -1
  48. package/out/renderer/assets/{treemap-KZPCXAKY-W2a2L6ff.js → wardley-RL74JXVD-DTbxPMj9.js} +1474 -977
  49. package/out/renderer/assets/wardleyDiagram-NUSXRM2D-BWw08wtD.js +901 -0
  50. package/out/renderer/assets/{xychartDiagram-JWTSCODW-CTzYHTbD.js → xychartDiagram-5P7HB3ND-EEYPnLDT.js} +20 -4
  51. package/out/renderer/index.html +3 -3
  52. package/out/renderer/progress.html +212 -62
  53. package/out/resources/mcp-server/aider-desk-mcp-server.js +642 -402
  54. package/out/resources/skills/extension-creator/SKILL.md +320 -0
  55. package/out/resources/skills/extension-creator/assets/templates/Component.jsx.template +76 -0
  56. package/out/resources/skills/extension-creator/assets/templates/ConfigComponent.jsx.template +38 -0
  57. package/out/resources/skills/extension-creator/assets/templates/folder-extension/config.ts.template +29 -0
  58. package/out/resources/skills/extension-creator/assets/templates/folder-extension/index.ts.template +42 -0
  59. package/out/resources/skills/extension-creator/assets/templates/folder-extension/package.json +12 -0
  60. package/out/resources/skills/extension-creator/assets/templates/folder-extension/tsconfig.json +23 -0
  61. package/out/resources/skills/extension-creator/assets/templates/folder-extension-with-config/index.ts.template +80 -0
  62. package/out/resources/skills/extension-creator/assets/templates/single-file.ts.template +30 -0
  63. package/out/resources/skills/extension-creator/assets/templates/ui-component-external.ts.template +91 -0
  64. package/out/resources/skills/extension-creator/assets/templates/ui-component.ts.template +79 -0
  65. package/out/resources/skills/extension-creator/references/command-definition.md +170 -0
  66. package/out/resources/skills/extension-creator/references/config-components.md +427 -0
  67. package/out/resources/skills/extension-creator/references/event-types.md +156 -0
  68. package/out/resources/skills/extension-creator/references/examples-gallery.md +583 -0
  69. package/out/resources/skills/extension-creator/references/extension-interface.md +240 -0
  70. package/out/resources/skills/extension-creator/references/extension-types.md +186 -0
  71. package/out/resources/skills/extension-creator/references/in-repo-flow.md +132 -0
  72. package/out/resources/skills/extension-creator/references/install-targets.md +96 -0
  73. package/out/resources/skills/extension-creator/references/project-global-flow.md +76 -0
  74. package/out/resources/skills/extension-creator/references/ui-components.md +663 -0
  75. package/out/runner.js +976 -386
  76. package/package.json +2 -3
  77. package/out/renderer/assets/_basePickBy-BWoXHZ8Z.js +0 -161
  78. package/out/renderer/assets/apl-fqmucPXA.js +0 -140
  79. package/out/renderer/assets/asciiarmor-DucZyvP0.js +0 -56
  80. package/out/renderer/assets/asn1-BnOEsgAm.js +0 -144
  81. package/out/renderer/assets/asterisk-QAlztEwS.js +0 -345
  82. package/out/renderer/assets/brainfuck-DZVCuF_t.js +0 -53
  83. package/out/renderer/assets/clike-xqXYL6ge.js +0 -805
  84. package/out/renderer/assets/clojure-BhXMqnxz.js +0 -849
  85. package/out/renderer/assets/cmake-BGaNd9E7.js +0 -71
  86. package/out/renderer/assets/cobol-4yqQntpt.js +0 -120
  87. package/out/renderer/assets/coffeescript-D2dXvhEc.js +0 -308
  88. package/out/renderer/assets/commonlisp-CF_VNHQR.js +0 -130
  89. package/out/renderer/assets/crystal-DyuLTqLs.js +0 -398
  90. package/out/renderer/assets/css-c-jst79C.js +0 -1783
  91. package/out/renderer/assets/cypher-Dlu_3r4V.js +0 -121
  92. package/out/renderer/assets/d-UURgV0Ux.js +0 -179
  93. package/out/renderer/assets/diff-B_Bi2Crb.js +0 -25
  94. package/out/renderer/assets/dockerfile-Bvk733Ga.js +0 -201
  95. package/out/renderer/assets/dtd-Dy74G54E.js +0 -114
  96. package/out/renderer/assets/dylan-TSb-Nfix.js +0 -314
  97. package/out/renderer/assets/ebnf-4fKAGW3a.js +0 -140
  98. package/out/renderer/assets/ecl-B59qGGVg.js +0 -178
  99. package/out/renderer/assets/eiffel-Dze7nlu3.js +0 -134
  100. package/out/renderer/assets/elm-DG7jkhNZ.js +0 -176
  101. package/out/renderer/assets/erlang-BO6gOnGA.js +0 -674
  102. package/out/renderer/assets/factor-CMxFHDqz.js +0 -65
  103. package/out/renderer/assets/fcl-CDDUNjTj.js +0 -141
  104. package/out/renderer/assets/forth-B9D2JCeE.js +0 -116
  105. package/out/renderer/assets/fortran-CAG2BFbe.js +0 -467
  106. package/out/renderer/assets/gas-d3KEcW3x.js +0 -294
  107. package/out/renderer/assets/gherkin-DhZlEZiy.js +0 -115
  108. package/out/renderer/assets/groovy-CpwJiBl7.js +0 -223
  109. package/out/renderer/assets/haskell-ySd-OUo8.js +0 -459
  110. package/out/renderer/assets/haxe-7MlzfeYV.js +0 -514
  111. package/out/renderer/assets/http-BqypyemW.js +0 -79
  112. package/out/renderer/assets/idl-4HIGJlDI.js +0 -985
  113. package/out/renderer/assets/index-6qedlt0q.js +0 -689
  114. package/out/renderer/assets/index-86jDpUJn.js +0 -385
  115. package/out/renderer/assets/index-BRjO8ber.js +0 -332
  116. package/out/renderer/assets/index-BVgw7j0d.js +0 -312
  117. package/out/renderer/assets/index-BhkyI1q3.js +0 -642
  118. package/out/renderer/assets/index-BqrmLPkg.js +0 -82
  119. package/out/renderer/assets/index-BuPbw4xM.js +0 -178
  120. package/out/renderer/assets/index-CTO-LPBg.js +0 -311
  121. package/out/renderer/assets/index-CTO4SzlI.js +0 -97
  122. package/out/renderer/assets/index-CZ9IQK_0.js +0 -2488
  123. package/out/renderer/assets/index-CZxsVxBZ.js +0 -1765
  124. package/out/renderer/assets/index-DIXV-3Xn.js +0 -406
  125. package/out/renderer/assets/index-DNzOtZX5.js +0 -61
  126. package/out/renderer/assets/index-DZtJe7oC.js +0 -1019
  127. package/out/renderer/assets/index-DaWjZz_g.js +0 -291
  128. package/out/renderer/assets/index-De056HHR.js +0 -151
  129. package/out/renderer/assets/index-Dk3wSDSN.js +0 -117
  130. package/out/renderer/assets/index-Dy4VRsnA.js +0 -1041
  131. package/out/renderer/assets/index-FnnayPBc.js +0 -82
  132. package/out/renderer/assets/index-MZb_zy6R.js +0 -704
  133. package/out/renderer/assets/index-chzQl8rJ.js +0 -157
  134. package/out/renderer/assets/index-s-Owx3Pm.js +0 -327
  135. package/out/renderer/assets/javascript-C_OHM9hj.js +0 -994
  136. package/out/renderer/assets/julia-Bs6JJhYG.js +0 -407
  137. package/out/renderer/assets/livescript-DmzgM3Yt.js +0 -296
  138. package/out/renderer/assets/lua-8cJgIlqe.js +0 -256
  139. package/out/renderer/assets/mathematica-DNLOL9PQ.js +0 -110
  140. package/out/renderer/assets/mbox-Ga7d4MMN.js +0 -117
  141. package/out/renderer/assets/mirc-Dma3B8rS.js +0 -107
  142. package/out/renderer/assets/mllike-DHn7xckP.js +0 -334
  143. package/out/renderer/assets/modelica-0d55jYY0.js +0 -147
  144. package/out/renderer/assets/mscgen-DdqZYINH.js +0 -135
  145. package/out/renderer/assets/mumps-Btr8VblO.js +0 -93
  146. package/out/renderer/assets/nginx-DTDtBDVN.js +0 -141
  147. package/out/renderer/assets/nsis-3zG7tgur.js +0 -62
  148. package/out/renderer/assets/ntriples-CvgOYMpL.js +0 -153
  149. package/out/renderer/assets/octave-DYBj3-tl.js +0 -200
  150. package/out/renderer/assets/oz-R_e8WMIi.js +0 -231
  151. package/out/renderer/assets/pascal-GD8iposT.js +0 -105
  152. package/out/renderer/assets/perl-DL9mHpoi.js +0 -1105
  153. package/out/renderer/assets/pig-C_4T4YIV.js +0 -101
  154. package/out/renderer/assets/powershell-B0suO7Vd.js +0 -328
  155. package/out/renderer/assets/properties-BR-vP1aU.js +0 -58
  156. package/out/renderer/assets/protobuf-BxgpyhoW.js +0 -77
  157. package/out/renderer/assets/pug-CTXt1f8z.js +0 -405
  158. package/out/renderer/assets/puppet-Bdao66PW.js +0 -137
  159. package/out/renderer/assets/python-CvWbmiX4.js +0 -427
  160. package/out/renderer/assets/q-CrbCVq4a.js +0 -131
  161. package/out/renderer/assets/r-V7nswm59.js +0 -170
  162. package/out/renderer/assets/rpm-C-DLY-If.js +0 -109
  163. package/out/renderer/assets/ruby-JDKLJNK0.js +0 -330
  164. package/out/renderer/assets/sas-D2UG-yhZ.js +0 -207
  165. package/out/renderer/assets/scheme-BKzrkGJD.js +0 -222
  166. package/out/renderer/assets/shell-BlsXDxCn.js +0 -222
  167. package/out/renderer/assets/sieve-CjwBwOY5.js +0 -135
  168. package/out/renderer/assets/simple-mode-DMneyfDu.js +0 -130
  169. package/out/renderer/assets/smalltalk-BOIGQuhN.js +0 -121
  170. package/out/renderer/assets/solr-CwD7U71z.js +0 -69
  171. package/out/renderer/assets/sparql-DYskk2vE.js +0 -249
  172. package/out/renderer/assets/spreadsheet-Bgtt3oLP.js +0 -87
  173. package/out/renderer/assets/sql-BSrOzCRI.js +0 -354
  174. package/out/renderer/assets/stex-B6LNC55o.js +0 -231
  175. package/out/renderer/assets/stylus-BkS-boTH.js +0 -565
  176. package/out/renderer/assets/swift-FRZi1uvB.js +0 -291
  177. package/out/renderer/assets/tcl-CUcaCdmq.js +0 -114
  178. package/out/renderer/assets/textile-BnFpjsrl.js +0 -414
  179. package/out/renderer/assets/tiddlywiki-CjprD-Qp.js +0 -218
  180. package/out/renderer/assets/tiki-DK9DOeWn.js +0 -268
  181. package/out/renderer/assets/toml-BOuWGMcf.js +0 -76
  182. package/out/renderer/assets/troff-E1bJ0PPL.js +0 -61
  183. package/out/renderer/assets/ttcn-cfg-Dc39-fIP.js +0 -133
  184. package/out/renderer/assets/ttcn-tKd4HLu4.js +0 -192
  185. package/out/renderer/assets/turtle-Dq7-1WAf.js +0 -124
  186. package/out/renderer/assets/vb-Dp90gtsv.js +0 -196
  187. package/out/renderer/assets/vbscript-CI6_mxxU.js +0 -479
  188. package/out/renderer/assets/velocity-BwIZK1TH.js +0 -149
  189. package/out/renderer/assets/verilog-DDCYnHN8.js +0 -430
  190. package/out/renderer/assets/vhdl-DCkMIyT9.js +0 -158
  191. package/out/renderer/assets/webidl-BTLTThCm.js +0 -204
  192. package/out/renderer/assets/xquery-BrBUuxMR.js +0 -525
  193. package/out/renderer/assets/yacas-b5lAVEIl.js +0 -130
  194. package/out/renderer/assets/z80-BZV19vqv.js +0 -93
  195. package/scripts/download-uv.mjs +0 -147
  196. /package/patches/{ai+5.0.161.patch → ai+5.0.167.patch} +0 -0
@@ -0,0 +1,901 @@
1
+ import { s as setAccDescription, g as getAccDescription, q as getDiagramTitle, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, l as log, I as selectSvgElement, e as configureSvgSize, z as clear, c as getConfig2$1, i as sanitizeText } from "./index-BL-57WPa.js";
2
+ import { p as populateCommonDb } from "./chunk-4BX2VUAB-0KM14cFd.js";
3
+ import { p as parse } from "./wardley-RL74JXVD-DTbxPMj9.js";
4
+ import "./min-DB8ixvoT.js";
5
+ import "./_baseUniq-BPF2Herp.js";
6
+ var toPercent = /* @__PURE__ */ __name((value, context) => {
7
+ const normalized = value <= 1 ? value * 100 : value;
8
+ if (normalized < 0 || normalized > 100) {
9
+ throw new Error(
10
+ `${context} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${value}`
11
+ );
12
+ }
13
+ return normalized;
14
+ }, "toPercent");
15
+ var toCoordinates = /* @__PURE__ */ __name((visibility, evolution, context) => {
16
+ return {
17
+ x: toPercent(evolution, `${context} evolution`),
18
+ y: toPercent(visibility, `${context} visibility`)
19
+ };
20
+ }, "toCoordinates");
21
+ var getFlowFromPort = /* @__PURE__ */ __name((port) => {
22
+ if (!port) {
23
+ return void 0;
24
+ }
25
+ if (port === "+<>") {
26
+ return "bidirectional";
27
+ }
28
+ if (port === "+<") {
29
+ return "backward";
30
+ }
31
+ if (port === "+>") {
32
+ return "forward";
33
+ }
34
+ return void 0;
35
+ }, "getFlowFromPort");
36
+ var extractFlowFromArrow = /* @__PURE__ */ __name((arrow) => {
37
+ if (!arrow?.startsWith("+")) {
38
+ return {};
39
+ }
40
+ const labelMatch = /^\+'([^']*)'/.exec(arrow);
41
+ const flowLabel = labelMatch?.[1];
42
+ if (arrow.includes("<>")) {
43
+ return { flow: "bidirectional", label: flowLabel };
44
+ }
45
+ if (arrow.includes("<")) {
46
+ return { flow: "backward", label: flowLabel };
47
+ }
48
+ if (arrow.includes(">")) {
49
+ return { flow: "forward", label: flowLabel };
50
+ }
51
+ return { label: flowLabel };
52
+ }, "extractFlowFromArrow");
53
+ var populateDb = /* @__PURE__ */ __name((ast, db) => {
54
+ populateCommonDb(ast, db);
55
+ if (ast.size) {
56
+ db.setSize(ast.size.width, ast.size.height);
57
+ }
58
+ if (ast.evolution) {
59
+ const stages = ast.evolution.stages.map((stage) => {
60
+ if (stage.secondName) {
61
+ return `${stage.name.trim()} / ${stage.secondName.trim()}`;
62
+ }
63
+ return stage.name.trim();
64
+ });
65
+ const stageBoundaries = ast.evolution.stages.filter((stage) => stage.boundary !== void 0).map((stage) => stage.boundary);
66
+ db.updateAxes({ stages, stageBoundaries });
67
+ }
68
+ ast.anchors.forEach((anchor) => {
69
+ const coords = toCoordinates(anchor.visibility, anchor.evolution, `Anchor "${anchor.name}"`);
70
+ db.addNode(anchor.name, anchor.name, coords.x, coords.y, "anchor");
71
+ });
72
+ ast.components.forEach((component) => {
73
+ const coords = toCoordinates(
74
+ component.visibility,
75
+ component.evolution,
76
+ `Component "${component.name}"`
77
+ );
78
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
79
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
80
+ const sourceStrategy = component.decorator?.strategy;
81
+ db.addNode(
82
+ component.name,
83
+ component.name,
84
+ coords.x,
85
+ coords.y,
86
+ "component",
87
+ labelOffsetX,
88
+ labelOffsetY,
89
+ component.inertia,
90
+ sourceStrategy
91
+ );
92
+ });
93
+ ast.notes.forEach((note) => {
94
+ const coords = toCoordinates(note.visibility, note.evolution, `Note "${note.text}"`);
95
+ db.addNote(note.text, coords.x, coords.y);
96
+ });
97
+ ast.pipelines.forEach((pipeline) => {
98
+ const parentNode = db.getNode(pipeline.parent);
99
+ if (!parentNode || typeof parentNode.y !== "number") {
100
+ throw new Error(
101
+ `Pipeline "${pipeline.parent}" must reference an existing component with coordinates.`
102
+ );
103
+ }
104
+ const parentY = parentNode.y;
105
+ db.startPipeline(pipeline.parent);
106
+ pipeline.components.forEach((component) => {
107
+ const componentId = `${pipeline.parent}_${component.name}`;
108
+ const labelOffsetX = component.label ? (component.label.negX ? -1 : 1) * component.label.offsetX : void 0;
109
+ const labelOffsetY = component.label ? (component.label.negY ? -1 : 1) * component.label.offsetY : void 0;
110
+ const x = toPercent(component.evolution, `Pipeline component "${component.name}" evolution`);
111
+ db.addNode(
112
+ componentId,
113
+ component.name,
114
+ x,
115
+ parentY,
116
+ "pipeline-component",
117
+ labelOffsetX,
118
+ labelOffsetY
119
+ );
120
+ db.addPipelineComponent(pipeline.parent, componentId);
121
+ });
122
+ });
123
+ ast.links.forEach((link) => {
124
+ const isDashed = !!link.arrow && (link.arrow.includes("-.->") || link.arrow.includes(".-."));
125
+ let flow = getFlowFromPort(link.fromPort) ?? getFlowFromPort(link.toPort);
126
+ const { flow: arrowFlow, label: flowLabel } = extractFlowFromArrow(link.arrow);
127
+ if (!flow && arrowFlow) {
128
+ flow = arrowFlow;
129
+ }
130
+ const annotation = link.linkLabel;
131
+ const label = flowLabel ?? annotation;
132
+ db.addLink(link.from, link.to, isDashed, label, flow);
133
+ });
134
+ ast.evolves.forEach((evolve) => {
135
+ const node = db.getNode(evolve.component);
136
+ if (node?.y !== void 0) {
137
+ const target = toPercent(evolve.target, `Evolve target for "${evolve.component}"`);
138
+ db.addTrend(evolve.component, target, node.y);
139
+ }
140
+ });
141
+ if (ast.annotations.length > 0) {
142
+ const annotationsBox = ast.annotations[0];
143
+ const coords = toCoordinates(annotationsBox.x, annotationsBox.y, "Annotations box");
144
+ db.setAnnotationsBox(coords.x, coords.y);
145
+ }
146
+ ast.annotation.forEach((annotation) => {
147
+ const coords = toCoordinates(annotation.x, annotation.y, `Annotation ${annotation.number}`);
148
+ db.addAnnotation(annotation.number, [{ x: coords.x, y: coords.y }], annotation.text);
149
+ });
150
+ ast.accelerators.forEach((accelerator) => {
151
+ const coords = toCoordinates(accelerator.x, accelerator.y, `Accelerator "${accelerator.name}"`);
152
+ db.addAccelerator(accelerator.name, coords.x, coords.y);
153
+ });
154
+ ast.deaccelerators.forEach((deaccelerator) => {
155
+ const coords = toCoordinates(
156
+ deaccelerator.x,
157
+ deaccelerator.y,
158
+ `Deaccelerator "${deaccelerator.name}"`
159
+ );
160
+ db.addDeaccelerator(deaccelerator.name, coords.x, coords.y);
161
+ });
162
+ }, "populateDb");
163
+ var parser = {
164
+ parser: {
165
+ // @ts-expect-error - WardleyDB is not assignable to DiagramDB
166
+ yy: void 0
167
+ },
168
+ parse: /* @__PURE__ */ __name(async (input) => {
169
+ const ast = await parse("wardley", input);
170
+ log.debug(ast);
171
+ const db = parser.parser?.yy;
172
+ if (!db || typeof db.addNode !== "function") {
173
+ throw new Error(
174
+ "parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues."
175
+ );
176
+ }
177
+ populateDb(ast, db);
178
+ }, "parse")
179
+ };
180
+ var WardleyBuilder = class {
181
+ constructor() {
182
+ this.nodes = /* @__PURE__ */ new Map();
183
+ this.links = [];
184
+ this.trends = /* @__PURE__ */ new Map();
185
+ this.pipelines = /* @__PURE__ */ new Map();
186
+ this.annotations = [];
187
+ this.notes = [];
188
+ this.accelerators = [];
189
+ this.deaccelerators = [];
190
+ this.axes = {};
191
+ }
192
+ static {
193
+ __name(this, "WardleyBuilder");
194
+ }
195
+ addNode(node) {
196
+ const existing = this.nodes.get(node.id) ?? { id: node.id, label: node.label };
197
+ const merged = {
198
+ ...existing,
199
+ ...node,
200
+ className: node.className ?? existing.className,
201
+ labelOffsetX: node.labelOffsetX ?? existing.labelOffsetX,
202
+ labelOffsetY: node.labelOffsetY ?? existing.labelOffsetY
203
+ };
204
+ this.nodes.set(node.id, merged);
205
+ }
206
+ addLink(link) {
207
+ this.links.push(link);
208
+ }
209
+ addTrend(trend) {
210
+ this.trends.set(trend.nodeId, trend);
211
+ }
212
+ startPipeline(nodeId) {
213
+ this.pipelines.set(nodeId, { nodeId, componentIds: [] });
214
+ const node = this.nodes.get(nodeId);
215
+ if (node) {
216
+ node.isPipelineParent = true;
217
+ }
218
+ }
219
+ addPipelineComponent(pipelineNodeId, componentId) {
220
+ const pipeline = this.pipelines.get(pipelineNodeId);
221
+ if (pipeline) {
222
+ pipeline.componentIds.push(componentId);
223
+ }
224
+ const node = this.nodes.get(componentId);
225
+ if (node) {
226
+ node.inPipeline = true;
227
+ }
228
+ }
229
+ addAnnotation(annotation) {
230
+ this.annotations.push(annotation);
231
+ }
232
+ addNote(note) {
233
+ this.notes.push(note);
234
+ }
235
+ addAccelerator(accelerator) {
236
+ this.accelerators.push(accelerator);
237
+ }
238
+ addDeaccelerator(deaccelerator) {
239
+ this.deaccelerators.push(deaccelerator);
240
+ }
241
+ setAnnotationsBox(x, y) {
242
+ this.annotationsBox = { x, y };
243
+ }
244
+ setAxes(partial) {
245
+ this.axes = {
246
+ ...this.axes,
247
+ ...partial
248
+ };
249
+ }
250
+ setSize(width, height) {
251
+ this.size = { width, height };
252
+ }
253
+ getNode(id) {
254
+ return this.nodes.get(id);
255
+ }
256
+ build() {
257
+ const nodes = [];
258
+ for (const node of this.nodes.values()) {
259
+ if (typeof node.x !== "number" || typeof node.y !== "number") {
260
+ throw new Error(`Node "${node.label}" is missing coordinates`);
261
+ }
262
+ nodes.push(node);
263
+ }
264
+ return {
265
+ nodes,
266
+ links: [...this.links],
267
+ trends: [...this.trends.values()],
268
+ pipelines: [...this.pipelines.values()],
269
+ annotations: [...this.annotations],
270
+ notes: [...this.notes],
271
+ accelerators: [...this.accelerators],
272
+ deaccelerators: [...this.deaccelerators],
273
+ annotationsBox: this.annotationsBox,
274
+ axes: { ...this.axes },
275
+ size: this.size
276
+ };
277
+ }
278
+ clear() {
279
+ this.nodes.clear();
280
+ this.links = [];
281
+ this.trends.clear();
282
+ this.pipelines.clear();
283
+ this.annotations = [];
284
+ this.notes = [];
285
+ this.accelerators = [];
286
+ this.deaccelerators = [];
287
+ this.annotationsBox = void 0;
288
+ this.axes = {};
289
+ this.size = void 0;
290
+ }
291
+ };
292
+ var builder = new WardleyBuilder();
293
+ function textSanitizer(text) {
294
+ const config = getConfig2$1();
295
+ return sanitizeText(text.trim(), config);
296
+ }
297
+ __name(textSanitizer, "textSanitizer");
298
+ function getConfig2() {
299
+ return getConfig2$1()["wardley-beta"];
300
+ }
301
+ __name(getConfig2, "getConfig");
302
+ function addNode(id, label, x, y, className, labelOffsetX, labelOffsetY, inertia, sourceStrategy) {
303
+ builder.addNode({
304
+ id,
305
+ label: textSanitizer(label),
306
+ x,
307
+ y,
308
+ className,
309
+ labelOffsetX,
310
+ labelOffsetY,
311
+ inertia,
312
+ sourceStrategy
313
+ });
314
+ }
315
+ __name(addNode, "addNode");
316
+ function addLink(sourceId, targetId, dashed = false, label, flow) {
317
+ builder.addLink({ source: sourceId, target: targetId, dashed, label, flow });
318
+ }
319
+ __name(addLink, "addLink");
320
+ function addTrend(nodeId, targetX, targetY) {
321
+ builder.addTrend({ nodeId, targetX, targetY });
322
+ }
323
+ __name(addTrend, "addTrend");
324
+ function addAnnotation(number, coordinates, text) {
325
+ builder.addAnnotation({
326
+ number,
327
+ coordinates,
328
+ text: text ? textSanitizer(text) : void 0
329
+ });
330
+ }
331
+ __name(addAnnotation, "addAnnotation");
332
+ function addNote(text, x, y) {
333
+ builder.addNote({
334
+ text: textSanitizer(text),
335
+ x,
336
+ y
337
+ });
338
+ }
339
+ __name(addNote, "addNote");
340
+ function addAccelerator(name, x, y) {
341
+ builder.addAccelerator({
342
+ name: textSanitizer(name),
343
+ x,
344
+ y
345
+ });
346
+ }
347
+ __name(addAccelerator, "addAccelerator");
348
+ function addDeaccelerator(name, x, y) {
349
+ builder.addDeaccelerator({
350
+ name: textSanitizer(name),
351
+ x,
352
+ y
353
+ });
354
+ }
355
+ __name(addDeaccelerator, "addDeaccelerator");
356
+ function setAnnotationsBox(x, y) {
357
+ builder.setAnnotationsBox(x, y);
358
+ }
359
+ __name(setAnnotationsBox, "setAnnotationsBox");
360
+ function setSize(width, height) {
361
+ builder.setSize(width, height);
362
+ }
363
+ __name(setSize, "setSize");
364
+ function startPipeline(nodeId) {
365
+ builder.startPipeline(nodeId);
366
+ }
367
+ __name(startPipeline, "startPipeline");
368
+ function addPipelineComponent(pipelineNodeId, componentId) {
369
+ builder.addPipelineComponent(pipelineNodeId, componentId);
370
+ }
371
+ __name(addPipelineComponent, "addPipelineComponent");
372
+ function updateAxes(partial) {
373
+ const sanitized = {};
374
+ if (partial.xLabel) {
375
+ sanitized.xLabel = textSanitizer(partial.xLabel);
376
+ }
377
+ if (partial.yLabel) {
378
+ sanitized.yLabel = textSanitizer(partial.yLabel);
379
+ }
380
+ if (partial.stages) {
381
+ sanitized.stages = partial.stages.map((stage) => textSanitizer(stage));
382
+ }
383
+ if (partial.stageBoundaries) {
384
+ sanitized.stageBoundaries = partial.stageBoundaries;
385
+ }
386
+ builder.setAxes(sanitized);
387
+ }
388
+ __name(updateAxes, "updateAxes");
389
+ function getNode(id) {
390
+ return builder.getNode(id);
391
+ }
392
+ __name(getNode, "getNode");
393
+ function getWardleyData() {
394
+ return builder.build();
395
+ }
396
+ __name(getWardleyData, "getWardleyData");
397
+ function clear2() {
398
+ builder.clear();
399
+ clear();
400
+ }
401
+ __name(clear2, "clear");
402
+ var wardleyDb_default = {
403
+ getConfig: getConfig2,
404
+ addNode,
405
+ addLink,
406
+ addTrend,
407
+ addAnnotation,
408
+ addNote,
409
+ addAccelerator,
410
+ addDeaccelerator,
411
+ setAnnotationsBox,
412
+ setSize,
413
+ startPipeline,
414
+ addPipelineComponent,
415
+ updateAxes,
416
+ getNode,
417
+ getWardleyData,
418
+ clear: clear2,
419
+ setAccTitle,
420
+ getAccTitle,
421
+ setDiagramTitle,
422
+ getDiagramTitle,
423
+ getAccDescription,
424
+ setAccDescription
425
+ };
426
+ var DEFAULT_STAGES = ["Genesis", "Custom Built", "Product", "Commodity"];
427
+ var getTheme = /* @__PURE__ */ __name(() => {
428
+ const { themeVariables } = getConfig2$1();
429
+ return {
430
+ backgroundColor: themeVariables.wardley?.backgroundColor ?? themeVariables.background ?? "#fff",
431
+ axisColor: themeVariables.wardley?.axisColor ?? "#000",
432
+ axisTextColor: themeVariables.wardley?.axisTextColor ?? themeVariables.primaryTextColor ?? "#222",
433
+ gridColor: themeVariables.wardley?.gridColor ?? "rgba(100, 100, 100, 0.2)",
434
+ componentFill: themeVariables.wardley?.componentFill ?? "#fff",
435
+ componentStroke: themeVariables.wardley?.componentStroke ?? "#000",
436
+ componentLabelColor: themeVariables.wardley?.componentLabelColor ?? themeVariables.primaryTextColor ?? "#222",
437
+ linkStroke: themeVariables.wardley?.linkStroke ?? "#000",
438
+ evolutionStroke: themeVariables.wardley?.evolutionStroke ?? "#dc3545",
439
+ annotationStroke: themeVariables.wardley?.annotationStroke ?? "#000",
440
+ annotationTextColor: themeVariables.wardley?.annotationTextColor ?? themeVariables.primaryTextColor ?? "#222",
441
+ annotationFill: themeVariables.wardley?.annotationFill ?? themeVariables.background ?? "#fff"
442
+ };
443
+ }, "getTheme");
444
+ var getConfigValues = /* @__PURE__ */ __name(() => {
445
+ const wardleyConfig = getConfig2$1()["wardley-beta"];
446
+ return {
447
+ width: wardleyConfig?.width ?? 900,
448
+ height: wardleyConfig?.height ?? 600,
449
+ padding: wardleyConfig?.padding ?? 48,
450
+ nodeRadius: wardleyConfig?.nodeRadius ?? 6,
451
+ nodeLabelOffset: wardleyConfig?.nodeLabelOffset ?? 8,
452
+ axisFontSize: wardleyConfig?.axisFontSize ?? 12,
453
+ labelFontSize: wardleyConfig?.labelFontSize ?? 10,
454
+ showGrid: wardleyConfig?.showGrid ?? false,
455
+ useMaxWidth: wardleyConfig?.useMaxWidth ?? true
456
+ };
457
+ }, "getConfigValues");
458
+ var draw = /* @__PURE__ */ __name((text, id, _version, diagObj) => {
459
+ log.debug("Rendering Wardley map\n" + text);
460
+ const configValues = getConfigValues();
461
+ const theme = getTheme();
462
+ const squareSize = configValues.nodeRadius * 1.6;
463
+ const db = diagObj.db;
464
+ const data = db.getWardleyData();
465
+ const title = db.getDiagramTitle();
466
+ const width = data.size?.width ?? configValues.width;
467
+ const height = data.size?.height ?? configValues.height;
468
+ const svg = selectSvgElement(id);
469
+ svg.selectAll("*").remove();
470
+ configureSvgSize(svg, height, width, configValues.useMaxWidth);
471
+ svg.attr("viewBox", `0 0 ${width} ${height}`);
472
+ const root = svg.append("g").attr("class", "wardley-map");
473
+ const defs = svg.append("defs");
474
+ defs.append("marker").attr("id", `arrow-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto-start-reverse").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.evolutionStroke).attr("stroke", "none");
475
+ defs.append("marker").attr("id", `link-arrow-end-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 9).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 0 0 L 10 5 L 0 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
476
+ defs.append("marker").attr("id", `link-arrow-start-${id}`).attr("viewBox", "0 0 10 10").attr("refX", 1).attr("refY", 5).attr("markerWidth", 5).attr("markerHeight", 5).attr("orient", "auto").append("path").attr("d", "M 10 0 L 0 5 L 10 10 z").attr("fill", theme.linkStroke).attr("stroke", "none");
477
+ root.append("rect").attr("class", "wardley-background").attr("width", width).attr("height", height).attr("fill", theme.backgroundColor);
478
+ const chartWidth = width - configValues.padding * 2;
479
+ const chartHeight = height - configValues.padding * 2;
480
+ if (title) {
481
+ root.append("text").attr("class", "wardley-title").attr("x", width / 2).attr("y", configValues.padding / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize * 1.05).attr("font-weight", "bold").attr("text-anchor", "middle").attr("dominant-baseline", "middle").text(title);
482
+ }
483
+ const projectX = /* @__PURE__ */ __name((value) => configValues.padding + value / 100 * chartWidth, "projectX");
484
+ const projectY = /* @__PURE__ */ __name((value) => height - configValues.padding - value / 100 * chartHeight, "projectY");
485
+ const axisGroup = root.append("g").attr("class", "wardley-axes");
486
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
487
+ axisGroup.append("line").attr("x1", configValues.padding).attr("x2", configValues.padding).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.axisColor).attr("stroke-width", 1);
488
+ const xLabel = data.axes.xLabel ?? "Evolution";
489
+ const yLabel = data.axes.yLabel ?? "Visibility";
490
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-x").attr("x", configValues.padding + chartWidth / 2).attr("y", height - configValues.padding / 4).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").text(xLabel);
491
+ axisGroup.append("text").attr("class", "wardley-axis-label wardley-axis-label-y").attr("x", configValues.padding / 3).attr("y", configValues.padding + chartHeight / 2).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize).attr("font-weight", "bold").attr("text-anchor", "middle").attr(
492
+ "transform",
493
+ `rotate(-90 ${configValues.padding / 3} ${configValues.padding + chartHeight / 2})`
494
+ ).text(yLabel);
495
+ const stages = data.axes.stages && data.axes.stages.length > 0 ? data.axes.stages : DEFAULT_STAGES;
496
+ if (stages.length > 0) {
497
+ const stageGroup = root.append("g").attr("class", "wardley-stages");
498
+ const boundaries = data.axes.stageBoundaries;
499
+ const stagePositions = [];
500
+ if (boundaries && boundaries.length === stages.length) {
501
+ let prevBoundary = 0;
502
+ boundaries.forEach((boundary) => {
503
+ stagePositions.push({ start: prevBoundary, end: boundary });
504
+ prevBoundary = boundary;
505
+ });
506
+ } else {
507
+ const stageWidth = 1 / stages.length;
508
+ stages.forEach((_, index) => {
509
+ stagePositions.push({
510
+ start: index * stageWidth,
511
+ end: (index + 1) * stageWidth
512
+ });
513
+ });
514
+ }
515
+ stages.forEach((stage, index) => {
516
+ const pos = stagePositions[index];
517
+ const startX = configValues.padding + pos.start * chartWidth;
518
+ const endX = configValues.padding + pos.end * chartWidth;
519
+ const centerX = (startX + endX) / 2;
520
+ if (index > 0) {
521
+ stageGroup.append("line").attr("x1", startX).attr("x2", startX).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", "#000").attr("stroke-width", 1).attr("stroke-dasharray", "5 5").attr("opacity", 0.8);
522
+ }
523
+ stageGroup.append("text").attr("class", "wardley-stage-label").attr("x", centerX).attr("y", height - configValues.padding / 1.5).attr("fill", theme.axisTextColor).attr("font-size", configValues.axisFontSize - 2).attr("text-anchor", "middle").text(stage);
524
+ });
525
+ }
526
+ if (configValues.showGrid) {
527
+ const gridGroup = root.append("g").attr("class", "wardley-grid");
528
+ for (let i = 1; i < 4; i++) {
529
+ const ratio = i / 4;
530
+ const x = configValues.padding + chartWidth * ratio;
531
+ gridGroup.append("line").attr("x1", x).attr("x2", x).attr("y1", configValues.padding).attr("y2", height - configValues.padding).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
532
+ gridGroup.append("line").attr("x1", configValues.padding).attr("x2", width - configValues.padding).attr("y1", height - configValues.padding - chartHeight * ratio).attr("y2", height - configValues.padding - chartHeight * ratio).attr("stroke", theme.gridColor).attr("stroke-dasharray", "2 6");
533
+ }
534
+ }
535
+ const positions = /* @__PURE__ */ new Map();
536
+ data.nodes.forEach((node) => {
537
+ positions.set(node.id, {
538
+ x: projectX(node.x),
539
+ y: projectY(node.y),
540
+ node
541
+ });
542
+ });
543
+ if (data.pipelines.length > 0) {
544
+ const pipelineGroup = root.append("g").attr("class", "wardley-pipelines");
545
+ const pipelineLinksGroup = root.append("g").attr("class", "wardley-pipeline-links");
546
+ data.pipelines.forEach((pipeline) => {
547
+ if (pipeline.componentIds.length === 0) {
548
+ return;
549
+ }
550
+ const sortedComponents = pipeline.componentIds.map((id2) => ({ id: id2, pos: positions.get(id2), node: data.nodes.find((n) => n.id === id2) })).filter((c) => c.pos && c.node).sort((a, b) => a.node.x - b.node.x);
551
+ for (let i = 0; i < sortedComponents.length - 1; i++) {
552
+ const current = sortedComponents[i];
553
+ const next = sortedComponents[i + 1];
554
+ pipelineLinksGroup.append("line").attr("class", "wardley-pipeline-evolution-link").attr("x1", current.pos.x).attr("y1", current.pos.y).attr("x2", next.pos.x).attr("y2", next.pos.y).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4");
555
+ }
556
+ let minX = Infinity;
557
+ let maxX = -Infinity;
558
+ let y = 0;
559
+ pipeline.componentIds.forEach((componentId) => {
560
+ const pos = positions.get(componentId);
561
+ if (pos) {
562
+ minX = Math.min(minX, pos.x);
563
+ maxX = Math.max(maxX, pos.x);
564
+ y = pos.y;
565
+ }
566
+ });
567
+ if (minX !== Infinity && maxX !== -Infinity) {
568
+ const padding = 15;
569
+ const height2 = configValues.nodeRadius * 4;
570
+ const boxTop = y - height2 / 2;
571
+ const parentPos = positions.get(pipeline.nodeId);
572
+ if (parentPos) {
573
+ const centerX = (minX + maxX) / 2;
574
+ parentPos.x = centerX;
575
+ parentPos.y = boxTop - squareSize / 6;
576
+ }
577
+ pipelineGroup.append("rect").attr("class", "wardley-pipeline-box").attr("x", minX - padding).attr("y", boxTop).attr("width", maxX - minX + padding * 2).attr("height", height2).attr("fill", "none").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
578
+ }
579
+ });
580
+ }
581
+ const linksGroup = root.append("g").attr("class", "wardley-links");
582
+ const pipelineMap = /* @__PURE__ */ new Map();
583
+ data.pipelines.forEach((pipeline) => {
584
+ pipelineMap.set(pipeline.nodeId, new Set(pipeline.componentIds));
585
+ });
586
+ const validLinks = data.links.filter((link) => {
587
+ if (!positions.has(link.source) || !positions.has(link.target)) {
588
+ return false;
589
+ }
590
+ const pipelineComponents = pipelineMap.get(link.target);
591
+ if (pipelineComponents?.has(link.source)) {
592
+ return false;
593
+ }
594
+ return true;
595
+ });
596
+ linksGroup.selectAll("line").data(validLinks).enter().append("line").attr("class", (link) => `wardley-link${link.dashed ? " wardley-link--dashed" : ""}`).attr("x1", (link) => {
597
+ const sourcePos = positions.get(link.source);
598
+ const targetPos = positions.get(link.target);
599
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
600
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
601
+ const dx = targetPos.x - sourcePos.x;
602
+ const dy = targetPos.y - sourcePos.y;
603
+ const distance = Math.sqrt(dx * dx + dy * dy);
604
+ return sourcePos.x + dx / distance * radius;
605
+ }).attr("y1", (link) => {
606
+ const sourcePos = positions.get(link.source);
607
+ const targetPos = positions.get(link.target);
608
+ const sourceNode = data.nodes.find((n) => n.id === link.source);
609
+ const radius = sourceNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
610
+ const dx = targetPos.x - sourcePos.x;
611
+ const dy = targetPos.y - sourcePos.y;
612
+ const distance = Math.sqrt(dx * dx + dy * dy);
613
+ return sourcePos.y + dy / distance * radius;
614
+ }).attr("x2", (link) => {
615
+ const sourcePos = positions.get(link.source);
616
+ const targetPos = positions.get(link.target);
617
+ const targetNode = data.nodes.find((n) => n.id === link.target);
618
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
619
+ const dx = sourcePos.x - targetPos.x;
620
+ const dy = sourcePos.y - targetPos.y;
621
+ const distance = Math.sqrt(dx * dx + dy * dy);
622
+ return targetPos.x + dx / distance * radius;
623
+ }).attr("y2", (link) => {
624
+ const sourcePos = positions.get(link.source);
625
+ const targetPos = positions.get(link.target);
626
+ const targetNode = data.nodes.find((n) => n.id === link.target);
627
+ const radius = targetNode.isPipelineParent ? squareSize / Math.sqrt(2) : configValues.nodeRadius;
628
+ const dx = sourcePos.x - targetPos.x;
629
+ const dy = sourcePos.y - targetPos.y;
630
+ const distance = Math.sqrt(dx * dx + dy * dy);
631
+ return targetPos.y + dy / distance * radius;
632
+ }).attr("stroke", theme.linkStroke).attr("stroke-width", 1).attr("stroke-dasharray", (link) => link.dashed ? "6 6" : null).attr("marker-end", (link) => {
633
+ if (link.flow === "forward" || link.flow === "bidirectional") {
634
+ return `url(#link-arrow-end-${id})`;
635
+ }
636
+ return null;
637
+ }).attr("marker-start", (link) => {
638
+ if (link.flow === "backward" || link.flow === "bidirectional") {
639
+ return `url(#link-arrow-start-${id})`;
640
+ }
641
+ return null;
642
+ });
643
+ linksGroup.selectAll("text").data(validLinks.filter((link) => link.label)).enter().append("text").attr("class", "wardley-link-label").attr("x", (link) => {
644
+ const sourcePos = positions.get(link.source);
645
+ const targetPos = positions.get(link.target);
646
+ const midX = (sourcePos.x + targetPos.x) / 2;
647
+ const dy = targetPos.y - sourcePos.y;
648
+ const dx = targetPos.x - sourcePos.x;
649
+ const distance = Math.sqrt(dx * dx + dy * dy);
650
+ const offset = 8;
651
+ const perpX = dy / distance;
652
+ return midX + perpX * offset;
653
+ }).attr("y", (link) => {
654
+ const sourcePos = positions.get(link.source);
655
+ const targetPos = positions.get(link.target);
656
+ const midY = (sourcePos.y + targetPos.y) / 2;
657
+ const dx = targetPos.x - sourcePos.x;
658
+ const dy = targetPos.y - sourcePos.y;
659
+ const distance = Math.sqrt(dx * dx + dy * dy);
660
+ const offset = 8;
661
+ const perpY = -dx / distance;
662
+ return midY + perpY * offset;
663
+ }).attr("fill", theme.axisTextColor).attr("font-size", configValues.labelFontSize).attr("text-anchor", "middle").attr("dominant-baseline", "middle").attr("transform", (link) => {
664
+ const sourcePos = positions.get(link.source);
665
+ const targetPos = positions.get(link.target);
666
+ const midX = (sourcePos.x + targetPos.x) / 2;
667
+ const midY = (sourcePos.y + targetPos.y) / 2;
668
+ const dx = targetPos.x - sourcePos.x;
669
+ const dy = targetPos.y - sourcePos.y;
670
+ const distance = Math.sqrt(dx * dx + dy * dy);
671
+ const offset = 8;
672
+ const perpX = dy / distance;
673
+ const perpY = -dx / distance;
674
+ const labelX = midX + perpX * offset;
675
+ const labelY = midY + perpY * offset;
676
+ let angle = Math.atan2(dy, dx) * 180 / Math.PI;
677
+ if (angle > 90 || angle < -90) {
678
+ angle += 180;
679
+ }
680
+ return `rotate(${angle} ${labelX} ${labelY})`;
681
+ }).text((link) => link.label);
682
+ const trendGroup = root.append("g").attr("class", "wardley-trends");
683
+ const trendsWithPositions = data.trends.map((trend) => {
684
+ const origin = positions.get(trend.nodeId);
685
+ if (!origin) {
686
+ return null;
687
+ }
688
+ const targetX = projectX(trend.targetX);
689
+ const targetY = projectY(trend.targetY);
690
+ const dx = targetX - origin.x;
691
+ const dy = targetY - origin.y;
692
+ const distance = Math.sqrt(dx * dx + dy * dy);
693
+ const shortenBy = configValues.nodeRadius + 2;
694
+ const adjustedX2 = distance > shortenBy ? targetX - dx / distance * shortenBy : targetX;
695
+ const adjustedY2 = distance > shortenBy ? targetY - dy / distance * shortenBy : targetY;
696
+ return {
697
+ origin,
698
+ targetX,
699
+ targetY,
700
+ adjustedX2,
701
+ adjustedY2
702
+ };
703
+ }).filter((trend) => trend !== null);
704
+ trendGroup.selectAll("line").data(trendsWithPositions).enter().append("line").attr("class", "wardley-trend").attr("x1", (trend) => trend.origin.x).attr("y1", (trend) => trend.origin.y).attr("x2", (trend) => trend.adjustedX2).attr("y2", (trend) => trend.adjustedY2).attr("stroke", theme.evolutionStroke).attr("stroke-width", 1).attr("stroke-dasharray", "4 4").attr("marker-end", `url(#arrow-${id})`);
705
+ const nodesGroup = root.append("g").attr("class", "wardley-nodes");
706
+ const nodeEnter = nodesGroup.selectAll("g").data(data.nodes).enter().append("g").attr(
707
+ "class",
708
+ (node) => ["wardley-node", node.className ? `wardley-node--${node.className}` : ""].filter(Boolean).join(" ")
709
+ );
710
+ nodeEnter.filter((node) => node.sourceStrategy === "outsource").append("circle").attr("class", "wardley-outsource-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#666").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
711
+ nodeEnter.filter((node) => node.sourceStrategy === "buy").append("circle").attr("class", "wardley-buy-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#ccc").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
712
+ nodeEnter.filter((node) => node.sourceStrategy === "build").append("circle").attr("class", "wardley-build-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "#eee").attr("stroke", "#000").attr("stroke-width", 1);
713
+ const marketNodes = nodeEnter.filter((node) => node.sourceStrategy === "market");
714
+ marketNodes.append("circle").attr("class", "wardley-market-overlay").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius * 2).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
715
+ nodeEnter.filter(
716
+ (node) => !node.isPipelineParent && node.sourceStrategy !== "market" && node.className !== "anchor"
717
+ ).append("circle").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y).attr("r", configValues.nodeRadius).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
718
+ const smallCircleRadius = configValues.nodeRadius * 0.7;
719
+ const triangleRadius = configValues.nodeRadius * 1.2;
720
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x).attr("y1", (node) => positions.get(node.id).y - triangleRadius).attr("x2", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
721
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y2", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
722
+ marketNodes.append("line").attr("class", "wardley-market-line").attr("x1", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("y1", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("x2", (node) => positions.get(node.id).x).attr("y2", (node) => positions.get(node.id).y - triangleRadius).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
723
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x).attr("cy", (node) => positions.get(node.id).y - triangleRadius).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
724
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x - triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
725
+ marketNodes.append("circle").attr("class", "wardley-market-dot").attr("cx", (node) => positions.get(node.id).x + triangleRadius * Math.cos(Math.PI / 6)).attr("cy", (node) => positions.get(node.id).y + triangleRadius * Math.sin(Math.PI / 6)).attr("r", smallCircleRadius).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 2);
726
+ nodeEnter.filter((node) => node.isPipelineParent === true).append("rect").attr("x", (node) => positions.get(node.id).x - squareSize / 2).attr("y", (node) => positions.get(node.id).y - squareSize / 2).attr("width", squareSize).attr("height", squareSize).attr("fill", theme.componentFill).attr("stroke", theme.componentStroke).attr("stroke-width", 1);
727
+ nodeEnter.filter((node) => node.inertia === true).append("line").attr("class", "wardley-inertia").attr("x1", (node) => {
728
+ const pos = positions.get(node.id);
729
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
730
+ if (node.sourceStrategy) {
731
+ offset += configValues.nodeRadius + 10;
732
+ }
733
+ return pos.x + offset;
734
+ }).attr("y1", (node) => {
735
+ const pos = positions.get(node.id);
736
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
737
+ return pos.y - lineHeight / 2;
738
+ }).attr("x2", (node) => {
739
+ const pos = positions.get(node.id);
740
+ let offset = node.isPipelineParent ? squareSize / 2 + 15 : configValues.nodeRadius + 15;
741
+ if (node.sourceStrategy) {
742
+ offset += configValues.nodeRadius + 10;
743
+ }
744
+ return pos.x + offset;
745
+ }).attr("y2", (node) => {
746
+ const pos = positions.get(node.id);
747
+ const lineHeight = node.isPipelineParent ? squareSize : configValues.nodeRadius * 2;
748
+ return pos.y + lineHeight / 2;
749
+ }).attr("stroke", theme.componentStroke).attr("stroke-width", 6);
750
+ nodeEnter.append("text").attr("x", (node) => {
751
+ const pos = positions.get(node.id);
752
+ if (node.className === "anchor") {
753
+ return node.labelOffsetX !== void 0 ? pos.x + node.labelOffsetX : pos.x;
754
+ }
755
+ let defaultOffset = configValues.nodeLabelOffset;
756
+ if (node.sourceStrategy && node.labelOffsetX === void 0) {
757
+ defaultOffset += 10;
758
+ }
759
+ const customOffset = node.labelOffsetX ?? defaultOffset;
760
+ return pos.x + customOffset;
761
+ }).attr("y", (node) => {
762
+ const pos = positions.get(node.id);
763
+ if (node.className === "anchor") {
764
+ return node.labelOffsetY !== void 0 ? pos.y + node.labelOffsetY : pos.y - 3;
765
+ }
766
+ let defaultOffset = -configValues.nodeLabelOffset;
767
+ if (node.sourceStrategy && node.labelOffsetY === void 0) {
768
+ defaultOffset -= 10;
769
+ }
770
+ const customOffset = node.labelOffsetY ?? defaultOffset;
771
+ return pos.y + customOffset;
772
+ }).attr("class", "wardley-node-label").attr("fill", (node) => {
773
+ if (node.className === "evolved") {
774
+ return theme.evolutionStroke;
775
+ }
776
+ if (node.className === "anchor") {
777
+ return "#000";
778
+ }
779
+ return theme.componentLabelColor;
780
+ }).attr("font-size", configValues.labelFontSize).attr("font-weight", (node) => node.className === "anchor" ? "bold" : "normal").attr("text-anchor", (node) => node.className === "anchor" ? "middle" : "start").attr("dominant-baseline", (node) => node.className === "anchor" ? "middle" : "auto").text((node) => node.label);
781
+ if (data.annotations.length > 0) {
782
+ const annotationsGroup = root.append("g").attr("class", "wardley-annotations");
783
+ data.annotations.forEach((annotation) => {
784
+ const projectedCoords = annotation.coordinates.map((coord) => ({
785
+ x: projectX(coord.x),
786
+ y: projectY(coord.y)
787
+ }));
788
+ if (projectedCoords.length > 1) {
789
+ for (let i = 0; i < projectedCoords.length - 1; i++) {
790
+ annotationsGroup.append("line").attr("class", "wardley-annotation-line").attr("x1", projectedCoords[i].x).attr("y1", projectedCoords[i].y).attr("x2", projectedCoords[i + 1].x).attr("y2", projectedCoords[i + 1].y).attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("stroke-dasharray", "4 4");
791
+ }
792
+ }
793
+ projectedCoords.forEach((coord) => {
794
+ const annotationNode = annotationsGroup.append("g").attr("class", "wardley-annotation");
795
+ annotationNode.append("circle").attr("cx", coord.x).attr("cy", coord.y).attr("r", 10).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5);
796
+ annotationNode.append("text").attr("x", coord.x).attr("y", coord.y).attr("text-anchor", "middle").attr("dominant-baseline", "central").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(annotation.number);
797
+ });
798
+ });
799
+ if (data.annotationsBox) {
800
+ let boxX = projectX(data.annotationsBox.x);
801
+ let boxY = projectY(data.annotationsBox.y);
802
+ const padding = 10;
803
+ const lineHeight = 16;
804
+ const fontSize = 11;
805
+ const textBoxGroup = annotationsGroup.append("g").attr("class", "wardley-annotations-box");
806
+ const sortedAnnotations = [...data.annotations].filter((a) => a.text).sort((a, b) => a.number - b.number);
807
+ const textElements = [];
808
+ sortedAnnotations.forEach((annotation, idx) => {
809
+ const text2 = textBoxGroup.append("text").attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight).attr("font-size", fontSize).attr("fill", theme.axisTextColor).attr("text-anchor", "start").attr("dominant-baseline", "middle").text(`${annotation.number}. ${annotation.text}`);
810
+ textElements.push(text2);
811
+ });
812
+ if (textElements.length > 0) {
813
+ let maxWidth = 0;
814
+ let maxHeight = 0;
815
+ textElements.forEach((text2) => {
816
+ const textNode = text2.node();
817
+ const textWidth = textNode.getComputedTextLength();
818
+ maxWidth = Math.max(maxWidth, textWidth);
819
+ const bbox = textNode.getBBox();
820
+ maxHeight = Math.max(maxHeight, bbox.height);
821
+ });
822
+ const boxWidth = maxWidth + padding * 2 + 105;
823
+ const boxHeight = sortedAnnotations.length * lineHeight + padding * 2 + maxHeight / 2;
824
+ const minX = configValues.padding;
825
+ const maxX = width - configValues.padding - boxWidth;
826
+ const minY = configValues.padding;
827
+ const maxY = height - configValues.padding - boxHeight;
828
+ boxX = Math.max(minX, Math.min(boxX, maxX));
829
+ boxY = Math.max(minY, Math.min(boxY, maxY));
830
+ textElements.forEach((text2, idx) => {
831
+ text2.attr("x", boxX + padding).attr("y", boxY + padding + (idx + 1) * lineHeight);
832
+ });
833
+ textBoxGroup.insert("rect", "text").attr("x", boxX).attr("y", boxY).attr("width", boxWidth).attr("height", boxHeight).attr("fill", "white").attr("stroke", theme.axisColor).attr("stroke-width", 1.5).attr("rx", 4).attr("ry", 4);
834
+ }
835
+ }
836
+ }
837
+ if (data.notes.length > 0) {
838
+ const notesGroup = root.append("g").attr("class", "wardley-notes");
839
+ data.notes.forEach((note) => {
840
+ const noteX = projectX(note.x);
841
+ const noteY = projectY(note.y);
842
+ notesGroup.append("text").attr("x", noteX).attr("y", noteY).attr("text-anchor", "start").attr("font-size", 11).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(note.text);
843
+ });
844
+ }
845
+ if (data.accelerators.length > 0) {
846
+ const acceleratorsGroup = root.append("g").attr("class", "wardley-accelerators");
847
+ data.accelerators.forEach((accelerator) => {
848
+ const accX = projectX(accelerator.x);
849
+ const accY = projectY(accelerator.y);
850
+ const arrowWidth = 60;
851
+ const arrowHeight = 30;
852
+ const arrowHeadWidth = 20;
853
+ const arrowPath = `
854
+ M ${accX} ${accY - arrowHeight / 2}
855
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2}
856
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY - arrowHeight / 2 - 8}
857
+ L ${accX + arrowWidth} ${accY}
858
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2 + 8}
859
+ L ${accX + arrowWidth - arrowHeadWidth} ${accY + arrowHeight / 2}
860
+ L ${accX} ${accY + arrowHeight / 2}
861
+ Z
862
+ `;
863
+ acceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
864
+ acceleratorsGroup.append("text").attr("x", accX + arrowWidth / 2).attr("y", accY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(accelerator.name);
865
+ });
866
+ }
867
+ if (data.deaccelerators.length > 0) {
868
+ const deacceleratorsGroup = root.append("g").attr("class", "wardley-deaccelerators");
869
+ data.deaccelerators.forEach((deaccelerator) => {
870
+ const decX = projectX(deaccelerator.x);
871
+ const decY = projectY(deaccelerator.y);
872
+ const arrowWidth = 60;
873
+ const arrowHeight = 30;
874
+ const arrowHeadWidth = 20;
875
+ const arrowPath = `
876
+ M ${decX + arrowWidth} ${decY - arrowHeight / 2}
877
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2}
878
+ L ${decX + arrowHeadWidth} ${decY - arrowHeight / 2 - 8}
879
+ L ${decX} ${decY}
880
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2 + 8}
881
+ L ${decX + arrowHeadWidth} ${decY + arrowHeight / 2}
882
+ L ${decX + arrowWidth} ${decY + arrowHeight / 2}
883
+ Z
884
+ `;
885
+ deacceleratorsGroup.append("path").attr("d", arrowPath).attr("fill", "white").attr("stroke", theme.componentStroke).attr("stroke-width", 1);
886
+ deacceleratorsGroup.append("text").attr("x", decX + arrowWidth / 2).attr("y", decY + arrowHeight / 2 + 15).attr("text-anchor", "middle").attr("font-size", 10).attr("fill", theme.axisTextColor).attr("font-weight", "bold").text(deaccelerator.name);
887
+ });
888
+ }
889
+ }, "draw");
890
+ var wardleyRenderer_default = {
891
+ draw
892
+ };
893
+ var diagram = {
894
+ parser,
895
+ db: wardleyDb_default,
896
+ renderer: wardleyRenderer_default,
897
+ styles: /* @__PURE__ */ __name(() => "", "styles")
898
+ };
899
+ export {
900
+ diagram
901
+ };