@webskill/sdk 0.20.0 → 0.22.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 (139) hide show
  1. package/dist/abnfDiagram-O67JEVCF-DtYFjfqO.js +109 -0
  2. package/dist/agent.d.ts +3 -3
  3. package/dist/agent.js +1171 -73
  4. package/dist/{approval-Bbh_Apwg.js → approval-DWQlDPbY.js} +527 -29
  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 +1129 -48
  11. package/dist/browser.js +3562 -278
  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/{eventTypes-CwciaqCU.js → eventTypes-DcTQXSV1.js} +7 -1
  58. package/dist/eventmodeling-NTZA5JFV-BlyuqGp0.js +4 -0
  59. package/dist/flowDiagram-KWPJA3E3-CcUJ6HbV.js +18 -0
  60. package/dist/ganttDiagram-FUAMR5RP-31UjY0KK.js +3939 -0
  61. package/dist/geometry-wx5ZTYzi.js +715 -0
  62. package/dist/gitGraph-4MIJSDKK-ChdVlrk7.js +4 -0
  63. package/dist/gitGraphDiagram-X574FWY7-DKuxJymB.js +1153 -0
  64. package/dist/governance.d.ts +9 -3
  65. package/dist/governance.js +1 -1
  66. package/dist/graphlib-tk9gQYuN.js +4194 -0
  67. package/dist/{index-ad11wflI.d.ts → index-BiO9_XRk.d.ts} +2 -2
  68. package/dist/{index-DQ3-6GFu.d.ts → index-CjwdZQOS.d.ts} +945 -8
  69. package/dist/{index-BDyXe-a5.d.ts → index-YPd8ZSEa.d.ts} +413 -7
  70. package/dist/index.d.ts +4 -4
  71. package/dist/index.js +47 -41
  72. package/dist/info-A6RAGUB7-CxRAt9S9.js +4 -0
  73. package/dist/infoDiagram-VRGFBTTK-pRspGfjZ.js +25 -0
  74. package/dist/init-CMOIWdg-.js +16 -0
  75. package/dist/ishikawaDiagram-OU5B5YK6-DKerAPAg.js +975 -0
  76. package/dist/journeyDiagram-ZHPQQLJL-C4MK-YO5.js +1227 -0
  77. package/dist/kanban-definition-PNTS6WVX-BqsZpMXx.js +1244 -0
  78. package/dist/katex-BcRRvyh_.js +26465 -0
  79. package/dist/kind-Dc8x0HWz.js +110 -0
  80. package/dist/line-LgV8iVMV.js +48 -0
  81. package/dist/linear-BWKR0Tqd.js +393 -0
  82. package/dist/linkedDocument-CIuh_Yp0.js +416 -0
  83. package/dist/mcp.d.ts +2 -2
  84. package/dist/{memoryArtifactStore-D6dLeY55.js → memoryArtifactStore-Bs7glPqm.js} +14 -0
  85. package/dist/mermaid-parser.core-pYR5siSx.js +754 -0
  86. package/dist/mermaid.core-DMtwGCHy.js +1756 -0
  87. package/dist/mindmap-definition-NLK3R4M7-CXbD-myG.js +1312 -0
  88. package/dist/node.d.ts +8 -3
  89. package/dist/node.js +79 -4
  90. package/dist/{openUiLibrary-b0i7F_oZ.js → openUiLibrary-B7j3rLrm.js} +1 -1
  91. package/dist/{openUiSpecLang-CLXJEeRU.js → openUiSpecLang-BSYYnjay.js} +1 -1
  92. package/dist/ordinal-CxA6GHQS.js +84 -0
  93. package/dist/packet-AYTQ26CC-BOm08cxl.js +4 -0
  94. package/dist/path-C27Z2Bjv.js +106 -0
  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/processSandboxEntry.js +5 -0
  99. package/dist/quadrantDiagram-O4NWA36T-Db_wFBkT.js +2236 -0
  100. package/dist/radar-RG4KPBEZ-BZDaTu06.js +4 -0
  101. package/dist/railroad-74A4TZTK-C-UhjkOy.js +4 -0
  102. package/dist/railroad-abnf-HS5TGJTU-dUKVA4OS.js +4 -0
  103. package/dist/railroad-ebnf-LZEXJU2U-DzQumk18.js +4 -0
  104. package/dist/railroad-peg-WCYAUIDC-B3vvTWed.js +4 -0
  105. package/dist/railroadDiagram-XR7U4H2S-BY0sTM4X.js +89 -0
  106. package/dist/requirementDiagram-PLB6GJNP-3rkQfEhs.js +2474 -0
  107. package/dist/rough.cjs-AmDd_NQk.js +1395 -0
  108. package/dist/sandboxWorkerEntry.js +5 -0
  109. package/dist/sankeyDiagram-IPEJSGJF-CGAJhyG2.js +3578 -0
  110. package/dist/sequenceDiagram-PO4LG4MO-9FJjFX06.js +5522 -0
  111. package/dist/sizeCapture-INFHLROL-D8PWxdOn.js +56 -0
  112. package/dist/{skillVersionStore-B24Jjjry-v2CCU0Xo.d.ts → skillVersionStore-B24Jjjry-BY1H7Krp.d.ts} +1 -1
  113. package/dist/src-NkhI3UMl.js +2653 -0
  114. package/dist/stateDiagram-v2-GCMORJYK-B0O3wc1-.js +2715 -0
  115. package/dist/swimlanes-2SLR337P-D4EOnrpu.js +6637 -0
  116. package/dist/swimlanesDiagram-TC7HE7FX-BUx29EJ9.js +30 -0
  117. package/dist/testing.d.ts +2 -1
  118. package/dist/testing.js +1 -1
  119. package/dist/timeline-definition-EJHVYXUP-CrgiiB4C.js +1513 -0
  120. package/dist/treeView-Q6P3EWNA-C1by-Gzc.js +4 -0
  121. package/dist/treemap-WGGIJYW6-mC2NZ6ad.js +4 -0
  122. package/dist/{types-Btpdd1y--BcxQ10Fa.d.ts → types-CpDRZ0rA-BM5FI9oN.d.ts} +111 -9
  123. package/dist/ui-react.d.ts +3 -3
  124. package/dist/ui-react.js +3718 -77
  125. package/dist/ui-vue.d.ts +1 -1
  126. package/dist/ui.d.ts +3 -3
  127. package/dist/ui.js +2 -2
  128. package/dist/untrustedText-BIaRvPZK.js +16 -0
  129. package/dist/usecaseDiagram-POWQR4AR-BUt_TQOY.js +14397 -0
  130. package/dist/vennDiagram-UO4OBE2U-CwXr0wjA.js +2808 -0
  131. package/dist/wardley-WFR3VGLG-CVSYjq_S.js +4 -0
  132. package/dist/wardleyDiagram-VNRHLVJA-Cpfd47dQ.js +874 -0
  133. package/dist/{webSkillApi-CsvA69qk.js → webSkillApi-Dy-Zjv0y.js} +1 -1
  134. package/dist/{webskillLitCatalog-W06npwej.js → webskillLitCatalog-D5BCiMCU.js} +1 -1
  135. package/dist/xychartDiagram-PMCCYNJV-e1TeVoc6.js +2704 -0
  136. package/package.json +6 -5
  137. package/dist/kind-DxgS8LM-.js +0 -77
  138. package/dist/linkedDocument-xNXF-z8n.js +0 -94
  139. package/dist/types-DOJI5YC3.js +0 -90
@@ -0,0 +1,402 @@
1
+ import { n as parse } from "./mermaid-parser.core-pYR5siSx.js";
2
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
3
+ import { m as log } from "./src-NkhI3UMl.js";
4
+ import { H as setAccDescription, U as setAccTitle, a as clear, b as getConfig, c as configureSvgSize, f as defaultConfig_default, q as setDiagramTitle, v as getAccDescription, w as getDiagramTitle, y as getAccTitle, z as sanitizeText } from "./chunk-O7XYJQB3-B6K0KOSL.js";
5
+ import { i as cleanAndMerge } from "./chunk-ZIGJFQKS-DqEFBuHR.js";
6
+ import { t as selectSvgElement } from "./chunk-6AEJRKK7-JXK89I-O.js";
7
+ import { t as populateCommonDb } from "./chunk-JWPE2WC7-D1rC79GS.js";
8
+ import { r as registerIconPacks, t as getIconSVG } from "./chunk-742MDFTN-CPmgCGwC.js";
9
+ import { t as ImperativeState } from "./chunk-2Q5K7J3B-Ck03gkFR.js";
10
+
11
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/diagram-CDSNMT55.mjs
12
+ var ALL_BOX_CHARS = /[─━│┃└┗├┣]/;
13
+ var BRANCH_CHAR = /[└┗├┣]/;
14
+ var DASH_CHAR = /[─━]/;
15
+ var DECORATION_ONLY = /^[\s│┃]+$/;
16
+ var METADATA_LINE = /^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/;
17
+ var COMMENT_LINE = /^\s*%%/;
18
+ var INDENT_UNIT = " ";
19
+ function isBoxDrawingFormat(lines) {
20
+ return lines.some((line) => ALL_BOX_CHARS.test(line));
21
+ }
22
+ __name(isBoxDrawingFormat, "isBoxDrawingFormat");
23
+ function inferSegmentWidth(contentLines) {
24
+ for (const line of contentLines) {
25
+ const match = BRANCH_CHAR.exec(line);
26
+ if (match?.index && match.index > 0) return match.index;
27
+ }
28
+ return 4;
29
+ }
30
+ __name(inferSegmentWidth, "inferSegmentWidth");
31
+ function remapErrorLines(message, lineMap) {
32
+ return message.replace(/\bline\s+(\d+)\b/gi, (match, lineStr) => {
33
+ const line = parseInt(lineStr, 10);
34
+ const original = lineMap.get(line);
35
+ return original ? `line ${original}` : match;
36
+ });
37
+ }
38
+ __name(remapErrorLines, "remapErrorLines");
39
+ function preprocessBoxDrawing(input) {
40
+ const lines = input.split("\n");
41
+ const lineMap = /* @__PURE__ */ new Map();
42
+ let keywordIdx = -1;
43
+ for (const [i, line] of lines.entries()) if (line.trim() === "treeView-beta") {
44
+ keywordIdx = i;
45
+ break;
46
+ }
47
+ if (keywordIdx === -1) return {
48
+ text: input,
49
+ lineMap
50
+ };
51
+ const contentLineTexts = [];
52
+ for (let i = keywordIdx + 1; i < lines.length; i++) {
53
+ const line = lines[i];
54
+ if (line.trim() === "" || COMMENT_LINE.test(line) || METADATA_LINE.test(line)) continue;
55
+ if (DECORATION_ONLY.test(line)) continue;
56
+ contentLineTexts.push(line.replace(/\t/g, " "));
57
+ }
58
+ if (!isBoxDrawingFormat(contentLineTexts)) return {
59
+ text: input,
60
+ lineMap
61
+ };
62
+ const segmentWidth = inferSegmentWidth(contentLineTexts);
63
+ const outputLines = [];
64
+ let outLineNo = 0;
65
+ for (let i = 0; i <= keywordIdx; i++) {
66
+ outputLines.push(lines[i]);
67
+ outLineNo++;
68
+ lineMap.set(outLineNo, i + 1);
69
+ }
70
+ for (let i = keywordIdx + 1; i < lines.length; i++) {
71
+ const line = lines[i];
72
+ const trimmed = line.trim();
73
+ const origLineNo = i + 1;
74
+ if (trimmed === "") {
75
+ outputLines.push(line);
76
+ outLineNo++;
77
+ lineMap.set(outLineNo, origLineNo);
78
+ continue;
79
+ }
80
+ if (COMMENT_LINE.test(line)) {
81
+ outputLines.push(line);
82
+ outLineNo++;
83
+ lineMap.set(outLineNo, origLineNo);
84
+ continue;
85
+ }
86
+ if (METADATA_LINE.test(line)) {
87
+ outputLines.push(line);
88
+ outLineNo++;
89
+ lineMap.set(outLineNo, origLineNo);
90
+ continue;
91
+ }
92
+ if (DECORATION_ONLY.test(line)) continue;
93
+ const normalized = line.replace(/\t/g, " ");
94
+ const branchMatch = BRANCH_CHAR.exec(normalized);
95
+ if (branchMatch?.index !== void 0) {
96
+ const branchCol = branchMatch.index;
97
+ const depth = Math.round(branchCol / segmentWidth) + 1;
98
+ let pos = branchCol + 1;
99
+ while (pos < normalized.length && DASH_CHAR.test(normalized[pos])) pos++;
100
+ while (pos < normalized.length && normalized[pos] === " ") pos++;
101
+ const content = normalized.slice(pos).trimEnd();
102
+ if (!content) throw new Error(`Line ${origLineNo}: Empty node \u2014 expected a filename or directory name after the box-drawing prefix`);
103
+ const indent = INDENT_UNIT.repeat(depth);
104
+ outputLines.push(indent + content);
105
+ outLineNo++;
106
+ lineMap.set(outLineNo, origLineNo);
107
+ } else if (/^[\s─━│┃└┗├┣]+$/.test(normalized)) continue;
108
+ else if (ALL_BOX_CHARS.test(normalized)) {
109
+ outputLines.push(line);
110
+ outLineNo++;
111
+ lineMap.set(outLineNo, origLineNo);
112
+ } else if (/^\s+/.test(normalized)) throw new Error(`Line ${origLineNo}: Unexpected indentation without box-drawing characters. In box-drawing format, use \u251C\u2500\u2500 or \u2514\u2500\u2500 prefixes for indented nodes.`);
113
+ else {
114
+ outputLines.push(line);
115
+ outLineNo++;
116
+ lineMap.set(outLineNo, origLineNo);
117
+ }
118
+ }
119
+ return {
120
+ text: outputLines.join("\n"),
121
+ lineMap
122
+ };
123
+ }
124
+ __name(preprocessBoxDrawing, "preprocessBoxDrawing");
125
+ var state = new ImperativeState(() => ({
126
+ cnt: 1,
127
+ stack: [{
128
+ id: 0,
129
+ level: -1,
130
+ name: "/",
131
+ nodeType: "directory",
132
+ children: []
133
+ }]
134
+ }));
135
+ var clear2 = /* @__PURE__ */ __name(() => {
136
+ state.reset();
137
+ clear();
138
+ }, "clear");
139
+ var getRoot = /* @__PURE__ */ __name(() => {
140
+ return state.records.stack[0];
141
+ }, "getRoot");
142
+ var getCount = /* @__PURE__ */ __name(() => state.records.cnt, "getCount");
143
+ var defaultConfig = defaultConfig_default.treeView;
144
+ var db_default = {
145
+ clear: clear2,
146
+ addNode: /* @__PURE__ */ __name((level, name, nodeType, cssClass, icon, description) => {
147
+ while (level <= state.records.stack[state.records.stack.length - 1].level) state.records.stack.pop();
148
+ const node = {
149
+ id: state.records.cnt++,
150
+ level,
151
+ name,
152
+ nodeType,
153
+ icon,
154
+ cssClass,
155
+ description,
156
+ children: []
157
+ };
158
+ state.records.stack[state.records.stack.length - 1].children.push(node);
159
+ state.records.stack.push(node);
160
+ }, "addNode"),
161
+ getRoot,
162
+ getCount,
163
+ getConfig: /* @__PURE__ */ __name(() => {
164
+ return cleanAndMerge(defaultConfig, getConfig().treeView);
165
+ }, "getConfig"),
166
+ getAccTitle,
167
+ getAccDescription,
168
+ getDiagramTitle,
169
+ setAccDescription,
170
+ setAccTitle,
171
+ setDiagramTitle
172
+ };
173
+ var populate = /* @__PURE__ */ __name((ast) => {
174
+ populateCommonDb(ast, db_default);
175
+ for (const node of ast.nodes) {
176
+ const level = typeof node.indent === "number" ? node.indent : 0;
177
+ let name = node.name;
178
+ const isDirectory = name.endsWith("/");
179
+ if (isDirectory) name = name.slice(0, -1);
180
+ const nodeType = isDirectory ? "directory" : "file";
181
+ const cssClass = node.classAnnotation || void 0;
182
+ const rawIcon = node.iconAnnotation;
183
+ const icon = rawIcon !== void 0 ? rawIcon || "none" : void 0;
184
+ const rawDesc = node.descAnnotation || void 0;
185
+ const description = rawDesc ? sanitizeText(rawDesc, getConfig()) : void 0;
186
+ db_default.addNode(level, name, nodeType, cssClass, icon, description);
187
+ }
188
+ }, "populate");
189
+ var parser = { parse: /* @__PURE__ */ __name(async (input) => {
190
+ const { text, lineMap } = preprocessBoxDrawing(input);
191
+ try {
192
+ const ast = await parse("treeView", text);
193
+ log.debug(ast);
194
+ populate(ast);
195
+ } catch (error) {
196
+ if (lineMap.size > 0 && error instanceof Error) error.message = remapErrorLines(error.message, lineMap);
197
+ throw error;
198
+ }
199
+ }, "parse") };
200
+ var treeViewIcons = {
201
+ prefix: "mermaid-treeview",
202
+ height: 24,
203
+ width: 24,
204
+ icons: {
205
+ folder: { body: "<path fill=\"currentColor\" d=\"M10.59 4.59A2 2 0 0 0 9.17 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.17z\"/>" },
206
+ file: { body: "<path fill=\"currentColor\" fill-rule=\"evenodd\" d=\"M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.83a2 2 0 0 0-.59-1.42l-4.82-4.82A2 2 0 0 0 13.17 2H6Zm7.5 1.9l4.6 4.6h-3.6a1 1 0 0 1-1-1V3.9Z\" clip-rule=\"evenodd\"/>" }
207
+ }
208
+ };
209
+ function detectIcon(name, config) {
210
+ const filenameIcon = config?.filenameIcons?.[name];
211
+ if (filenameIcon) return filenameIcon;
212
+ const dotIdx = name.lastIndexOf(".");
213
+ if (dotIdx > 0) {
214
+ const ext = name.substring(dotIdx).toLowerCase();
215
+ const extensionIcons = config?.extensionIcons;
216
+ return extensionIcons?.[ext] ?? extensionIcons?.[ext.slice(1)];
217
+ }
218
+ }
219
+ __name(detectIcon, "detectIcon");
220
+ function qualifyIcon(icon, defaultIconPack) {
221
+ if (icon.includes(":")) return icon;
222
+ if (icon in treeViewIcons.icons || !defaultIconPack) return `${treeViewIcons.prefix}:${icon}`;
223
+ return `${defaultIconPack}:${icon}`;
224
+ }
225
+ __name(qualifyIcon, "qualifyIcon");
226
+ function getNodeIcon(node, config) {
227
+ if (node.icon === "none") return;
228
+ if (node.icon) return qualifyIcon(node.icon, config.defaultIconPack);
229
+ if (!config.showIcons) return;
230
+ if (node.nodeType === "file") {
231
+ const detected = detectIcon(node.name, config);
232
+ if (detected === "none") return;
233
+ if (detected) return qualifyIcon(detected, config.defaultIconPack);
234
+ }
235
+ return `${treeViewIcons.prefix}:${node.nodeType === "directory" ? "folder" : "file"}`;
236
+ }
237
+ __name(getNodeIcon, "getNodeIcon");
238
+ registerIconPacks([{
239
+ name: treeViewIcons.prefix,
240
+ icons: treeViewIcons
241
+ }]);
242
+ var ICON_SIZE = 14;
243
+ var ICON_GAP = 4;
244
+ var DESC_GAP = 16;
245
+ var resolveNodeIcons = /* @__PURE__ */ __name(async (root, config) => {
246
+ const nodeIcons = [];
247
+ const collect = /* @__PURE__ */ __name((node) => {
248
+ const icon = getNodeIcon(node, config);
249
+ if (icon) nodeIcons.push({
250
+ icon,
251
+ node
252
+ });
253
+ node.children.forEach(collect);
254
+ }, "collect");
255
+ collect(root);
256
+ const resolvedIcons = await Promise.all(nodeIcons.map(async ({ icon, node }) => ({
257
+ id: node.id,
258
+ svg: await getIconSVG(icon, {
259
+ height: ICON_SIZE,
260
+ width: ICON_SIZE
261
+ })
262
+ })));
263
+ return new Map(resolvedIcons.map(({ id, svg }) => [id, svg]));
264
+ }, "resolveNodeIcons");
265
+ var positionLabel = /* @__PURE__ */ __name((x, y, node, domElem, config, iconSVGs) => {
266
+ const nodeGroup = domElem.append("g");
267
+ let cssClasses = "treeView-node-label";
268
+ if (node.nodeType === "directory") cssClasses += " treeView-node-dir";
269
+ if (node.cssClass) cssClasses += ` ${node.cssClass}`;
270
+ const iconOffset = ICON_SIZE + ICON_GAP;
271
+ const icon = getNodeIcon(node, config);
272
+ const showIcon = icon !== void 0;
273
+ if (icon) nodeGroup.append("g").attr("class", "treeView-node-icon").attr("transform", `translate(${x + config.paddingX}, ${y + config.paddingY})`).html(iconSVGs.get(node.id) ?? "");
274
+ const label = nodeGroup.append("text").text(node.name).attr("dominant-baseline", "middle").attr("class", cssClasses);
275
+ const { height: labelHeight, width: labelWidth } = label.node().getBBox();
276
+ const height = labelHeight + config.paddingY * 2;
277
+ const labelX = x + config.paddingX + (showIcon ? iconOffset : 0);
278
+ label.attr("x", labelX);
279
+ label.attr("y", y + height / 2);
280
+ const labelRightEdge = labelX + labelWidth;
281
+ node.BBox = {
282
+ x,
283
+ y,
284
+ width: labelWidth + config.paddingX * 2 + (showIcon ? iconOffset : 0),
285
+ height
286
+ };
287
+ if (node.cssClass?.split(/\s+/).includes("highlight")) nodeGroup.insert("rect", ":first-child").attr("x", x).attr("y", y + 1).attr("width", 0).attr("height", height - 2).attr("rx", 3).attr("class", "treeView-highlight-bg");
288
+ return {
289
+ node,
290
+ nodeGroup,
291
+ labelRightEdge,
292
+ centerY: y + height / 2
293
+ };
294
+ }, "positionLabel");
295
+ var positionLine = /* @__PURE__ */ __name((domElem, x1, y1, x2, y2, lineThickness) => {
296
+ return domElem.append("line").attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2).attr("stroke-width", lineThickness).attr("class", "treeView-node-line");
297
+ }, "positionLine");
298
+ var drawTree = /* @__PURE__ */ __name((elem, root, config, iconSVGs) => {
299
+ let totalHeight = 0;
300
+ let totalWidth = 0;
301
+ const renderInfos = [];
302
+ const drawNode = /* @__PURE__ */ __name((elem2, node, config2, depth) => {
303
+ const indent = depth * (config2.rowIndent + config2.paddingX);
304
+ const info = positionLabel(indent, totalHeight, node, elem2, config2, iconSVGs);
305
+ renderInfos.push(info);
306
+ const { height, width } = node.BBox;
307
+ positionLine(elem2, indent - config2.rowIndent, totalHeight + height / 2, indent, totalHeight + height / 2, config2.lineThickness);
308
+ totalWidth = Math.max(totalWidth, indent + width);
309
+ totalHeight += height;
310
+ }, "drawNode");
311
+ const processNode = /* @__PURE__ */ __name((node, depth = 0) => {
312
+ drawNode(elem, node, config, depth);
313
+ node.children.forEach((child) => {
314
+ processNode(child, depth + 1);
315
+ });
316
+ const { x, y, height } = node.BBox;
317
+ if (node.children.length) {
318
+ const { y: endY, height: endHeight } = node.children[node.children.length - 1].BBox;
319
+ positionLine(elem, x + config.paddingX, y + height, x + config.paddingX, endY + endHeight / 2 + config.lineThickness / 2, config.lineThickness);
320
+ }
321
+ }, "processNode");
322
+ processNode(root);
323
+ const nodesWithDesc = renderInfos.filter((ri) => ri.node.description);
324
+ if (nodesWithDesc.length > 0) {
325
+ const descX = Math.max(...renderInfos.map((ri) => ri.labelRightEdge)) + DESC_GAP;
326
+ for (const ri of nodesWithDesc) {
327
+ const descBBox = ri.nodeGroup.append("text").text(ri.node.description).attr("dominant-baseline", "middle").attr("class", "treeView-node-description").attr("x", descX).attr("y", ri.centerY).node().getBBox();
328
+ totalWidth = Math.max(totalWidth, descX + descBBox.width + config.paddingX);
329
+ }
330
+ }
331
+ for (const ri of renderInfos) if (ri.node.cssClass?.split(/\s+/).includes("highlight")) {
332
+ const rect = ri.nodeGroup.select(".treeView-highlight-bg");
333
+ if (!rect.empty()) {
334
+ const rectWidth = totalWidth - ri.node.BBox.x + 8;
335
+ rect.attr("width", rectWidth);
336
+ totalWidth = Math.max(totalWidth, ri.node.BBox.x + rectWidth + 2);
337
+ }
338
+ }
339
+ return {
340
+ totalHeight,
341
+ totalWidth
342
+ };
343
+ }, "drawTree");
344
+ var renderer_default = { draw: /* @__PURE__ */ __name(async (text, id, _ver, diagObj) => {
345
+ log.debug("Rendering treeView diagram\n" + text);
346
+ const db2 = diagObj.db;
347
+ const root = db2.getRoot();
348
+ const config = db2.getConfig();
349
+ const svg = selectSvgElement(id);
350
+ const treeElem = svg.append("g");
351
+ treeElem.attr("class", "tree-view");
352
+ const { totalHeight, totalWidth } = drawTree(treeElem, root, config, await resolveNodeIcons(root, config));
353
+ svg.attr("viewBox", `-${config.lineThickness / 2} 0 ${totalWidth} ${totalHeight}`);
354
+ configureSvgSize(svg, totalHeight, totalWidth, config.useMaxWidth);
355
+ }, "draw") };
356
+ var defaultTreeViewDiagramStyles = {
357
+ labelFontSize: "16px",
358
+ labelColor: "black",
359
+ lineColor: "black",
360
+ iconColor: "#546e7a",
361
+ descriptionColor: "#6a9955",
362
+ highlightBg: "rgba(255, 193, 7, 0.15)",
363
+ highlightStroke: "#ffc107"
364
+ };
365
+ var diagram = {
366
+ db: db_default,
367
+ renderer: renderer_default,
368
+ parser,
369
+ styles: /* @__PURE__ */ __name(({ treeView }) => {
370
+ const { labelFontSize, labelColor, lineColor, iconColor, descriptionColor, highlightBg, highlightStroke } = cleanAndMerge(defaultTreeViewDiagramStyles, treeView);
371
+ return `
372
+ .treeView-node-label {
373
+ font-size: ${labelFontSize};
374
+ fill: ${labelColor};
375
+ white-space: pre;
376
+ }
377
+ .treeView-node-dir {
378
+ font-weight: bold;
379
+ }
380
+ .treeView-node-line {
381
+ stroke: ${lineColor};
382
+ }
383
+ .treeView-node-icon {
384
+ color: ${iconColor};
385
+ }
386
+ .treeView-node-description {
387
+ font-size: ${labelFontSize};
388
+ fill: ${descriptionColor};
389
+ font-style: italic;
390
+ white-space: pre;
391
+ }
392
+ .treeView-highlight-bg {
393
+ fill: ${highlightBg};
394
+ stroke: ${highlightStroke};
395
+ stroke-width: 1;
396
+ }
397
+ `;
398
+ }, "styles")
399
+ };
400
+
401
+ //#endregion
402
+ export { diagram };
@@ -0,0 +1,186 @@
1
+ import { n as parse } from "./mermaid-parser.core-pYR5siSx.js";
2
+ import { n as __name } from "./chunk-Y2CYZVJY-U3QOMqrW.js";
3
+ import { m as log } from "./src-NkhI3UMl.js";
4
+ import { H as setAccDescription, U as setAccTitle, a as clear, b as getConfig, c as configureSvgSize, f as defaultConfig_default, q as setDiagramTitle, v as getAccDescription, w as getDiagramTitle, y as getAccTitle } from "./chunk-O7XYJQB3-B6K0KOSL.js";
5
+ import { i as cleanAndMerge } from "./chunk-ZIGJFQKS-DqEFBuHR.js";
6
+ import { t as selectSvgElement } from "./chunk-6AEJRKK7-JXK89I-O.js";
7
+ import { t as populateCommonDb } from "./chunk-JWPE2WC7-D1rC79GS.js";
8
+
9
+ //#region ../../node_modules/.pnpm/mermaid@12.0.0/node_modules/mermaid/dist/chunks/mermaid.core/diagram-MLGK6HIB.mjs
10
+ var DEFAULT_PACKET_CONFIG = defaultConfig_default.packet;
11
+ var PacketDB = class {
12
+ constructor() {
13
+ this.packet = [];
14
+ this.setAccTitle = setAccTitle;
15
+ this.getAccTitle = getAccTitle;
16
+ this.setDiagramTitle = setDiagramTitle;
17
+ this.getDiagramTitle = getDiagramTitle;
18
+ this.getAccDescription = getAccDescription;
19
+ this.setAccDescription = setAccDescription;
20
+ }
21
+ static {
22
+ __name(this, "PacketDB");
23
+ }
24
+ getConfig() {
25
+ const config = cleanAndMerge({
26
+ ...DEFAULT_PACKET_CONFIG,
27
+ ...getConfig().packet
28
+ });
29
+ if (config.showBits) config.paddingY += 10;
30
+ return config;
31
+ }
32
+ getPacket() {
33
+ return this.packet;
34
+ }
35
+ pushWord(word) {
36
+ if (word.length > 0) this.packet.push(word);
37
+ }
38
+ clear() {
39
+ clear();
40
+ this.packet = [];
41
+ }
42
+ };
43
+ var maxPacketSize = 1e4;
44
+ var populate = /* @__PURE__ */ __name((ast, db) => {
45
+ populateCommonDb(ast, db);
46
+ let lastBit = -1;
47
+ let word = [];
48
+ let row = 1;
49
+ const { bitsPerRow } = db.getConfig();
50
+ for (let { start, end, bits, label } of ast.blocks) {
51
+ if (start !== void 0 && end !== void 0 && end < start) throw new Error(`Packet block ${start} - ${end} is invalid. End must be greater than start.`);
52
+ start ??= lastBit + 1;
53
+ if (start !== lastBit + 1) throw new Error(`Packet block ${start} - ${end ?? start} is not contiguous. It should start from ${lastBit + 1}.`);
54
+ if (bits === 0) throw new Error(`Packet block ${start} is invalid. Cannot have a zero bit field.`);
55
+ end ??= start + (bits ?? 1) - 1;
56
+ bits ??= end - start + 1;
57
+ lastBit = end;
58
+ log.debug(`Packet block ${start} - ${lastBit} with label ${label}`);
59
+ while (word.length <= bitsPerRow + 1 && db.getPacket().length < maxPacketSize) {
60
+ const [block, nextBlock] = getNextFittingBlock({
61
+ start,
62
+ end,
63
+ bits,
64
+ label
65
+ }, row, bitsPerRow);
66
+ word.push(block);
67
+ if (block.end + 1 === row * bitsPerRow) {
68
+ db.pushWord(word);
69
+ word = [];
70
+ row++;
71
+ }
72
+ if (!nextBlock) break;
73
+ ({start, end, bits, label} = nextBlock);
74
+ }
75
+ }
76
+ db.pushWord(word);
77
+ }, "populate");
78
+ var getNextFittingBlock = /* @__PURE__ */ __name((block, row, bitsPerRow) => {
79
+ if (block.start === void 0) throw new Error("start should have been set during first phase");
80
+ if (block.end === void 0) throw new Error("end should have been set during first phase");
81
+ if (block.start > block.end) throw new Error(`Block start ${block.start} is greater than block end ${block.end}.`);
82
+ if (block.end + 1 <= row * bitsPerRow) return [block, void 0];
83
+ const rowEnd = row * bitsPerRow - 1;
84
+ const rowStart = row * bitsPerRow;
85
+ return [{
86
+ start: block.start,
87
+ end: rowEnd,
88
+ label: block.label,
89
+ bits: rowEnd - block.start
90
+ }, {
91
+ start: rowStart,
92
+ end: block.end,
93
+ label: block.label,
94
+ bits: block.end - rowStart
95
+ }];
96
+ }, "getNextFittingBlock");
97
+ var parser = {
98
+ parser: { yy: void 0 },
99
+ parse: /* @__PURE__ */ __name(async (input) => {
100
+ const ast = await parse("packet", input);
101
+ const db = parser.parser?.yy;
102
+ if (!(db instanceof PacketDB)) throw new Error("parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");
103
+ log.debug(ast);
104
+ populate(ast, db);
105
+ }, "parse")
106
+ };
107
+ var draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {
108
+ const db = diagram2.db;
109
+ const config = db.getConfig();
110
+ const { rowHeight, paddingY, bitWidth, bitsPerRow } = config;
111
+ const words = db.getPacket();
112
+ const title = db.getDiagramTitle();
113
+ const totalRowHeight = rowHeight + paddingY;
114
+ const svgHeight = totalRowHeight * (words.length + 1) - (title ? 0 : rowHeight);
115
+ const svgWidth = bitWidth * bitsPerRow + 2;
116
+ const svg = selectSvgElement(id);
117
+ svg.attr("viewBox", `0 0 ${svgWidth} ${svgHeight}`);
118
+ configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);
119
+ for (const [word, packet] of words.entries()) drawWord(svg, packet, word, config);
120
+ svg.append("text").text(title).attr("x", svgWidth / 2).attr("y", svgHeight - totalRowHeight / 2).attr("dominant-baseline", "middle").attr("text-anchor", "middle").attr("class", "packetTitle");
121
+ }, "draw");
122
+ var drawWord = /* @__PURE__ */ __name((svg, word, rowNumber, { rowHeight, paddingX, paddingY, bitWidth, bitsPerRow, showBits }) => {
123
+ const group = svg.append("g");
124
+ const wordY = rowNumber * (rowHeight + paddingY) + paddingY;
125
+ for (const block of word) {
126
+ const blockX = block.start % bitsPerRow * bitWidth + 1;
127
+ const width = (block.end - block.start + 1) * bitWidth - paddingX;
128
+ group.append("rect").attr("x", blockX).attr("y", wordY).attr("width", width).attr("height", rowHeight).attr("class", "packetBlock");
129
+ group.append("text").attr("x", blockX + width / 2).attr("y", wordY + rowHeight / 2).attr("class", "packetLabel").attr("dominant-baseline", "middle").attr("text-anchor", "middle").text(block.label);
130
+ if (!showBits) continue;
131
+ const isSingleBlock = block.end === block.start;
132
+ const bitNumberY = wordY - 2;
133
+ group.append("text").attr("x", blockX + (isSingleBlock ? width / 2 : 0)).attr("y", bitNumberY).attr("class", "packetByte start").attr("dominant-baseline", "auto").attr("text-anchor", isSingleBlock ? "middle" : "start").text(block.start);
134
+ if (!isSingleBlock) group.append("text").attr("x", blockX + width).attr("y", bitNumberY).attr("class", "packetByte end").attr("dominant-baseline", "auto").attr("text-anchor", "end").text(block.end);
135
+ }
136
+ }, "drawWord");
137
+ var renderer = { draw };
138
+ var defaultPacketStyleOptions = {
139
+ byteFontSize: "10px",
140
+ startByteColor: "black",
141
+ endByteColor: "black",
142
+ labelColor: "black",
143
+ labelFontSize: "12px",
144
+ titleColor: "black",
145
+ titleFontSize: "14px",
146
+ blockStrokeColor: "black",
147
+ blockStrokeWidth: "1",
148
+ blockFillColor: "#efefef"
149
+ };
150
+ var diagram = {
151
+ parser,
152
+ get db() {
153
+ return new PacketDB();
154
+ },
155
+ renderer,
156
+ styles: /* @__PURE__ */ __name(({ packet } = {}) => {
157
+ const options = cleanAndMerge(defaultPacketStyleOptions, packet);
158
+ return `
159
+ .packetByte {
160
+ font-size: ${options.byteFontSize};
161
+ }
162
+ .packetByte.start {
163
+ fill: ${options.startByteColor};
164
+ }
165
+ .packetByte.end {
166
+ fill: ${options.endByteColor};
167
+ }
168
+ .packetLabel {
169
+ fill: ${options.labelColor};
170
+ font-size: ${options.labelFontSize};
171
+ }
172
+ .packetTitle {
173
+ fill: ${options.titleColor};
174
+ font-size: ${options.titleFontSize};
175
+ }
176
+ .packetBlock {
177
+ stroke: ${options.blockStrokeColor};
178
+ stroke-width: ${options.blockStrokeWidth};
179
+ fill: ${options.blockFillColor};
180
+ }
181
+ `;
182
+ }, "styles")
183
+ };
184
+
185
+ //#endregion
186
+ export { diagram };