@webskill/sdk 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/abnfDiagram-O67JEVCF-DtYFjfqO.js +109 -0
  2. package/dist/agent.d.ts +3 -3
  3. package/dist/agent.js +1174 -169
  4. package/dist/{approval-DwN2o2QG.js → approval-7CuZS3Z4.js} +104 -18
  5. package/dist/arc-8U_6NQWm.js +130 -0
  6. package/dist/architecture-7GRP2DOG-RTw1wpAq.js +4 -0
  7. package/dist/architectureDiagram-NJMV4G6O-XmmXrJAK.js +7473 -0
  8. package/dist/array-DQfpQNY8.js +8 -0
  9. package/dist/blockDiagram-BEXU5L5S-D4yjnCD1.js +2582 -0
  10. package/dist/browser.d.ts +455 -49
  11. package/dist/browser.js +2134 -138
  12. package/dist/c4Diagram-YGBWAQC7-BLmA_JSd.js +3668 -0
  13. package/dist/channel-CZxxLrG7.js +9 -0
  14. package/dist/chunk-2Q5K7J3B-Ck03gkFR.js +21 -0
  15. package/dist/chunk-3FUC2YCW-tr6jmbQf.js +530 -0
  16. package/dist/chunk-5DYCD2WN-Bt97YGTd.js +58 -0
  17. package/dist/chunk-5VM5RSS4-BBxa48HL.js +21 -0
  18. package/dist/chunk-6AEJRKK7-JXK89I-O.js +14 -0
  19. package/dist/chunk-742MDFTN-CPmgCGwC.js +466 -0
  20. package/dist/chunk-7INBJB4K-C9jq9o66.js +6552 -0
  21. package/dist/chunk-7M6MHVWA-BrKCWcR1.js +4894 -0
  22. package/dist/chunk-7PRAP22T-BHED6GVs.js +95 -0
  23. package/dist/chunk-DUW6YSOI-DoZj78PO.js +19 -0
  24. package/dist/chunk-FOHPRMQF-Dkbp819z.js +27189 -0
  25. package/dist/chunk-GNY47TPC-Bpvq1T49.js +87 -0
  26. package/dist/chunk-GTNCS2PH-CLmh4I2c.js +686 -0
  27. package/dist/chunk-GWA4HPMP-B6vN3fkL.js +95 -0
  28. package/dist/chunk-J5ZVWO5B-Bi_Pcobw.js +26 -0
  29. package/dist/chunk-JWPE2WC7-D1rC79GS.js +12 -0
  30. package/dist/chunk-LNGE3PJU-D5OIoe3Z.js +2582 -0
  31. package/dist/chunk-MBY4JIJT-C34L7a4f.js +2276 -0
  32. package/dist/chunk-NETBCI7D-Cg84k8N8.js +321 -0
  33. package/dist/chunk-O7XYJQB3-B6K0KOSL.js +8846 -0
  34. package/dist/chunk-UA2S7LBM-DxHM29_K.js +612 -0
  35. package/dist/chunk-WEXAMYUT-Ba6jFWhB.js +33 -0
  36. package/dist/chunk-XXDRQBXY-DPbSy4kg.js +12 -0
  37. package/dist/chunk-Y2CYZVJY-U3QOMqrW.js +15 -0
  38. package/dist/chunk-Z7XXMR3K-oLg1h8F3.js +1038 -0
  39. package/dist/chunk-ZIGJFQKS-DqEFBuHR.js +2215 -0
  40. package/dist/classDiagram-v2-NBCMYWYE-BqnOWIUt.js +3845 -0
  41. package/dist/cose-bilkent-JH36ORCC-C0dTAHVK.js +4270 -0
  42. package/dist/cynefin-OW5HDTMX-B2QvgEQj.js +4 -0
  43. package/dist/cynefinDiagram-VND7K2PF-yAWc6Z3W.js +479 -0
  44. package/dist/cytoscape.esm-C64mRh9B.js +28325 -0
  45. package/dist/dagre-6A5THRUB-D0w2W27v.js +4816 -0
  46. package/dist/defaultLocale-B_EoOkSF.js +249 -0
  47. package/dist/diagram-22UHCM2B-DvgzhUzP.js +6115 -0
  48. package/dist/diagram-3UASUU5V-DWgUB-ef.js +795 -0
  49. package/dist/diagram-ATOU4E4O-P1olqwIs.js +553 -0
  50. package/dist/diagram-CDSNMT55-BUlZuLUe.js +402 -0
  51. package/dist/diagram-MLGK6HIB-6w5qmkGt.js +186 -0
  52. package/dist/diagram-MPIPVDR6-DEFiSo8o.js +289 -0
  53. package/dist/dist-UajCDt3n.js +92 -0
  54. package/dist/ebnfDiagram-ZINNZB2B-CI8liCfR.js +123 -0
  55. package/dist/elk-276RUBZZ-3SvW6OAK.js +90034 -0
  56. package/dist/erDiagram-OPXOYQCR-CPTbKhwP.js +2301 -0
  57. package/dist/eventmodeling-NTZA5JFV-BlyuqGp0.js +4 -0
  58. package/dist/flowDiagram-KWPJA3E3-CcUJ6HbV.js +18 -0
  59. package/dist/ganttDiagram-FUAMR5RP-31UjY0KK.js +3939 -0
  60. package/dist/{toolSource-C9oNuKmr.js → geometry-CRhuySKV.js} +169 -12
  61. package/dist/gitGraph-4MIJSDKK-ChdVlrk7.js +4 -0
  62. package/dist/gitGraphDiagram-X574FWY7-DKuxJymB.js +1153 -0
  63. package/dist/governance.d.ts +22 -4
  64. package/dist/governance.js +100 -10
  65. package/dist/graphlib-tk9gQYuN.js +4194 -0
  66. package/dist/{index-DHopiH_m.d.ts → index-7No55dRb.d.ts} +161 -11
  67. package/dist/{index-B8Tgmpwh.d.ts → index-ShvCB5I9.d.ts} +2 -2
  68. package/dist/{index-CYLt5u4L.d.ts → index-V76_OFj2.d.ts} +789 -21
  69. package/dist/index.d.ts +4 -4
  70. package/dist/index.js +11 -9
  71. package/dist/info-A6RAGUB7-CxRAt9S9.js +4 -0
  72. package/dist/infoDiagram-VRGFBTTK-pRspGfjZ.js +25 -0
  73. package/dist/init-CMOIWdg-.js +16 -0
  74. package/dist/ishikawaDiagram-OU5B5YK6-DKerAPAg.js +975 -0
  75. package/dist/journeyDiagram-ZHPQQLJL-C4MK-YO5.js +1227 -0
  76. package/dist/kanban-definition-PNTS6WVX-BqsZpMXx.js +1244 -0
  77. package/dist/katex-BcRRvyh_.js +26465 -0
  78. package/dist/{kind-DaKqLX2F.js → kind-Dc8x0HWz.js} +54 -7
  79. package/dist/line-LgV8iVMV.js +48 -0
  80. package/dist/linear-BWKR0Tqd.js +393 -0
  81. package/dist/linkedDocument-CZZOl9cO.js +456 -0
  82. package/dist/mcp.d.ts +2 -2
  83. package/dist/{memoryArtifactStore-D6dLeY55.js → memoryArtifactStore-Bs7glPqm.js} +14 -0
  84. package/dist/mermaid-parser.core-pYR5siSx.js +754 -0
  85. package/dist/mermaid.core-DMtwGCHy.js +1756 -0
  86. package/dist/mindmap-definition-NLK3R4M7-CXbD-myG.js +1312 -0
  87. package/dist/node.d.ts +3 -3
  88. package/dist/node.js +12 -5
  89. package/dist/{openUiLibrary-b0i7F_oZ.js → openUiLibrary-B7j3rLrm.js} +1 -1
  90. package/dist/{openUiSpecLang-CLXJEeRU.js → openUiSpecLang-BSYYnjay.js} +1 -1
  91. package/dist/ordinal-CxA6GHQS.js +84 -0
  92. package/dist/packet-AYTQ26CC-BOm08cxl.js +4 -0
  93. package/dist/path-C27Z2Bjv.js +106 -0
  94. package/dist/{pathSecurity-B1owvJAF.js → pathSecurity-CirkQwWP.js} +12 -1
  95. package/dist/pegDiagram-GJSIUBJH-BLGJOewQ.js +115 -0
  96. package/dist/pie-WAS4IAKB-Dvg7glpk.js +4 -0
  97. package/dist/pieDiagram-5QR66LMP-laoaV_PB.js +298 -0
  98. package/dist/quadrantDiagram-O4NWA36T-Db_wFBkT.js +2236 -0
  99. package/dist/radar-RG4KPBEZ-BZDaTu06.js +4 -0
  100. package/dist/railroad-74A4TZTK-C-UhjkOy.js +4 -0
  101. package/dist/railroad-abnf-HS5TGJTU-dUKVA4OS.js +4 -0
  102. package/dist/railroad-ebnf-LZEXJU2U-DzQumk18.js +4 -0
  103. package/dist/railroad-peg-WCYAUIDC-B3vvTWed.js +4 -0
  104. package/dist/railroadDiagram-XR7U4H2S-BY0sTM4X.js +89 -0
  105. package/dist/requirementDiagram-PLB6GJNP-3rkQfEhs.js +2474 -0
  106. package/dist/rough.cjs-AmDd_NQk.js +1395 -0
  107. package/dist/sankeyDiagram-IPEJSGJF-CGAJhyG2.js +3578 -0
  108. package/dist/sequenceDiagram-PO4LG4MO-9FJjFX06.js +5522 -0
  109. package/dist/sizeCapture-INFHLROL-D8PWxdOn.js +56 -0
  110. package/dist/{skill-CAJMsLod.js → skill-WSUDp6A1.js} +1 -1
  111. package/dist/{skillVersionStore-B24Jjjry-BkOk9wI_.d.ts → skillVersionStore-S4_HJ_Fl-Cvy9LqVu.d.ts} +35 -4
  112. package/dist/src-NkhI3UMl.js +2653 -0
  113. package/dist/stateDiagram-v2-GCMORJYK-B0O3wc1-.js +2715 -0
  114. package/dist/swimlanes-2SLR337P-D4EOnrpu.js +6637 -0
  115. package/dist/swimlanesDiagram-TC7HE7FX-BUx29EJ9.js +30 -0
  116. package/dist/testing.d.ts +2 -1
  117. package/dist/testing.js +1 -1
  118. package/dist/timeline-definition-EJHVYXUP-CrgiiB4C.js +1513 -0
  119. package/dist/treeView-Q6P3EWNA-C1by-Gzc.js +4 -0
  120. package/dist/treemap-WGGIJYW6-mC2NZ6ad.js +4 -0
  121. package/dist/{types-BvTV_05--BW8zDuEk.d.ts → types-CpDRZ0rA-BiZBXGm4.d.ts} +66 -8
  122. package/dist/ui-react.d.ts +3 -3
  123. package/dist/ui-react.js +3746 -96
  124. package/dist/ui-vue.d.ts +1 -1
  125. package/dist/ui.d.ts +3 -3
  126. package/dist/ui.js +2 -2
  127. package/dist/usecaseDiagram-POWQR4AR-BUt_TQOY.js +14397 -0
  128. package/dist/vennDiagram-UO4OBE2U-CwXr0wjA.js +2808 -0
  129. package/dist/wardley-WFR3VGLG-CVSYjq_S.js +4 -0
  130. package/dist/wardleyDiagram-VNRHLVJA-Cpfd47dQ.js +874 -0
  131. package/dist/{webSkillApi-Cib6G-94.js → webSkillApi-D5VMUnrv.js} +2 -2
  132. package/dist/{webskillLitCatalog-W06npwej.js → webskillLitCatalog-D5BCiMCU.js} +1 -1
  133. package/dist/xychartDiagram-PMCCYNJV-e1TeVoc6.js +2704 -0
  134. package/package.json +1 -1
  135. package/dist/linkedDocument-C0gj1sMq.js +0 -245
@@ -0,0 +1,9 @@
1
+ import { ot as Color, st as Utils } from "./chunk-O7XYJQB3-B6K0KOSL.js";
2
+
3
+ //#region ../../node_modules/.pnpm/khroma@2.1.0/node_modules/khroma/dist/methods/channel.js
4
+ const channel = (color, channel) => {
5
+ return Utils.lang.round(Color.parse(color)[channel]);
6
+ };
7
+
8
+ //#endregion
9
+ export { channel as t };
@@ -0,0 +1,21 @@
1
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
2
+
3
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/chunk-2Q5K7J3B.mjs
4
+ var ImperativeState = class {
5
+ /**
6
+ * @param init - Function that creates the default state.
7
+ */
8
+ constructor(init) {
9
+ this.init = init;
10
+ this.records = this.init();
11
+ }
12
+ static {
13
+ __name(this, "ImperativeState");
14
+ }
15
+ reset() {
16
+ this.records = this.init();
17
+ }
18
+ };
19
+
20
+ //#endregion
21
+ export { ImperativeState as t };
@@ -0,0 +1,530 @@
1
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
2
+ import { m as log } from "./src-NkhI3UMl.js";
3
+ import { b as getConfig, x as getConfig2 } from "./chunk-O7XYJQB3-B6K0KOSL.js";
4
+ import { g as utils_default } from "./chunk-ZIGJFQKS-DqEFBuHR.js";
5
+ import { o as labelHelper } from "./chunk-7INBJB4K-C9jq9o66.js";
6
+ import { i as positionNode, n as getSubGraphTitleMargins, r as insertNode, t as clear } from "./chunk-5DYCD2WN-Bt97YGTd.js";
7
+ import { a as insertEdgeLabel, c as markers_default, i as insertEdge, n as edgeLabels, r as hasEdgeLabel, t as clear$1, u as terminalLabels } from "./chunk-Z7XXMR3K-oLg1h8F3.js";
8
+ import { t as Graph } from "./graphlib-tk9gQYuN.js";
9
+ import { r as insertCluster, t as clear$2 } from "./chunk-UA2S7LBM-DxHM29_K.js";
10
+
11
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/chunk-3FUC2YCW.mjs
12
+ function createLayoutElementGroups(element, { edgePathsClass = "edges edgePaths" } = {}) {
13
+ const rootGroups = element.insert("g").attr("class", "root");
14
+ return {
15
+ clusters: rootGroups.insert("g").attr("class", "clusters"),
16
+ edgePaths: rootGroups.insert("g").attr("class", edgePathsClass),
17
+ edgeLabels: rootGroups.insert("g").attr("class", "edgeLabels"),
18
+ nodes: rootGroups.insert("g").attr("class", "nodes"),
19
+ rootGroups
20
+ };
21
+ }
22
+ __name(createLayoutElementGroups, "createLayoutElementGroups");
23
+ async function measureGroupLabel(nodesGroup, node, measureWidth) {
24
+ if (node.label) {
25
+ const { shapeSvg, bbox } = await labelHelper(nodesGroup, measureWidth === void 0 ? node : {
26
+ ...node,
27
+ width: measureWidth
28
+ });
29
+ node.labelBBox = {
30
+ width: bbox.width,
31
+ height: bbox.height
32
+ };
33
+ shapeSvg.remove();
34
+ } else node.labelBBox = {
35
+ width: 0,
36
+ height: 0
37
+ };
38
+ }
39
+ __name(measureGroupLabel, "measureGroupLabel");
40
+ async function insertMeasuredNode(nodesGroup, node, renderOptions) {
41
+ const childNodeEl = await insertNode(nodesGroup, node, renderOptions);
42
+ const boundingBox = childNodeEl.node()?.getBBox() ?? {
43
+ width: 0,
44
+ height: 0
45
+ };
46
+ node.width = boundingBox.width;
47
+ node.height = boundingBox.height;
48
+ return childNodeEl;
49
+ }
50
+ __name(insertMeasuredNode, "insertMeasuredNode");
51
+ function resolveNodeDir(node, nodeById, diagramDir) {
52
+ let current = node;
53
+ const seen = /* @__PURE__ */ new Set();
54
+ while (current) {
55
+ if (current.dir) return current.dir;
56
+ if (!current.parentId || seen.has(current.parentId)) break;
57
+ seen.add(current.parentId);
58
+ current = nodeById.get(current.parentId);
59
+ }
60
+ return diagramDir;
61
+ }
62
+ __name(resolveNodeDir, "resolveNodeDir");
63
+ async function createGraphWithElements(element, data4Layout, options = {}) {
64
+ const graph = new Graph({
65
+ multigraph: true,
66
+ compound: true
67
+ });
68
+ const edgesToProcess = [...data4Layout.edges];
69
+ const config = getConfig2();
70
+ const groups = createLayoutElementGroups(element);
71
+ const { edgeLabels: edgeLabels2, nodes: nodesGroup } = groups;
72
+ const nodeElements = /* @__PURE__ */ new Map();
73
+ const nodeById = new Map(data4Layout.nodes.map((node) => [node.id, node]));
74
+ const diagramDir = data4Layout.direction;
75
+ const hasDom = element.node() != null;
76
+ await Promise.all(data4Layout.nodes.map(async (node) => {
77
+ if (node.isGroup) {
78
+ if (hasDom) {
79
+ const unwrap = options.unwrapGroupLabels && node.labelType !== "markdown";
80
+ await measureGroupLabel(nodesGroup, node, unwrap ? Number.POSITIVE_INFINITY : void 0);
81
+ }
82
+ graph.setNode(node.id, { ...node });
83
+ } else {
84
+ if (hasDom) {
85
+ const childNodeEl = await insertMeasuredNode(nodesGroup, node, {
86
+ config,
87
+ dir: resolveNodeDir(node, nodeById, diagramDir)
88
+ });
89
+ nodeElements.set(node.id, childNodeEl);
90
+ }
91
+ graph.setNode(node.id, { ...node });
92
+ }
93
+ }));
94
+ for (const edge of edgesToProcess) {
95
+ if (hasDom && hasEdgeLabel(edge)) await insertEdgeLabel(edgeLabels2, edge);
96
+ graph.setEdge(edge.start, edge.end, { ...edge }, edge.id);
97
+ if (!data4Layout.edges.some((existingEdge) => existingEdge.id === edge.id)) data4Layout.edges.push(edge);
98
+ }
99
+ if (globalThis.mermaidCaptureSizes) {
100
+ const { captureNodeSizes } = await import("./sizeCapture-INFHLROL-D8PWxdOn.js");
101
+ captureNodeSizes(element, data4Layout);
102
+ }
103
+ return {
104
+ graph,
105
+ groups,
106
+ nodeElements
107
+ };
108
+ }
109
+ __name(createGraphWithElements, "createGraphWithElements");
110
+ var clusterDb = /* @__PURE__ */ new Map();
111
+ var descendants = /* @__PURE__ */ new Map();
112
+ var parents = /* @__PURE__ */ new Map();
113
+ var clear4 = /* @__PURE__ */ __name(() => {
114
+ descendants.clear();
115
+ parents.clear();
116
+ clusterDb.clear();
117
+ }, "clear");
118
+ var isDescendant = /* @__PURE__ */ __name((id, ancestorId) => {
119
+ const ancestorDescendants = descendants.get(ancestorId) || [];
120
+ log.trace("In isDescendant", ancestorId, " ", id, " = ", ancestorDescendants.includes(id));
121
+ return ancestorDescendants.includes(id);
122
+ }, "isDescendant");
123
+ var edgeInCluster = /* @__PURE__ */ __name((edge, clusterId) => {
124
+ const clusterDescendants = descendants.get(clusterId) || [];
125
+ log.info("Descendants of ", clusterId, " is ", clusterDescendants);
126
+ log.info("Edge is ", edge);
127
+ if (edge.v === clusterId || edge.w === clusterId) return false;
128
+ if (!clusterDescendants) {
129
+ log.debug("Tilt, ", clusterId, ",not in descendants");
130
+ return false;
131
+ }
132
+ return clusterDescendants.includes(edge.v) || isDescendant(edge.v, clusterId) || isDescendant(edge.w, clusterId) || clusterDescendants.includes(edge.w);
133
+ }, "edgeInCluster");
134
+ var copy = /* @__PURE__ */ __name((clusterId, graph, newGraph, rootId) => {
135
+ log.debug("Copying children of ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId);
136
+ const nodes = graph.children(clusterId) || [];
137
+ if (clusterId !== rootId) nodes.push(clusterId);
138
+ log.debug("Copying (nodes) clusterId", clusterId, "nodes", nodes);
139
+ nodes.forEach((node) => {
140
+ if (graph.children(node).length > 0) copy(node, graph, newGraph, rootId);
141
+ else {
142
+ const data = graph.node(node);
143
+ log.info("cp ", node, " to ", rootId, " with parent ", clusterId);
144
+ newGraph.setNode(node, data);
145
+ if (rootId !== graph.parent(node)) {
146
+ log.debug("Setting parent", node, graph.parent(node));
147
+ newGraph.setParent(node, graph.parent(node));
148
+ }
149
+ if (clusterId !== rootId && node !== clusterId) {
150
+ log.debug("Setting parent", node, clusterId);
151
+ newGraph.setParent(node, clusterId);
152
+ } else {
153
+ log.info("In copy ", clusterId, "root", rootId, "data", graph.node(clusterId), rootId);
154
+ log.debug("Not Setting parent for node=", node, "cluster!==rootId", clusterId !== rootId, "node!==clusterId", node !== clusterId);
155
+ }
156
+ const edges = graph.edges(node);
157
+ log.debug("Copying Edges", edges);
158
+ edges.forEach((edge) => {
159
+ log.info("Edge", edge);
160
+ const data2 = graph.edge(edge.v, edge.w, edge.name);
161
+ log.info("Edge data", data2, rootId);
162
+ try {
163
+ if (edgeInCluster(edge, rootId)) {
164
+ log.info("Copying as ", edge.v, edge.w, data2, edge.name);
165
+ newGraph.setEdge(edge.v, edge.w, data2, edge.name);
166
+ log.info("newGraph edges ", newGraph.edges(), newGraph.edge(newGraph.edges()[0]));
167
+ } else log.info("Skipping copy of edge ", edge.v, "-->", edge.w, " rootId: ", rootId, " clusterId:", clusterId);
168
+ } catch (e) {
169
+ log.error(e);
170
+ }
171
+ });
172
+ }
173
+ log.debug("Removing node", node);
174
+ graph.removeNode(node);
175
+ });
176
+ }, "copy");
177
+ var extractDescendants = /* @__PURE__ */ __name((id, graph) => {
178
+ const children = graph.children(id);
179
+ let res = [...children];
180
+ for (const child of children) {
181
+ parents.set(child, id);
182
+ res = [...res, ...extractDescendants(child, graph)];
183
+ }
184
+ return res;
185
+ }, "extractDescendants");
186
+ var findCommonEdges = /* @__PURE__ */ __name((graph, id1, id2) => {
187
+ const edges1 = graph.edges().filter((edge) => edge.v === id1 || edge.w === id1);
188
+ const edges2 = graph.edges().filter((edge) => edge.v === id2 || edge.w === id2);
189
+ const edges1Prim = edges1.map((edge) => {
190
+ return {
191
+ v: edge.v === id1 ? id2 : edge.v,
192
+ w: edge.w === id1 ? id1 : edge.w
193
+ };
194
+ });
195
+ const edges2Prim = edges2.map((edge) => {
196
+ return {
197
+ v: edge.v,
198
+ w: edge.w
199
+ };
200
+ });
201
+ return edges1Prim.filter((edgeIn1) => {
202
+ return edges2Prim.some((edge) => edgeIn1.v === edge.v && edgeIn1.w === edge.w);
203
+ });
204
+ }, "findCommonEdges");
205
+ var findNonClusterChild = /* @__PURE__ */ __name((id, graph, clusterId) => {
206
+ const children = graph.children(id);
207
+ log.trace("Searching children of id ", id, children);
208
+ if (children.length < 1) return id;
209
+ let reserve;
210
+ for (const child of children) {
211
+ const _id = findNonClusterChild(child, graph, clusterId);
212
+ const commonEdges = findCommonEdges(graph, clusterId, _id);
213
+ if (_id) if (commonEdges.length > 0) reserve = _id;
214
+ else return _id;
215
+ }
216
+ return reserve;
217
+ }, "findNonClusterChild");
218
+ var getAnchorId = /* @__PURE__ */ __name((id) => {
219
+ if (!clusterDb.has(id)) return id;
220
+ if (!clusterDb.get(id).externalConnections) return id;
221
+ if (clusterDb.has(id)) return clusterDb.get(id).id;
222
+ return id;
223
+ }, "getAnchorId");
224
+ var adjustClustersAndEdges = /* @__PURE__ */ __name((graph, depth) => {
225
+ if (!graph || depth > 10) {
226
+ log.debug("Opting out, no graph ");
227
+ return;
228
+ } else log.debug("Opting in, graph ");
229
+ graph.nodes().forEach(function(id) {
230
+ if (graph.children(id).length > 0) {
231
+ log.debug("Cluster identified", id, " Replacement id in edges: ", findNonClusterChild(id, graph, id));
232
+ descendants.set(id, extractDescendants(id, graph));
233
+ clusterDb.set(id, {
234
+ id: findNonClusterChild(id, graph, id),
235
+ clusterData: graph.node(id)
236
+ });
237
+ }
238
+ });
239
+ graph.nodes().forEach(function(id) {
240
+ const children = graph.children(id);
241
+ const edges = graph.edges();
242
+ if (children.length > 0) {
243
+ log.debug("Cluster identified", id, descendants);
244
+ edges.forEach((edge) => {
245
+ if (isDescendant(edge.v, id) ^ isDescendant(edge.w, id)) {
246
+ log.debug("Edge: ", edge, " leaves cluster ", id);
247
+ log.debug("Descendants of XXX ", id, ": ", descendants.get(id));
248
+ clusterDb.get(id).externalConnections = true;
249
+ }
250
+ });
251
+ } else log.debug("Not a cluster ", id, descendants);
252
+ });
253
+ for (let id of clusterDb.keys()) {
254
+ const nonClusterChild = clusterDb.get(id).id;
255
+ const parent = graph.parent(nonClusterChild);
256
+ if (parent !== id && clusterDb.has(parent) && !clusterDb.get(parent).externalConnections) clusterDb.get(id).id = parent;
257
+ const hasDirectOutgoingEdge = graph.edges().some((edge) => edge.v === id);
258
+ if (nonClusterChild && clusterDb.get(id)?.externalConnections && hasDirectOutgoingEdge && isNodeInExtractableCluster(graph, nonClusterChild, id)) {
259
+ const safeAnchor = findSafeAnchorNode(graph, id, graph.parent(nonClusterChild));
260
+ if (safeAnchor) clusterDb.get(id).id = safeAnchor;
261
+ }
262
+ }
263
+ graph.edges().forEach(function(e) {
264
+ const edge = graph.edge(e);
265
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(e));
266
+ log.debug("Edge " + e.v + " -> " + e.w + ": " + JSON.stringify(graph.edge(e)));
267
+ let v = e.v;
268
+ let w = e.w;
269
+ log.debug("Fix XXX", clusterDb, "ids:", e.v, e.w, "Translating: ", clusterDb.get(e.v), " --- ", clusterDb.get(e.w));
270
+ if (clusterDb.get(e.v) || clusterDb.get(e.w)) {
271
+ log.debug("Fixing and trying - removing XXX", e.v, e.w, e.name);
272
+ v = getAnchorId(e.v);
273
+ w = getAnchorId(e.w);
274
+ graph.removeEdge(e.v, e.w, e.name);
275
+ if (v !== e.v) {
276
+ const parent = graph.parent(v);
277
+ clusterDb.get(parent).externalConnections = true;
278
+ edge.fromCluster = e.v;
279
+ }
280
+ if (w !== e.w) {
281
+ const parent = graph.parent(w);
282
+ clusterDb.get(parent).externalConnections = true;
283
+ edge.toCluster = e.w;
284
+ }
285
+ log.debug("Fix Replacing with XXX", v, w, e.name);
286
+ graph.setEdge(v, w, edge, e.name);
287
+ }
288
+ });
289
+ extractor(graph, 0);
290
+ log.trace(clusterDb);
291
+ }, "adjustClustersAndEdges");
292
+ var extractor = /* @__PURE__ */ __name((graph, depth) => {
293
+ if (depth > 10) {
294
+ log.error("Bailing out");
295
+ return;
296
+ }
297
+ let nodes = graph.nodes();
298
+ let hasChildren = false;
299
+ for (const node of nodes) {
300
+ const children = graph.children(node);
301
+ hasChildren = hasChildren || children.length > 0;
302
+ }
303
+ if (!hasChildren) {
304
+ log.debug("Done, no node has children", graph.nodes());
305
+ return;
306
+ }
307
+ log.debug("Nodes = ", nodes, depth);
308
+ for (const node of nodes) {
309
+ log.debug("Extracting node", node, clusterDb, clusterDb.has(node) && !clusterDb.get(node).externalConnections, !graph.parent(node), graph.node(node), graph.children("D"), " Depth ", depth);
310
+ if (!clusterDb.has(node)) log.debug("Not a cluster", node, depth);
311
+ else if (!clusterDb.get(node).externalConnections && graph.children(node) && graph.children(node).length > 0) {
312
+ log.debug("Cluster without external connections, without a parent and with children", node, depth);
313
+ let dir = graph.graph().rankdir === "TB" ? "LR" : "TB";
314
+ if (clusterDb.get(node)?.clusterData?.dir) {
315
+ dir = clusterDb.get(node).clusterData.dir;
316
+ log.debug("Fixing dir", clusterDb.get(node).clusterData.dir, dir);
317
+ }
318
+ const clusterGraph = new Graph({
319
+ multigraph: true,
320
+ compound: true
321
+ }).setGraph({
322
+ rankdir: dir,
323
+ nodesep: 50,
324
+ ranksep: 50,
325
+ marginx: 8,
326
+ marginy: 8
327
+ }).setDefaultEdgeLabel(function() {
328
+ return {};
329
+ });
330
+ copy(node, graph, clusterGraph, node);
331
+ graph.setNode(node, {
332
+ clusterNode: true,
333
+ id: node,
334
+ clusterData: clusterDb.get(node).clusterData,
335
+ label: clusterDb.get(node).label,
336
+ graph: clusterGraph
337
+ });
338
+ } else {
339
+ log.debug("Cluster ** ", node, " **not meeting the criteria !externalConnections:", !clusterDb.get(node).externalConnections, " no parent: ", !graph.parent(node), " children ", graph.children(node) && graph.children(node).length > 0, graph.children("D"), depth);
340
+ log.debug(clusterDb);
341
+ }
342
+ }
343
+ nodes = graph.nodes();
344
+ log.debug("New list of nodes", nodes);
345
+ for (const node of nodes) {
346
+ const data = graph.node(node);
347
+ log.debug(" Now next level", node, data);
348
+ if (data?.clusterNode) extractor(data.graph, depth + 1);
349
+ }
350
+ }, "extractor");
351
+ var sorter = /* @__PURE__ */ __name((graph, nodes) => {
352
+ if (nodes.length === 0) return [];
353
+ let result = Object.assign([], nodes);
354
+ nodes.forEach((node) => {
355
+ const sorted = sorter(graph, graph.children(node));
356
+ result = [...result, ...sorted];
357
+ });
358
+ return result;
359
+ }, "sorter");
360
+ var sortNodesByHierarchy = /* @__PURE__ */ __name((graph) => sorter(graph, graph.children()), "sortNodesByHierarchy");
361
+ var isNodeInExtractableCluster = /* @__PURE__ */ __name((graph, node, rootId) => {
362
+ let parent = graph.parent(node);
363
+ while (parent && parent !== rootId) {
364
+ const cluster = clusterDb.get(parent);
365
+ if (cluster && !cluster.externalConnections) return true;
366
+ parent = graph.parent(parent);
367
+ }
368
+ return false;
369
+ }, "isNodeInExtractableCluster");
370
+ var findSafeAnchorNode = /* @__PURE__ */ __name((graph, clusterId, excludedCluster) => {
371
+ const children = graph.children(clusterId) ?? [];
372
+ for (const child of children) {
373
+ if (child === excludedCluster || isDescendant(child, excludedCluster)) continue;
374
+ const candidate = findNonClusterChild(child, graph, clusterId);
375
+ if (!candidate) continue;
376
+ if (!isNodeInExtractableCluster(graph, candidate, clusterId)) return candidate;
377
+ }
378
+ return null;
379
+ }, "findSafeAnchorNode");
380
+ function createCommonLayoutRenderer({ prepareLayout, measureLayout, runLayoutCore, paintLayout, afterPaint, paintOptions }) {
381
+ const measureLayoutFn = measureLayout ?? defaultMeasureLayout;
382
+ return /* @__PURE__ */ __name(async function render(data4Layout, svg, helpers, options) {
383
+ const element = svg.select("g");
384
+ (helpers?.insertMarkers ?? markers_default)(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
385
+ clearLayoutRenderState();
386
+ const renderContext = {
387
+ element,
388
+ helpers,
389
+ options
390
+ };
391
+ renderContext.preparedLayout = await prepareLayout?.(data4Layout, renderContext);
392
+ const measure = await measureLayoutFn(data4Layout, renderContext);
393
+ const coreResult = await runLayoutCore(data4Layout, renderContext);
394
+ const paintContext = {
395
+ ...renderContext,
396
+ measure
397
+ };
398
+ if (paintLayout) await paintLayout(data4Layout, paintContext, coreResult);
399
+ else await paintLayoutData(data4Layout, paintContext, paintOptions);
400
+ await afterPaint?.(data4Layout, paintContext, coreResult);
401
+ }, "render");
402
+ }
403
+ __name(createCommonLayoutRenderer, "createCommonLayoutRenderer");
404
+ function clearLayoutRenderState() {
405
+ clear();
406
+ clear$1();
407
+ clear$2();
408
+ clear4();
409
+ }
410
+ __name(clearLayoutRenderState, "clearLayoutRenderState");
411
+ async function defaultMeasureLayout(data4Layout, { element }, options) {
412
+ return await createGraphWithElements(element, data4Layout, options);
413
+ }
414
+ __name(defaultMeasureLayout, "defaultMeasureLayout");
415
+ async function paintLayoutData(data4Layout, context, options = {}) {
416
+ const { measure } = context;
417
+ const { groups } = measure;
418
+ for (const node of options.getNodes?.(data4Layout, context) ?? data4Layout.nodes) {
419
+ if (options.skipNode?.(node, context)) continue;
420
+ await paintLayoutNode(groups, node, context, options);
421
+ }
422
+ const nodeById = buildNodeLookup(data4Layout.nodes);
423
+ for (const edge of data4Layout.edges) {
424
+ if (shouldSkipPaintEdge(edge, options)) continue;
425
+ await paintLayoutEdge(groups, edge, nodeById, data4Layout, options, context);
426
+ }
427
+ }
428
+ __name(paintLayoutData, "paintLayoutData");
429
+ async function paintLayoutNode(groups, node, context, options) {
430
+ if (node.clusterNode) positionNode(node);
431
+ else if (shouldPaintAsCluster(node, context, options)) await insertCluster(groups.clusters, node);
432
+ else positionNode(node);
433
+ }
434
+ __name(paintLayoutNode, "paintLayoutNode");
435
+ function shouldPaintAsCluster(node, context, options) {
436
+ return node.isGroup === true && (options.isCluster?.(node, context) ?? true);
437
+ }
438
+ __name(shouldPaintAsCluster, "shouldPaintAsCluster");
439
+ function buildNodeLookup(nodes) {
440
+ const nodeById = /* @__PURE__ */ new Map();
441
+ for (const node of nodes) if (node?.id) nodeById.set(node.id, node);
442
+ return nodeById;
443
+ }
444
+ __name(buildNodeLookup, "buildNodeLookup");
445
+ function shouldSkipPaintEdge(edge, options) {
446
+ return edge.isLayoutOnly || Boolean(options.skipEdge?.(edge));
447
+ }
448
+ __name(shouldSkipPaintEdge, "shouldSkipPaintEdge");
449
+ async function paintLayoutEdge(groups, edge, nodeById, data4Layout, options, context) {
450
+ const paths = insertEdge(groups.edgePaths, { ...edge }, options.clusterDb ?? /* @__PURE__ */ new Map(), data4Layout.type, getRenderedNode(edge.start, edge, nodeById, context, options), getRenderedNode(edge.end, edge, nodeById, context, options), data4Layout.diagramId, shouldSkipIntersect(edge, options));
451
+ if (hasEdgeLabel(edge)) {
452
+ if (!edgeLabels.has(edge.id)) await insertEdgeLabel(groups.edgeLabels, edge);
453
+ positionRenderedEdgeLabel(edge, paths);
454
+ }
455
+ }
456
+ __name(paintLayoutEdge, "paintLayoutEdge");
457
+ function getRenderedNode(id, edge, nodeById, context, options) {
458
+ return options.getEdgeNode?.(id, edge, context) ?? (id ? nodeById.get(id) ?? {} : {});
459
+ }
460
+ __name(getRenderedNode, "getRenderedNode");
461
+ function shouldSkipIntersect(edge, options) {
462
+ return typeof options.skipIntersect === "function" ? options.skipIntersect(edge) : options.skipIntersect ?? false;
463
+ }
464
+ __name(shouldSkipIntersect, "shouldSkipIntersect");
465
+ function positionRenderedEdgeLabel(edge, paths) {
466
+ const path = paths?.updatedPath ?? paths?.originalPath;
467
+ const { subGraphTitleTotalMargin } = getSubGraphTitleMargins({ flowchart: getConfig().flowchart ?? {} });
468
+ if (edge.label) {
469
+ const el = edgeLabels.get(edge.id);
470
+ let x = edge.x;
471
+ let y = edge.y;
472
+ if (path) {
473
+ const pos = utils_default.calcLabelPosition(path);
474
+ log.debug("Moving label " + edge.label + " from (", x, ",", y, ") to (", pos.x, ",", pos.y, ") abc88");
475
+ if (paths?.updatedPath) {
476
+ x = pos.x;
477
+ y = pos.y;
478
+ }
479
+ }
480
+ el.attr("transform", `translate(${x}, ${y + subGraphTitleTotalMargin / 2})`);
481
+ }
482
+ if (edge?.startLabelLeft) {
483
+ const el = terminalLabels.get(edge.id).startLeft;
484
+ let x = edge?.x;
485
+ let y = edge?.y;
486
+ if (path) {
487
+ const pos = utils_default.calcTerminalLabelPosition(edge.arrowTypeStart ? 10 : 0, "start_left", path);
488
+ x = pos.x;
489
+ y = pos.y;
490
+ }
491
+ el.attr("transform", `translate(${x}, ${y})`);
492
+ }
493
+ if (edge.startLabelRight) {
494
+ const el = terminalLabels.get(edge.id).startRight;
495
+ let x = edge.x;
496
+ let y = edge.y;
497
+ if (path) {
498
+ const pos = utils_default.calcTerminalLabelPosition(edge.arrowTypeStart ? 10 : 0, "start_right", path);
499
+ x = pos.x;
500
+ y = pos.y;
501
+ }
502
+ el.attr("transform", `translate(${x}, ${y})`);
503
+ }
504
+ if (edge.endLabelLeft) {
505
+ const el = terminalLabels.get(edge.id).endLeft;
506
+ let x = edge.x;
507
+ let y = edge.y;
508
+ if (path) {
509
+ const pos = utils_default.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_left", path);
510
+ x = pos.x;
511
+ y = pos.y;
512
+ }
513
+ el.attr("transform", `translate(${x}, ${y})`);
514
+ }
515
+ if (edge.endLabelRight) {
516
+ const el = terminalLabels.get(edge.id).endRight;
517
+ let x = edge.x;
518
+ let y = edge.y;
519
+ if (path) {
520
+ const pos = utils_default.calcTerminalLabelPosition(edge.arrowTypeEnd ? 10 : 0, "end_right", path);
521
+ x = pos.x;
522
+ y = pos.y;
523
+ }
524
+ el.attr("transform", `translate(${x}, ${y})`);
525
+ }
526
+ }
527
+ __name(positionRenderedEdgeLabel, "positionRenderedEdgeLabel");
528
+
529
+ //#endregion
530
+ export { defaultMeasureLayout as a, sortNodesByHierarchy as c, createLayoutElementGroups as i, clusterDb as n, findNonClusterChild as o, createCommonLayoutRenderer as r, insertMeasuredNode as s, adjustClustersAndEdges as t };
@@ -0,0 +1,58 @@
1
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
2
+ import { m as log } from "./src-NkhI3UMl.js";
3
+ import { u as handleUndefinedAttr } from "./chunk-ZIGJFQKS-DqEFBuHR.js";
4
+ import { s as shapes } from "./chunk-7INBJB4K-C9jq9o66.js";
5
+
6
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/chunk-5DYCD2WN.mjs
7
+ var getSubGraphTitleMargins = /* @__PURE__ */ __name(({ flowchart }) => {
8
+ const subGraphTitleTopMargin = flowchart?.subGraphTitleMargin?.top ?? 0;
9
+ const subGraphTitleBottomMargin = flowchart?.subGraphTitleMargin?.bottom ?? 0;
10
+ return {
11
+ subGraphTitleTopMargin,
12
+ subGraphTitleBottomMargin,
13
+ subGraphTitleTotalMargin: subGraphTitleTopMargin + subGraphTitleBottomMargin
14
+ };
15
+ }, "getSubGraphTitleMargins");
16
+ var nodeElems = /* @__PURE__ */ new Map();
17
+ async function insertNode(elem, node, renderOptions) {
18
+ let newEl;
19
+ let el;
20
+ if (node.shape === "rect") if (node.rx && node.ry) node.shape = "roundedRect";
21
+ else node.shape = "squareRect";
22
+ const shapeHandler = node.shape ? shapes[node.shape] : void 0;
23
+ if (!shapeHandler) throw new Error(`No such shape: ${node.shape}. Please check your syntax.`);
24
+ if (node.link) {
25
+ let target;
26
+ if (renderOptions.config.securityLevel === "sandbox") target = "_top";
27
+ else if (node.linkTarget) target = node.linkTarget || "_blank";
28
+ newEl = elem.insert("svg:a").attr("xlink:href", node.link).attr("target", target ?? null);
29
+ el = await shapeHandler(newEl, node, renderOptions);
30
+ } else {
31
+ el = await shapeHandler(elem, node, renderOptions);
32
+ newEl = el;
33
+ }
34
+ newEl.attr("data-look", handleUndefinedAttr(node.look));
35
+ if (node.tooltip) el.attr("title", node.tooltip);
36
+ nodeElems.set(node.id, newEl);
37
+ if (node.haveCallback) newEl.attr("class", newEl.attr("class") + " clickable");
38
+ return newEl;
39
+ }
40
+ __name(insertNode, "insertNode");
41
+ var setNodeElem = /* @__PURE__ */ __name((elem, node) => {
42
+ nodeElems.set(node.id, elem);
43
+ }, "setNodeElem");
44
+ var clear = /* @__PURE__ */ __name(() => {
45
+ nodeElems.clear();
46
+ }, "clear");
47
+ var positionNode = /* @__PURE__ */ __name((node) => {
48
+ const el = nodeElems.get(node.id);
49
+ log.trace("Transforming node", node.diff, node, "translate(" + (node.x - node.width / 2 - 5) + ", " + node.width / 2 + ")");
50
+ const padding = 8;
51
+ const diff = node.diff || 0;
52
+ if (node.clusterNode) el.attr("transform", "translate(" + (node.x + diff - node.width / 2) + ", " + (node.y - node.height / 2 - padding) + ")");
53
+ else el.attr("transform", "translate(" + node.x + ", " + node.y + ")");
54
+ return diff;
55
+ }, "positionNode");
56
+
57
+ //#endregion
58
+ export { setNodeElem as a, positionNode as i, getSubGraphTitleMargins as n, insertNode as r, clear as t };
@@ -0,0 +1,21 @@
1
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
2
+
3
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/chunk-5VM5RSS4.mjs
4
+ var getIconStyles = /* @__PURE__ */ __name(() => `
5
+ /* Font Awesome icon styling - consolidated */
6
+ .label-icon {
7
+ display: inline-block;
8
+ height: 1em;
9
+ overflow: visible;
10
+ vertical-align: -0.125em;
11
+ }
12
+
13
+ .node .label-icon path {
14
+ fill: currentColor;
15
+ stroke: revert;
16
+ stroke-width: revert;
17
+ }
18
+ `, "getIconStyles");
19
+
20
+ //#endregion
21
+ export { getIconStyles as t };
@@ -0,0 +1,14 @@
1
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
2
+ import { p as select_default } from "./src-NkhI3UMl.js";
3
+ import { x as getConfig2 } from "./chunk-O7XYJQB3-B6K0KOSL.js";
4
+
5
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/chunk-6AEJRKK7.mjs
6
+ var selectSvgElement = /* @__PURE__ */ __name((id) => {
7
+ const { securityLevel } = getConfig2();
8
+ let root = select_default("body");
9
+ if (securityLevel === "sandbox") root = select_default((select_default(`#i${id}`).node()?.contentDocument ?? document).body);
10
+ return root.select(`#${id}`);
11
+ }, "selectSvgElement");
12
+
13
+ //#endregion
14
+ export { selectSvgElement as t };