semajsx 0.6.1 → 0.8.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 (74) hide show
  1. package/dist/{client-CButR91p.mjs → client-BrupjhG0.mjs} +4 -4
  2. package/dist/{client-CButR91p.mjs.map → client-BrupjhG0.mjs.map} +1 -1
  3. package/dist/{computed-BidG06Lt.mjs → computed-BpjqvQu1.mjs} +2 -2
  4. package/dist/{computed-BidG06Lt.mjs.map → computed-BpjqvQu1.mjs.map} +1 -1
  5. package/dist/document-DsiJO2jG.mjs +5 -0
  6. package/dist/{document-BOJDaiBc.mjs → document-XKyAs62C.mjs} +2 -2
  7. package/dist/{document-BOJDaiBc.mjs.map → document-XKyAs62C.mjs.map} +1 -1
  8. package/dist/dom/index.mjs +3 -3
  9. package/dist/dom/jsx-dev-runtime.d.mts +1 -1
  10. package/dist/dom/jsx-dev-runtime.mjs +2 -2
  11. package/dist/dom/jsx-runtime.d.mts +1 -1
  12. package/dist/dom/jsx-runtime.mjs +2 -2
  13. package/dist/{index-D_FIlSk3.d.mts → index-CmxkYOtR.d.mts} +2 -2
  14. package/dist/{index-D_FIlSk3.d.mts.map → index-CmxkYOtR.d.mts.map} +1 -1
  15. package/dist/index.mjs +4 -4
  16. package/dist/{jsx-runtime-D9ZNjMJ2.mjs → jsx-runtime-BFs1c0xz.mjs} +1 -1
  17. package/dist/jsx-runtime-BFs1c0xz.mjs.map +1 -0
  18. package/dist/{jsx-runtime-tIuFmhTh.d.mts → jsx-runtime-C-TtSL51.d.mts} +9 -4
  19. package/dist/jsx-runtime-C-TtSL51.d.mts.map +1 -0
  20. package/dist/{jsx-runtime-BjCGsceN.mjs → jsx-runtime-kv_6vBiR.mjs} +1 -1
  21. package/dist/{jsx-runtime-BjCGsceN.mjs.map → jsx-runtime-kv_6vBiR.mjs.map} +1 -1
  22. package/dist/{lucide-C5BghhSl.mjs → lucide-Ddt_N9dJ.mjs} +3 -3
  23. package/dist/{lucide-C5BghhSl.mjs.map → lucide-Ddt_N9dJ.mjs.map} +1 -1
  24. package/dist/{resource-CNwiNxJX.d.mts → resource-CX-sVeS_.d.mts} +5 -2
  25. package/dist/resource-CX-sVeS_.d.mts.map +1 -0
  26. package/dist/{resource-DSlXDZZi.mjs → resource-pm7qP-jV.mjs} +2 -2
  27. package/dist/{resource-DSlXDZZi.mjs.map → resource-pm7qP-jV.mjs.map} +1 -1
  28. package/dist/signal/index.mjs +3 -3
  29. package/dist/{signal-BN8vHXDb.mjs → signal-4PgGfydw.mjs} +1 -1
  30. package/dist/{signal-BN8vHXDb.mjs.map → signal-4PgGfydw.mjs.map} +1 -1
  31. package/dist/{src-B4VBiHa8.mjs → src-CAyv9Uf9.mjs} +24 -17
  32. package/dist/src-CAyv9Uf9.mjs.map +1 -0
  33. package/dist/{src-DUpFNNM_.mjs → src-CXY-7FC3.mjs} +4 -4
  34. package/dist/{src-DUpFNNM_.mjs.map → src-CXY-7FC3.mjs.map} +1 -1
  35. package/dist/{src-BqX3sryB.mjs → src-C_aFsFJ3.mjs} +4 -4
  36. package/dist/{src-BqX3sryB.mjs.map → src-C_aFsFJ3.mjs.map} +1 -1
  37. package/dist/{src-DW3tIczg.mjs → src-Cv4rRVzv.mjs} +4 -4
  38. package/dist/{src-DW3tIczg.mjs.map → src-Cv4rRVzv.mjs.map} +1 -1
  39. package/dist/{src-Ds9vl42d.mjs → src-DV9uwtE5.mjs} +2 -2
  40. package/dist/{src-Ds9vl42d.mjs.map → src-DV9uwtE5.mjs.map} +1 -1
  41. package/dist/{src-75qcxwT_.mjs → src-SqJ6k7Xv.mjs} +13 -29
  42. package/dist/src-SqJ6k7Xv.mjs.map +1 -0
  43. package/dist/ssg/index.d.mts +1 -1
  44. package/dist/ssg/index.d.mts.map +1 -1
  45. package/dist/ssg/index.mjs +14 -9
  46. package/dist/ssg/index.mjs.map +1 -1
  47. package/dist/ssg/plugins/docs-theme.d.mts +76 -29
  48. package/dist/ssg/plugins/docs-theme.d.mts.map +1 -1
  49. package/dist/ssg/plugins/docs-theme.mjs +3564 -380
  50. package/dist/ssg/plugins/docs-theme.mjs.map +1 -1
  51. package/dist/ssg/plugins/lucide.d.mts +2 -2
  52. package/dist/ssg/plugins/lucide.mjs +5 -5
  53. package/dist/ssr/client.d.mts +1 -1
  54. package/dist/ssr/client.mjs +5 -5
  55. package/dist/ssr/index.d.mts +1 -1
  56. package/dist/ssr/index.d.mts.map +1 -1
  57. package/dist/ssr/index.mjs +8 -8
  58. package/dist/style/index.mjs +1 -1
  59. package/dist/style/react.mjs +2 -2
  60. package/dist/style/vue.mjs +2 -2
  61. package/dist/terminal/index.mjs +3 -3
  62. package/dist/terminal/jsx-dev-runtime.mjs +2 -2
  63. package/dist/terminal/jsx-runtime.mjs +2 -2
  64. package/dist/{types-BmDIxXiP.d.mts → types-BaS-zTDX.d.mts} +3 -1
  65. package/dist/{types-BmDIxXiP.d.mts.map → types-BaS-zTDX.d.mts.map} +1 -1
  66. package/dist/{utils-DbTAs943.mjs → utils-BrGmTgfG.mjs} +1 -1
  67. package/dist/{utils-DbTAs943.mjs.map → utils-BrGmTgfG.mjs.map} +1 -1
  68. package/package.json +1 -1
  69. package/dist/document-CwHVG_PJ.mjs +0 -5
  70. package/dist/jsx-runtime-D9ZNjMJ2.mjs.map +0 -1
  71. package/dist/jsx-runtime-tIuFmhTh.d.mts.map +0 -1
  72. package/dist/resource-CNwiNxJX.d.mts.map +0 -1
  73. package/dist/src-75qcxwT_.mjs.map +0 -1
  74. package/dist/src-B4VBiHa8.mjs.map +0 -1
@@ -1,16 +1,17 @@
1
- import { d as defineCollection, v as __exportAll } from "../../src-75qcxwT_.mjs";
2
- import { t as signal } from "../../signal-BN8vHXDb.mjs";
3
- import { a as jsxs, i as jsx, v as Fragment } from "../../src-DW3tIczg.mjs";
4
- import "../../src-BqX3sryB.mjs";
5
- import { G as rules, K as classes, M as createTheme, N as defineTokens, U as isStyleToken, W as rule } from "../../src-Ds9vl42d.mjs";
6
- import "../../jsx-runtime-D9ZNjMJ2.mjs";
7
- import "../../src-DUpFNNM_.mjs";
8
- import "../../jsx-runtime-BjCGsceN.mjs";
9
- import { d as island } from "../../resource-DSlXDZZi.mjs";
10
- import "../../src-B4VBiHa8.mjs";
11
- import "../../document-BOJDaiBc.mjs";
12
- import "../../client-CButR91p.mjs";
13
- import { n as Icon, t as lucide } from "../../lucide-C5BghhSl.mjs";
1
+ import { t as signal } from "../../signal-4PgGfydw.mjs";
2
+ import { n as unwrap } from "../../utils-BrGmTgfG.mjs";
3
+ import { a as jsxs, i as jsx, u as context, v as Fragment } from "../../src-Cv4rRVzv.mjs";
4
+ import "../../src-C_aFsFJ3.mjs";
5
+ import { G as rules, K as classes, M as createTheme, N as defineTokens, W as rule } from "../../src-DV9uwtE5.mjs";
6
+ import "../../jsx-runtime-BFs1c0xz.mjs";
7
+ import "../../src-CXY-7FC3.mjs";
8
+ import "../../jsx-runtime-kv_6vBiR.mjs";
9
+ import { d as island } from "../../resource-pm7qP-jV.mjs";
10
+ import "../../src-CAyv9Uf9.mjs";
11
+ import "../../document-XKyAs62C.mjs";
12
+ import "../../client-BrupjhG0.mjs";
13
+ import { d as defineCollection } from "../../src-SqJ6k7Xv.mjs";
14
+ import { n as Icon, t as lucide } from "../../lucide-Ddt_N9dJ.mjs";
14
15
  import { dirname, join } from "path";
15
16
  import { mkdir, writeFile } from "fs/promises";
16
17
  import { z } from "zod";
@@ -19,12 +20,3338 @@ import { dirname as dirname$1, join as join$1 } from "node:path";
19
20
  import { fileURLToPath } from "node:url";
20
21
  import remarkGfm from "remark-gfm";
21
22
 
23
+ //#region ../mermaid/src/parser/tokenizer.ts
24
+ const KEYWORDS = new Set([
25
+ "graph",
26
+ "flowchart",
27
+ "sequenceDiagram",
28
+ "subgraph",
29
+ "end",
30
+ "direction",
31
+ "participant",
32
+ "actor",
33
+ "as",
34
+ "activate",
35
+ "deactivate",
36
+ "loop",
37
+ "alt",
38
+ "else",
39
+ "opt",
40
+ "par",
41
+ "and",
42
+ "critical",
43
+ "break",
44
+ "Note",
45
+ "over",
46
+ "left",
47
+ "right",
48
+ "of"
49
+ ]);
50
+ const ARROW_PATTERNS = [
51
+ "-->>",
52
+ "--))",
53
+ "->>",
54
+ "-))",
55
+ "x-.-x",
56
+ "o-.-o",
57
+ "<-.->",
58
+ "x==x",
59
+ "o==o",
60
+ "<==>",
61
+ "x--x",
62
+ "o--o",
63
+ "<-->",
64
+ "o-.->",
65
+ "o==>",
66
+ "o-->",
67
+ "-.-o",
68
+ "-.-x",
69
+ "-.->|",
70
+ "-.->",
71
+ "-.-",
72
+ "==o",
73
+ "==x",
74
+ "==>|",
75
+ "==>",
76
+ "===",
77
+ "--o",
78
+ "--x",
79
+ "-->|",
80
+ "-->",
81
+ "---",
82
+ "-x",
83
+ "->",
84
+ "--"
85
+ ];
86
+ function tokenize(input) {
87
+ const tokens = [];
88
+ let pos = 0;
89
+ let line = 1;
90
+ let col = 1;
91
+ while (pos < input.length) {
92
+ const ch = input[pos];
93
+ if (ch === " " || ch === " ") {
94
+ pos++;
95
+ col++;
96
+ continue;
97
+ }
98
+ if (ch === "\n") {
99
+ tokens.push({
100
+ type: "newline",
101
+ value: "\n",
102
+ line,
103
+ column: col
104
+ });
105
+ pos++;
106
+ line++;
107
+ col = 1;
108
+ continue;
109
+ }
110
+ if (ch === "\r") {
111
+ pos++;
112
+ if (pos < input.length && input[pos] === "\n") pos++;
113
+ tokens.push({
114
+ type: "newline",
115
+ value: "\n",
116
+ line,
117
+ column: col
118
+ });
119
+ line++;
120
+ col = 1;
121
+ continue;
122
+ }
123
+ if (ch === "%" && pos + 1 < input.length && input[pos + 1] === "%") {
124
+ const start = pos;
125
+ pos += 2;
126
+ while (pos < input.length && input[pos] !== "\n") pos++;
127
+ tokens.push({
128
+ type: "comment",
129
+ value: input.slice(start, pos),
130
+ line,
131
+ column: col
132
+ });
133
+ col += pos - start;
134
+ continue;
135
+ }
136
+ if (ch === ";") {
137
+ tokens.push({
138
+ type: "semicolon",
139
+ value: ";",
140
+ line,
141
+ column: col
142
+ });
143
+ pos++;
144
+ col++;
145
+ continue;
146
+ }
147
+ if (ch === ":") {
148
+ tokens.push({
149
+ type: "colon",
150
+ value: ":",
151
+ line,
152
+ column: col
153
+ });
154
+ pos++;
155
+ col++;
156
+ continue;
157
+ }
158
+ if (ch === "|") {
159
+ tokens.push({
160
+ type: "pipe",
161
+ value: "|",
162
+ line,
163
+ column: col
164
+ });
165
+ pos++;
166
+ col++;
167
+ continue;
168
+ }
169
+ if (ch === "[") {
170
+ tokens.push({
171
+ type: "openBracket",
172
+ value: "[",
173
+ line,
174
+ column: col
175
+ });
176
+ pos++;
177
+ col++;
178
+ continue;
179
+ }
180
+ if (ch === "]") {
181
+ tokens.push({
182
+ type: "closeBracket",
183
+ value: "]",
184
+ line,
185
+ column: col
186
+ });
187
+ pos++;
188
+ col++;
189
+ continue;
190
+ }
191
+ if (ch === "(") {
192
+ if (pos + 1 < input.length && input[pos + 1] === "(") {
193
+ tokens.push({
194
+ type: "openParen",
195
+ value: "((",
196
+ line,
197
+ column: col
198
+ });
199
+ pos += 2;
200
+ col += 2;
201
+ } else {
202
+ tokens.push({
203
+ type: "openParen",
204
+ value: "(",
205
+ line,
206
+ column: col
207
+ });
208
+ pos++;
209
+ col++;
210
+ }
211
+ continue;
212
+ }
213
+ if (ch === ")") {
214
+ if (pos + 1 < input.length && input[pos + 1] === ")") {
215
+ tokens.push({
216
+ type: "closeParen",
217
+ value: "))",
218
+ line,
219
+ column: col
220
+ });
221
+ pos += 2;
222
+ col += 2;
223
+ } else {
224
+ tokens.push({
225
+ type: "closeParen",
226
+ value: ")",
227
+ line,
228
+ column: col
229
+ });
230
+ pos++;
231
+ col++;
232
+ }
233
+ continue;
234
+ }
235
+ if (ch === "{") {
236
+ tokens.push({
237
+ type: "openBrace",
238
+ value: "{",
239
+ line,
240
+ column: col
241
+ });
242
+ pos++;
243
+ col++;
244
+ continue;
245
+ }
246
+ if (ch === "}") {
247
+ tokens.push({
248
+ type: "closeBrace",
249
+ value: "}",
250
+ line,
251
+ column: col
252
+ });
253
+ pos++;
254
+ col++;
255
+ continue;
256
+ }
257
+ if (ch === "\"" || ch === "'") {
258
+ const quote = ch;
259
+ const startCol = col;
260
+ pos++;
261
+ col++;
262
+ let value = "";
263
+ while (pos < input.length && input[pos] !== quote) {
264
+ if (input[pos] === "\\") {
265
+ pos++;
266
+ col++;
267
+ }
268
+ value += input[pos];
269
+ pos++;
270
+ col++;
271
+ }
272
+ if (pos < input.length) {
273
+ pos++;
274
+ col++;
275
+ }
276
+ tokens.push({
277
+ type: "string",
278
+ value,
279
+ line,
280
+ column: startCol
281
+ });
282
+ continue;
283
+ }
284
+ let matchedArrow = false;
285
+ for (const arrow of ARROW_PATTERNS) if (input.startsWith(arrow, pos)) {
286
+ tokens.push({
287
+ type: "arrow",
288
+ value: arrow,
289
+ line,
290
+ column: col
291
+ });
292
+ pos += arrow.length;
293
+ col += arrow.length;
294
+ matchedArrow = true;
295
+ break;
296
+ }
297
+ if (matchedArrow) continue;
298
+ if (isIdStart(ch)) {
299
+ const startCol = col;
300
+ let value = "";
301
+ while (pos < input.length && isIdPart(input[pos])) {
302
+ value += input[pos];
303
+ pos++;
304
+ col++;
305
+ }
306
+ const type = KEYWORDS.has(value) ? "keyword" : "identifier";
307
+ tokens.push({
308
+ type,
309
+ value,
310
+ line,
311
+ column: startCol
312
+ });
313
+ continue;
314
+ }
315
+ if (ch === ">") {
316
+ tokens.push({
317
+ type: "openBracket",
318
+ value: ">",
319
+ line,
320
+ column: col
321
+ });
322
+ pos++;
323
+ col++;
324
+ continue;
325
+ }
326
+ pos++;
327
+ col++;
328
+ }
329
+ tokens.push({
330
+ type: "eof",
331
+ value: "",
332
+ line,
333
+ column: col
334
+ });
335
+ return tokens;
336
+ }
337
+ function isIdStart(ch) {
338
+ return ch != null && /[a-zA-Z_$0-9]/.test(ch);
339
+ }
340
+ function isIdPart(ch) {
341
+ return ch != null && /[a-zA-Z0-9_$]/.test(ch);
342
+ }
343
+ /** Filter out comments and newlines for easier parsing */
344
+ function filterTokens(tokens) {
345
+ return tokens.filter((t) => t.type !== "comment");
346
+ }
347
+
348
+ //#endregion
349
+ //#region ../mermaid/src/parser/flowchart.ts
350
+ function parseFlowchart(input) {
351
+ const state = {
352
+ tokens: filterTokens(tokenize(input)),
353
+ pos: 0,
354
+ nodes: /* @__PURE__ */ new Map(),
355
+ edges: [],
356
+ subgraphs: [],
357
+ direction: "TD"
358
+ };
359
+ if (!parseHeader(state)) return {
360
+ message: "Expected 'graph' or 'flowchart' keyword",
361
+ line: 1,
362
+ column: 1
363
+ };
364
+ while (!isEof$1(state)) {
365
+ skipNewlines$1(state);
366
+ if (isEof$1(state)) break;
367
+ const token = peek$1(state);
368
+ if (token.type === "keyword" && token.value === "subgraph") {
369
+ const result = parseSubgraph(state);
370
+ if ("message" in result) return result;
371
+ continue;
372
+ }
373
+ if (token.type === "keyword" && token.value === "direction") {
374
+ advance$1(state);
375
+ const dir = peek$1(state);
376
+ if (dir.type === "identifier" || dir.type === "keyword") {
377
+ state.direction = dir.value;
378
+ advance$1(state);
379
+ }
380
+ skipSemicolon(state);
381
+ continue;
382
+ }
383
+ if (token.type === "keyword" && token.value === "end") break;
384
+ const result = parseStatement(state);
385
+ if (result && "message" in result) return result;
386
+ }
387
+ return {
388
+ type: "flowchart",
389
+ direction: state.direction,
390
+ nodes: Array.from(state.nodes.values()),
391
+ edges: state.edges,
392
+ subgraphs: state.subgraphs
393
+ };
394
+ }
395
+ function parseHeader(state) {
396
+ skipNewlines$1(state);
397
+ const token = peek$1(state);
398
+ if (token.type !== "keyword" || token.value !== "graph" && token.value !== "flowchart") return false;
399
+ advance$1(state);
400
+ skipNewlines$1(state);
401
+ const dir = peek$1(state);
402
+ if (dir.type === "identifier" || dir.type === "keyword") {
403
+ const dirVal = dir.value.toUpperCase();
404
+ if ([
405
+ "TB",
406
+ "TD",
407
+ "BT",
408
+ "LR",
409
+ "RL"
410
+ ].includes(dirVal)) {
411
+ state.direction = dirVal;
412
+ advance$1(state);
413
+ }
414
+ }
415
+ skipSemicolon(state);
416
+ return true;
417
+ }
418
+ function parseStatement(state) {
419
+ let currentNode = parseNodeRef(state);
420
+ if (!currentNode) {
421
+ advance$1(state);
422
+ return;
423
+ }
424
+ while (!isEof$1(state) && peek$1(state).type === "arrow") {
425
+ const arrowToken = advance$1(state);
426
+ const { lineStyle, sourceMarker, targetMarker } = parseArrow(arrowToken.value);
427
+ let edgeLabel;
428
+ if (arrowToken.value.endsWith("|")) edgeLabel = parseEdgeLabel(state);
429
+ else if (peek$1(state).type === "pipe") {
430
+ advance$1(state);
431
+ edgeLabel = parseEdgeLabel(state);
432
+ }
433
+ const targetNode = parseNodeRef(state);
434
+ if (!targetNode) return {
435
+ message: "Expected target node after arrow",
436
+ line: arrowToken.line,
437
+ column: arrowToken.column
438
+ };
439
+ state.edges.push({
440
+ source: currentNode,
441
+ target: targetNode,
442
+ lineStyle,
443
+ sourceMarker,
444
+ targetMarker,
445
+ label: edgeLabel
446
+ });
447
+ currentNode = targetNode;
448
+ }
449
+ skipSemicolon(state);
450
+ }
451
+ function parseNodeRef(state) {
452
+ skipNewlines$1(state);
453
+ const token = peek$1(state);
454
+ if (token.type !== "identifier" && token.type !== "keyword") return;
455
+ if (token.type === "keyword" && [
456
+ "subgraph",
457
+ "end",
458
+ "direction"
459
+ ].includes(token.value)) return;
460
+ const id = token.value;
461
+ advance$1(state);
462
+ const next = peek$1(state);
463
+ if (next.type === "openBracket" || next.type === "openParen" || next.type === "openBrace") {
464
+ const shape = parseNodeShape(state, id);
465
+ if (shape) {
466
+ if (!state.nodes.has(id)) state.nodes.set(id, shape);
467
+ state.nodeRefCollector?.push(id);
468
+ return id;
469
+ }
470
+ }
471
+ if (!state.nodes.has(id)) state.nodes.set(id, {
472
+ id,
473
+ label: id,
474
+ shape: "rect"
475
+ });
476
+ state.nodeRefCollector?.push(id);
477
+ return id;
478
+ }
479
+ function parseNodeShape(state, id) {
480
+ const open = peek$1(state);
481
+ if (open.value === "[") {
482
+ advance$1(state);
483
+ const next = peek$1(state);
484
+ if (next.type === "openParen") {
485
+ advance$1(state);
486
+ const label = readUntil(state, "closeParen");
487
+ expect(state, "closeBracket");
488
+ return {
489
+ id,
490
+ label,
491
+ shape: "cylinder"
492
+ };
493
+ }
494
+ if (next.type === "openBracket") {
495
+ advance$1(state);
496
+ const label = readUntil(state, "closeBracket");
497
+ expect(state, "closeBracket");
498
+ return {
499
+ id,
500
+ label,
501
+ shape: "subroutine"
502
+ };
503
+ }
504
+ return {
505
+ id,
506
+ label: readUntil(state, "closeBracket"),
507
+ shape: "rect"
508
+ };
509
+ }
510
+ if (open.value === "(") {
511
+ advance$1(state);
512
+ const next = peek$1(state);
513
+ if (next.type === "openParen" || next.value === "(") {
514
+ advance$1(state);
515
+ const label = readUntil(state, "closeParen");
516
+ if (peek$1(state).type === "closeParen") advance$1(state);
517
+ return {
518
+ id,
519
+ label,
520
+ shape: "double-circle"
521
+ };
522
+ }
523
+ if (next.type === "openBracket") {
524
+ advance$1(state);
525
+ const label = readUntil(state, "closeBracket");
526
+ expect(state, "closeParen");
527
+ return {
528
+ id,
529
+ label,
530
+ shape: "stadium"
531
+ };
532
+ }
533
+ return {
534
+ id,
535
+ label: readUntil(state, "closeParen"),
536
+ shape: "round"
537
+ };
538
+ }
539
+ if (open.value === "((") {
540
+ advance$1(state);
541
+ const label = readUntil(state, "closeParen");
542
+ if (peek$1(state).type === "closeParen") advance$1(state);
543
+ return {
544
+ id,
545
+ label,
546
+ shape: "double-circle"
547
+ };
548
+ }
549
+ if (open.value === "{") {
550
+ advance$1(state);
551
+ if (peek$1(state).type === "openBrace") {
552
+ advance$1(state);
553
+ const label = readUntil(state, "closeBrace");
554
+ expect(state, "closeBrace");
555
+ return {
556
+ id,
557
+ label,
558
+ shape: "hexagon"
559
+ };
560
+ }
561
+ return {
562
+ id,
563
+ label: readUntil(state, "closeBrace"),
564
+ shape: "rhombus"
565
+ };
566
+ }
567
+ if (open.value === ">") {
568
+ advance$1(state);
569
+ return {
570
+ id,
571
+ label: readUntil(state, "closeBracket"),
572
+ shape: "asymmetric"
573
+ };
574
+ }
575
+ }
576
+ function parseEdgeLabel(state) {
577
+ let label = "";
578
+ while (!isEof$1(state) && peek$1(state).type !== "pipe") {
579
+ label += peek$1(state).value;
580
+ advance$1(state);
581
+ }
582
+ if (peek$1(state).type === "pipe") advance$1(state);
583
+ return label.trim();
584
+ }
585
+ function parseSubgraph(state) {
586
+ advance$1(state);
587
+ skipNewlines$1(state);
588
+ let id = "";
589
+ let label = "";
590
+ const next = peek$1(state);
591
+ if (next.type === "identifier" || next.type === "keyword") {
592
+ id = next.value;
593
+ label = id;
594
+ advance$1(state);
595
+ }
596
+ if (peek$1(state).type === "openBracket") {
597
+ advance$1(state);
598
+ label = readUntil(state, "closeBracket");
599
+ }
600
+ skipSemicolon(state);
601
+ skipNewlines$1(state);
602
+ let direction;
603
+ if (peek$1(state).type === "keyword" && peek$1(state).value === "direction") {
604
+ advance$1(state);
605
+ const dir = peek$1(state);
606
+ if (dir.type === "identifier" || dir.type === "keyword") {
607
+ direction = dir.value;
608
+ advance$1(state);
609
+ }
610
+ skipSemicolon(state);
611
+ }
612
+ const childSubgraphs = [];
613
+ const childNodeIds = /* @__PURE__ */ new Set();
614
+ const nodeIds = [];
615
+ while (!isEof$1(state)) {
616
+ skipNewlines$1(state);
617
+ if (isEof$1(state)) break;
618
+ const token = peek$1(state);
619
+ if (token.type === "keyword" && token.value === "end") {
620
+ advance$1(state);
621
+ break;
622
+ }
623
+ if (token.type === "keyword" && token.value === "subgraph") {
624
+ const sgCountBefore = state.subgraphs.length;
625
+ const result = parseSubgraph(state);
626
+ if ("message" in result) return result;
627
+ if (state.subgraphs.length > sgCountBefore) {
628
+ const child = state.subgraphs.pop();
629
+ childSubgraphs.push(child);
630
+ collectAllNodes(child, childNodeIds);
631
+ }
632
+ continue;
633
+ }
634
+ state.nodeRefCollector = [];
635
+ const result = parseStatement(state);
636
+ const refs = state.nodeRefCollector;
637
+ state.nodeRefCollector = void 0;
638
+ if (result && "message" in result) return result;
639
+ for (const nodeId of refs) if (!childNodeIds.has(nodeId) && !nodeIds.includes(nodeId)) nodeIds.push(nodeId);
640
+ }
641
+ const sg = {
642
+ id: id || `subgraph_${state.subgraphs.length}`,
643
+ label,
644
+ nodes: nodeIds,
645
+ direction
646
+ };
647
+ if (childSubgraphs.length > 0) sg.subgraphs = childSubgraphs;
648
+ state.subgraphs.push(sg);
649
+ return { ok: true };
650
+ }
651
+ /** Recursively collect all node IDs owned by a subgraph and its children. */
652
+ function collectAllNodes(sg, out) {
653
+ for (const id of sg.nodes) out.add(id);
654
+ for (const child of sg.subgraphs ?? []) collectAllNodes(child, out);
655
+ }
656
+ function parseArrow(arrow) {
657
+ const raw = arrow.endsWith("|") ? arrow.slice(0, -1) : arrow;
658
+ let sourceMarker = "none";
659
+ let rest = raw;
660
+ if (rest.startsWith("o")) {
661
+ sourceMarker = "dot";
662
+ rest = rest.slice(1);
663
+ } else if (rest.startsWith("x")) {
664
+ sourceMarker = "cross";
665
+ rest = rest.slice(1);
666
+ } else if (rest.startsWith("<")) {
667
+ sourceMarker = "arrow";
668
+ rest = rest.slice(1);
669
+ }
670
+ let targetMarker = "none";
671
+ if (rest.endsWith(">")) {
672
+ targetMarker = "arrow";
673
+ rest = rest.slice(0, -1);
674
+ } else if (rest.endsWith("o")) {
675
+ targetMarker = "dot";
676
+ rest = rest.slice(0, -1);
677
+ } else if (rest.endsWith("x")) {
678
+ targetMarker = "cross";
679
+ rest = rest.slice(0, -1);
680
+ }
681
+ let lineStyle = "solid";
682
+ if (rest.includes("-.") || rest.includes(".-")) lineStyle = "dotted";
683
+ else if (rest.startsWith("==") || rest.startsWith("=")) lineStyle = "thick";
684
+ return {
685
+ lineStyle,
686
+ sourceMarker,
687
+ targetMarker
688
+ };
689
+ }
690
+ function peek$1(state) {
691
+ return state.tokens[state.pos] ?? {
692
+ type: "eof",
693
+ value: "",
694
+ line: 0,
695
+ column: 0
696
+ };
697
+ }
698
+ function advance$1(state) {
699
+ const token = state.tokens[state.pos] ?? {
700
+ type: "eof",
701
+ value: "",
702
+ line: 0,
703
+ column: 0
704
+ };
705
+ if (state.pos < state.tokens.length) state.pos++;
706
+ return token;
707
+ }
708
+ function isEof$1(state) {
709
+ return state.pos >= state.tokens.length || state.tokens[state.pos]?.type === "eof";
710
+ }
711
+ function skipNewlines$1(state) {
712
+ while (!isEof$1(state) && peek$1(state).type === "newline") advance$1(state);
713
+ }
714
+ function skipSemicolon(state) {
715
+ if (!isEof$1(state) && peek$1(state).type === "semicolon") advance$1(state);
716
+ }
717
+ function expect(state, type) {
718
+ if (peek$1(state).type === type) return advance$1(state);
719
+ }
720
+ function readUntil(state, closeType) {
721
+ let value = "";
722
+ while (!isEof$1(state) && peek$1(state).type !== closeType) {
723
+ if (value) value += " ";
724
+ value += peek$1(state).value;
725
+ advance$1(state);
726
+ }
727
+ if (peek$1(state).type === closeType) advance$1(state);
728
+ return value.trim();
729
+ }
730
+
731
+ //#endregion
732
+ //#region ../mermaid/src/parser/sequence.ts
733
+ function parseSequence(input) {
734
+ const state = {
735
+ tokens: filterTokens(tokenize(input)),
736
+ pos: 0,
737
+ participants: /* @__PURE__ */ new Map(),
738
+ messages: [],
739
+ blocks: [],
740
+ notes: [],
741
+ noteMessageCounts: []
742
+ };
743
+ skipNewlines(state);
744
+ const header = peek(state);
745
+ if (header.type !== "keyword" || header.value !== "sequenceDiagram") return {
746
+ message: "Expected 'sequenceDiagram' keyword",
747
+ line: header.line,
748
+ column: header.column
749
+ };
750
+ advance(state);
751
+ skipNewlines(state);
752
+ while (!isEof(state)) {
753
+ skipNewlines(state);
754
+ if (isEof(state)) break;
755
+ const token = peek(state);
756
+ if (token.type === "keyword" && (token.value === "participant" || token.value === "actor")) {
757
+ parseParticipant(state, token.value);
758
+ continue;
759
+ }
760
+ if (token.type === "keyword" && (token.value === "activate" || token.value === "deactivate")) {
761
+ advance(state);
762
+ skipNewlines(state);
763
+ if (!isEof(state) && peek(state).type === "identifier") advance(state);
764
+ skipNewlines(state);
765
+ continue;
766
+ }
767
+ if (token.type === "keyword" && token.value === "Note") {
768
+ const result = parseNote(state);
769
+ if (result && "message" in result) return result;
770
+ continue;
771
+ }
772
+ if (token.type === "keyword" && isBlockKeyword(token.value)) {
773
+ const result = parseBlock(state);
774
+ if ("message" in result) return result;
775
+ continue;
776
+ }
777
+ if (token.type === "keyword" && token.value === "end") break;
778
+ if (token.type === "identifier" || token.type === "keyword") {
779
+ const result = parseMessage(state);
780
+ if (result && "message" in result && "line" in result) return result;
781
+ continue;
782
+ }
783
+ advance(state);
784
+ }
785
+ return {
786
+ type: "sequence",
787
+ participants: Array.from(state.participants.values()),
788
+ messages: state.messages,
789
+ blocks: state.blocks,
790
+ notes: state.notes,
791
+ _noteMessageCounts: state.noteMessageCounts
792
+ };
793
+ }
794
+ function parseParticipant(state, type) {
795
+ advance(state);
796
+ skipNewlines(state);
797
+ const idToken = peek(state);
798
+ if (idToken.type !== "identifier" && idToken.type !== "keyword") return;
799
+ const id = idToken.value;
800
+ advance(state);
801
+ let label = id;
802
+ if (peek(state).type === "keyword" && peek(state).value === "as") {
803
+ advance(state);
804
+ label = readRestOfLine(state);
805
+ }
806
+ state.participants.set(id, {
807
+ id,
808
+ label,
809
+ type
810
+ });
811
+ skipNewlines(state);
812
+ }
813
+ function parseMessage(state) {
814
+ const from = peek(state).value;
815
+ advance(state);
816
+ ensureParticipant(state, from);
817
+ if (peek(state).type !== "arrow") {
818
+ skipToEndOfLine(state);
819
+ return;
820
+ }
821
+ const arrowToken = advance(state);
822
+ const arrow = arrowToType(arrowToken.value);
823
+ const toToken = peek(state);
824
+ if (toToken.type !== "identifier" && toToken.type !== "keyword") return {
825
+ message: `Expected target after arrow at line ${arrowToken.line}`,
826
+ line: arrowToken.line,
827
+ column: arrowToken.column
828
+ };
829
+ const to = toToken.value;
830
+ advance(state);
831
+ ensureParticipant(state, to);
832
+ let text = "";
833
+ if (peek(state).type === "colon") {
834
+ advance(state);
835
+ text = readRestOfLine(state);
836
+ }
837
+ const activate = arrowToken.value.includes("+") || void 0;
838
+ const deactivate = arrowToken.value.includes("-") || void 0;
839
+ state.messages.push({
840
+ from,
841
+ to,
842
+ text,
843
+ arrow,
844
+ activate,
845
+ deactivate
846
+ });
847
+ skipNewlines(state);
848
+ }
849
+ function parseNote(state) {
850
+ advance(state);
851
+ let position;
852
+ const posToken = peek(state);
853
+ if (posToken.value === "left" || posToken.value === "right") {
854
+ const side = posToken.value;
855
+ advance(state);
856
+ if (peek(state).value === "of") advance(state);
857
+ position = `${side} of`;
858
+ } else if (posToken.value === "over") {
859
+ advance(state);
860
+ position = "over";
861
+ } else return {
862
+ message: `Expected note position (left of, right of, over) at line ${posToken.line}`,
863
+ line: posToken.line,
864
+ column: posToken.column
865
+ };
866
+ const participants = [];
867
+ while (!isEof(state) && peek(state).type !== "colon" && peek(state).type !== "newline") {
868
+ const p = peek(state);
869
+ if (p.type === "identifier" || p.type === "keyword") {
870
+ participants.push(p.value);
871
+ ensureParticipant(state, p.value);
872
+ }
873
+ advance(state);
874
+ }
875
+ let text = "";
876
+ if (peek(state).type === "colon") {
877
+ advance(state);
878
+ text = readRestOfLine(state);
879
+ }
880
+ state.noteMessageCounts.push(state.messages.length);
881
+ state.notes.push({
882
+ position,
883
+ participants,
884
+ text
885
+ });
886
+ skipNewlines(state);
887
+ }
888
+ function parseBlock(state) {
889
+ const blockType = advance(state).value;
890
+ let label = "";
891
+ if (peek(state).type !== "newline" && !isEof(state)) label = readRestOfLine(state);
892
+ skipNewlines(state);
893
+ const messages = [];
894
+ const sections = [];
895
+ let currentSection;
896
+ while (!isEof(state)) {
897
+ skipNewlines(state);
898
+ if (isEof(state)) break;
899
+ const token = peek(state);
900
+ if (token.type === "keyword" && token.value === "end") {
901
+ advance(state);
902
+ break;
903
+ }
904
+ if (token.type === "keyword" && token.value === "else") {
905
+ advance(state);
906
+ const sectionLabel = readRestOfLine(state);
907
+ if (currentSection) sections.push(currentSection);
908
+ currentSection = {
909
+ label: sectionLabel,
910
+ messages: []
911
+ };
912
+ skipNewlines(state);
913
+ continue;
914
+ }
915
+ if (token.type === "keyword" && token.value === "and") {
916
+ advance(state);
917
+ const sectionLabel = readRestOfLine(state);
918
+ if (currentSection) sections.push(currentSection);
919
+ currentSection = {
920
+ label: sectionLabel,
921
+ messages: []
922
+ };
923
+ skipNewlines(state);
924
+ continue;
925
+ }
926
+ if (token.type === "keyword" && token.value === "Note") {
927
+ parseNote(state);
928
+ continue;
929
+ }
930
+ if (token.type === "keyword" && isBlockKeyword(token.value)) {
931
+ const result = parseBlock(state);
932
+ if ("message" in result) return result;
933
+ continue;
934
+ }
935
+ if (token.type === "identifier" || token.type === "keyword") {
936
+ const beforeLen = state.messages.length;
937
+ parseMessage(state);
938
+ if (state.messages.length > beforeLen) {
939
+ const msg = state.messages[state.messages.length - 1];
940
+ if (currentSection) currentSection.messages.push(msg);
941
+ else messages.push(msg);
942
+ }
943
+ continue;
944
+ }
945
+ advance(state);
946
+ }
947
+ if (currentSection) sections.push(currentSection);
948
+ state.blocks.push({
949
+ type: blockType,
950
+ label,
951
+ messages,
952
+ sections: sections.length > 0 ? sections : void 0
953
+ });
954
+ skipNewlines(state);
955
+ return { ok: true };
956
+ }
957
+ function arrowToType(arrow) {
958
+ if (arrow === "->>") return "solid";
959
+ if (arrow === "-->>") return "dotted";
960
+ if (arrow === "-x" || arrow === "-X") return "solidCross";
961
+ if (arrow === "--x" || arrow === "--X") return "dottedCross";
962
+ if (arrow === "-))") return "solidOpen";
963
+ if (arrow === "--))") return "dottedOpen";
964
+ if (arrow === "->") return "solid";
965
+ return "solid";
966
+ }
967
+ function isBlockKeyword(value) {
968
+ return [
969
+ "loop",
970
+ "alt",
971
+ "opt",
972
+ "par",
973
+ "critical",
974
+ "break"
975
+ ].includes(value);
976
+ }
977
+ function ensureParticipant(state, id) {
978
+ if (!state.participants.has(id)) state.participants.set(id, {
979
+ id,
980
+ label: id,
981
+ type: "participant"
982
+ });
983
+ }
984
+ function peek(state) {
985
+ return state.tokens[state.pos] ?? {
986
+ type: "eof",
987
+ value: "",
988
+ line: 0,
989
+ column: 0
990
+ };
991
+ }
992
+ function advance(state) {
993
+ const token = state.tokens[state.pos] ?? {
994
+ type: "eof",
995
+ value: "",
996
+ line: 0,
997
+ column: 0
998
+ };
999
+ if (state.pos < state.tokens.length) state.pos++;
1000
+ return token;
1001
+ }
1002
+ function isEof(state) {
1003
+ return state.pos >= state.tokens.length || state.tokens[state.pos]?.type === "eof";
1004
+ }
1005
+ function skipNewlines(state) {
1006
+ while (!isEof(state) && peek(state).type === "newline") advance(state);
1007
+ }
1008
+ function skipToEndOfLine(state) {
1009
+ while (!isEof(state) && peek(state).type !== "newline") advance(state);
1010
+ }
1011
+ function readRestOfLine(state) {
1012
+ let text = "";
1013
+ while (!isEof(state) && peek(state).type !== "newline" && peek(state).type !== "semicolon") {
1014
+ if (text) text += " ";
1015
+ text += peek(state).value;
1016
+ advance(state);
1017
+ }
1018
+ return text.trim();
1019
+ }
1020
+
1021
+ //#endregion
1022
+ //#region ../mermaid/src/parser/index.ts
1023
+ /**
1024
+ * Parse a Mermaid DSL string into a structured diagram IR.
1025
+ *
1026
+ * Returns a FlowchartDiagram, SequenceDiagram, or ParseError.
1027
+ * Check for errors with: `if ("message" in result)`
1028
+ */
1029
+ function parse(input) {
1030
+ const trimmed = input.trim();
1031
+ if (trimmed.startsWith("sequenceDiagram")) return parseSequence(trimmed);
1032
+ if (trimmed.startsWith("graph") || trimmed.startsWith("flowchart")) return parseFlowchart(trimmed);
1033
+ return {
1034
+ message: `Unknown diagram type. Expected 'graph', 'flowchart', or 'sequenceDiagram'.`,
1035
+ line: 1,
1036
+ column: 1
1037
+ };
1038
+ }
1039
+
1040
+ //#endregion
1041
+ //#region ../mermaid/src/root.style.ts
1042
+ const c$15 = classes(["svgRoot"]);
1043
+ const svgRoot = rule`${c$15.svgRoot} {
1044
+ width: 100%;
1045
+ height: auto;
1046
+ font-family: inherit;
1047
+ }`;
1048
+
1049
+ //#endregion
1050
+ //#region ../mermaid/src/tokens.ts
1051
+ const tokenDefinition$1 = {
1052
+ nodeFill: "#e8f4f8",
1053
+ nodeStroke: "#23395d",
1054
+ nodeText: "#1d1d1f",
1055
+ nodeRadius: "8",
1056
+ edgeStroke: "#666",
1057
+ edgeWidth: "2",
1058
+ edgeLabelBg: "#fff",
1059
+ edgeLabelText: "#333",
1060
+ arrowFill: "#666",
1061
+ animatedDashArray: "5",
1062
+ animatedDuration: "0.5s",
1063
+ animatedDashOffset: "10",
1064
+ subgraphFill: "#f8f9fa",
1065
+ subgraphStroke: "#ccc",
1066
+ subgraphTitleBg: "#eee",
1067
+ subgraphTitleText: "#333",
1068
+ actorFill: "#e8f4f8",
1069
+ actorStroke: "#23395d",
1070
+ lifelineStroke: "#999",
1071
+ activationFill: "#d4e6f1",
1072
+ messageStroke: "#333",
1073
+ blockFill: "rgba(200,200,200,0.1)",
1074
+ blockStroke: "#aaa",
1075
+ noteBg: "#fffacd",
1076
+ noteStroke: "#e6d800",
1077
+ noteText: "#333",
1078
+ bgColor: "#ffffff",
1079
+ gridDotColor: "rgba(0, 0, 0, 0.1)",
1080
+ gridDotGap: "20",
1081
+ gridDotRadius: "1",
1082
+ fontFamily: "-apple-system, BlinkMacSystemFont, 'Inter', sans-serif",
1083
+ fontSize: "14"
1084
+ };
1085
+ const tokens$1 = defineTokens(tokenDefinition$1);
1086
+ /**
1087
+ * Default mermaid theme — sets CSS custom properties on :root.
1088
+ * Embed its __cssTemplate in an SVG <style> for self-contained rendering.
1089
+ */
1090
+ const defaultTheme = createTheme(tokens$1);
1091
+
1092
+ //#endregion
1093
+ //#region ../mermaid/src/base.style.ts
1094
+ /**
1095
+ * Common SVG text label properties.
1096
+ * Produces: fill, stroke:none, font-family, font-size, text-anchor, dominant-baseline.
1097
+ */
1098
+ function textLabel(fill, fontSize) {
1099
+ return `fill: ${fill};
1100
+ stroke: none;
1101
+ font-family: ${tokens$1.fontFamily};
1102
+ font-size: ${fontSize};
1103
+ text-anchor: middle;
1104
+ dominant-baseline: central;`;
1105
+ }
1106
+ /**
1107
+ * Common SVG box/container properties.
1108
+ * Produces: fill, stroke, stroke-width.
1109
+ */
1110
+ function boxShape(fill, stroke, strokeWidth = 1) {
1111
+ return `fill: ${fill};
1112
+ stroke: ${stroke};
1113
+ stroke-width: ${strokeWidth};`;
1114
+ }
1115
+
1116
+ //#endregion
1117
+ //#region ../mermaid/src/edge.style.ts
1118
+ const c$14 = classes([
1119
+ "edgeLine",
1120
+ "edgeInteraction",
1121
+ "edgeArrow",
1122
+ "edgeDotted",
1123
+ "edgeThick",
1124
+ "edgeAnimated",
1125
+ "edgeLabel",
1126
+ "edgeLabelBg",
1127
+ "arrowHead",
1128
+ "arrowHeadClosed",
1129
+ "dotMarker",
1130
+ "crossMarker"
1131
+ ]);
1132
+ const edgeLine = rule`${c$14.edgeLine} {
1133
+ fill: none;
1134
+ stroke: ${tokens$1.edgeStroke};
1135
+ stroke-width: ${tokens$1.edgeWidth};
1136
+ stroke-linecap: round;
1137
+ stroke-linejoin: round;
1138
+ }`;
1139
+ const edgeInteraction = rule`${c$14.edgeInteraction} {
1140
+ fill: none;
1141
+ stroke-opacity: 0;
1142
+ stroke-width: 20;
1143
+ }`;
1144
+ const edgeDotted = rule`${c$14.edgeDotted} {
1145
+ stroke-dasharray: 6, 4;
1146
+ }`;
1147
+ const edgeAnimated = rule`${c$14.edgeAnimated} {
1148
+ stroke-dasharray: ${tokens$1.animatedDashArray};
1149
+ animation: mmd-dash-flow ${tokens$1.animatedDuration} linear infinite;
1150
+ }`;
1151
+ const edgeAnimatedKeyframes = rule`
1152
+ @keyframes mmd-dash-flow {
1153
+ from {
1154
+ stroke-dashoffset: ${tokens$1.animatedDashOffset};
1155
+ }
1156
+ }
1157
+ `;
1158
+ const edgeThick = rule`${c$14.edgeThick} {
1159
+ stroke-width: 3;
1160
+ }`;
1161
+ const edgeLabel = rule`${c$14.edgeLabel} {
1162
+ ${textLabel(tokens$1.edgeLabelText, "12px")}
1163
+ }`;
1164
+ const edgeLabelBg = rule`${c$14.edgeLabelBg} {
1165
+ fill: ${tokens$1.edgeLabelBg};
1166
+ stroke: none;
1167
+ }`;
1168
+ const arrowHead = rule`${c$14.arrowHead} {
1169
+ fill: none;
1170
+ stroke: ${tokens$1.arrowFill};
1171
+ stroke-width: 1;
1172
+ stroke-linecap: round;
1173
+ stroke-linejoin: round;
1174
+ }`;
1175
+ const arrowHeadClosed = rule`${c$14.arrowHeadClosed} {
1176
+ fill: ${tokens$1.arrowFill};
1177
+ stroke: ${tokens$1.arrowFill};
1178
+ stroke-width: 1.5;
1179
+ stroke-linecap: round;
1180
+ stroke-linejoin: round;
1181
+ }`;
1182
+ const dotMarker = rule`${c$14.dotMarker} {
1183
+ fill: ${tokens$1.bgColor};
1184
+ stroke: ${tokens$1.edgeStroke};
1185
+ stroke-width: 1.5;
1186
+ }`;
1187
+ const crossMarker = rule`${c$14.crossMarker} {
1188
+ fill: none;
1189
+ stroke: ${tokens$1.edgeStroke};
1190
+ stroke-width: 2;
1191
+ stroke-linecap: round;
1192
+ }`;
1193
+
1194
+ //#endregion
1195
+ //#region ../mermaid/src/components/defs.tsx
1196
+ /**
1197
+ * Arrow markers follow xyflow conventions:
1198
+ * - viewBox "-10 -10 20 20", tip at origin (0,0)
1199
+ * - refX=0 so the arrow tip aligns with the path endpoint
1200
+ * - markerUnits="strokeWidth" for automatic scaling
1201
+ *
1202
+ * Closed arrow: polyline "-5,-4 0,0 -5,4 -5,-4" (filled triangle)
1203
+ * Open arrow: polyline "-5,-4 0,0 -5,4" (chevron)
1204
+ */
1205
+ const ARROW_CLOSED_POINTS = "-5,-4 0,0 -5,4 -5,-4";
1206
+ const ARROW_OPEN_POINTS = "-5,-4 0,0 -5,4";
1207
+ /** Dot marker radius in marker coordinate space. */
1208
+ const DOT_RADIUS = 4;
1209
+ function Defs() {
1210
+ return /* @__PURE__ */ jsxs("defs", { children: [
1211
+ /* @__PURE__ */ jsx("pattern", {
1212
+ id: "mmd-grid",
1213
+ x: 0,
1214
+ y: 0,
1215
+ width: tokens$1.gridDotGap,
1216
+ height: tokens$1.gridDotGap,
1217
+ patternUnits: "userSpaceOnUse",
1218
+ children: /* @__PURE__ */ jsx("circle", {
1219
+ cx: tokens$1.gridDotGap,
1220
+ cy: tokens$1.gridDotGap,
1221
+ r: tokens$1.gridDotRadius,
1222
+ fill: tokens$1.gridDotColor
1223
+ })
1224
+ }),
1225
+ /* @__PURE__ */ jsx("marker", {
1226
+ id: "mmd-arrow",
1227
+ viewBox: "-10 -10 20 20",
1228
+ refX: 0,
1229
+ refY: 0,
1230
+ markerWidth: 12.5,
1231
+ markerHeight: 12.5,
1232
+ markerUnits: "strokeWidth",
1233
+ orient: "auto-start-reverse",
1234
+ children: /* @__PURE__ */ jsx("polyline", {
1235
+ class: arrowHeadClosed,
1236
+ points: ARROW_CLOSED_POINTS,
1237
+ "stroke-linecap": "round",
1238
+ "stroke-linejoin": "round"
1239
+ })
1240
+ }),
1241
+ /* @__PURE__ */ jsx("marker", {
1242
+ id: "mmd-arrow-filled",
1243
+ viewBox: "-10 -10 20 20",
1244
+ refX: 0,
1245
+ refY: 0,
1246
+ markerWidth: 12.5,
1247
+ markerHeight: 12.5,
1248
+ markerUnits: "strokeWidth",
1249
+ orient: "auto-start-reverse",
1250
+ children: /* @__PURE__ */ jsx("polyline", {
1251
+ class: arrowHeadClosed,
1252
+ points: ARROW_CLOSED_POINTS,
1253
+ "stroke-linecap": "round",
1254
+ "stroke-linejoin": "round"
1255
+ })
1256
+ }),
1257
+ /* @__PURE__ */ jsx("marker", {
1258
+ id: "mmd-arrow-open",
1259
+ viewBox: "-10 -10 20 20",
1260
+ refX: 0,
1261
+ refY: 0,
1262
+ markerWidth: 12.5,
1263
+ markerHeight: 12.5,
1264
+ markerUnits: "strokeWidth",
1265
+ orient: "auto-start-reverse",
1266
+ children: /* @__PURE__ */ jsx("polyline", {
1267
+ class: arrowHead,
1268
+ points: ARROW_OPEN_POINTS,
1269
+ "stroke-linecap": "round",
1270
+ "stroke-linejoin": "round"
1271
+ })
1272
+ }),
1273
+ /* @__PURE__ */ jsx("marker", {
1274
+ id: "mmd-dot",
1275
+ viewBox: "-10 -10 20 20",
1276
+ refX: 0,
1277
+ refY: 0,
1278
+ markerWidth: 8,
1279
+ markerHeight: 8,
1280
+ markerUnits: "strokeWidth",
1281
+ orient: "auto-start-reverse",
1282
+ children: /* @__PURE__ */ jsx("circle", {
1283
+ class: dotMarker,
1284
+ cx: 0,
1285
+ cy: 0,
1286
+ r: DOT_RADIUS
1287
+ })
1288
+ }),
1289
+ /* @__PURE__ */ jsx("marker", {
1290
+ id: "mmd-cross",
1291
+ viewBox: "-10 -10 20 20",
1292
+ refX: 0,
1293
+ refY: 0,
1294
+ markerWidth: 10,
1295
+ markerHeight: 10,
1296
+ markerUnits: "strokeWidth",
1297
+ orient: "auto-start-reverse",
1298
+ children: /* @__PURE__ */ jsx("path", {
1299
+ class: crossMarker,
1300
+ d: "M -4,-4 L 4,4 M -4,4 L 4,-4"
1301
+ })
1302
+ })
1303
+ ] });
1304
+ }
1305
+
1306
+ //#endregion
1307
+ //#region ../mermaid/src/node.style.ts
1308
+ const c$13 = classes([
1309
+ "node",
1310
+ "nodeShape",
1311
+ "nodeRect",
1312
+ "nodeRound",
1313
+ "nodeCircle",
1314
+ "nodeRhombus",
1315
+ "nodeHexagon",
1316
+ "nodeCylinder",
1317
+ "nodeStadium",
1318
+ "nodeLabel"
1319
+ ]);
1320
+ const nodeShape = rule`${c$13.nodeShape} {
1321
+ ${boxShape(tokens$1.nodeFill, tokens$1.nodeStroke, tokens$1.edgeWidth)}
1322
+ }`;
1323
+ const nodeShapeHover = rule`${c$13.nodeShape} {
1324
+ transition: filter 0.15s ease;
1325
+ cursor: pointer;
1326
+ }
1327
+ ${c$13.nodeShape}:hover {
1328
+ filter: brightness(0.93);
1329
+ }`;
1330
+ const nodeLabel = rule`${c$13.nodeLabel} {
1331
+ ${textLabel(tokens$1.nodeText, `${tokens$1.fontSize}px`)}
1332
+ pointer-events: none;
1333
+ }`;
1334
+
1335
+ //#endregion
1336
+ //#region ../mermaid/src/components/nodes/rect.tsx
1337
+ function RectNode(props) {
1338
+ const { node, x, y, width, height } = props.positioned;
1339
+ return /* @__PURE__ */ jsxs("g", {
1340
+ class: [c$13.node, props.class],
1341
+ transform: `translate(${x}, ${y})`,
1342
+ children: [/* @__PURE__ */ jsx("rect", {
1343
+ class: [nodeShape, nodeShapeHover],
1344
+ x: -width / 2,
1345
+ y: -height / 2,
1346
+ width,
1347
+ height,
1348
+ rx: 12
1349
+ }), /* @__PURE__ */ jsx("text", {
1350
+ class: nodeLabel,
1351
+ children: node.label
1352
+ })]
1353
+ });
1354
+ }
1355
+
1356
+ //#endregion
1357
+ //#region ../mermaid/src/components/nodes/round.tsx
1358
+ function RoundNode(props) {
1359
+ const { node, x, y, width, height } = props.positioned;
1360
+ return /* @__PURE__ */ jsxs("g", {
1361
+ class: [c$13.node, props.class],
1362
+ transform: `translate(${x}, ${y})`,
1363
+ children: [/* @__PURE__ */ jsx("rect", {
1364
+ class: [nodeShape, nodeShapeHover],
1365
+ x: -width / 2,
1366
+ y: -height / 2,
1367
+ width,
1368
+ height,
1369
+ rx: height / 2
1370
+ }), /* @__PURE__ */ jsx("text", {
1371
+ class: nodeLabel,
1372
+ children: node.label
1373
+ })]
1374
+ });
1375
+ }
1376
+
1377
+ //#endregion
1378
+ //#region ../mermaid/src/components/nodes/circle.tsx
1379
+ function CircleNode(props) {
1380
+ const { node, x, y, width } = props.positioned;
1381
+ return /* @__PURE__ */ jsxs("g", {
1382
+ class: [c$13.node, props.class],
1383
+ transform: `translate(${x}, ${y})`,
1384
+ children: [/* @__PURE__ */ jsx("circle", {
1385
+ class: [nodeShape, nodeShapeHover],
1386
+ r: width / 2
1387
+ }), /* @__PURE__ */ jsx("text", {
1388
+ class: nodeLabel,
1389
+ children: node.label
1390
+ })]
1391
+ });
1392
+ }
1393
+
1394
+ //#endregion
1395
+ //#region ../mermaid/src/components/nodes/rhombus.tsx
1396
+ function RhombusNode(props) {
1397
+ const { node, x, y, width, height } = props.positioned;
1398
+ const hw = width / 2;
1399
+ const hh = height / 2;
1400
+ return /* @__PURE__ */ jsxs("g", {
1401
+ class: [c$13.node, props.class],
1402
+ transform: `translate(${x}, ${y})`,
1403
+ children: [/* @__PURE__ */ jsx("polygon", {
1404
+ class: [nodeShape, nodeShapeHover],
1405
+ points: `0,${-hh} ${hw},0 0,${hh} ${-hw},0`
1406
+ }), /* @__PURE__ */ jsx("text", {
1407
+ class: nodeLabel,
1408
+ children: node.label
1409
+ })]
1410
+ });
1411
+ }
1412
+
1413
+ //#endregion
1414
+ //#region ../mermaid/src/components/nodes/hexagon.tsx
1415
+ function HexagonNode(props) {
1416
+ const { node, x, y, width, height } = props.positioned;
1417
+ const hw = width / 2;
1418
+ const hh = height / 2;
1419
+ const inset = width * .15;
1420
+ return /* @__PURE__ */ jsxs("g", {
1421
+ class: [c$13.node, props.class],
1422
+ transform: `translate(${x}, ${y})`,
1423
+ children: [/* @__PURE__ */ jsx("polygon", {
1424
+ class: [nodeShape, nodeShapeHover],
1425
+ points: `${-hw + inset},${-hh} ${hw - inset},${-hh} ${hw},0 ${hw - inset},${hh} ${-hw + inset},${hh} ${-hw},0`
1426
+ }), /* @__PURE__ */ jsx("text", {
1427
+ class: nodeLabel,
1428
+ children: node.label
1429
+ })]
1430
+ });
1431
+ }
1432
+
1433
+ //#endregion
1434
+ //#region ../mermaid/src/components/nodes/stadium.tsx
1435
+ function StadiumNode(props) {
1436
+ const { node, x, y, width, height } = props.positioned;
1437
+ return /* @__PURE__ */ jsxs("g", {
1438
+ class: [c$13.node, props.class],
1439
+ transform: `translate(${x}, ${y})`,
1440
+ children: [/* @__PURE__ */ jsx("rect", {
1441
+ class: [nodeShape, nodeShapeHover],
1442
+ x: -width / 2,
1443
+ y: -height / 2,
1444
+ width,
1445
+ height,
1446
+ rx: height / 2,
1447
+ ry: height / 2
1448
+ }), /* @__PURE__ */ jsx("text", {
1449
+ class: nodeLabel,
1450
+ children: node.label
1451
+ })]
1452
+ });
1453
+ }
1454
+
1455
+ //#endregion
1456
+ //#region ../mermaid/src/components/nodes/cylinder.tsx
1457
+ function CylinderNode(props) {
1458
+ const { node, x, y, width, height } = props.positioned;
1459
+ const hw = width / 2;
1460
+ const hh = height / 2;
1461
+ const ry = 8;
1462
+ return /* @__PURE__ */ jsxs("g", {
1463
+ class: [c$13.node, props.class],
1464
+ transform: `translate(${x}, ${y})`,
1465
+ children: [
1466
+ /* @__PURE__ */ jsx("path", {
1467
+ class: [nodeShape, nodeShapeHover],
1468
+ d: `M ${-hw} ${-hh + ry} A ${hw} ${ry} 0 0 1 ${hw} ${-hh + ry} L ${hw} ${hh - ry} A ${hw} ${ry} 0 0 1 ${-hw} ${hh - ry} Z`
1469
+ }),
1470
+ /* @__PURE__ */ jsx("ellipse", {
1471
+ class: nodeShape,
1472
+ cx: 0,
1473
+ cy: -hh + ry,
1474
+ rx: hw,
1475
+ ry
1476
+ }),
1477
+ /* @__PURE__ */ jsx("text", {
1478
+ class: nodeLabel,
1479
+ y: ry / 2,
1480
+ children: node.label
1481
+ })
1482
+ ]
1483
+ });
1484
+ }
1485
+
1486
+ //#endregion
1487
+ //#region ../mermaid/src/components/nodes/subroutine.tsx
1488
+ function SubroutineNode(props) {
1489
+ const { node, x, y, width, height } = props.positioned;
1490
+ const hw = width / 2;
1491
+ const hh = height / 2;
1492
+ const inset = 8;
1493
+ return /* @__PURE__ */ jsxs("g", {
1494
+ class: [c$13.node, props.class],
1495
+ transform: `translate(${x}, ${y})`,
1496
+ children: [
1497
+ /* @__PURE__ */ jsx("rect", {
1498
+ class: [nodeShape, nodeShapeHover],
1499
+ x: -hw,
1500
+ y: -hh,
1501
+ width,
1502
+ height,
1503
+ rx: 0
1504
+ }),
1505
+ /* @__PURE__ */ jsx("line", {
1506
+ class: nodeShape,
1507
+ x1: -hw + inset,
1508
+ y1: -hh,
1509
+ x2: -hw + inset,
1510
+ y2: hh
1511
+ }),
1512
+ /* @__PURE__ */ jsx("line", {
1513
+ class: nodeShape,
1514
+ x1: hw - inset,
1515
+ y1: -hh,
1516
+ x2: hw - inset,
1517
+ y2: hh
1518
+ }),
1519
+ /* @__PURE__ */ jsx("text", {
1520
+ class: nodeLabel,
1521
+ children: node.label
1522
+ })
1523
+ ]
1524
+ });
1525
+ }
1526
+
1527
+ //#endregion
1528
+ //#region ../mermaid/src/components/nodes/asymmetric.tsx
1529
+ function AsymmetricNode(props) {
1530
+ const { node, x, y, width, height } = props.positioned;
1531
+ const hw = width / 2;
1532
+ const hh = height / 2;
1533
+ return /* @__PURE__ */ jsxs("g", {
1534
+ class: [c$13.node, props.class],
1535
+ transform: `translate(${x}, ${y})`,
1536
+ children: [/* @__PURE__ */ jsx("polygon", {
1537
+ class: [nodeShape, nodeShapeHover],
1538
+ points: `${-hw},${-hh} ${hw},${-hh} ${hw},${hh} ${-hw},${hh} ${-hw + 10},0`
1539
+ }), /* @__PURE__ */ jsx("text", {
1540
+ class: nodeLabel,
1541
+ children: node.label
1542
+ })]
1543
+ });
1544
+ }
1545
+
1546
+ //#endregion
1547
+ //#region ../mermaid/src/components/nodes/parallelogram.tsx
1548
+ function ParallelogramNode(props) {
1549
+ const { node, x, y, width, height } = props.positioned;
1550
+ const hw = width / 2;
1551
+ const hh = height / 2;
1552
+ const skew = width * .15;
1553
+ return /* @__PURE__ */ jsxs("g", {
1554
+ class: [c$13.node, props.class],
1555
+ transform: `translate(${x}, ${y})`,
1556
+ children: [/* @__PURE__ */ jsx("polygon", {
1557
+ class: [nodeShape, nodeShapeHover],
1558
+ points: `${-hw + skew},${-hh} ${hw + skew},${-hh} ${hw - skew},${hh} ${-hw - skew},${hh}`
1559
+ }), /* @__PURE__ */ jsx("text", {
1560
+ class: nodeLabel,
1561
+ children: node.label
1562
+ })]
1563
+ });
1564
+ }
1565
+
1566
+ //#endregion
1567
+ //#region ../mermaid/src/components/nodes/trapezoid.tsx
1568
+ function TrapezoidNode(props) {
1569
+ const { node, x, y, width, height } = props.positioned;
1570
+ const hw = width / 2;
1571
+ const hh = height / 2;
1572
+ const inset = width * .15;
1573
+ return /* @__PURE__ */ jsxs("g", {
1574
+ class: [c$13.node, props.class],
1575
+ transform: `translate(${x}, ${y})`,
1576
+ children: [/* @__PURE__ */ jsx("polygon", {
1577
+ class: [nodeShape, nodeShapeHover],
1578
+ points: `${-hw + inset},${-hh} ${hw - inset},${-hh} ${hw},${hh} ${-hw},${hh}`
1579
+ }), /* @__PURE__ */ jsx("text", {
1580
+ class: nodeLabel,
1581
+ children: node.label
1582
+ })]
1583
+ });
1584
+ }
1585
+
1586
+ //#endregion
1587
+ //#region ../mermaid/src/components/nodes/double-circle.tsx
1588
+ function DoubleCircleNode(props) {
1589
+ const { node, x, y, width } = props.positioned;
1590
+ const outerR = width / 2;
1591
+ const innerR = outerR - 4;
1592
+ return /* @__PURE__ */ jsxs("g", {
1593
+ class: [c$13.node, props.class],
1594
+ transform: `translate(${x}, ${y})`,
1595
+ children: [
1596
+ /* @__PURE__ */ jsx("circle", {
1597
+ class: [nodeShape, nodeShapeHover],
1598
+ r: outerR
1599
+ }),
1600
+ /* @__PURE__ */ jsx("circle", {
1601
+ class: nodeShape,
1602
+ r: innerR
1603
+ }),
1604
+ /* @__PURE__ */ jsx("text", {
1605
+ class: nodeLabel,
1606
+ children: node.label
1607
+ })
1608
+ ]
1609
+ });
1610
+ }
1611
+
1612
+ //#endregion
1613
+ //#region ../mermaid/src/components/nodes/index.ts
1614
+ const shapeMap = {
1615
+ rect: RectNode,
1616
+ round: RoundNode,
1617
+ stadium: StadiumNode,
1618
+ circle: CircleNode,
1619
+ rhombus: RhombusNode,
1620
+ hexagon: HexagonNode,
1621
+ cylinder: CylinderNode,
1622
+ subroutine: SubroutineNode,
1623
+ asymmetric: AsymmetricNode,
1624
+ parallelogram: ParallelogramNode,
1625
+ trapezoid: TrapezoidNode,
1626
+ "double-circle": DoubleCircleNode
1627
+ };
1628
+
1629
+ //#endregion
1630
+ //#region ../mermaid/src/components/markers.ts
1631
+ /** SVG marker URL by EdgeMarker type (used by flowchart edges). */
1632
+ const MARKER_URL = {
1633
+ arrow: "url(#mmd-arrow)",
1634
+ dot: "url(#mmd-dot)",
1635
+ cross: "url(#mmd-cross)",
1636
+ none: void 0
1637
+ };
1638
+ /**
1639
+ * Resolve an ArrowType (sequence diagram) to a marker URL.
1640
+ * This bridges the sequence-specific enum to the shared marker definitions in defs.tsx.
1641
+ */
1642
+ const SEQUENCE_MARKER = {
1643
+ solid: "url(#mmd-arrow)",
1644
+ dotted: "url(#mmd-arrow)",
1645
+ solidCross: "url(#mmd-cross)",
1646
+ dottedCross: "url(#mmd-cross)",
1647
+ solidOpen: "url(#mmd-arrow-open)",
1648
+ dottedOpen: "url(#mmd-arrow-open)"
1649
+ };
1650
+ /** Get marker-end URL for a sequence message arrow type. */
1651
+ function sequenceMarker(arrow) {
1652
+ return SEQUENCE_MARKER[arrow];
1653
+ }
1654
+ /** Check if an ArrowType renders with a dashed stroke. */
1655
+ function isDottedArrow(arrow) {
1656
+ return arrow === "dotted" || arrow === "dottedCross" || arrow === "dottedOpen";
1657
+ }
1658
+
1659
+ //#endregion
1660
+ //#region ../mermaid/src/components/edge.tsx
1661
+ const LINE_STYLE = {
1662
+ solid: void 0,
1663
+ dotted: edgeDotted,
1664
+ thick: edgeThick
1665
+ };
1666
+ function Edge(props) {
1667
+ const { edge, path, labelPosition, labelSize } = props.positioned;
1668
+ const lineStyle = LINE_STYLE[edge.lineStyle];
1669
+ const markerEnd = MARKER_URL[edge.targetMarker];
1670
+ const markerStart = MARKER_URL[edge.sourceMarker];
1671
+ return /* @__PURE__ */ jsxs("g", {
1672
+ class: props.class,
1673
+ children: [
1674
+ /* @__PURE__ */ jsx("path", {
1675
+ class: [edgeLine, lineStyle],
1676
+ d: path,
1677
+ "marker-start": markerStart,
1678
+ "marker-end": markerEnd
1679
+ }),
1680
+ /* @__PURE__ */ jsx("path", {
1681
+ class: edgeInteraction,
1682
+ d: path
1683
+ }),
1684
+ edge.label && labelPosition && labelSize ? /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("rect", {
1685
+ class: edgeLabelBg,
1686
+ x: labelPosition.x - labelSize.width / 2 - 4,
1687
+ y: labelPosition.y - labelSize.height / 2 - 2,
1688
+ width: labelSize.width + 8,
1689
+ height: labelSize.height + 4,
1690
+ rx: 4
1691
+ }), /* @__PURE__ */ jsx("text", {
1692
+ class: edgeLabel,
1693
+ x: labelPosition.x,
1694
+ y: labelPosition.y,
1695
+ children: edge.label
1696
+ })] }) : null
1697
+ ]
1698
+ });
1699
+ }
1700
+
1701
+ //#endregion
1702
+ //#region ../mermaid/src/subgraph.style.ts
1703
+ const c$12 = classes(["subgraphBg", "subgraphTitle"]);
1704
+ const subgraphBg = rule`${c$12.subgraphBg} {
1705
+ ${boxShape(tokens$1.subgraphFill, tokens$1.subgraphStroke, 1)}
1706
+ }`;
1707
+ const subgraphTitle = rule`${c$12.subgraphTitle} {
1708
+ fill: ${tokens$1.subgraphTitleText};
1709
+ font-family: ${tokens$1.fontFamily};
1710
+ font-size: 12px;
1711
+ font-weight: 600;
1712
+ }`;
1713
+
1714
+ //#endregion
1715
+ //#region ../mermaid/src/components/subgraph.tsx
1716
+ function SubgraphBox(props) {
1717
+ const { subgraph, x, y, width, height } = props.positioned;
1718
+ return /* @__PURE__ */ jsxs("g", {
1719
+ class: props.class,
1720
+ transform: `translate(${x}, ${y})`,
1721
+ children: [/* @__PURE__ */ jsx("rect", {
1722
+ class: subgraphBg,
1723
+ width,
1724
+ height,
1725
+ rx: 8
1726
+ }), /* @__PURE__ */ jsx("text", {
1727
+ class: subgraphTitle,
1728
+ x: 16,
1729
+ y: 24,
1730
+ children: subgraph.label
1731
+ })]
1732
+ });
1733
+ }
1734
+
1735
+ //#endregion
1736
+ //#region ../mermaid/src/layout/measure.ts
1737
+ /**
1738
+ * Per-character width multipliers relative to fontSize, derived from
1739
+ * font metrics of common sans-serif typefaces (Helvetica / Arial).
1740
+ * Covers ASCII printable range; anything outside falls back to a
1741
+ * sensible default (0.55 for Latin, 1.0 for CJK / fullwidth).
1742
+ */
1743
+ const CHAR_WIDTH = {
1744
+ " ": .28,
1745
+ "!": .28,
1746
+ "'": .19,
1747
+ ",": .28,
1748
+ ".": .28,
1749
+ ":": .28,
1750
+ ";": .28,
1751
+ i: .22,
1752
+ j: .22,
1753
+ l: .22,
1754
+ f: .28,
1755
+ r: .33,
1756
+ t: .33,
1757
+ I: .22,
1758
+ "|": .22,
1759
+ a: .5,
1760
+ b: .55,
1761
+ c: .5,
1762
+ d: .55,
1763
+ e: .5,
1764
+ g: .55,
1765
+ h: .55,
1766
+ k: .5,
1767
+ n: .55,
1768
+ o: .55,
1769
+ p: .55,
1770
+ q: .55,
1771
+ s: .5,
1772
+ u: .55,
1773
+ v: .5,
1774
+ x: .5,
1775
+ y: .5,
1776
+ z: .5,
1777
+ "0": .55,
1778
+ "1": .55,
1779
+ "2": .55,
1780
+ "3": .55,
1781
+ "4": .55,
1782
+ "5": .55,
1783
+ "6": .55,
1784
+ "7": .55,
1785
+ "8": .55,
1786
+ "9": .55,
1787
+ "-": .33,
1788
+ "(": .33,
1789
+ ")": .33,
1790
+ "/": .28,
1791
+ m: .83,
1792
+ w: .72,
1793
+ M: .72,
1794
+ W: .83,
1795
+ A: .67,
1796
+ B: .67,
1797
+ C: .67,
1798
+ D: .72,
1799
+ E: .61,
1800
+ F: .56,
1801
+ G: .72,
1802
+ H: .72,
1803
+ J: .5,
1804
+ K: .67,
1805
+ L: .56,
1806
+ N: .72,
1807
+ O: .72,
1808
+ P: .67,
1809
+ Q: .72,
1810
+ R: .67,
1811
+ S: .67,
1812
+ T: .61,
1813
+ U: .72,
1814
+ V: .67,
1815
+ X: .67,
1816
+ Y: .67,
1817
+ Z: .61,
1818
+ "@": .92,
1819
+ "#": .55,
1820
+ $: .55,
1821
+ "%": .89,
1822
+ "&": .67,
1823
+ "+": .58,
1824
+ "=": .58,
1825
+ "<": .58,
1826
+ ">": .58,
1827
+ _: .55,
1828
+ "{": .33,
1829
+ "}": .33,
1830
+ "[": .28,
1831
+ "]": .28,
1832
+ "\"": .35,
1833
+ "~": .58,
1834
+ "^": .47,
1835
+ "*": .39,
1836
+ "\\": .28,
1837
+ "`": .33,
1838
+ "?": .56
1839
+ };
1840
+ /** Default multiplier for unlisted Latin / symbol characters. */
1841
+ const DEFAULT_CHAR_WIDTH = .55;
1842
+ /**
1843
+ * Check whether a code point is in a CJK / fullwidth Unicode range.
1844
+ * These characters are typically rendered at roughly 1em width.
1845
+ */
1846
+ function isCJKOrFullwidth(code) {
1847
+ return code >= 11904 && code <= 40959 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65103 || code >= 65280 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 131072 && code <= 195103 || code >= 12288 && code <= 12351 || code >= 12352 && code <= 12543 || code >= 44032 && code <= 55215;
1848
+ }
1849
+ /**
1850
+ * Estimate text dimensions using per-character width tables.
1851
+ * Falls back to this when no Canvas / DOM measurement is available.
1852
+ */
1853
+ function estimateTextSize(text, fontSize) {
1854
+ let totalWidth = 0;
1855
+ for (let i = 0; i < text.length; i++) {
1856
+ const ch = text[i];
1857
+ const known = CHAR_WIDTH[ch];
1858
+ if (known !== void 0) totalWidth += known;
1859
+ else {
1860
+ const code = ch.charCodeAt(0);
1861
+ totalWidth += isCJKOrFullwidth(code) ? 1 : DEFAULT_CHAR_WIDTH;
1862
+ }
1863
+ }
1864
+ return {
1865
+ width: totalWidth * fontSize,
1866
+ height: fontSize * 1.4
1867
+ };
1868
+ }
1869
+ let _ctx;
1870
+ function canvasMeasureText(text, fontSize) {
1871
+ if (_ctx === void 0) {
1872
+ _ctx = null;
1873
+ try {
1874
+ if (typeof OffscreenCanvas !== "undefined") _ctx = new OffscreenCanvas(1, 1).getContext("2d");
1875
+ else if (typeof document !== "undefined") _ctx = document.createElement("canvas").getContext("2d");
1876
+ } catch {}
1877
+ }
1878
+ if (_ctx) {
1879
+ _ctx.font = `${fontSize}px sans-serif`;
1880
+ return {
1881
+ width: _ctx.measureText(text).width,
1882
+ height: fontSize * 1.2
1883
+ };
1884
+ }
1885
+ return estimateTextSize(text, fontSize);
1886
+ }
1887
+ /** Measure a node label (default 14px). */
1888
+ function measureNode(label, opts) {
1889
+ const textSize = (opts.measureText ?? canvasMeasureText)(label, 14);
1890
+ return {
1891
+ width: Math.max(textSize.width + opts.nodePadding * 2, opts.nodeWidth),
1892
+ height: Math.max(textSize.height + opts.nodePadding * 2, opts.nodeHeight)
1893
+ };
1894
+ }
1895
+ /** Measure an edge / message label (default 12px). */
1896
+ function measureLabel(text, opts) {
1897
+ return (opts.measureText ?? canvasMeasureText)(text, 12);
1898
+ }
1899
+
1900
+ //#endregion
1901
+ //#region ../mermaid/src/layout/flowchart.ts
1902
+ const DEFAULT_OPTIONS$1 = {
1903
+ nodeSpacing: 60,
1904
+ rankSpacing: 80,
1905
+ nodeWidth: 150,
1906
+ nodeHeight: 50,
1907
+ nodePadding: 16,
1908
+ diagramPadding: 20,
1909
+ edgeRouting: "bezier"
1910
+ };
1911
+ function flowchartLayout(diagram, options) {
1912
+ const opts = {
1913
+ ...DEFAULT_OPTIONS$1,
1914
+ ...options
1915
+ };
1916
+ const { nodes, edges, subgraphs, direction } = diagram;
1917
+ if (nodes.length === 0) return {
1918
+ width: 0,
1919
+ height: 0,
1920
+ viewBox: "0 0 0 0",
1921
+ nodes: [],
1922
+ edges: [],
1923
+ subgraphs: []
1924
+ };
1925
+ const nodeSizes = /* @__PURE__ */ new Map();
1926
+ for (const node of nodes) nodeSizes.set(node.id, measureNode(node.label, opts));
1927
+ const selfLoops = [];
1928
+ const nonSelfEdges = [];
1929
+ for (const edge of edges) if (edge.source === edge.target) selfLoops.push(edge);
1930
+ else nonSelfEdges.push(edge);
1931
+ const backEdgeSet = /* @__PURE__ */ new Set();
1932
+ const adj = /* @__PURE__ */ new Map();
1933
+ const visited = /* @__PURE__ */ new Set();
1934
+ const inStack = /* @__PURE__ */ new Set();
1935
+ for (const node of nodes) adj.set(node.id, []);
1936
+ for (const edge of nonSelfEdges) adj.get(edge.source)?.push(edge.target);
1937
+ function dfs(node) {
1938
+ visited.add(node);
1939
+ inStack.add(node);
1940
+ for (const neighbor of adj.get(node) ?? []) if (inStack.has(neighbor)) {
1941
+ const edge = nonSelfEdges.find((e) => e.source === node && e.target === neighbor);
1942
+ if (edge) backEdgeSet.add(edge);
1943
+ } else if (!visited.has(neighbor)) dfs(neighbor);
1944
+ inStack.delete(node);
1945
+ }
1946
+ for (const node of nodes) if (!visited.has(node.id)) dfs(node.id);
1947
+ const origToSafe = /* @__PURE__ */ new Map();
1948
+ const safeEdges = nonSelfEdges.map((edge) => {
1949
+ const safe = backEdgeSet.has(edge) ? {
1950
+ ...edge,
1951
+ source: edge.target,
1952
+ target: edge.source
1953
+ } : edge;
1954
+ origToSafe.set(edge, safe);
1955
+ return safe;
1956
+ });
1957
+ const layers = /* @__PURE__ */ new Map();
1958
+ const safeAdj = /* @__PURE__ */ new Map();
1959
+ const inDegree = /* @__PURE__ */ new Map();
1960
+ for (const node of nodes) {
1961
+ safeAdj.set(node.id, []);
1962
+ inDegree.set(node.id, 0);
1963
+ }
1964
+ for (const edge of safeEdges) {
1965
+ safeAdj.get(edge.source)?.push(edge.target);
1966
+ inDegree.set(edge.target, (inDegree.get(edge.target) ?? 0) + 1);
1967
+ }
1968
+ const queue = [];
1969
+ for (const node of nodes) if ((inDegree.get(node.id) ?? 0) === 0) {
1970
+ queue.push(node.id);
1971
+ layers.set(node.id, 0);
1972
+ }
1973
+ while (queue.length > 0) {
1974
+ const current = queue.shift();
1975
+ const currentLayer = layers.get(current) ?? 0;
1976
+ for (const neighbor of safeAdj.get(current) ?? []) {
1977
+ const existingLayer = layers.get(neighbor) ?? -1;
1978
+ layers.set(neighbor, Math.max(existingLayer, currentLayer + 1));
1979
+ inDegree.set(neighbor, (inDegree.get(neighbor) ?? 1) - 1);
1980
+ if (inDegree.get(neighbor) === 0) queue.push(neighbor);
1981
+ }
1982
+ }
1983
+ for (const node of nodes) if (!layers.has(node.id)) layers.set(node.id, 0);
1984
+ const DUMMY_DIM = 8;
1985
+ const dummySet = /* @__PURE__ */ new Set();
1986
+ const dummySize = {
1987
+ width: DUMMY_DIM,
1988
+ height: DUMMY_DIM
1989
+ };
1990
+ const edgeDummies = /* @__PURE__ */ new Map();
1991
+ let workEdges = [...safeEdges];
1992
+ {
1993
+ const newEdges = [];
1994
+ for (const edge of workEdges) {
1995
+ const srcLayer = layers.get(edge.source) ?? 0;
1996
+ const tgtLayer = layers.get(edge.target) ?? 0;
1997
+ if (tgtLayer - srcLayer <= 1) {
1998
+ newEdges.push(edge);
1999
+ continue;
2000
+ }
2001
+ const dummies = [];
2002
+ let prev = edge.source;
2003
+ for (let l = srcLayer + 1; l < tgtLayer; l++) {
2004
+ const dummyId = `__dummy_${edge.source}_${edge.target}_${l}`;
2005
+ dummies.push(dummyId);
2006
+ dummySet.add(dummyId);
2007
+ layers.set(dummyId, l);
2008
+ nodeSizes.set(dummyId, dummySize);
2009
+ newEdges.push({
2010
+ source: prev,
2011
+ target: dummyId,
2012
+ lineStyle: edge.lineStyle,
2013
+ sourceMarker: "none",
2014
+ targetMarker: "none"
2015
+ });
2016
+ prev = dummyId;
2017
+ }
2018
+ newEdges.push({
2019
+ source: prev,
2020
+ target: edge.target,
2021
+ lineStyle: edge.lineStyle,
2022
+ sourceMarker: "none",
2023
+ targetMarker: "none"
2024
+ });
2025
+ edgeDummies.set(edge, dummies);
2026
+ }
2027
+ workEdges = newEdges;
2028
+ }
2029
+ const maxLayer = Math.max(...Array.from(layers.values()), 0);
2030
+ const layerGroups = Array.from({ length: maxLayer + 1 }, () => []);
2031
+ for (const node of nodes) layerGroups[layers.get(node.id) ?? 0].push(node.id);
2032
+ for (const dummyId of dummySet) layerGroups[layers.get(dummyId) ?? 0].push(dummyId);
2033
+ const nodeSubgraph = /* @__PURE__ */ new Map();
2034
+ for (const sg of subgraphs) mapNodesToSubgraph(sg, nodeSubgraph);
2035
+ const allNodeIds = [...nodes.map((n) => n.id), ...dummySet];
2036
+ const parents = /* @__PURE__ */ new Map();
2037
+ const children = /* @__PURE__ */ new Map();
2038
+ for (const id of allNodeIds) {
2039
+ parents.set(id, []);
2040
+ children.set(id, []);
2041
+ }
2042
+ for (const edge of workEdges) {
2043
+ children.get(edge.source)?.push(edge.target);
2044
+ parents.get(edge.target)?.push(edge.source);
2045
+ }
2046
+ for (let pass = 0; pass < 4; pass++) if (pass % 2 === 0) for (let l = 1; l <= maxLayer; l++) orderLayerByBarycenter(layerGroups[l], layerGroups[l - 1], parents, nodeSubgraph);
2047
+ else for (let l = maxLayer - 1; l >= 0; l--) orderLayerByBarycenter(layerGroups[l], layerGroups[l + 1], children, nodeSubgraph);
2048
+ for (let pass = 0; pass < 3; pass++) {
2049
+ let improved = false;
2050
+ for (let l = 0; l < maxLayer; l++) {
2051
+ const layer = layerGroups[l];
2052
+ const nextLayer = layerGroups[l + 1];
2053
+ for (let i = 0; i < layer.length - 1; i++) {
2054
+ const crossBefore = countCrossings(layer, nextLayer, children);
2055
+ const tmp = layer[i];
2056
+ layer[i] = layer[i + 1];
2057
+ layer[i + 1] = tmp;
2058
+ if (countCrossings(layer, nextLayer, children) < crossBefore) improved = true;
2059
+ else {
2060
+ layer[i + 1] = layer[i];
2061
+ layer[i] = tmp;
2062
+ }
2063
+ }
2064
+ }
2065
+ if (!improved) break;
2066
+ }
2067
+ const isVertical = direction === "TB" || direction === "TD" || direction === "BT";
2068
+ const sgLayerRanges = computeSubgraphLayerRanges(subgraphs, layers);
2069
+ const allSubgraphs = flattenSubgraphs(subgraphs);
2070
+ const rankNodeDim = isVertical ? opts.nodeHeight : opts.nodeWidth;
2071
+ const sgTitleHeight = 20;
2072
+ const rankPos = [0];
2073
+ for (let l = 0; l < maxLayer; l++) {
2074
+ let overhead = 0;
2075
+ for (const sg of allSubgraphs) {
2076
+ const range = sgLayerRanges.get(sg.id);
2077
+ if (!range || range.minLayer > range.maxLayer) continue;
2078
+ if (range.maxLayer === l) overhead += opts.nodePadding;
2079
+ if (range.minLayer === l + 1) overhead += opts.nodePadding + sgTitleHeight;
2080
+ }
2081
+ const extra = overhead > 0 ? Math.max(0, overhead - opts.rankSpacing + opts.nodePadding) : 0;
2082
+ rankPos.push(rankPos[l] + rankNodeDim + opts.rankSpacing + extra);
2083
+ }
2084
+ const dim = (id) => {
2085
+ if (dummySet.has(id)) return DUMMY_DIM;
2086
+ const size = nodeSizes.get(id);
2087
+ return isVertical ? size.width : size.height;
2088
+ };
2089
+ const gap = (a, b) => {
2090
+ if (nodeSubgraph.get(a) !== nodeSubgraph.get(b)) return opts.nodeSpacing + opts.nodePadding * 2;
2091
+ return opts.nodeSpacing;
2092
+ };
2093
+ const bkResults = [];
2094
+ for (let dir = 0; dir < 4; dir++) {
2095
+ const isDown = dir < 2;
2096
+ const isLeft = dir % 2 === 0;
2097
+ const alignment = isDown ? parents : children;
2098
+ const p = /* @__PURE__ */ new Map();
2099
+ for (let l = 0; l <= maxLayer; l++) packLayerCentered(layerGroups[l], p, dim, gap);
2100
+ const sweeps = 4;
2101
+ for (let s = 0; s < sweeps; s++) if (isDown) for (let l = 1; l <= maxLayer; l++) alignLayerBK(layerGroups[l], alignment, p, dim, gap, isLeft);
2102
+ else for (let l = maxLayer - 1; l >= 0; l--) alignLayerBK(layerGroups[l], alignment, p, dim, gap, isLeft);
2103
+ bkResults.push(p);
2104
+ }
2105
+ const pos = /* @__PURE__ */ new Map();
2106
+ for (const id of allNodeIds) {
2107
+ const vals = bkResults.map((r) => r.get(id) ?? 0).sort((a, b) => a - b);
2108
+ pos.set(id, (vals[1] + vals[2]) / 2);
2109
+ }
2110
+ for (const [, dummies] of edgeDummies) {
2111
+ if (dummies.length === 0) continue;
2112
+ let sum = 0;
2113
+ for (const id of dummies) sum += pos.get(id) ?? 0;
2114
+ const avg = sum / dummies.length;
2115
+ for (const id of dummies) pos.set(id, avg);
2116
+ }
2117
+ const nodeLayer = /* @__PURE__ */ new Map();
2118
+ for (let l = 0; l <= maxLayer; l++) for (const id of layerGroups[l]) nodeLayer.set(id, l);
2119
+ const positions = /* @__PURE__ */ new Map();
2120
+ for (const id of allNodeIds) {
2121
+ const p = pos.get(id) ?? 0;
2122
+ const l = nodeLayer.get(id) ?? 0;
2123
+ if (isVertical) positions.set(id, {
2124
+ x: p,
2125
+ y: rankPos[l]
2126
+ });
2127
+ else positions.set(id, {
2128
+ x: rankPos[l],
2129
+ y: p
2130
+ });
2131
+ }
2132
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
2133
+ for (const [id, p] of positions) {
2134
+ if (dummySet.has(id)) continue;
2135
+ const size = nodeSizes.get(id);
2136
+ minX = Math.min(minX, p.x - size.width / 2);
2137
+ minY = Math.min(minY, p.y - size.height / 2);
2138
+ maxX = Math.max(maxX, p.x + size.width / 2);
2139
+ maxY = Math.max(maxY, p.y + size.height / 2);
2140
+ }
2141
+ const offsetX = opts.diagramPadding - minX;
2142
+ const offsetY = opts.diagramPadding - minY;
2143
+ for (const [, p] of positions) {
2144
+ p.x += offsetX;
2145
+ p.y += offsetY;
2146
+ }
2147
+ if (direction === "BT") {
2148
+ const totalHeight = maxY - minY;
2149
+ for (const [, p] of positions) p.y = totalHeight - (p.y - opts.diagramPadding) + opts.diagramPadding;
2150
+ }
2151
+ if (direction === "RL") {
2152
+ const totalWidth = maxX - minX;
2153
+ for (const [, p] of positions) p.x = totalWidth - (p.x - opts.diagramPadding) + opts.diagramPadding;
2154
+ }
2155
+ if (subgraphs.length > 0) {
2156
+ let extraShiftX = 0;
2157
+ let extraShiftY = 0;
2158
+ for (const sg of subgraphs) {
2159
+ const sgMin = precomputeSgMin(sg, positions, nodeSizes, opts);
2160
+ extraShiftX = Math.max(extraShiftX, opts.diagramPadding - sgMin.minX);
2161
+ extraShiftY = Math.max(extraShiftY, opts.diagramPadding - sgMin.minY);
2162
+ }
2163
+ if (extraShiftX > 0 || extraShiftY > 0) for (const [, p] of positions) {
2164
+ p.x += extraShiftX;
2165
+ p.y += extraShiftY;
2166
+ }
2167
+ }
2168
+ const positionedNodes = nodes.map((node) => {
2169
+ const p = positions.get(node.id);
2170
+ const size = nodeSizes.get(node.id);
2171
+ return {
2172
+ node,
2173
+ x: p.x,
2174
+ y: p.y,
2175
+ width: size.width,
2176
+ height: size.height
2177
+ };
2178
+ });
2179
+ const positionedEdges = edges.map((edge) => {
2180
+ if (edge.source === edge.target) {
2181
+ const p = positions.get(edge.source);
2182
+ const size = nodeSizes.get(edge.source);
2183
+ if (!p || !size) return {
2184
+ edge,
2185
+ path: "M 0 0"
2186
+ };
2187
+ const loopSize = 30;
2188
+ const rx = size.width / 2;
2189
+ const ry = size.height / 2;
2190
+ let path;
2191
+ let labelMid;
2192
+ if (isVertical) {
2193
+ const sx = p.x + rx;
2194
+ const sy = p.y - ry * .3;
2195
+ const tx = p.x + rx;
2196
+ const ty = p.y + ry * .3;
2197
+ const cx = p.x + rx + loopSize;
2198
+ path = `M ${sx} ${sy} C ${cx} ${sy - loopSize} ${cx} ${ty + loopSize} ${tx} ${ty}`;
2199
+ labelMid = {
2200
+ x: cx + 4,
2201
+ y: p.y
2202
+ };
2203
+ } else {
2204
+ const sx = p.x - rx * .3;
2205
+ const sy = p.y + ry;
2206
+ const tx = p.x + rx * .3;
2207
+ const ty = p.y + ry;
2208
+ const cy = p.y + ry + loopSize;
2209
+ path = `M ${sx} ${sy} C ${sx - loopSize} ${cy} ${tx + loopSize} ${cy} ${tx} ${ty}`;
2210
+ labelMid = {
2211
+ x: p.x,
2212
+ y: cy + 4
2213
+ };
2214
+ }
2215
+ let labelPosition;
2216
+ let labelSize;
2217
+ if (edge.label) {
2218
+ labelPosition = labelMid;
2219
+ labelSize = measureLabel(edge.label, opts);
2220
+ }
2221
+ return {
2222
+ edge,
2223
+ path,
2224
+ labelPosition,
2225
+ labelSize
2226
+ };
2227
+ }
2228
+ const sourcePos = positions.get(edge.source);
2229
+ const targetPos = positions.get(edge.target);
2230
+ if (!sourcePos || !targetPos) return {
2231
+ edge,
2232
+ path: "M 0 0"
2233
+ };
2234
+ const sourceSize = nodeSizes.get(edge.source);
2235
+ const targetSize = nodeSizes.get(edge.target);
2236
+ const safeEdge = origToSafe.get(edge);
2237
+ const dummies = safeEdge ? edgeDummies.get(safeEdge) : void 0;
2238
+ if (dummies && dummies.length > 0) {
2239
+ const result = buildLongEdgePath(sourcePos, targetPos, sourceSize, targetSize, dummies.map((id) => positions.get(id)), isVertical, opts);
2240
+ let labelPosition;
2241
+ let labelSize;
2242
+ if (edge.label) {
2243
+ labelPosition = result.labelMid;
2244
+ labelSize = measureLabel(edge.label, opts);
2245
+ }
2246
+ return {
2247
+ edge,
2248
+ path: result.path,
2249
+ labelPosition,
2250
+ labelSize
2251
+ };
2252
+ }
2253
+ const result = buildEdgePath(sourcePos, targetPos, sourceSize, targetSize, isVertical, opts);
2254
+ let labelPosition;
2255
+ let labelSize;
2256
+ if (edge.label) {
2257
+ labelPosition = result.labelMid;
2258
+ labelSize = measureLabel(edge.label, opts);
2259
+ }
2260
+ return {
2261
+ edge,
2262
+ path: result.path,
2263
+ labelPosition,
2264
+ labelSize
2265
+ };
2266
+ });
2267
+ const positionedSubgraphs = [];
2268
+ function layoutSubgraph(sg) {
2269
+ const childPositioned = [];
2270
+ for (const child of sg.subgraphs ?? []) childPositioned.push(layoutSubgraph(child));
2271
+ let sgMinX = Infinity, sgMinY = Infinity, sgMaxX = -Infinity, sgMaxY = -Infinity;
2272
+ for (const nodeId of sg.nodes) {
2273
+ const p = positions.get(nodeId);
2274
+ const size = nodeSizes.get(nodeId);
2275
+ if (p && size) {
2276
+ sgMinX = Math.min(sgMinX, p.x - size.width / 2);
2277
+ sgMinY = Math.min(sgMinY, p.y - size.height / 2);
2278
+ sgMaxX = Math.max(sgMaxX, p.x + size.width / 2);
2279
+ sgMaxY = Math.max(sgMaxY, p.y + size.height / 2);
2280
+ }
2281
+ }
2282
+ for (const child of childPositioned) {
2283
+ sgMinX = Math.min(sgMinX, child.x);
2284
+ sgMinY = Math.min(sgMinY, child.y);
2285
+ sgMaxX = Math.max(sgMaxX, child.x + child.width);
2286
+ sgMaxY = Math.max(sgMaxY, child.y + child.height);
2287
+ }
2288
+ const padding = opts.nodePadding;
2289
+ const positioned = {
2290
+ subgraph: sg,
2291
+ x: sgMinX - padding,
2292
+ y: sgMinY - padding - 20,
2293
+ width: sgMaxX - sgMinX + padding * 2,
2294
+ height: sgMaxY - sgMinY + padding * 2 + 20
2295
+ };
2296
+ positionedSubgraphs.push(positioned);
2297
+ return positioned;
2298
+ }
2299
+ for (const sg of subgraphs) layoutSubgraph(sg);
2300
+ let extMaxX = -Infinity;
2301
+ let extMaxY = -Infinity;
2302
+ for (const pn of positionedNodes) {
2303
+ extMaxX = Math.max(extMaxX, pn.x + pn.width / 2);
2304
+ extMaxY = Math.max(extMaxY, pn.y + pn.height / 2);
2305
+ }
2306
+ for (const psg of positionedSubgraphs) {
2307
+ extMaxX = Math.max(extMaxX, psg.x + psg.width);
2308
+ extMaxY = Math.max(extMaxY, psg.y + psg.height);
2309
+ }
2310
+ const diagramWidth = extMaxX + opts.diagramPadding;
2311
+ const diagramHeight = extMaxY + opts.diagramPadding;
2312
+ return {
2313
+ width: diagramWidth,
2314
+ height: diagramHeight,
2315
+ viewBox: `0 0 ${diagramWidth} ${diagramHeight}`,
2316
+ nodes: positionedNodes,
2317
+ edges: positionedEdges,
2318
+ subgraphs: positionedSubgraphs
2319
+ };
2320
+ }
2321
+ /** Map each node to its most immediate (deepest) containing subgraph. */
2322
+ function mapNodesToSubgraph(sg, out) {
2323
+ for (const nodeId of sg.nodes) out.set(nodeId, sg.id);
2324
+ for (const child of sg.subgraphs ?? []) mapNodesToSubgraph(child, out);
2325
+ }
2326
+ /**
2327
+ * Order a layer using barycenter heuristic with subgraph clustering.
2328
+ * `neighbors` maps each node to its connected nodes in the reference layer.
2329
+ * Nodes in the same subgraph are kept adjacent.
2330
+ */
2331
+ function orderLayerByBarycenter(layer, refLayer, neighborMap, nodeSubgraph) {
2332
+ const barycenters = /* @__PURE__ */ new Map();
2333
+ const refIndex = /* @__PURE__ */ new Map();
2334
+ for (let i = 0; i < refLayer.length; i++) refIndex.set(refLayer[i], i);
2335
+ for (const nodeId of layer) {
2336
+ const nbrs = neighborMap.get(nodeId) ?? [];
2337
+ let sum = 0;
2338
+ let count = 0;
2339
+ for (const n of nbrs) {
2340
+ const idx = refIndex.get(n);
2341
+ if (idx !== void 0) {
2342
+ sum += idx;
2343
+ count++;
2344
+ }
2345
+ }
2346
+ if (count > 0) barycenters.set(nodeId, sum / count);
2347
+ }
2348
+ const groupBary = /* @__PURE__ */ new Map();
2349
+ for (const nodeId of layer) {
2350
+ const sgId = nodeSubgraph.get(nodeId) ?? "";
2351
+ if (!groupBary.has(sgId)) {
2352
+ const connected = layer.filter((n) => (nodeSubgraph.get(n) ?? "") === sgId).filter((n) => barycenters.has(n));
2353
+ if (connected.length > 0) {
2354
+ const avg = connected.reduce((s, n) => s + barycenters.get(n), 0) / connected.length;
2355
+ groupBary.set(sgId, avg);
2356
+ }
2357
+ }
2358
+ }
2359
+ const original = [...layer];
2360
+ layer.sort((a, b) => {
2361
+ const sgA = nodeSubgraph.get(a) ?? "";
2362
+ const sgB = nodeSubgraph.get(b) ?? "";
2363
+ if (sgA !== sgB) {
2364
+ const ga = groupBary.get(sgA);
2365
+ const gb = groupBary.get(sgB);
2366
+ if (ga !== void 0 && gb !== void 0 && ga !== gb) return ga - gb;
2367
+ if (ga !== void 0 && gb === void 0) return -1;
2368
+ if (ga === void 0 && gb !== void 0) return 1;
2369
+ }
2370
+ const ba = barycenters.get(a);
2371
+ const bb = barycenters.get(b);
2372
+ if (ba !== void 0 && bb !== void 0 && ba !== bb) return ba - bb;
2373
+ if (ba !== void 0 && bb === void 0) return -1;
2374
+ if (ba === void 0 && bb !== void 0) return 1;
2375
+ return original.indexOf(a) - original.indexOf(b);
2376
+ });
2377
+ }
2378
+ /**
2379
+ * Count edge crossings between two adjacent layers.
2380
+ * Two edges (u1→v1) and (u2→v2) cross iff u1 < u2 and v1 > v2 (or vice versa).
2381
+ */
2382
+ function countCrossings(upperLayer, lowerLayer, children) {
2383
+ const lowerIdx = /* @__PURE__ */ new Map();
2384
+ for (let i = 0; i < lowerLayer.length; i++) lowerIdx.set(lowerLayer[i], i);
2385
+ const edgePairs = [];
2386
+ for (let ui = 0; ui < upperLayer.length; ui++) for (const child of children.get(upperLayer[ui]) ?? []) {
2387
+ const li = lowerIdx.get(child);
2388
+ if (li !== void 0) edgePairs.push([ui, li]);
2389
+ }
2390
+ let crossings = 0;
2391
+ for (let i = 0; i < edgePairs.length; i++) for (let j = i + 1; j < edgePairs.length; j++) {
2392
+ const [u1, v1] = edgePairs[i];
2393
+ const [u2, v2] = edgePairs[j];
2394
+ if (u1 < u2 && v1 > v2 || u1 > u2 && v1 < v2) crossings++;
2395
+ }
2396
+ return crossings;
2397
+ }
2398
+ /** Pack a layer centered at x=0 with minimum spacing. */
2399
+ function packLayerCentered(layer, pos, dim, gap) {
2400
+ if (layer.length === 0) return;
2401
+ let totalWidth = dim(layer[0]);
2402
+ for (let i = 1; i < layer.length; i++) totalWidth += gap(layer[i - 1], layer[i]) + dim(layer[i]);
2403
+ let offset = -totalWidth / 2;
2404
+ for (let i = 0; i < layer.length; i++) {
2405
+ const id = layer[i];
2406
+ const d = dim(id);
2407
+ if (i > 0) offset += gap(layer[i - 1], id);
2408
+ pos.set(id, offset + d / 2);
2409
+ offset += d;
2410
+ }
2411
+ }
2412
+ /**
2413
+ * Brandes-Köpf style single-direction alignment.
2414
+ * `isLeft`: when true, prefer the left (lower-index) median neighbor;
2415
+ * when false, prefer the right (higher-index) median neighbor.
2416
+ * This produces 4 distinct alignments that are then merged via median.
2417
+ */
2418
+ function alignLayerBK(layer, neighborMap, pos, dim, gap, isLeft) {
2419
+ if (layer.length === 0) return;
2420
+ const ideal = /* @__PURE__ */ new Map();
2421
+ for (const id of layer) {
2422
+ const nbrs = neighborMap.get(id) ?? [];
2423
+ if (nbrs.length > 0) {
2424
+ const xs = nbrs.map((n) => pos.get(n)).sort((a, b) => a - b);
2425
+ const mid = Math.floor(xs.length / 2);
2426
+ if (xs.length % 2 === 1) ideal.set(id, xs[mid]);
2427
+ else ideal.set(id, isLeft ? xs[mid - 1] : xs[mid]);
2428
+ }
2429
+ }
2430
+ if (ideal.size === 0) return;
2431
+ const indices = layer.map((_, i) => i);
2432
+ if (!isLeft) indices.reverse();
2433
+ for (const i of indices) {
2434
+ const id = layer[i];
2435
+ const target = ideal.get(id);
2436
+ if (target === void 0) continue;
2437
+ const halfDim = dim(id) / 2;
2438
+ let minPos = -Infinity;
2439
+ if (i > 0) {
2440
+ const leftId = layer[i - 1];
2441
+ minPos = pos.get(leftId) + dim(leftId) / 2 + gap(leftId, id) + halfDim;
2442
+ }
2443
+ let maxPos = Infinity;
2444
+ if (i < layer.length - 1) {
2445
+ const rightId = layer[i + 1];
2446
+ maxPos = pos.get(rightId) - dim(rightId) / 2 - gap(id, rightId) - halfDim;
2447
+ }
2448
+ pos.set(id, Math.max(minPos, Math.min(maxPos, target)));
2449
+ }
2450
+ }
2451
+ /** Default curvature factor (matches xyflow) */
2452
+ const DEFAULT_CURVATURE = .25;
2453
+ /**
2454
+ * Calculate control-point offset along the primary axis.
2455
+ * When distance >= 0 (normal flow), the offset is half the distance.
2456
+ * When distance < 0 (backward edge), use a wider curve via sqrt scaling.
2457
+ */
2458
+ function controlOffset(distance, curvature) {
2459
+ if (distance >= 0) return .5 * distance;
2460
+ return curvature * 25 * Math.sqrt(-distance);
2461
+ }
2462
+ /**
2463
+ * Compute the label position on a cubic bezier at t=0.5.
2464
+ * Uses the exact bezier midpoint formula instead of a simple linear midpoint.
2465
+ */
2466
+ function bezierMidpoint(sx, sy, cx1, cy1, cx2, cy2, tx, ty) {
2467
+ return {
2468
+ x: sx * .125 + cx1 * .375 + cx2 * .375 + tx * .125,
2469
+ y: sy * .125 + cy1 * .375 + cy2 * .375 + ty * .125
2470
+ };
2471
+ }
2472
+ function buildEdgePath(source, target, sourceSize, targetSize, isVertical, opts) {
2473
+ let sx, sy, tx, ty;
2474
+ if (isVertical) {
2475
+ sx = source.x;
2476
+ sy = source.y + sourceSize.height / 2;
2477
+ tx = target.x;
2478
+ ty = target.y - targetSize.height / 2;
2479
+ if (source.y > target.y) {
2480
+ sy = source.y - sourceSize.height / 2;
2481
+ ty = target.y + targetSize.height / 2;
2482
+ }
2483
+ } else {
2484
+ sx = source.x + sourceSize.width / 2;
2485
+ sy = source.y;
2486
+ tx = target.x - targetSize.width / 2;
2487
+ ty = target.y;
2488
+ if (source.x > target.x) {
2489
+ sx = source.x - sourceSize.width / 2;
2490
+ tx = target.x + targetSize.width / 2;
2491
+ }
2492
+ }
2493
+ if (opts.edgeRouting === "bezier") if (isVertical) {
2494
+ const offset = controlOffset(ty - sy, DEFAULT_CURVATURE);
2495
+ const cy1 = sy + offset;
2496
+ const cy2 = ty - offset;
2497
+ const mid = bezierMidpoint(sx, sy, sx, cy1, tx, cy2, tx, ty);
2498
+ return {
2499
+ path: `M ${sx} ${sy} C ${sx} ${cy1} ${tx} ${cy2} ${tx} ${ty}`,
2500
+ labelMid: mid
2501
+ };
2502
+ } else {
2503
+ const offset = controlOffset(tx - sx, DEFAULT_CURVATURE);
2504
+ const cx1 = sx + offset;
2505
+ const cx2 = tx - offset;
2506
+ const mid = bezierMidpoint(sx, sy, cx1, sy, cx2, ty, tx, ty);
2507
+ return {
2508
+ path: `M ${sx} ${sy} C ${cx1} ${sy} ${cx2} ${ty} ${tx} ${ty}`,
2509
+ labelMid: mid
2510
+ };
2511
+ }
2512
+ if (opts.edgeRouting === "orthogonal") if (isVertical) {
2513
+ const midY = (sy + ty) / 2;
2514
+ return {
2515
+ path: `M ${sx} ${sy} L ${sx} ${midY} L ${tx} ${midY} L ${tx} ${ty}`,
2516
+ labelMid: {
2517
+ x: (sx + tx) / 2,
2518
+ y: midY
2519
+ }
2520
+ };
2521
+ } else {
2522
+ const midX = (sx + tx) / 2;
2523
+ return {
2524
+ path: `M ${sx} ${sy} L ${midX} ${sy} L ${midX} ${ty} L ${tx} ${ty}`,
2525
+ labelMid: {
2526
+ x: midX,
2527
+ y: (sy + ty) / 2
2528
+ }
2529
+ };
2530
+ }
2531
+ return {
2532
+ path: `M ${sx} ${sy} L ${tx} ${ty}`,
2533
+ labelMid: {
2534
+ x: (sx + tx) / 2,
2535
+ y: (sy + ty) / 2
2536
+ }
2537
+ };
2538
+ }
2539
+ /**
2540
+ * Build a smooth path through dummy waypoints for edges spanning multiple layers.
2541
+ * Uses cubic Bezier spline fitting through the waypoints for bezier mode,
2542
+ * or polyline/orthogonal segments through the waypoints for other modes.
2543
+ */
2544
+ function buildLongEdgePath(source, target, sourceSize, targetSize, waypoints, isVertical, opts) {
2545
+ let sx, sy, tx, ty;
2546
+ if (isVertical) {
2547
+ sx = source.x;
2548
+ sy = source.y + sourceSize.height / 2;
2549
+ tx = target.x;
2550
+ ty = target.y - targetSize.height / 2;
2551
+ if (source.y > target.y) {
2552
+ sy = source.y - sourceSize.height / 2;
2553
+ ty = target.y + targetSize.height / 2;
2554
+ }
2555
+ } else {
2556
+ sx = source.x + sourceSize.width / 2;
2557
+ sy = source.y;
2558
+ tx = target.x - targetSize.width / 2;
2559
+ ty = target.y;
2560
+ if (source.x > target.x) {
2561
+ sx = source.x - sourceSize.width / 2;
2562
+ tx = target.x + targetSize.width / 2;
2563
+ }
2564
+ }
2565
+ const points = [
2566
+ {
2567
+ x: sx,
2568
+ y: sy
2569
+ },
2570
+ ...waypoints,
2571
+ {
2572
+ x: tx,
2573
+ y: ty
2574
+ }
2575
+ ];
2576
+ const labelMid = points[Math.floor(points.length / 2)];
2577
+ if (opts.edgeRouting === "bezier" && points.length >= 3) {
2578
+ let d = `M ${points[0].x} ${points[0].y}`;
2579
+ for (let i = 0; i < points.length - 1; i++) {
2580
+ const p0 = points[Math.max(0, i - 1)];
2581
+ const p1 = points[i];
2582
+ const p2 = points[i + 1];
2583
+ const p3 = points[Math.min(points.length - 1, i + 2)];
2584
+ const cp1x = p1.x + (p2.x - p0.x) / 6;
2585
+ const cp1y = p1.y + (p2.y - p0.y) / 6;
2586
+ const cp2x = p2.x - (p3.x - p1.x) / 6;
2587
+ const cp2y = p2.y - (p3.y - p1.y) / 6;
2588
+ d += ` C ${cp1x} ${cp1y} ${cp2x} ${cp2y} ${p2.x} ${p2.y}`;
2589
+ }
2590
+ return {
2591
+ path: d,
2592
+ labelMid
2593
+ };
2594
+ }
2595
+ if (opts.edgeRouting === "orthogonal") {
2596
+ let d = `M ${points[0].x} ${points[0].y}`;
2597
+ for (let i = 1; i < points.length; i++) {
2598
+ const prev = points[i - 1];
2599
+ const curr = points[i];
2600
+ if (isVertical) {
2601
+ const midY = (prev.y + curr.y) / 2;
2602
+ d += ` L ${prev.x} ${midY} L ${curr.x} ${midY} L ${curr.x} ${curr.y}`;
2603
+ } else {
2604
+ const midX = (prev.x + curr.x) / 2;
2605
+ d += ` L ${midX} ${prev.y} L ${midX} ${curr.y} L ${curr.x} ${curr.y}`;
2606
+ }
2607
+ }
2608
+ return {
2609
+ path: d,
2610
+ labelMid
2611
+ };
2612
+ }
2613
+ let d = `M ${points[0].x} ${points[0].y}`;
2614
+ for (let i = 1; i < points.length; i++) d += ` L ${points[i].x} ${points[i].y}`;
2615
+ return {
2616
+ path: d,
2617
+ labelMid
2618
+ };
2619
+ }
2620
+ /** Compute the layer range (min, max) for each subgraph including nested children. */
2621
+ function computeSubgraphLayerRanges(subgraphs, layers) {
2622
+ const ranges = /* @__PURE__ */ new Map();
2623
+ function compute(sg) {
2624
+ let minL = Infinity;
2625
+ let maxL = -Infinity;
2626
+ for (const nodeId of sg.nodes) {
2627
+ const l = layers.get(nodeId);
2628
+ if (l !== void 0) {
2629
+ minL = Math.min(minL, l);
2630
+ maxL = Math.max(maxL, l);
2631
+ }
2632
+ }
2633
+ for (const child of sg.subgraphs ?? []) {
2634
+ const childRange = compute(child);
2635
+ minL = Math.min(minL, childRange.minLayer);
2636
+ maxL = Math.max(maxL, childRange.maxLayer);
2637
+ }
2638
+ const range = {
2639
+ minLayer: minL,
2640
+ maxLayer: maxL
2641
+ };
2642
+ ranges.set(sg.id, range);
2643
+ return range;
2644
+ }
2645
+ for (const sg of subgraphs) compute(sg);
2646
+ return ranges;
2647
+ }
2648
+ /** Flatten a subgraph tree into a flat array of all subgraphs. */
2649
+ function flattenSubgraphs(subgraphs) {
2650
+ const result = [];
2651
+ function collect(sg) {
2652
+ result.push(sg);
2653
+ for (const child of sg.subgraphs ?? []) collect(child);
2654
+ }
2655
+ for (const sg of subgraphs) collect(sg);
2656
+ return result;
2657
+ }
2658
+ /** Pre-compute the minimum x/y bounds of a subgraph (including nested children). */
2659
+ function precomputeSgMin(sg, positions, nodeSizes, opts) {
2660
+ const titleHeight = 20;
2661
+ let minX = Infinity;
2662
+ let minY = Infinity;
2663
+ for (const nodeId of sg.nodes) {
2664
+ const p = positions.get(nodeId);
2665
+ const size = nodeSizes.get(nodeId);
2666
+ if (p && size) {
2667
+ minX = Math.min(minX, p.x - size.width / 2);
2668
+ minY = Math.min(minY, p.y - size.height / 2);
2669
+ }
2670
+ }
2671
+ for (const child of sg.subgraphs ?? []) {
2672
+ const childMin = precomputeSgMin(child, positions, nodeSizes, opts);
2673
+ minX = Math.min(minX, childMin.minX);
2674
+ minY = Math.min(minY, childMin.minY);
2675
+ }
2676
+ return {
2677
+ minX: minX - opts.nodePadding,
2678
+ minY: minY - opts.nodePadding - titleHeight
2679
+ };
2680
+ }
2681
+
2682
+ //#endregion
2683
+ //#region ../mermaid/src/layout/sequence.ts
2684
+ const DEFAULT_OPTIONS = {
2685
+ nodeSpacing: 200,
2686
+ rankSpacing: 50,
2687
+ nodeWidth: 120,
2688
+ nodeHeight: 40,
2689
+ nodePadding: 16,
2690
+ diagramPadding: 20,
2691
+ edgeRouting: "bezier"
2692
+ };
2693
+ function sequenceLayout(diagram, options) {
2694
+ const opts = {
2695
+ ...DEFAULT_OPTIONS,
2696
+ ...options
2697
+ };
2698
+ const { participants, messages, blocks, notes } = diagram;
2699
+ if (participants.length === 0) return {
2700
+ width: 0,
2701
+ height: 0,
2702
+ viewBox: "0 0 0 0",
2703
+ participants: [],
2704
+ messages: [],
2705
+ lifelines: [],
2706
+ activations: [],
2707
+ blocks: [],
2708
+ notes: []
2709
+ };
2710
+ const participantIndex = /* @__PURE__ */ new Map();
2711
+ const participantSizes = /* @__PURE__ */ new Map();
2712
+ for (let i = 0; i < participants.length; i++) {
2713
+ const p = participants[i];
2714
+ participantIndex.set(p.id, i);
2715
+ participantSizes.set(p.id, measureNode(p.label, opts));
2716
+ }
2717
+ const pairSpacing = [];
2718
+ for (let i = 0; i < participants.length - 1; i++) {
2719
+ const left = participants[i];
2720
+ const right = participants[i + 1];
2721
+ const leftSize = participantSizes.get(left.id);
2722
+ const rightSize = participantSizes.get(right.id);
2723
+ let minDist = leftSize.width / 2 + rightSize.width / 2 + opts.nodePadding * 2;
2724
+ for (const msg of messages) {
2725
+ const fi = participantIndex.get(msg.from);
2726
+ const ti = participantIndex.get(msg.to);
2727
+ if (fi === void 0 || ti === void 0) continue;
2728
+ const lo = Math.min(fi, ti);
2729
+ const hi = Math.max(fi, ti);
2730
+ if (lo <= i && hi >= i + 1 && msg.text) {
2731
+ const labelSize = measureLabel(msg.text, opts);
2732
+ const spanCols = hi - lo;
2733
+ const perGap = (labelSize.width + opts.nodePadding * 2) / spanCols;
2734
+ minDist = Math.max(minDist, perGap);
2735
+ }
2736
+ }
2737
+ pairSpacing.push(Math.max(minDist, opts.nodeSpacing));
2738
+ }
2739
+ const participantX = /* @__PURE__ */ new Map();
2740
+ let currentX = opts.diagramPadding + (participantSizes.get(participants[0].id)?.width ?? opts.nodeWidth) / 2;
2741
+ participantX.set(participants[0].id, currentX);
2742
+ for (let i = 1; i < participants.length; i++) {
2743
+ currentX += pairSpacing[i - 1];
2744
+ participantX.set(participants[i].id, currentX);
2745
+ }
2746
+ const headerY = opts.diagramPadding + opts.nodeHeight / 2;
2747
+ const headerBottom = headerY + opts.nodeHeight / 2 + 20;
2748
+ const selfMessageWidth = 40;
2749
+ const selfMessageHeight = 30;
2750
+ const positionedMessages = [];
2751
+ const positionedNotes = [];
2752
+ let currentY = headerBottom;
2753
+ const noteMessageCounts = diagram._noteMessageCounts ?? notes.map(() => messages.length);
2754
+ let nextNoteIdx = 0;
2755
+ for (let msgIdx = 0; msgIdx < messages.length; msgIdx++) {
2756
+ while (nextNoteIdx < notes.length && (noteMessageCounts[nextNoteIdx] ?? messages.length) <= msgIdx) {
2757
+ currentY = positionNote(notes[nextNoteIdx], nextNoteIdx, currentY, positionedNotes, participantX, opts);
2758
+ nextNoteIdx++;
2759
+ }
2760
+ const msg = messages[msgIdx];
2761
+ const fromX = participantX.get(msg.from) ?? 0;
2762
+ const toX = participantX.get(msg.to) ?? 0;
2763
+ const isSelf = msg.from === msg.to;
2764
+ positionedMessages.push({
2765
+ message: msg,
2766
+ fromX,
2767
+ toX: isSelf ? fromX + selfMessageWidth : toX,
2768
+ y: currentY
2769
+ });
2770
+ currentY += isSelf ? selfMessageHeight + opts.rankSpacing * .5 : opts.rankSpacing;
2771
+ }
2772
+ while (nextNoteIdx < notes.length) {
2773
+ currentY = positionNote(notes[nextNoteIdx], nextNoteIdx, currentY, positionedNotes, participantX, opts);
2774
+ nextNoteIdx++;
2775
+ }
2776
+ const activationStarts = /* @__PURE__ */ new Map();
2777
+ const positionedActivations = [];
2778
+ for (const pmsg of positionedMessages) {
2779
+ const msg = pmsg.message;
2780
+ if (msg.activate) activationStarts.set(msg.to, pmsg.y);
2781
+ if (msg.deactivate) {
2782
+ const startY = activationStarts.get(msg.from);
2783
+ if (startY !== void 0) {
2784
+ const x = participantX.get(msg.from) ?? 0;
2785
+ const participant = participants.find((p) => p.id === msg.from);
2786
+ if (participant) positionedActivations.push({
2787
+ participant,
2788
+ x: x - 7,
2789
+ y: startY,
2790
+ width: 14,
2791
+ height: pmsg.y - startY
2792
+ });
2793
+ activationStarts.delete(msg.from);
2794
+ }
2795
+ }
2796
+ }
2797
+ const lastMsg = positionedMessages[positionedMessages.length - 1];
2798
+ const lastNote = positionedNotes[positionedNotes.length - 1];
2799
+ const lastMessageY = lastMsg ? lastMsg.y : headerBottom;
2800
+ const lastNoteY = lastNote ? lastNote.y + lastNote.height : headerBottom;
2801
+ const diagramBottom = Math.max(lastMessageY, lastNoteY) + opts.rankSpacing;
2802
+ const positionedLifelines = participants.map((p) => {
2803
+ return {
2804
+ participant: p,
2805
+ x: participantX.get(p.id) ?? 0,
2806
+ y1: headerY + opts.nodeHeight / 2,
2807
+ y2: diagramBottom
2808
+ };
2809
+ });
2810
+ const msgIndexMap = /* @__PURE__ */ new Map();
2811
+ for (let i = 0; i < messages.length; i++) msgIndexMap.set(messages[i], i);
2812
+ const positionedBlocks = blocks.map((block) => {
2813
+ const allMsgs = [...block.messages, ...block.sections?.flatMap((s) => s.messages) ?? []];
2814
+ let minX = Infinity;
2815
+ let maxX = -Infinity;
2816
+ for (const msg of allMsgs) {
2817
+ const fromX = participantX.get(msg.from) ?? 0;
2818
+ const toX = participantX.get(msg.to) ?? 0;
2819
+ minX = Math.min(minX, fromX, toX);
2820
+ maxX = Math.max(maxX, fromX, toX);
2821
+ }
2822
+ const msgIndices = allMsgs.map((m) => msgIndexMap.get(m) ?? -1).filter((i) => i >= 0);
2823
+ const firstBlockMsg = msgIndices.length > 0 ? positionedMessages[Math.min(...msgIndices)] : void 0;
2824
+ const lastBlockMsg = msgIndices.length > 0 ? positionedMessages[Math.max(...msgIndices)] : void 0;
2825
+ const startY = firstBlockMsg ? firstBlockMsg.y - 20 : headerBottom;
2826
+ const endY = lastBlockMsg ? lastBlockMsg.y + 20 : headerBottom + opts.rankSpacing;
2827
+ let sectionDividers;
2828
+ if (block.sections && block.sections.length > 0) {
2829
+ sectionDividers = [];
2830
+ for (const section of block.sections) {
2831
+ const sectionMsgIndices = section.messages.map((m) => msgIndexMap.get(m) ?? -1).filter((i) => i >= 0);
2832
+ if (sectionMsgIndices.length > 0) {
2833
+ const firstSectionMsg = positionedMessages[Math.min(...sectionMsgIndices)];
2834
+ if (firstSectionMsg) sectionDividers.push({
2835
+ y: firstSectionMsg.y - 15,
2836
+ label: section.label
2837
+ });
2838
+ }
2839
+ }
2840
+ }
2841
+ const padding = opts.nodePadding;
2842
+ return {
2843
+ block,
2844
+ x: minX - padding - opts.nodeWidth / 2,
2845
+ y: startY,
2846
+ width: maxX - minX + opts.nodeWidth + padding * 2,
2847
+ height: endY - startY,
2848
+ sectionDividers
2849
+ };
2850
+ });
2851
+ const positionedParticipants = participants.map((p) => {
2852
+ return {
2853
+ participant: p,
2854
+ x: participantX.get(p.id) ?? 0,
2855
+ y: headerY,
2856
+ width: participantSizes.get(p.id).width,
2857
+ height: opts.nodeHeight
2858
+ };
2859
+ });
2860
+ const firstX = participantX.get(participants[0].id);
2861
+ const lastX = participantX.get(participants[participants.length - 1].id);
2862
+ const firstHalf = (participantSizes.get(participants[0].id)?.width ?? opts.nodeWidth) / 2;
2863
+ const diagramWidth = lastX + (participantSizes.get(participants[participants.length - 1].id)?.width ?? opts.nodeWidth) / 2 + opts.diagramPadding - (firstX - firstHalf - opts.diagramPadding);
2864
+ const diagramHeight = diagramBottom + opts.diagramPadding;
2865
+ return {
2866
+ width: diagramWidth,
2867
+ height: diagramHeight,
2868
+ viewBox: `0 0 ${diagramWidth} ${diagramHeight}`,
2869
+ participants: positionedParticipants,
2870
+ messages: positionedMessages,
2871
+ lifelines: positionedLifelines,
2872
+ activations: positionedActivations,
2873
+ blocks: positionedBlocks,
2874
+ notes: positionedNotes
2875
+ };
2876
+ }
2877
+ /** Position a single note and advance currentY, returning the new currentY */
2878
+ function positionNote(note, _index, currentY, out, participantX, opts) {
2879
+ const xs = note.participants.map((id) => participantX.get(id) ?? 0).filter((x) => x > 0);
2880
+ let x;
2881
+ if (note.position === "left of") x = (xs[0] ?? opts.diagramPadding) - opts.nodeWidth;
2882
+ else if (note.position === "right of") x = (xs[0] ?? opts.diagramPadding) + opts.nodeWidth;
2883
+ else x = xs.length > 0 ? xs.reduce((a, b) => a + b, 0) / xs.length : opts.diagramPadding;
2884
+ const size = estimateTextSize(note.text, 12);
2885
+ const noteHeight = Math.max(size.height + opts.nodePadding, 30);
2886
+ out.push({
2887
+ note,
2888
+ x,
2889
+ y: currentY,
2890
+ width: Math.max(size.width + opts.nodePadding * 2, 80),
2891
+ height: noteHeight
2892
+ });
2893
+ return currentY + noteHeight + opts.rankSpacing * .3;
2894
+ }
2895
+
2896
+ //#endregion
2897
+ //#region ../mermaid/src/layout/index.ts
2898
+ const builtinLayout = {
2899
+ flowchart: flowchartLayout,
2900
+ sequence: sequenceLayout
2901
+ };
2902
+
2903
+ //#endregion
2904
+ //#region ../mermaid/src/themes.ts
2905
+ const lightTheme$1 = createTheme(tokens$1);
2906
+ const darkTheme$1 = createTheme(tokens$1, {
2907
+ nodeFill: "#2d3748",
2908
+ nodeStroke: "#63b3ed",
2909
+ nodeText: "#e2e8f0",
2910
+ edgeStroke: "#a0aec0",
2911
+ edgeLabelBg: "#1a202c",
2912
+ edgeLabelText: "#e2e8f0",
2913
+ arrowFill: "#a0aec0",
2914
+ subgraphFill: "#1a202c",
2915
+ subgraphStroke: "#4a5568",
2916
+ subgraphTitleBg: "#2d3748",
2917
+ subgraphTitleText: "#e2e8f0",
2918
+ actorFill: "#2d3748",
2919
+ actorStroke: "#63b3ed",
2920
+ lifelineStroke: "#4a5568",
2921
+ activationFill: "#2d3748",
2922
+ messageStroke: "#a0aec0",
2923
+ blockFill: "rgba(100,100,100,0.15)",
2924
+ blockStroke: "#4a5568",
2925
+ noteBg: "#4a4528",
2926
+ noteStroke: "#b8a900",
2927
+ noteText: "#e2e8f0",
2928
+ bgColor: "#1a202c",
2929
+ gridDotColor: "rgba(255, 255, 255, 0.08)"
2930
+ });
2931
+
2932
+ //#endregion
2933
+ //#region ../mermaid/src/provider.tsx
2934
+ /** @jsxImportSource @semajsx/dom */
2935
+ const MermaidRenderers = context("mermaid-renderers");
2936
+ const MermaidLayout = context("mermaid-layout");
2937
+
2938
+ //#endregion
2939
+ //#region ../mermaid/src/components/label.tsx
2940
+ function Label(props) {
2941
+ return /* @__PURE__ */ jsx("text", {
2942
+ class: [nodeLabel, props.class],
2943
+ x: props.x,
2944
+ y: props.y,
2945
+ children: props.text
2946
+ });
2947
+ }
2948
+
2949
+ //#endregion
2950
+ //#region ../mermaid/src/sequence.style.ts
2951
+ const c$11 = classes([
2952
+ "participantBox",
2953
+ "participantLabel",
2954
+ "lifeline",
2955
+ "activation",
2956
+ "messageLine",
2957
+ "messageDotted",
2958
+ "messageText",
2959
+ "blockBg",
2960
+ "blockLabel",
2961
+ "blockLabelText",
2962
+ "blockSectionLine",
2963
+ "blockSectionLabel",
2964
+ "noteBg",
2965
+ "noteText"
2966
+ ]);
2967
+ const participantBox = rule`${c$11.participantBox} {
2968
+ ${boxShape(tokens$1.actorFill, tokens$1.actorStroke, 2)}
2969
+ }`;
2970
+ const participantLabel = rule`${c$11.participantLabel} {
2971
+ ${textLabel(tokens$1.nodeText, `${tokens$1.fontSize}px`)}
2972
+ }`;
2973
+ const lifeline = rule`${c$11.lifeline} {
2974
+ stroke: ${tokens$1.lifelineStroke};
2975
+ stroke-width: 1;
2976
+ stroke-dasharray: 6, 4;
2977
+ }`;
2978
+ const activation = rule`${c$11.activation} {
2979
+ ${boxShape(tokens$1.activationFill, tokens$1.actorStroke, 1)}
2980
+ }`;
2981
+ const messageLine = rule`${c$11.messageLine} {
2982
+ stroke: ${tokens$1.messageStroke};
2983
+ stroke-width: 1.5;
2984
+ fill: none;
2985
+ }`;
2986
+ const messageDotted = rule`${c$11.messageDotted} {
2987
+ stroke-dasharray: 6, 4;
2988
+ }`;
2989
+ const messageText = rule`${c$11.messageText} {
2990
+ ${textLabel(tokens$1.nodeText, "12px")}
2991
+ }`;
2992
+ const blockBg = rule`${c$11.blockBg} {
2993
+ ${boxShape(tokens$1.blockFill, tokens$1.blockStroke, 1)}
2994
+ }`;
2995
+ const blockLabel = rule`${c$11.blockLabel} {
2996
+ fill: ${tokens$1.blockStroke};
2997
+ }`;
2998
+ const blockLabelText = rule`${c$11.blockLabelText} {
2999
+ ${textLabel(tokens$1.nodeText, "11px")}
3000
+ font-weight: 600;
3001
+ }`;
3002
+ const blockSectionLine = rule`${c$11.blockSectionLine} {
3003
+ stroke: ${tokens$1.blockStroke};
3004
+ stroke-width: 1;
3005
+ stroke-dasharray: 6, 4;
3006
+ }`;
3007
+ const blockSectionLabel = rule`${c$11.blockSectionLabel} {
3008
+ ${textLabel(tokens$1.nodeText, "11px")}
3009
+ font-weight: 600;
3010
+ font-style: italic;
3011
+ }`;
3012
+ const noteBg = rule`${c$11.noteBg} {
3013
+ ${boxShape(tokens$1.noteBg, tokens$1.noteStroke, 1)}
3014
+ }`;
3015
+ const noteText = rule`${c$11.noteText} {
3016
+ ${textLabel(tokens$1.noteText, "12px")}
3017
+ }`;
3018
+
3019
+ //#endregion
3020
+ //#region ../mermaid/src/components/sequence/participant.tsx
3021
+ function Participant(props) {
3022
+ const { participant, x, y, width, height } = props;
3023
+ return /* @__PURE__ */ jsxs("g", {
3024
+ class: props.class,
3025
+ transform: `translate(${x}, ${y})`,
3026
+ children: [/* @__PURE__ */ jsx("rect", {
3027
+ class: participantBox,
3028
+ x: -width / 2,
3029
+ y: -height / 2,
3030
+ width,
3031
+ height,
3032
+ rx: 6
3033
+ }), /* @__PURE__ */ jsx("text", {
3034
+ class: participantLabel,
3035
+ children: participant.label
3036
+ })]
3037
+ });
3038
+ }
3039
+
3040
+ //#endregion
3041
+ //#region ../mermaid/src/components/sequence/message.tsx
3042
+ function Message(props) {
3043
+ const { message, fromX, toX, y } = props;
3044
+ const isDotted = isDottedArrow(message.arrow);
3045
+ const markerEnd = sequenceMarker(message.arrow);
3046
+ if (message.from === message.to) {
3047
+ const loopWidth = toX - fromX;
3048
+ const loopHeight = 30;
3049
+ const path = [
3050
+ `M ${fromX} ${y}`,
3051
+ `L ${fromX + loopWidth} ${y}`,
3052
+ `L ${fromX + loopWidth} ${y + loopHeight}`,
3053
+ `L ${fromX} ${y + loopHeight}`
3054
+ ].join(" ");
3055
+ return /* @__PURE__ */ jsxs("g", {
3056
+ class: props.class,
3057
+ children: [/* @__PURE__ */ jsx("path", {
3058
+ class: [messageLine, isDotted ? messageDotted : void 0],
3059
+ d: path,
3060
+ fill: "none",
3061
+ "marker-end": markerEnd
3062
+ }), /* @__PURE__ */ jsx("text", {
3063
+ class: messageText,
3064
+ x: fromX + loopWidth / 2 + loopWidth / 2 + 6,
3065
+ y: y + loopHeight / 2,
3066
+ "text-anchor": "start",
3067
+ children: message.text
3068
+ })]
3069
+ });
3070
+ }
3071
+ const midX = (fromX + toX) / 2;
3072
+ return /* @__PURE__ */ jsxs("g", {
3073
+ class: props.class,
3074
+ children: [/* @__PURE__ */ jsx("line", {
3075
+ class: [messageLine, isDotted ? messageDotted : void 0],
3076
+ x1: fromX,
3077
+ y1: y,
3078
+ x2: toX,
3079
+ y2: y,
3080
+ "marker-end": markerEnd
3081
+ }), /* @__PURE__ */ jsx("text", {
3082
+ class: messageText,
3083
+ x: midX,
3084
+ y: y - 8,
3085
+ children: message.text
3086
+ })]
3087
+ });
3088
+ }
3089
+
3090
+ //#endregion
3091
+ //#region ../mermaid/src/components/sequence/lifeline.tsx
3092
+ function Lifeline(props) {
3093
+ return /* @__PURE__ */ jsx("line", {
3094
+ class: [lifeline, props.class],
3095
+ x1: props.x,
3096
+ y1: props.y1,
3097
+ x2: props.x,
3098
+ y2: props.y2
3099
+ });
3100
+ }
3101
+
3102
+ //#endregion
3103
+ //#region ../mermaid/src/components/sequence/activation.tsx
3104
+ function Activation(props) {
3105
+ return /* @__PURE__ */ jsx("rect", {
3106
+ class: [activation, props.class],
3107
+ x: props.x - props.width / 2,
3108
+ y: props.y,
3109
+ width: props.width,
3110
+ height: props.height
3111
+ });
3112
+ }
3113
+
3114
+ //#endregion
3115
+ //#region ../mermaid/src/components/sequence/block.tsx
3116
+ function Block(props) {
3117
+ const { block, x, y, width, height, sectionDividers } = props;
3118
+ const typeText = block.type;
3119
+ const labelText = block.label ? `${typeText} [${block.label}]` : typeText;
3120
+ const labelWidth = Math.max(labelText.length * 7 + 10, 50);
3121
+ return /* @__PURE__ */ jsxs("g", {
3122
+ class: props.class,
3123
+ children: [
3124
+ /* @__PURE__ */ jsx("rect", {
3125
+ class: blockBg,
3126
+ x,
3127
+ y,
3128
+ width,
3129
+ height,
3130
+ rx: 4
3131
+ }),
3132
+ /* @__PURE__ */ jsx("rect", {
3133
+ class: blockLabel,
3134
+ x,
3135
+ y,
3136
+ width: labelWidth,
3137
+ height: 20,
3138
+ rx: 4
3139
+ }),
3140
+ /* @__PURE__ */ jsx("text", {
3141
+ class: blockLabelText,
3142
+ x: x + labelWidth / 2,
3143
+ y: y + 10,
3144
+ children: labelText
3145
+ }),
3146
+ sectionDividers?.map((div) => /* @__PURE__ */ jsxs("g", { children: [/* @__PURE__ */ jsx("line", {
3147
+ class: blockSectionLine,
3148
+ x1: x,
3149
+ y1: div.y,
3150
+ x2: x + width,
3151
+ y2: div.y
3152
+ }), div.label && /* @__PURE__ */ jsxs("text", {
3153
+ class: blockSectionLabel,
3154
+ x: x + 8,
3155
+ y: div.y + 14,
3156
+ "text-anchor": "start",
3157
+ children: [
3158
+ "[",
3159
+ div.label,
3160
+ "]"
3161
+ ]
3162
+ })] }))
3163
+ ]
3164
+ });
3165
+ }
3166
+
3167
+ //#endregion
3168
+ //#region ../mermaid/src/components/sequence/note.tsx
3169
+ function Note(props) {
3170
+ const { note, x, y, width, height } = props;
3171
+ return /* @__PURE__ */ jsxs("g", {
3172
+ class: props.class,
3173
+ transform: `translate(${x}, ${y})`,
3174
+ children: [/* @__PURE__ */ jsx("rect", {
3175
+ class: noteBg,
3176
+ x: -width / 2,
3177
+ y: -height / 2,
3178
+ width,
3179
+ height,
3180
+ rx: 4
3181
+ }), /* @__PURE__ */ jsx("text", {
3182
+ class: noteText,
3183
+ children: note.text
3184
+ })]
3185
+ });
3186
+ }
3187
+
3188
+ //#endregion
3189
+ //#region ../mermaid/src/components/index.ts
3190
+ const defaultRenderers = {
3191
+ node: shapeMap.rect,
3192
+ edge: Edge,
3193
+ subgraph: SubgraphBox,
3194
+ label: Label,
3195
+ participant: Participant,
3196
+ message: Message,
3197
+ lifeline: Lifeline,
3198
+ activation: Activation,
3199
+ block: Block,
3200
+ note: Note
3201
+ };
3202
+
3203
+ //#endregion
3204
+ //#region ../mermaid/src/flowchart.tsx
3205
+ function Flowchart(props, ctx) {
3206
+ const engine = ctx?.inject(MermaidLayout) ?? builtinLayout;
3207
+ const renderers = ctx?.inject(MermaidRenderers) ?? defaultRenderers;
3208
+ const graphData = unwrap(props.graph);
3209
+ const positioned = engine.flowchart(graphData);
3210
+ return /* @__PURE__ */ jsxs("svg", {
3211
+ class: [svgRoot, props.class],
3212
+ viewBox: positioned.viewBox,
3213
+ xmlns: "http://www.w3.org/2000/svg",
3214
+ children: [
3215
+ /* @__PURE__ */ jsx("style", { children: defaultTheme.__cssTemplate }),
3216
+ /* @__PURE__ */ jsx(Defs, {}),
3217
+ /* @__PURE__ */ jsx("rect", {
3218
+ x: 0,
3219
+ y: 0,
3220
+ width: positioned.width,
3221
+ height: positioned.height,
3222
+ fill: "url(#mmd-grid)"
3223
+ }),
3224
+ positioned.subgraphs.map((s) => {
3225
+ return /* @__PURE__ */ jsx(renderers.subgraph ?? SubgraphBox, { positioned: s });
3226
+ }),
3227
+ positioned.edges.map((e) => {
3228
+ return /* @__PURE__ */ jsx(renderers[`edge:${e.edge.lineStyle}`] ?? renderers.edge ?? Edge, { positioned: e });
3229
+ }),
3230
+ positioned.nodes.map((n) => {
3231
+ return /* @__PURE__ */ jsx(renderers[`node:${n.node.shape}`] ?? renderers.node ?? shapeMap[n.node.shape] ?? shapeMap.rect, { positioned: n });
3232
+ })
3233
+ ]
3234
+ });
3235
+ }
3236
+
3237
+ //#endregion
3238
+ //#region ../mermaid/src/sequence.tsx
3239
+ function Sequence(props, ctx) {
3240
+ const engine = ctx?.inject(MermaidLayout) ?? builtinLayout;
3241
+ const renderers = ctx?.inject(MermaidRenderers) ?? defaultRenderers;
3242
+ const graphData = unwrap(props.graph);
3243
+ const positioned = engine.sequence(graphData);
3244
+ const LifelineComp = renderers.lifeline;
3245
+ const BlockComp = renderers.block;
3246
+ const ActivationComp = renderers.activation;
3247
+ const NoteComp = renderers.note;
3248
+ const MessageComp = renderers.message;
3249
+ const ParticipantComp = renderers.participant;
3250
+ return /* @__PURE__ */ jsxs("svg", {
3251
+ class: [svgRoot, props.class],
3252
+ viewBox: positioned.viewBox,
3253
+ xmlns: "http://www.w3.org/2000/svg",
3254
+ children: [
3255
+ /* @__PURE__ */ jsx("style", { children: defaultTheme.__cssTemplate }),
3256
+ /* @__PURE__ */ jsx(Defs, {}),
3257
+ positioned.lifelines.map((l) => /* @__PURE__ */ jsx(LifelineComp, {
3258
+ participant: l.participant,
3259
+ x: l.x,
3260
+ y1: l.y1,
3261
+ y2: l.y2
3262
+ })),
3263
+ positioned.blocks.map((b) => /* @__PURE__ */ jsx(BlockComp, {
3264
+ block: b.block,
3265
+ x: b.x,
3266
+ y: b.y,
3267
+ width: b.width,
3268
+ height: b.height,
3269
+ sectionDividers: b.sectionDividers
3270
+ })),
3271
+ positioned.activations.map((a) => /* @__PURE__ */ jsx(ActivationComp, {
3272
+ participant: a.participant,
3273
+ x: a.x,
3274
+ y: a.y,
3275
+ width: a.width,
3276
+ height: a.height
3277
+ })),
3278
+ positioned.notes.map((n) => /* @__PURE__ */ jsx(NoteComp, {
3279
+ note: n.note,
3280
+ x: n.x,
3281
+ y: n.y,
3282
+ width: n.width,
3283
+ height: n.height
3284
+ })),
3285
+ positioned.messages.map((m) => /* @__PURE__ */ jsx(MessageComp, {
3286
+ message: m.message,
3287
+ fromX: m.fromX,
3288
+ toX: m.toX,
3289
+ y: m.y
3290
+ })),
3291
+ positioned.participants.map((p) => /* @__PURE__ */ jsx(ParticipantComp, {
3292
+ participant: p.participant,
3293
+ x: p.x,
3294
+ y: p.y,
3295
+ width: p.width,
3296
+ height: p.height
3297
+ }))
3298
+ ]
3299
+ });
3300
+ }
3301
+
3302
+ //#endregion
3303
+ //#region ../mermaid/src/mermaid.tsx
3304
+ function Mermaid(props) {
3305
+ const diagram = parse(unwrap(props.code));
3306
+ if ("message" in diagram) {
3307
+ props.onError?.(diagram);
3308
+ return null;
3309
+ }
3310
+ if (diagram.type === "flowchart") return /* @__PURE__ */ jsx(Flowchart, {
3311
+ graph: diagram,
3312
+ class: props.class
3313
+ });
3314
+ if (diagram.type === "sequence") return /* @__PURE__ */ jsx(Sequence, {
3315
+ graph: diagram,
3316
+ class: props.class
3317
+ });
3318
+ return null;
3319
+ }
3320
+
3321
+ //#endregion
3322
+ //#region ../mermaid/src/remark-mermaid.ts
3323
+ function walk(node) {
3324
+ if (!node.children) return;
3325
+ for (let i = 0; i < node.children.length; i++) {
3326
+ const child = node.children[i];
3327
+ if (child.type === "code" && child.lang === "mermaid") {
3328
+ if (child.meta && /\braw\b/.test(child.meta)) continue;
3329
+ node.children[i] = {
3330
+ type: "mdxJsxFlowElement",
3331
+ name: "Mermaid",
3332
+ attributes: [{
3333
+ type: "mdxJsxAttribute",
3334
+ name: "code",
3335
+ value: child.value ?? ""
3336
+ }],
3337
+ children: [],
3338
+ data: { _mdxExplicitJsx: true }
3339
+ };
3340
+ } else walk(child);
3341
+ }
3342
+ }
3343
+ function remarkMermaid() {
3344
+ return (tree) => walk(tree);
3345
+ }
3346
+
3347
+ //#endregion
22
3348
  //#region ../ssg/src/plugins/docs-theme/styles.ts
23
3349
  /**
24
3350
  * Apple-inspired theme CSS for the docs-theme plugin.
25
3351
  *
26
3352
  * All class names are prefixed with `dt-` to avoid collisions.
27
- * Component styles (Card, Callout, Badge) come from @semajsx/ui via componentCSS.
3353
+ * Component styles (Card, Callout, Badge) from @semajsx/ui are collected automatically
3354
+ * by the SSR renderer from StyleTokens.
28
3355
  * This file contains layout, navigation, hero, typography, animations, and responsive styles.
29
3356
  */
30
3357
  const THEME_CSS = `
@@ -1019,26 +4346,20 @@ const tokens = defineTokens(tokenDefinition);
1019
4346
  * Five semantic variants: info, warning, success, error, tip
1020
4347
  * Matching the docs site callout design.
1021
4348
  */
1022
- var callout_style_exports = /* @__PURE__ */ __exportAll({
1023
- content: () => content$1,
1024
- icon: () => icon$2,
1025
- root: () => root$11,
1026
- title: () => title$1
1027
- });
1028
- const c$11 = classes([
4349
+ const c$10 = classes([
1029
4350
  "root",
1030
4351
  "title",
1031
4352
  "icon",
1032
4353
  "content"
1033
4354
  ]);
1034
- const root$11 = rule`${c$11.root} {
4355
+ const root$10 = rule`${c$10.root} {
1035
4356
  padding: 1.25rem 1.5rem;
1036
4357
  margin: 1.5rem 0;
1037
4358
  border-radius: 14px;
1038
4359
  border: 0.5px solid rgba(0, 0, 0, 0.04);
1039
4360
  font-family: ${tokens.fonts.base};
1040
4361
  }`;
1041
- const title$1 = rule`${c$11.title} {
4362
+ const title$1 = rule`${c$10.title} {
1042
4363
  font-weight: ${tokens.fontWeights.semibold};
1043
4364
  font-size: 0.9375rem;
1044
4365
  margin: 0 0 0.5rem;
@@ -1047,7 +4368,7 @@ const title$1 = rule`${c$11.title} {
1047
4368
  gap: ${tokens.space.sm};
1048
4369
  letter-spacing: -0.005em;
1049
4370
  }`;
1050
- const icon$2 = rule`${c$11.icon} {
4371
+ const icon$2 = rule`${c$10.icon} {
1051
4372
  width: 18px;
1052
4373
  height: 18px;
1053
4374
  display: inline-flex;
@@ -1055,7 +4376,7 @@ const icon$2 = rule`${c$11.icon} {
1055
4376
  justify-content: center;
1056
4377
  flex-shrink: 0;
1057
4378
  }`;
1058
- const content$1 = rule`${c$11.content} {
4379
+ const content$1 = rule`${c$10.content} {
1059
4380
  color: ${tokens.colors.text};
1060
4381
  font-size: 0.9375rem;
1061
4382
  line-height: ${tokens.lineHeights.normal};
@@ -1159,7 +4480,7 @@ function Callout(props) {
1159
4480
  const config = calloutConfig[props.type ?? "info"];
1160
4481
  const IconComponent = config.icon;
1161
4482
  return /* @__PURE__ */ jsxs("div", {
1162
- class: [root$11, props.class],
4483
+ class: [root$10, props.class],
1163
4484
  style: `background: ${config.bg}`,
1164
4485
  role: "note",
1165
4486
  children: [props.title && /* @__PURE__ */ jsxs("div", {
@@ -1183,9 +4504,8 @@ function Callout(props) {
1183
4504
  *
1184
4505
  * Pill-shaped labels with semantic color variants.
1185
4506
  */
1186
- var badge_style_exports = /* @__PURE__ */ __exportAll({ root: () => root$10 });
1187
- const c$10 = classes(["root"]);
1188
- const root$10 = rule`${c$10.root} {
4507
+ const c$9 = classes(["root"]);
4508
+ const root$9 = rule`${c$9.root} {
1189
4509
  display: inline-flex;
1190
4510
  align-items: center;
1191
4511
  font-size: 0.6875rem;
@@ -1230,7 +4550,7 @@ const badgeColors = {
1230
4550
  function Badge(props) {
1231
4551
  const config = badgeColors[props.color ?? "default"];
1232
4552
  return /* @__PURE__ */ jsx("span", {
1233
- class: [root$10, props.class],
4553
+ class: [root$9, props.class],
1234
4554
  style: `background: ${config.bg}; color: ${config.fg}`,
1235
4555
  children: props.children
1236
4556
  });
@@ -1245,19 +4565,7 @@ function Badge(props) {
1245
4565
  * - feature: Large card with icon, heading, description
1246
4566
  * - link: Smaller clickable card for navigation
1247
4567
  */
1248
- var card_style_exports = /* @__PURE__ */ __exportAll({
1249
- desc: () => desc,
1250
- descLink: () => descLink,
1251
- feature: () => feature,
1252
- featureStates: () => featureStates,
1253
- heading: () => heading,
1254
- headingLink: () => headingLink,
1255
- icon: () => icon$1,
1256
- link: () => link,
1257
- linkStates: () => linkStates,
1258
- root: () => root$9
1259
- });
1260
- const c$9 = classes([
4568
+ const c$8 = classes([
1261
4569
  "root",
1262
4570
  "feature",
1263
4571
  "link",
@@ -1265,22 +4573,22 @@ const c$9 = classes([
1265
4573
  "heading",
1266
4574
  "desc"
1267
4575
  ]);
1268
- const root$9 = rule`${c$9.root} {
4576
+ const root$8 = rule`${c$8.root} {
1269
4577
  background: white;
1270
4578
  border: 0.5px solid rgba(0, 0, 0, 0.06);
1271
4579
  font-family: ${tokens.fonts.base};
1272
4580
  transition: all 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
1273
4581
  }`;
1274
- const feature = rule`${c$9.feature} {
4582
+ const feature = rule`${c$8.feature} {
1275
4583
  border-radius: ${tokens.radii.xl};
1276
4584
  padding: 2.5rem;
1277
4585
  box-shadow: ${tokens.shadows.md};
1278
4586
  }`;
1279
- const featureStates = rule`${c$9.feature}:hover {
4587
+ const featureStates = rule`${c$8.feature}:hover {
1280
4588
  transform: translateY(-4px) scale(1.01);
1281
4589
  box-shadow: ${tokens.shadows.lg};
1282
4590
  }`;
1283
- const link = rule`${c$9.link} {
4591
+ const link = rule`${c$8.link} {
1284
4592
  display: block;
1285
4593
  border-radius: ${tokens.radii.lg};
1286
4594
  padding: 1.75rem;
@@ -1288,12 +4596,12 @@ const link = rule`${c$9.link} {
1288
4596
  text-decoration: none;
1289
4597
  cursor: pointer;
1290
4598
  }`;
1291
- const linkStates = rules(rule`${c$9.link}:hover {
4599
+ const linkStates = rules(rule`${c$8.link}:hover {
1292
4600
  border-color: rgba(0, 113, 227, 0.3);
1293
4601
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
1294
4602
  transform: translateY(-2px);
1295
4603
  }`);
1296
- const icon$1 = rule`${c$9.icon} {
4604
+ const icon$1 = rule`${c$8.icon} {
1297
4605
  font-size: 2rem;
1298
4606
  width: 48px;
1299
4607
  height: 48px;
@@ -1304,24 +4612,24 @@ const icon$1 = rule`${c$9.icon} {
1304
4612
  border-radius: ${tokens.radii.md};
1305
4613
  margin-bottom: 1.25rem;
1306
4614
  }`;
1307
- const heading = rule`${c$9.heading} {
4615
+ const heading = rule`${c$8.heading} {
1308
4616
  font-size: 1.375rem;
1309
4617
  font-weight: ${tokens.fontWeights.semibold};
1310
4618
  color: ${tokens.colors.text};
1311
4619
  margin: 0 0 0.5rem;
1312
4620
  letter-spacing: -0.01em;
1313
4621
  }`;
1314
- const headingLink = rule`${c$9.link} ${c$9.heading} {
4622
+ const headingLink = rule`${c$8.link} ${c$8.heading} {
1315
4623
  font-size: ${tokens.fontSizes.lg};
1316
4624
  margin-bottom: 0.25rem;
1317
4625
  }`;
1318
- const desc = rule`${c$9.desc} {
4626
+ const desc = rule`${c$8.desc} {
1319
4627
  color: ${tokens.colors.textMuted};
1320
4628
  line-height: ${tokens.lineHeights.normal};
1321
4629
  font-size: 0.9375rem;
1322
4630
  margin: 0;
1323
4631
  }`;
1324
- const descLink = rule`${c$9.link} ${c$9.desc} {
4632
+ const descLink = rule`${c$8.link} ${c$8.desc} {
1325
4633
  font-size: ${tokens.fontSizes.sm};
1326
4634
  line-height: 1.5;
1327
4635
  }`;
@@ -1348,7 +4656,7 @@ function Card(props) {
1348
4656
  if (variant === "link") return /* @__PURE__ */ jsx("a", {
1349
4657
  href: props.href,
1350
4658
  class: [
1351
- root$9,
4659
+ root$8,
1352
4660
  link,
1353
4661
  linkStates,
1354
4662
  props.class
@@ -1358,7 +4666,7 @@ function Card(props) {
1358
4666
  });
1359
4667
  return /* @__PURE__ */ jsx("div", {
1360
4668
  class: [
1361
- root$9,
4669
+ root$8,
1362
4670
  feature,
1363
4671
  featureStates,
1364
4672
  props.class
@@ -1375,26 +4683,18 @@ function Card(props) {
1375
4683
  *
1376
4684
  * A tab bar with active indicator and content panels.
1377
4685
  */
1378
- var tabs_style_exports = /* @__PURE__ */ __exportAll({
1379
- active: () => active,
1380
- list: () => list,
1381
- panel: () => panel,
1382
- root: () => root$8,
1383
- trigger: () => trigger,
1384
- triggerStates: () => triggerStates
1385
- });
1386
- const c$8 = classes([
4686
+ const c$7 = classes([
1387
4687
  "root",
1388
4688
  "list",
1389
4689
  "trigger",
1390
4690
  "active",
1391
4691
  "panel"
1392
4692
  ]);
1393
- const root$8 = rule`${c$8.root} {
4693
+ const root$7 = rule`${c$7.root} {
1394
4694
  margin: 1.5rem 0;
1395
4695
  font-family: ${tokens.fonts.base};
1396
4696
  }`;
1397
- const list = rule`${c$8.list} {
4697
+ const list = rule`${c$7.list} {
1398
4698
  display: flex;
1399
4699
  gap: 0;
1400
4700
  border-bottom: 1px solid ${tokens.colors.border};
@@ -1402,7 +4702,7 @@ const list = rule`${c$8.list} {
1402
4702
  overflow-x: auto;
1403
4703
  -webkit-overflow-scrolling: touch;
1404
4704
  }`;
1405
- const trigger = rule`${c$8.trigger} {
4705
+ const trigger = rule`${c$7.trigger} {
1406
4706
  padding: 0.625rem 1rem;
1407
4707
  font-size: ${tokens.fontSizes.sm};
1408
4708
  font-weight: ${tokens.fontWeights.medium};
@@ -1416,17 +4716,17 @@ const trigger = rule`${c$8.trigger} {
1416
4716
  transition: color ${tokens.transitions.fast}, border-color ${tokens.transitions.fast};
1417
4717
  margin-bottom: -1px;
1418
4718
  }`;
1419
- const triggerStates = rules(rule`${c$8.trigger}:hover {
4719
+ const triggerStates = rules(rule`${c$7.trigger}:hover {
1420
4720
  color: ${tokens.colors.text};
1421
- }`, rule`${c$8.trigger}:focus-visible {
4721
+ }`, rule`${c$7.trigger}:focus-visible {
1422
4722
  outline: 2px solid ${tokens.colors.primary};
1423
4723
  outline-offset: -2px;
1424
4724
  }`);
1425
- const active = rule`${c$8.active} {
4725
+ const active = rule`${c$7.active} {
1426
4726
  color: ${tokens.colors.primary};
1427
4727
  border-bottom-color: ${tokens.colors.primary};
1428
4728
  }`;
1429
- const panel = rule`${c$8.panel} {
4729
+ const panel = rule`${c$7.panel} {
1430
4730
  padding: 1rem 0;
1431
4731
  }`;
1432
4732
 
@@ -1448,7 +4748,7 @@ function Tabs(props) {
1448
4748
  const active = signal(props.defaultValue);
1449
4749
  _ssrDefaultTab = props.defaultValue;
1450
4750
  return /* @__PURE__ */ jsx("div", {
1451
- class: [root$8, props.class],
4751
+ class: [root$7, props.class],
1452
4752
  "data-tabs": active,
1453
4753
  onClick: (e) => {
1454
4754
  const tab = e.target.closest("[role=tab]");
@@ -1506,15 +4806,7 @@ function TabPanel(props) {
1506
4806
  *
1507
4807
  * Numbered step indicators for tutorials and guides.
1508
4808
  */
1509
- var steps_style_exports = /* @__PURE__ */ __exportAll({
1510
- body: () => body,
1511
- content: () => content,
1512
- item: () => item,
1513
- number: () => number,
1514
- root: () => root$7,
1515
- title: () => title
1516
- });
1517
- const c$7 = classes([
4809
+ const c$6 = classes([
1518
4810
  "root",
1519
4811
  "item",
1520
4812
  "number",
@@ -1522,20 +4814,20 @@ const c$7 = classes([
1522
4814
  "title",
1523
4815
  "body"
1524
4816
  ]);
1525
- const root$7 = rule`${c$7.root} {
4817
+ const root$6 = rule`${c$6.root} {
1526
4818
  display: flex;
1527
4819
  flex-direction: column;
1528
4820
  gap: 0;
1529
4821
  margin: 1.5rem 0;
1530
4822
  font-family: ${tokens.fonts.base};
1531
4823
  }`;
1532
- const item = rule`${c$7.item} {
4824
+ const item = rule`${c$6.item} {
1533
4825
  display: flex;
1534
4826
  gap: 1rem;
1535
4827
  padding: 1.25rem 0;
1536
4828
  border-bottom: 0.5px solid ${tokens.colors.border};
1537
4829
  }`;
1538
- const number = rule`${c$7.number} {
4830
+ const number = rule`${c$6.number} {
1539
4831
  flex-shrink: 0;
1540
4832
  width: 28px;
1541
4833
  height: 28px;
@@ -1549,18 +4841,18 @@ const number = rule`${c$7.number} {
1549
4841
  justify-content: center;
1550
4842
  margin-top: 0.125rem;
1551
4843
  }`;
1552
- const content = rule`${c$7.content} {
4844
+ const content = rule`${c$6.content} {
1553
4845
  flex: 1;
1554
4846
  min-width: 0;
1555
4847
  }`;
1556
- const title = rule`${c$7.title} {
4848
+ const title = rule`${c$6.title} {
1557
4849
  font-size: ${tokens.fontSizes.md};
1558
4850
  font-weight: ${tokens.fontWeights.semibold};
1559
4851
  color: ${tokens.colors.text};
1560
4852
  margin: 0 0 0.375rem;
1561
4853
  letter-spacing: -0.005em;
1562
4854
  }`;
1563
- const body = rule`${c$7.body} {
4855
+ const body = rule`${c$6.body} {
1564
4856
  color: ${tokens.colors.textMuted};
1565
4857
  font-size: ${tokens.fontSizes.sm};
1566
4858
  line-height: ${tokens.lineHeights.normal};
@@ -1570,7 +4862,7 @@ const body = rule`${c$7.body} {
1570
4862
  //#region ../ui/src/components/steps/steps.tsx
1571
4863
  function Steps(props) {
1572
4864
  return /* @__PURE__ */ jsx("div", {
1573
- class: [root$7, props.class],
4865
+ class: [root$6, props.class],
1574
4866
  children: props.children
1575
4867
  });
1576
4868
  }
@@ -1650,6 +4942,38 @@ const darkTheme = createTheme(tokens, {
1650
4942
  }
1651
4943
  });
1652
4944
 
4945
+ //#endregion
4946
+ //#region ../ui/src/theme/provider.tsx
4947
+ /** @jsxImportSource @semajsx/dom */
4948
+ /**
4949
+ * ThemeProvider component
4950
+ *
4951
+ * Wraps the application to provide theme context and inject CSS custom properties.
4952
+ * Components can access theme tokens via ctx.inject(ThemeContext).
4953
+ *
4954
+ * @example
4955
+ * ```tsx
4956
+ * import { ThemeProvider } from "@semajsx/ui/theme";
4957
+ *
4958
+ * function App() {
4959
+ * return (
4960
+ * <ThemeProvider>
4961
+ * <Button>Themed button</Button>
4962
+ * </ThemeProvider>
4963
+ * );
4964
+ * }
4965
+ *
4966
+ * // With dark theme
4967
+ * <ThemeProvider theme="dark">
4968
+ * <App />
4969
+ * </ThemeProvider>
4970
+ * ```
4971
+ */
4972
+ /**
4973
+ * Context for passing theme tokens through the component tree
4974
+ */
4975
+ const ThemeContext = context("semajsx-theme");
4976
+
1653
4977
  //#endregion
1654
4978
  //#region ../ui/src/components/button/button.style.ts
1655
4979
  /**
@@ -1658,23 +4982,7 @@ const darkTheme = createTheme(tokens, {
1658
4982
  * All styles reference theme tokens via CSS custom properties,
1659
4983
  * so they respond to theme changes automatically.
1660
4984
  */
1661
- var button_style_exports = /* @__PURE__ */ __exportAll({
1662
- danger: () => danger,
1663
- dangerStates: () => dangerStates,
1664
- ghost: () => ghost,
1665
- ghostStates: () => ghostStates,
1666
- icon: () => icon,
1667
- lg: () => lg$2,
1668
- md: () => md$2,
1669
- outline: () => outline,
1670
- outlineStates: () => outlineStates,
1671
- root: () => root$6,
1672
- rootStates: () => rootStates$1,
1673
- sm: () => sm$2,
1674
- solid: () => solid,
1675
- solidStates: () => solidStates
1676
- });
1677
- const c$6 = classes([
4985
+ const c$5 = classes([
1678
4986
  "root",
1679
4987
  "solid",
1680
4988
  "outline",
@@ -1685,7 +4993,7 @@ const c$6 = classes([
1685
4993
  "danger",
1686
4994
  "icon"
1687
4995
  ]);
1688
- const root$6 = rule`${c$6.root} {
4996
+ const root$5 = rule`${c$5.root} {
1689
4997
  display: inline-flex;
1690
4998
  align-items: center;
1691
4999
  justify-content: center;
@@ -1700,155 +5008,121 @@ const root$6 = rule`${c$6.root} {
1700
5008
  user-select: none;
1701
5009
  transition: all ${tokens.transitions.normal};
1702
5010
  }`;
1703
- const rootStates$1 = rules(rule`${c$6.root}:focus-visible {
5011
+ const rootStates$1 = rules(rule`${c$5.root}:focus-visible {
1704
5012
  outline: 2px solid ${tokens.colors.primary};
1705
5013
  outline-offset: 2px;
1706
- }`, rule`${c$6.root}:disabled {
5014
+ }`, rule`${c$5.root}:disabled {
1707
5015
  opacity: 0.5;
1708
5016
  cursor: not-allowed;
1709
5017
  pointer-events: none;
1710
5018
  }`);
1711
- const solid = rule`${c$6.solid} {
5019
+ const solid = rule`${c$5.solid} {
1712
5020
  background: ${tokens.colors.primary};
1713
5021
  color: ${tokens.colors.onPrimary};
1714
5022
  border-color: ${tokens.colors.primary};
1715
5023
  }`;
1716
- const solidStates = rules(rule`${c$6.solid}:hover:not(:disabled) {
5024
+ const solidStates = rules(rule`${c$5.solid}:hover:not(:disabled) {
1717
5025
  background: ${tokens.colors.primaryHover};
1718
5026
  border-color: ${tokens.colors.primaryHover};
1719
5027
  transform: scale(1.02);
1720
5028
  box-shadow: ${tokens.shadows.primaryGlow};
1721
- }`, rule`${c$6.solid}:active:not(:disabled) {
5029
+ }`, rule`${c$5.solid}:active:not(:disabled) {
1722
5030
  background: ${tokens.colors.primaryActive};
1723
5031
  border-color: ${tokens.colors.primaryActive};
1724
5032
  transform: scale(0.98);
1725
5033
  box-shadow: none;
1726
5034
  }`);
1727
- const outline = rule`${c$6.outline} {
5035
+ const outline = rule`${c$5.outline} {
1728
5036
  background: transparent;
1729
5037
  color: ${tokens.colors.primary};
1730
5038
  border-color: ${tokens.colors.primary};
1731
5039
  }`;
1732
- const outlineStates = rules(rule`${c$6.outline}:hover:not(:disabled) {
5040
+ const outlineStates = rules(rule`${c$5.outline}:hover:not(:disabled) {
1733
5041
  background: ${tokens.colors.primary};
1734
5042
  color: ${tokens.colors.onPrimary};
1735
5043
  transform: scale(1.02);
1736
- }`, rule`${c$6.outline}:active:not(:disabled) {
5044
+ }`, rule`${c$5.outline}:active:not(:disabled) {
1737
5045
  background: ${tokens.colors.primaryActive};
1738
5046
  color: ${tokens.colors.onPrimary};
1739
5047
  transform: scale(0.98);
1740
5048
  }`);
1741
- const ghost = rule`${c$6.ghost} {
5049
+ const ghost = rule`${c$5.ghost} {
1742
5050
  background: transparent;
1743
5051
  color: ${tokens.colors.text};
1744
5052
  border-color: transparent;
1745
5053
  }`;
1746
- const ghostStates = rules(rule`${c$6.ghost}:hover:not(:disabled) {
5054
+ const ghostStates = rules(rule`${c$5.ghost}:hover:not(:disabled) {
1747
5055
  background: ${tokens.colors.surface};
1748
- }`, rule`${c$6.ghost}:active:not(:disabled) {
5056
+ }`, rule`${c$5.ghost}:active:not(:disabled) {
1749
5057
  background: ${tokens.colors.border};
1750
5058
  }`);
1751
- const danger = rule`${c$6.danger} {
5059
+ const danger = rule`${c$5.danger} {
1752
5060
  background: ${tokens.colors.danger};
1753
5061
  color: ${tokens.colors.onDanger};
1754
5062
  border-color: ${tokens.colors.danger};
1755
5063
  }`;
1756
- const dangerStates = rules(rule`${c$6.danger}:hover:not(:disabled) {
5064
+ const dangerStates = rules(rule`${c$5.danger}:hover:not(:disabled) {
1757
5065
  background: ${tokens.colors.dangerHover};
1758
5066
  border-color: ${tokens.colors.dangerHover};
1759
5067
  transform: scale(1.02);
1760
- }`, rule`${c$6.danger}:focus-visible {
5068
+ }`, rule`${c$5.danger}:focus-visible {
1761
5069
  outline-color: ${tokens.colors.danger};
1762
5070
  }`);
1763
- const sm$2 = rule`${c$6.sm} {
5071
+ const sm$2 = rule`${c$5.sm} {
1764
5072
  padding: ${tokens.space.sm} ${tokens.space.lg};
1765
5073
  font-size: ${tokens.fontSizes.sm};
1766
5074
  }`;
1767
- const md$2 = rule`${c$6.md} {
5075
+ const md$2 = rule`${c$5.md} {
1768
5076
  padding: ${tokens.space.md} ${tokens.space.xl};
1769
5077
  font-size: ${tokens.fontSizes.md};
1770
5078
  }`;
1771
- const lg$2 = rule`${c$6.lg} {
5079
+ const lg$2 = rule`${c$5.lg} {
1772
5080
  padding: 0.875rem 1.75rem;
1773
5081
  font-size: ${tokens.fontSizes.lg};
1774
5082
  }`;
1775
- const icon = rule`${c$6.icon} {
5083
+ const icon = rule`${c$5.icon} {
1776
5084
  display: inline-flex;
1777
5085
  flex-shrink: 0;
1778
5086
  }`;
1779
5087
 
1780
5088
  //#endregion
1781
- //#region ../ui/src/components/code-block/code-block.style.ts
1782
- /**
1783
- * CodeBlock component styles
1784
- *
1785
- * Dark-themed code display with optional language header.
1786
- */
1787
- var code_block_style_exports = /* @__PURE__ */ __exportAll({
1788
- header: () => header,
1789
- inline: () => inline,
1790
- lang: () => lang,
1791
- pre: () => pre,
1792
- root: () => root$5
1793
- });
1794
- const c$5 = classes([
1795
- "root",
1796
- "header",
1797
- "lang",
1798
- "pre",
1799
- "inline"
1800
- ]);
1801
- const root$5 = rule`${c$5.root} {
1802
- margin: 1.5rem 0;
1803
- border-radius: ${tokens.radii.md};
1804
- overflow: hidden;
1805
- border: 0.5px solid rgba(0, 0, 0, 0.1);
1806
- font-family: ${tokens.fonts.mono};
1807
- }`;
1808
- const header = rule`${c$5.header} {
1809
- background: #161617;
1810
- padding: 0.5rem 1.25rem;
1811
- display: flex;
1812
- justify-content: space-between;
1813
- align-items: center;
1814
- }`;
1815
- const lang = rule`${c$5.lang} {
1816
- color: #86868b;
1817
- font-size: 0.6875rem;
1818
- text-transform: uppercase;
1819
- font-weight: ${tokens.fontWeights.semibold};
1820
- letter-spacing: 0.04em;
1821
- font-family: ${tokens.fonts.mono};
1822
- }`;
1823
- const pre = rule`${c$5.pre} {
1824
- background: #1d1d1f;
1825
- color: #e5e5ea;
1826
- padding: 1.25rem 1.5rem;
1827
- overflow-x: auto;
1828
- margin: 0;
1829
- font-size: ${tokens.fontSizes.sm};
1830
- line-height: 1.65;
1831
- font-family: ${tokens.fonts.mono};
1832
- }`;
1833
- const inline = rule`${c$5.inline} {
1834
- background: rgba(0, 0, 0, 0.04);
1835
- padding: 0.15rem 0.4rem;
1836
- border-radius: 5px;
1837
- font-size: 0.875em;
1838
- border: 0.5px solid rgba(0, 0, 0, 0.06);
1839
- font-family: ${tokens.fonts.mono};
1840
- }`;
5089
+ //#region ../ui/src/components/button/button.tsx
5090
+ const variantStyles = {
5091
+ solid: [solid, solidStates],
5092
+ outline: [outline, outlineStates],
5093
+ ghost: [ghost, ghostStates]
5094
+ };
5095
+ const sizeStyles$2 = {
5096
+ sm: sm$2,
5097
+ md: md$2,
5098
+ lg: lg$2
5099
+ };
5100
+ function Button(props) {
5101
+ const variant = props.variant ?? "solid";
5102
+ const size = props.size ?? "md";
5103
+ const color = props.color ?? "default";
5104
+ return /* @__PURE__ */ jsx("button", {
5105
+ type: props.type ?? "button",
5106
+ disabled: props.disabled,
5107
+ class: [
5108
+ root$5,
5109
+ rootStates$1,
5110
+ ...variantStyles[variant],
5111
+ sizeStyles$2[size],
5112
+ color === "danger" && [danger, dangerStates],
5113
+ props.class
5114
+ ],
5115
+ onClick: props.onClick,
5116
+ "aria-label": props["aria-label"],
5117
+ children: props.children
5118
+ });
5119
+ }
1841
5120
 
1842
5121
  //#endregion
1843
5122
  //#region ../ui/src/components/separator/separator.style.ts
1844
5123
  /**
1845
5124
  * Separator component styles
1846
5125
  */
1847
- var separator_style_exports = /* @__PURE__ */ __exportAll({
1848
- horizontal: () => horizontal,
1849
- root: () => root$4,
1850
- vertical: () => vertical
1851
- });
1852
5126
  const c$4 = classes(["root", "vertical"]);
1853
5127
  const root$4 = rule`${c$4.root} {
1854
5128
  border: none;
@@ -1867,20 +5141,28 @@ const vertical = rule`${c$4.vertical} {
1867
5141
  margin: 0 ${tokens.space.lg};
1868
5142
  }`;
1869
5143
 
5144
+ //#endregion
5145
+ //#region ../ui/src/components/separator/separator.tsx
5146
+ function Separator(props) {
5147
+ const orientation = props.orientation ?? "horizontal";
5148
+ return /* @__PURE__ */ jsx("div", {
5149
+ role: "separator",
5150
+ "aria-orientation": orientation,
5151
+ class: [
5152
+ root$4,
5153
+ horizontal,
5154
+ orientation === "vertical" && vertical,
5155
+ props.class
5156
+ ],
5157
+ style: props.style
5158
+ });
5159
+ }
5160
+
1870
5161
  //#endregion
1871
5162
  //#region ../ui/src/components/input/input.style.ts
1872
5163
  /**
1873
5164
  * Input component styles
1874
5165
  */
1875
- var input_style_exports = /* @__PURE__ */ __exportAll({
1876
- label: () => label$1,
1877
- lg: () => lg$1,
1878
- md: () => md$1,
1879
- root: () => root$3,
1880
- rootStates: () => rootStates,
1881
- sm: () => sm$1,
1882
- wrapper: () => wrapper
1883
- });
1884
5166
  const c$3 = classes([
1885
5167
  "root",
1886
5168
  "wrapper",
@@ -1937,19 +5219,47 @@ const lg$1 = rule`${c$3.lg} {
1937
5219
  font-size: ${tokens.fontSizes.lg};
1938
5220
  }`;
1939
5221
 
5222
+ //#endregion
5223
+ //#region ../ui/src/components/input/input.tsx
5224
+ const sizeStyles$1 = {
5225
+ sm: sm$1,
5226
+ md: md$1,
5227
+ lg: lg$1
5228
+ };
5229
+ function Input(props) {
5230
+ const size = props.size ?? "md";
5231
+ const inputId = props.id ?? props.name;
5232
+ const input = /* @__PURE__ */ jsx("input", {
5233
+ type: props.type ?? "text",
5234
+ id: inputId,
5235
+ name: props.name,
5236
+ placeholder: props.placeholder,
5237
+ value: props.value,
5238
+ disabled: props.disabled,
5239
+ readOnly: props.readOnly,
5240
+ class: [
5241
+ root$3,
5242
+ rootStates,
5243
+ sizeStyles$1[size],
5244
+ props.class
5245
+ ]
5246
+ });
5247
+ if (props.label) return /* @__PURE__ */ jsxs("div", {
5248
+ class: wrapper,
5249
+ children: [/* @__PURE__ */ jsx("label", {
5250
+ class: label$1,
5251
+ for: inputId,
5252
+ children: props.label
5253
+ }), input]
5254
+ });
5255
+ return input;
5256
+ }
5257
+
1940
5258
  //#endregion
1941
5259
  //#region ../ui/src/components/avatar/avatar.style.ts
1942
5260
  /**
1943
5261
  * Avatar component styles
1944
5262
  */
1945
- var avatar_style_exports = /* @__PURE__ */ __exportAll({
1946
- fallback: () => fallback,
1947
- image: () => image,
1948
- lg: () => lg,
1949
- md: () => md,
1950
- root: () => root$2,
1951
- sm: () => sm
1952
- });
1953
5263
  const c$2 = classes([
1954
5264
  "root",
1955
5265
  "image",
@@ -1997,12 +5307,39 @@ const lg = rule`${c$2.lg} {
1997
5307
  font-size: ${tokens.fontSizes.md};
1998
5308
  }`;
1999
5309
 
5310
+ //#endregion
5311
+ //#region ../ui/src/components/avatar/avatar.tsx
5312
+ const sizeStyles = {
5313
+ sm,
5314
+ md,
5315
+ lg
5316
+ };
5317
+ function Avatar(props) {
5318
+ const size = props.size ?? "md";
5319
+ return /* @__PURE__ */ jsx("div", {
5320
+ class: [
5321
+ root$2,
5322
+ sizeStyles[size],
5323
+ props.class
5324
+ ],
5325
+ role: "img",
5326
+ "aria-label": props.alt ?? props.initials ?? "Avatar",
5327
+ children: props.src ? /* @__PURE__ */ jsx("img", {
5328
+ class: image,
5329
+ src: props.src,
5330
+ alt: props.alt ?? ""
5331
+ }) : /* @__PURE__ */ jsx("span", {
5332
+ class: fallback,
5333
+ children: props.initials ?? "?"
5334
+ })
5335
+ });
5336
+ }
5337
+
2000
5338
  //#endregion
2001
5339
  //#region ../ui/src/components/kbd/kbd.style.ts
2002
5340
  /**
2003
5341
  * Kbd (keyboard) component styles
2004
5342
  */
2005
- var kbd_style_exports = /* @__PURE__ */ __exportAll({ root: () => root$1 });
2006
5343
  const c$1 = classes(["root"]);
2007
5344
  const root$1 = rule`${c$1.root} {
2008
5345
  display: inline-flex;
@@ -2024,20 +5361,20 @@ const root$1 = rule`${c$1.root} {
2024
5361
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
2025
5362
  }`;
2026
5363
 
5364
+ //#endregion
5365
+ //#region ../ui/src/components/kbd/kbd.tsx
5366
+ function Kbd(props) {
5367
+ return /* @__PURE__ */ jsx("kbd", {
5368
+ class: [root$1, props.class],
5369
+ children: props.children
5370
+ });
5371
+ }
5372
+
2027
5373
  //#endregion
2028
5374
  //#region ../ui/src/components/switch/switch.style.ts
2029
5375
  /**
2030
5376
  * Switch component styles
2031
5377
  */
2032
- var switch_style_exports = /* @__PURE__ */ __exportAll({
2033
- label: () => label,
2034
- root: () => root,
2035
- rootDisabled: () => rootDisabled,
2036
- thumb: () => thumb,
2037
- thumbOn: () => thumbOn,
2038
- track: () => track,
2039
- trackOn: () => trackOn
2040
- });
2041
5378
  const c = classes([
2042
5379
  "root",
2043
5380
  "track",
@@ -2091,165 +5428,6 @@ const label = rule`${c.label} {
2091
5428
  letter-spacing: -0.005em;
2092
5429
  }`;
2093
5430
 
2094
- //#endregion
2095
- //#region ../ui/src/css.ts
2096
- /**
2097
- * Pre-collected CSS for SSG/SSR usage
2098
- *
2099
- * Since @semajsx/style's inject() requires a DOM, this module provides
2100
- * all component CSS as a static string for server-side rendering.
2101
- *
2102
- * @example
2103
- * ```tsx
2104
- * import { componentCSS } from "@semajsx/ui/css";
2105
- *
2106
- * // Include in a <style> tag for SSG output
2107
- * <style>{componentCSS}</style>
2108
- * ```
2109
- */
2110
- function collectCSS(styles) {
2111
- return Object.values(styles).filter((v) => isStyleToken(v)).map((t) => t.__cssTemplate).join("\n");
2112
- }
2113
- /** All @semajsx/ui component CSS (theme variables + component rules) */
2114
- const componentCSS = [
2115
- lightTheme.__cssTemplate,
2116
- collectCSS(button_style_exports),
2117
- collectCSS(card_style_exports),
2118
- collectCSS(callout_style_exports),
2119
- collectCSS(badge_style_exports),
2120
- collectCSS(code_block_style_exports),
2121
- collectCSS(tabs_style_exports),
2122
- collectCSS(steps_style_exports),
2123
- collectCSS(separator_style_exports),
2124
- collectCSS(input_style_exports),
2125
- collectCSS(avatar_style_exports),
2126
- collectCSS(kbd_style_exports),
2127
- collectCSS(switch_style_exports)
2128
- ].join("\n");
2129
-
2130
- //#endregion
2131
- //#region ../ui/src/components/button/button.tsx
2132
- const variantStyles = {
2133
- solid: [solid, solidStates],
2134
- outline: [outline, outlineStates],
2135
- ghost: [ghost, ghostStates]
2136
- };
2137
- const sizeStyles$2 = {
2138
- sm: sm$2,
2139
- md: md$2,
2140
- lg: lg$2
2141
- };
2142
- function Button(props) {
2143
- const variant = props.variant ?? "solid";
2144
- const size = props.size ?? "md";
2145
- const color = props.color ?? "default";
2146
- return /* @__PURE__ */ jsx("button", {
2147
- type: props.type ?? "button",
2148
- disabled: props.disabled,
2149
- class: [
2150
- root$6,
2151
- rootStates$1,
2152
- ...variantStyles[variant],
2153
- sizeStyles$2[size],
2154
- color === "danger" && [danger, dangerStates],
2155
- props.class
2156
- ],
2157
- onClick: props.onClick,
2158
- "aria-label": props["aria-label"],
2159
- children: props.children
2160
- });
2161
- }
2162
-
2163
- //#endregion
2164
- //#region ../ui/src/components/separator/separator.tsx
2165
- function Separator(props) {
2166
- const orientation = props.orientation ?? "horizontal";
2167
- return /* @__PURE__ */ jsx("div", {
2168
- role: "separator",
2169
- "aria-orientation": orientation,
2170
- class: [
2171
- root$4,
2172
- horizontal,
2173
- orientation === "vertical" && vertical,
2174
- props.class
2175
- ],
2176
- style: props.style
2177
- });
2178
- }
2179
-
2180
- //#endregion
2181
- //#region ../ui/src/components/input/input.tsx
2182
- const sizeStyles$1 = {
2183
- sm: sm$1,
2184
- md: md$1,
2185
- lg: lg$1
2186
- };
2187
- function Input(props) {
2188
- const size = props.size ?? "md";
2189
- const inputId = props.id ?? props.name;
2190
- const input = /* @__PURE__ */ jsx("input", {
2191
- type: props.type ?? "text",
2192
- id: inputId,
2193
- name: props.name,
2194
- placeholder: props.placeholder,
2195
- value: props.value,
2196
- disabled: props.disabled,
2197
- readOnly: props.readOnly,
2198
- class: [
2199
- root$3,
2200
- rootStates,
2201
- sizeStyles$1[size],
2202
- props.class
2203
- ]
2204
- });
2205
- if (props.label) return /* @__PURE__ */ jsxs("div", {
2206
- class: wrapper,
2207
- children: [/* @__PURE__ */ jsx("label", {
2208
- class: label$1,
2209
- for: inputId,
2210
- children: props.label
2211
- }), input]
2212
- });
2213
- return input;
2214
- }
2215
-
2216
- //#endregion
2217
- //#region ../ui/src/components/avatar/avatar.tsx
2218
- const sizeStyles = {
2219
- sm,
2220
- md,
2221
- lg
2222
- };
2223
- function Avatar(props) {
2224
- const size = props.size ?? "md";
2225
- return /* @__PURE__ */ jsx("div", {
2226
- class: [
2227
- root$2,
2228
- sizeStyles[size],
2229
- props.class
2230
- ],
2231
- role: "img",
2232
- "aria-label": props.alt ?? props.initials ?? "Avatar",
2233
- children: props.src ? /* @__PURE__ */ jsx("img", {
2234
- class: image,
2235
- src: props.src,
2236
- alt: props.alt ?? ""
2237
- }) : /* @__PURE__ */ jsx("span", {
2238
- class: fallback,
2239
- children: props.initials ?? "?"
2240
- })
2241
- });
2242
- }
2243
-
2244
- //#endregion
2245
- //#region ../ui/src/components/kbd/kbd.tsx
2246
- function Kbd(props) {
2247
- return /* @__PURE__ */ jsx("kbd", {
2248
- class: [root$1, props.class],
2249
- children: props.children
2250
- });
2251
- }
2252
-
2253
5431
  //#endregion
2254
5432
  //#region ../ui/src/components/switch/switch.tsx
2255
5433
  function Switch(props) {
@@ -2344,7 +5522,7 @@ const DIFFICULTY_LABELS = {
2344
5522
  };
2345
5523
  function createComponents(options) {
2346
5524
  function Document(props) {
2347
- const { children, title, scripts, css } = props;
5525
+ const { children, title, scripts, css, styles } = props;
2348
5526
  const defaultTitle = options.title;
2349
5527
  const pageTitle = title ?? defaultTitle;
2350
5528
  const desc = options.description ?? "";
@@ -2385,7 +5563,8 @@ function createComponents(options) {
2385
5563
  css?.map((href) => /* @__PURE__ */ jsx("link", {
2386
5564
  rel: "stylesheet",
2387
5565
  href
2388
- }, href))
5566
+ }, href)),
5567
+ styles && styles.length > 0 && /* @__PURE__ */ jsx("style", { children: styles.join("\n") })
2389
5568
  ] }), /* @__PURE__ */ jsxs("body", { children: [children, scripts] })]
2390
5569
  });
2391
5570
  }
@@ -2395,7 +5574,7 @@ function createComponents(options) {
2395
5574
  return /* @__PURE__ */ jsxs("div", {
2396
5575
  class: "dt-root",
2397
5576
  children: [
2398
- /* @__PURE__ */ jsx("style", { children: componentCSS }),
5577
+ /* @__PURE__ */ jsx("style", { children: lightTheme.__cssTemplate }),
2399
5578
  /* @__PURE__ */ jsx("style", { children: THEME_CSS }),
2400
5579
  /* @__PURE__ */ jsx("nav", {
2401
5580
  class: "dt-glass-nav",
@@ -3463,6 +6642,7 @@ function docsTheme(options) {
3463
6642
  Avatar,
3464
6643
  Kbd,
3465
6644
  Switch,
6645
+ Mermaid,
3466
6646
  ...options.mdx?.components
3467
6647
  };
3468
6648
  return {
@@ -3470,7 +6650,11 @@ function docsTheme(options) {
3470
6650
  collections,
3471
6651
  routes,
3472
6652
  mdx: {
3473
- remarkPlugins: [remarkGfm, ...options.mdx?.remarkPlugins ?? []],
6653
+ remarkPlugins: [
6654
+ remarkGfm,
6655
+ remarkMermaid,
6656
+ ...options.mdx?.remarkPlugins ?? []
6657
+ ],
3474
6658
  rehypePlugins: options.mdx?.rehypePlugins,
3475
6659
  components: mdxComponents
3476
6660
  }
@@ -3515,5 +6699,5 @@ function docsTheme(options) {
3515
6699
  }
3516
6700
 
3517
6701
  //#endregion
3518
- export { Avatar, Badge, Button, Callout, Card, CodeBlock, ComponentPreview, Input, Kbd, Separator, Step, Steps, Switch, Tab, TabList, TabPanel, Tabs, docsTheme };
6702
+ export { Avatar, Badge, Button, Callout, Card, CodeBlock, ComponentPreview, Input, Kbd, Mermaid, Separator, Step, Steps, Switch, Tab, TabList, TabPanel, Tabs, docsTheme, remarkMermaid };
3519
6703
  //# sourceMappingURL=docs-theme.mjs.map