@zombie-mermaid/core 4.1.0 → 4.2.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.
package/dist/index.d.cts CHANGED
@@ -92,6 +92,23 @@ export declare type CommonRenderOptions = Pick<RenderOptions, 'bg' | 'fg' | 'lin
92
92
  /** How an edge path is interpolated between its routed points. */
93
93
  export declare type CurveStyle = 'linear' | 'basis' | 'natural' | 'step' | 'stepBefore' | 'stepAfter';
94
94
 
95
+ /**
96
+ * Decode Mermaid's entity codes (`#quot;`, `#lt;`, `#35;`, `#x5B;`), the way
97
+ * Mermaid writes characters that would otherwise end a label or break its
98
+ * syntax. Call it on a single already-parsed label, never on diagram source:
99
+ * decoding up front would let the characters it produces (`<`, `"`, `[`)
100
+ * change how the line parses, and would hit `#fff;` colors in style lines.
101
+ * Unknown names and out-of-range numbers are left untouched.
102
+ */
103
+ export declare function decodeMermaidEntities(text: string): string;
104
+
105
+ /**
106
+ * Decode HTML/XML entities (`&quot;`, `&lt;`, `&#35;`, `&#x5B;`) in one label,
107
+ * in a single pass so `&amp;lt;` becomes `&lt;` rather than `<`. Used by the
108
+ * ASCII renderer, which (unlike SVG) has no source-level decode step.
109
+ */
110
+ export declare function decodeXmlEntitiesInLabel(text: string): string;
111
+
95
112
  /** Default bg/fg when no colors are provided (zinc light) */
96
113
  export declare const DEFAULTS: Readonly<{
97
114
  bg: string;
@@ -118,7 +135,7 @@ export declare function detectDiagramType(text: string): DiagramType;
118
135
  * need to enumerate the types (e.g. the MCP `list_diagram_types` tool) never
119
136
  * keep a duplicate list that could drift.
120
137
  */
121
- export declare const DIAGRAM_TYPES: readonly ["flowchart", "sequence", "class", "er", "xychart", "architecture", "c4"];
138
+ export declare const DIAGRAM_TYPES: readonly ["flowchart", "sequence", "class", "er", "xychart", "architecture", "c4", "pie"];
122
139
 
123
140
  /**
124
141
  * Diagram color configuration.
@@ -1149,8 +1166,13 @@ export declare interface SvgEmitOptions {
1149
1166
  * See #239 — forces no root `role` so the link
1150
1167
  * stays reachable, regardless of `decorative`.
1151
1168
  * @param styleAttribute - Emit the root `style="…"` attribute. Default true.
1169
+ * @param description - Accessible description: a `<desc id="zm-desc-N">`
1170
+ * after the title plus `aria-describedby` on the root.
1171
+ * Follows the same rules as `title` (dropped when
1172
+ * decorative without interactive links). Used for
1173
+ * Mermaid's `accDescr`.
1152
1174
  */
1153
- export declare function svgOpenTag(width: number, height: number, colors: DiagramColors, transparent?: boolean, title?: string, decorative?: boolean, hasInteractiveLinks?: boolean, styleAttribute?: boolean): string;
1175
+ export declare function svgOpenTag(width: number, height: number, colors: DiagramColors, transparent?: boolean, title?: string, decorative?: boolean, hasInteractiveLinks?: boolean, styleAttribute?: boolean, description?: string): string;
1154
1176
 
1155
1177
  export declare type ThemeName = keyof typeof THEMES;
1156
1178
 
package/dist/index.d.ts CHANGED
@@ -92,6 +92,23 @@ export declare type CommonRenderOptions = Pick<RenderOptions, 'bg' | 'fg' | 'lin
92
92
  /** How an edge path is interpolated between its routed points. */
93
93
  export declare type CurveStyle = 'linear' | 'basis' | 'natural' | 'step' | 'stepBefore' | 'stepAfter';
94
94
 
95
+ /**
96
+ * Decode Mermaid's entity codes (`#quot;`, `#lt;`, `#35;`, `#x5B;`), the way
97
+ * Mermaid writes characters that would otherwise end a label or break its
98
+ * syntax. Call it on a single already-parsed label, never on diagram source:
99
+ * decoding up front would let the characters it produces (`<`, `"`, `[`)
100
+ * change how the line parses, and would hit `#fff;` colors in style lines.
101
+ * Unknown names and out-of-range numbers are left untouched.
102
+ */
103
+ export declare function decodeMermaidEntities(text: string): string;
104
+
105
+ /**
106
+ * Decode HTML/XML entities (`&quot;`, `&lt;`, `&#35;`, `&#x5B;`) in one label,
107
+ * in a single pass so `&amp;lt;` becomes `&lt;` rather than `<`. Used by the
108
+ * ASCII renderer, which (unlike SVG) has no source-level decode step.
109
+ */
110
+ export declare function decodeXmlEntitiesInLabel(text: string): string;
111
+
95
112
  /** Default bg/fg when no colors are provided (zinc light) */
96
113
  export declare const DEFAULTS: Readonly<{
97
114
  bg: string;
@@ -118,7 +135,7 @@ export declare function detectDiagramType(text: string): DiagramType;
118
135
  * need to enumerate the types (e.g. the MCP `list_diagram_types` tool) never
119
136
  * keep a duplicate list that could drift.
120
137
  */
121
- export declare const DIAGRAM_TYPES: readonly ["flowchart", "sequence", "class", "er", "xychart", "architecture", "c4"];
138
+ export declare const DIAGRAM_TYPES: readonly ["flowchart", "sequence", "class", "er", "xychart", "architecture", "c4", "pie"];
122
139
 
123
140
  /**
124
141
  * Diagram color configuration.
@@ -1149,8 +1166,13 @@ export declare interface SvgEmitOptions {
1149
1166
  * See #239 — forces no root `role` so the link
1150
1167
  * stays reachable, regardless of `decorative`.
1151
1168
  * @param styleAttribute - Emit the root `style="…"` attribute. Default true.
1169
+ * @param description - Accessible description: a `<desc id="zm-desc-N">`
1170
+ * after the title plus `aria-describedby` on the root.
1171
+ * Follows the same rules as `title` (dropped when
1172
+ * decorative without interactive links). Used for
1173
+ * Mermaid's `accDescr`.
1152
1174
  */
1153
- export declare function svgOpenTag(width: number, height: number, colors: DiagramColors, transparent?: boolean, title?: string, decorative?: boolean, hasInteractiveLinks?: boolean, styleAttribute?: boolean): string;
1175
+ export declare function svgOpenTag(width: number, height: number, colors: DiagramColors, transparent?: boolean, title?: string, decorative?: boolean, hasInteractiveLinks?: boolean, styleAttribute?: boolean, description?: string): string;
1154
1176
 
1155
1177
  export declare type ThemeName = keyof typeof THEMES;
1156
1178
 
package/dist/index.js CHANGED
@@ -83,10 +83,10 @@ function l(e) {
83
83
  function u(e) {
84
84
  return e.endsWith("%") ? Number(e.slice(0, -1)) / 100 * 255 : Number(e);
85
85
  }
86
- function ee(e) {
86
+ function d(e) {
87
87
  return e === void 0 ? 1 : e.endsWith("%") ? Number(e.slice(0, -1)) / 100 : Number(e);
88
88
  }
89
- function d(e) {
89
+ function f(e) {
90
90
  let t = e.trim();
91
91
  if (t.toLowerCase() === "transparent") return {
92
92
  r: 0,
@@ -104,7 +104,7 @@ function d(e) {
104
104
  r: u(e),
105
105
  g: u(t),
106
106
  b: u(n),
107
- a: ee(i)
107
+ a: d(i)
108
108
  };
109
109
  return [
110
110
  a.r,
@@ -115,7 +115,7 @@ function d(e) {
115
115
  }
116
116
  return null;
117
117
  }
118
- function f(e, t, n, r) {
118
+ function p(e, t, n, r) {
119
119
  let i, a;
120
120
  n === void 0 && r === void 0 ? (i = 50, a = 50) : n === void 0 ? (a = r ?? 50, i = 100 - a) : r === void 0 ? (i = n, a = 100 - i) : (i = n, a = r);
121
121
  let o = i + a;
@@ -130,15 +130,15 @@ function f(e, t, n, r) {
130
130
  a: c * s
131
131
  };
132
132
  }
133
- function te(e, t, n) {
134
- let r = d(e), i = d(t);
133
+ function ee(e, t, n) {
134
+ let r = f(e), i = f(t);
135
135
  if (!r || !i) return e;
136
- let a = f(r, i, n, 100 - n);
137
- return a ? m(a) : e;
136
+ let a = p(r, i, n, 100 - n);
137
+ return a ? h(a) : e;
138
138
  }
139
- var p = (e) => Math.min(255, Math.max(0, Math.round(e)));
140
- function m(e) {
141
- let t = p(e.r), n = p(e.g), r = p(e.b), i = Math.min(1, Math.max(0, e.a));
139
+ var m = (e) => Math.min(255, Math.max(0, Math.round(e)));
140
+ function h(e) {
141
+ let t = m(e.r), n = m(e.g), r = m(e.b), i = Math.min(1, Math.max(0, e.a));
142
142
  return i >= 1 ? "#" + [
143
143
  t,
144
144
  n,
@@ -147,8 +147,8 @@ function m(e) {
147
147
  }
148
148
  //#endregion
149
149
  //#region packages/core/src/statements.ts
150
- var h = /^[&#](?:#?[0-9]+|#?[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/, g = /* @__PURE__ */ new Set(["&", "#"]);
151
- function _(e) {
150
+ var g = /^[&#](?:#?[0-9]+|#?[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z0-9]*);/, _ = /* @__PURE__ */ new Set(["&", "#"]);
151
+ function te(e) {
152
152
  let t = null;
153
153
  for (let n = 0; n < e.length; n++) {
154
154
  let r = e[n];
@@ -160,8 +160,8 @@ function _(e) {
160
160
  t = r;
161
161
  continue;
162
162
  }
163
- if (g.has(r)) {
164
- let t = h.exec(e.slice(n));
163
+ if (_.has(r)) {
164
+ let t = g.exec(e.slice(n));
165
165
  if (t) {
166
166
  n += t[0].length - 1;
167
167
  continue;
@@ -183,8 +183,8 @@ function ne(e) {
183
183
  r = a, n += a;
184
184
  continue;
185
185
  }
186
- if (g.has(a)) {
187
- let t = h.exec(e.slice(i));
186
+ if (_.has(a)) {
187
+ let t = g.exec(e.slice(i));
188
188
  if (t) {
189
189
  n += t[0], i += t[0].length - 1;
190
190
  continue;
@@ -201,7 +201,7 @@ function ne(e) {
201
201
  function v(e) {
202
202
  let t = [], n = e.split("\n");
203
203
  for (let e = 0; e < n.length; e++) {
204
- let r = n[e].trim(), i = e + 1, a = _(r);
204
+ let r = n[e].trim(), i = e + 1, a = te(r);
205
205
  if (a !== -1 && (r = r.slice(0, a).trim()), r.length === 0) continue;
206
206
  let o = [];
207
207
  for (let e of ne(r)) {
@@ -227,33 +227,34 @@ var re = [
227
227
  "er",
228
228
  "xychart",
229
229
  "architecture",
230
- "c4"
230
+ "c4",
231
+ "pie"
231
232
  ];
232
- function b(e) {
233
- let t = y(e)[0]?.text.toLowerCase() ?? "";
234
- return /^xychart(?:-beta)?(?:\s|$)/.test(t) ? "xychart" : /^architecture(?:-beta)?\s*$/.test(t) ? "architecture" : /^c4(?:context|container|component|dynamic|deployment)\s*$/.test(t) ? "c4" : /^sequencediagram\s*$/.test(t) ? "sequence" : /^classdiagram\s*$/.test(t) ? "class" : /^erdiagram\s*$/.test(t) ? "er" : "flowchart";
233
+ function ie(e) {
234
+ let t = y(e)[0]?.text ?? "", n = t.toLowerCase();
235
+ return /^pie(?:\s|$)/.test(t) ? "pie" : /^xychart(?:-beta)?(?:\s|$)/.test(n) ? "xychart" : /^architecture(?:-beta)?\s*$/.test(n) ? "architecture" : /^c4(?:context|container|component|dynamic|deployment)\s*$/.test(n) ? "c4" : /^sequencediagram\s*$/.test(n) ? "sequence" : /^classdiagram\s*$/.test(n) ? "class" : /^erdiagram\s*$/.test(n) ? "er" : "flowchart";
235
236
  }
236
237
  //#endregion
237
238
  //#region packages/core/src/direction.ts
238
- function x(e) {
239
+ function b(e) {
239
240
  return e === "TD" || e === "TB" || e === "LR" || e === "BT" || e === "RL";
240
241
  }
241
- function S(e) {
242
+ function x(e) {
242
243
  let t = e?.toUpperCase();
243
- if (t === void 0 || !x(t)) throw Error(`Invalid direction: "${e}"`);
244
+ if (t === void 0 || !b(t)) throw Error(`Invalid direction: "${e}"`);
244
245
  return t;
245
246
  }
246
247
  //#endregion
247
248
  //#region packages/core/src/direction-override.ts
248
- function C(e, t) {
249
- return t === void 0 || !x(t) ? e : {
249
+ function S(e, t) {
250
+ return t === void 0 || !b(t) ? e : {
250
251
  ...e,
251
252
  direction: t
252
253
  };
253
254
  }
254
255
  //#endregion
255
256
  //#region packages/core/src/init-directive.ts
256
- var ie = /* @__PURE__ */ new Set([
257
+ var C = /* @__PURE__ */ new Set([
257
258
  "linear",
258
259
  "basis",
259
260
  "natural",
@@ -324,7 +325,7 @@ function E(e) {
324
325
  let e = { ...t };
325
326
  for (let [t, n] of Object.entries(e)) {
326
327
  if (t.toLowerCase() === "curve" && typeof n == "string") {
327
- ie.has(n) && (r.curve = n);
328
+ C.has(n) && (r.curve = n);
328
329
  continue;
329
330
  }
330
331
  t.toLowerCase() in w && r.ignored.push(t);
@@ -495,23 +496,23 @@ function he(e) {
495
496
  function O(e) {
496
497
  return e >= 4352 && e <= 4447 || e >= 11904 && e <= 12031 || e >= 12032 && e <= 12255 || e >= 12288 && e <= 12351 || e >= 12352 && e <= 12447 || e >= 12448 && e <= 12543 || e >= 12544 && e <= 12591 || e >= 12592 && e <= 12687 || e >= 12688 && e <= 12799 || e >= 12800 && e <= 13311 || e >= 13312 && e <= 19903 || e >= 19968 && e <= 40959 || e >= 44032 && e <= 55215 || e >= 63744 && e <= 64255 || e >= 65280 && e <= 65376 || e >= 65504 && e <= 65510 || e >= 131072;
497
498
  }
498
- var k = /\p{Emoji_Presentation}/u, A = /\p{Extended_Pictographic}/u;
499
- function j(e) {
499
+ var ge = /\p{Emoji_Presentation}/u, _e = /\p{Extended_Pictographic}/u;
500
+ function ve(e) {
500
501
  return e >= 9632 && e <= 9727;
501
502
  }
502
- function M(e) {
503
+ function k(e) {
503
504
  return e >= 8596 && e <= 8601 || e === 8617 || e === 8618;
504
505
  }
505
- function N(e) {
506
- if (k.test(e)) return !0;
506
+ function A(e) {
507
+ if (ge.test(e)) return !0;
507
508
  let t = e.codePointAt(0);
508
- return t !== void 0 && j(t) || t !== void 0 && M(t) ? !1 : A.test(e);
509
+ return t !== void 0 && ve(t) || t !== void 0 && k(t) ? !1 : _e.test(e);
509
510
  }
510
- function P(e) {
511
+ function j(e) {
511
512
  let t = e.codePointAt(0);
512
- return t === void 0 ? !1 : O(t) || N(e);
513
+ return t === void 0 ? !1 : O(t) || A(e);
513
514
  }
514
- function F(e) {
515
+ function M(e) {
515
516
  let t = e.codePointAt(0);
516
517
  if (t === void 0) return 0;
517
518
  if (Object.hasOwn(D, e)) {
@@ -520,7 +521,7 @@ function F(e) {
520
521
  if (t !== void 0) return t;
521
522
  }
522
523
  if (he(t)) return 0;
523
- if (O(t) || N(e)) return 2;
524
+ if (O(t) || A(e)) return 2;
524
525
  let n = e.normalize("NFD")[0];
525
526
  if (n !== void 0 && n !== e) {
526
527
  let e = D[n];
@@ -528,29 +529,29 @@ function F(e) {
528
529
  }
529
530
  return e === " " ? .3 : pe.has(e) ? 1.5 : fe.has(e) ? 1.2 : de.has(e) ? .4 : me.has(e) ? .5 : e === "r" ? .8 : t >= 65 && t <= 90 ? 1.2 : 1;
530
531
  }
531
- var I = .6, L = !1;
532
- function R(e) {
532
+ var N = .6, P = !1;
533
+ function F(e) {
533
534
  return /mono|consol|menlo|courier|\bcode\b/i.test(e);
534
535
  }
535
- function ge(e) {
536
- L = e;
536
+ function ye(e) {
537
+ P = e;
537
538
  }
538
- function z(e, t, n) {
539
+ function I(e, t, n) {
539
540
  let r = t * .15;
540
- if (L) {
541
+ if (P) {
541
542
  let n = 0;
542
543
  for (let t of e) n += 1;
543
- return n * t * I + r;
544
+ return n * t * N + r;
544
545
  }
545
546
  let i = n >= 600 ? .6 : n >= 500 ? .57 : .54, a = 0;
546
- for (let t of e) a += F(t);
547
+ for (let t of e) a += M(t);
547
548
  return a * t * i + r;
548
549
  }
549
- var B = 1.3;
550
- function _e(e, t, n) {
551
- let r = e.split("\n"), i = t * B, a = 0;
550
+ var L = 1.3;
551
+ function be(e, t, n) {
552
+ let r = e.split("\n"), i = t * L, a = 0;
552
553
  for (let e of r) {
553
- let r = z(e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, ""), t, n);
554
+ let r = I(e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, ""), t, n);
554
555
  r > a && (a = r);
555
556
  }
556
557
  return {
@@ -562,24 +563,41 @@ function _e(e, t, n) {
562
563
  }
563
564
  //#endregion
564
565
  //#region packages/core/src/render-utils.ts
565
- function ve(e) {
566
+ function xe(e) {
566
567
  return Number.isFinite(e) ? Number(e.toFixed(2)) : 0;
567
568
  }
568
- function V(e, ...t) {
569
+ function R(e, ...t) {
569
570
  let n = e[0] ?? "";
570
571
  for (let r = 0; r < t.length; r++) {
571
572
  let i = t[r];
572
- n += String(typeof i == "number" ? ve(i) : i), n += e[r + 1] ?? "";
573
+ n += String(typeof i == "number" ? xe(i) : i), n += e[r + 1] ?? "";
573
574
  }
574
575
  return n;
575
576
  }
576
577
  //#endregion
577
578
  //#region packages/core/src/multiline-utils.ts
578
- function ye(e) {
579
+ function Se(e) {
579
580
  let t = e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
580
- return (t.length >= 2 && t.startsWith("`") && t.endsWith("`") ? t.slice(1, -1) : t).replace(/<br\s*\/?>/gi, "\n").replace(/\\n/g, "\n").replace(/<\/?(?:sub|sup|small|mark)\s*>/gi, "").replace(/\*\*(.+?)\*\*/g, "<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g, "<i>$1</i>").replace(/~~(.+?)~~/g, "<s>$1</s>");
581
+ return V((t.length >= 2 && t.startsWith("`") && t.endsWith("`") ? t.slice(1, -1) : t).replace(/<br\s*\/?>/gi, "\n").replace(/\\n/g, "\n").replace(/<\/?(?:sub|sup|small|mark)\s*>/gi, "").replace(/\*\*(.+?)\*\*/g, "<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g, "<i>$1</i>").replace(/~~(.+?)~~/g, "<s>$1</s>"));
582
+ }
583
+ var Ce = 1114111, z = {
584
+ quot: "\"",
585
+ amp: "&",
586
+ lt: "<",
587
+ gt: ">",
588
+ apos: "'",
589
+ nbsp: "\xA0"
590
+ };
591
+ function B(e) {
592
+ return Number.isInteger(e) && e > 0 && e <= Ce && !(e >= 55296 && e <= 57343) ? String.fromCodePoint(e) : void 0;
593
+ }
594
+ function V(e) {
595
+ return e.replace(/#([xX][0-9a-fA-F]+|[0-9]+|[a-zA-Z]+);/g, (e, t) => /^x/i.test(t) ? B(parseInt(t.slice(1), 16)) ?? e : /^[0-9]+$/.test(t) ? B(parseInt(t, 10)) ?? e : z[t.toLowerCase()] ?? e);
596
+ }
597
+ function we(e) {
598
+ return e.replace(/&(#[xX][0-9a-fA-F]+|#[0-9]+|quot|amp|lt|gt|apos);/g, (e, t) => /^#x/i.test(t) ? B(parseInt(t.slice(2), 16)) ?? e : t.startsWith("#") ? B(parseInt(t.slice(1), 10)) ?? e : z[t] ?? e);
581
599
  }
582
- function be(e) {
600
+ function Te(e) {
583
601
  return e.replace(/<\/?(?:b|strong|i|em|u|s|del)\s*>/gi, "");
584
602
  }
585
603
  function H(e) {
@@ -589,7 +607,7 @@ function U(e) {
589
607
  return e.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
590
608
  }
591
609
  var W = /<(\/)?(?:(b|strong)|(i|em)|(u)|(s|del))\s*>/gi;
592
- function xe(e) {
610
+ function Ee(e) {
593
611
  let t = [], n = !1, r = !1, i = !1, a = !1, o = 0;
594
612
  W.lastIndex = 0;
595
613
  let s;
@@ -612,10 +630,10 @@ function xe(e) {
612
630
  strikethrough: a
613
631
  }), t;
614
632
  }
615
- var Se = /<\/?(?:b|strong|i|em|u|s|del)\s*>/i;
633
+ var De = /<\/?(?:b|strong|i|em|u|s|del)\s*>/i;
616
634
  function G(e) {
617
- if (!Se.test(e)) return H(e);
618
- let t = xe(e);
635
+ if (!De.test(e)) return H(e);
636
+ let t = Ee(e);
619
637
  return t.length === 0 ? "" : t.every((e) => !e.bold && !e.italic && !e.underline && !e.strikethrough) ? t.map((e) => H(e.text)).join("") : t.map((e) => {
620
638
  let t = H(e.text);
621
639
  if (!e.bold && !e.italic && !e.underline && !e.strikethrough) return t;
@@ -627,13 +645,13 @@ function G(e) {
627
645
  }
628
646
  function K(e, t, n, r, i, a = .35) {
629
647
  let o = e.split("\n");
630
- if (o.length === 1) return V`<text x="${t}" y="${n}" ${i} dy="${r * a}">${G(e)}</text>`;
631
- let s = r * B, c = -((o.length - 1) / 2) * s + r * a;
632
- return V`<text x="${t}" y="${n}" ${i}>${o.map((e, n) => V`<tspan x="${t}" dy="${n === 0 ? c : s}">${G(e)}</tspan>`).join("")}</text>`;
648
+ if (o.length === 1) return R`<text x="${t}" y="${n}" ${i} dy="${r * a}">${G(e)}</text>`;
649
+ let s = r * L, c = -((o.length - 1) / 2) * s + r * a;
650
+ return R`<text x="${t}" y="${n}" ${i}>${o.map((e, n) => R`<tspan x="${t}" dy="${n === 0 ? c : s}">${G(e)}</tspan>`).join("")}</text>`;
633
651
  }
634
- function Ce(e, t, n, r, i, a, o, s, c) {
652
+ function Oe(e, t, n, r, i, a, o, s, c) {
635
653
  let l = r + o * 2, u = i + o * 2;
636
- return `${V`<rect x="${t - l / 2}" y="${n - u / 2}" ` + V`width="${l}" height="${u}" ${c} />`}\n${K(e, t, n, a, s)}`;
654
+ return `${R`<rect x="${t - l / 2}" y="${n - u / 2}" ` + R`width="${l}" height="${u}" ${c} />`}\n${K(e, t, n, a, s)}`;
637
655
  }
638
656
  //#endregion
639
657
  //#region packages/core/src/style-directives.ts
@@ -648,7 +666,7 @@ function q(e) {
648
666
  }
649
667
  return n;
650
668
  }
651
- function we(e, t) {
669
+ function ke(e, t) {
652
670
  let n = e.match(/^classDef\s+([\w,-]+)\s+(.+)$/);
653
671
  if (!n) return !1;
654
672
  let r = q(n[2]);
@@ -658,14 +676,14 @@ function we(e, t) {
658
676
  }
659
677
  return !0;
660
678
  }
661
- function Te(e, t) {
679
+ function Ae(e, t) {
662
680
  let n = e.match(/^class\s+([\w-]+(?:\s*,\s*[\w-]+)*)\s+([\w-]+)\s*;?\s*$/);
663
681
  if (!n) return !1;
664
682
  let r = n[2];
665
683
  for (let e of n[1].split(",")) t.classAssignments.set(e.trim(), r);
666
684
  return !0;
667
685
  }
668
- function Ee(e, t) {
686
+ function je(e, t) {
669
687
  let n = e.match(/^cssClass\s+"([^"]*)"\s+([\w-]+)\s*;?\s*$/);
670
688
  if (!n) return !1;
671
689
  let r = n[2];
@@ -675,7 +693,7 @@ function Ee(e, t) {
675
693
  }
676
694
  return !0;
677
695
  }
678
- function De(e, t) {
696
+ function Me(e, t) {
679
697
  let n = e.match(/^style\s+([\w,-]+)\s+(.+)$/);
680
698
  if (!n) return !1;
681
699
  let r = q(n[2]);
@@ -685,14 +703,14 @@ function De(e, t) {
685
703
  });
686
704
  return !0;
687
705
  }
688
- function Oe(e) {
706
+ function Ne(e) {
689
707
  let t = e.match(/^(.+?):::([\w][\w-]*)$/);
690
708
  return t ? {
691
709
  id: t[1],
692
710
  className: t[2]
693
711
  } : { id: e };
694
712
  }
695
- function ke(e, t) {
713
+ function Pe(e, t) {
696
714
  let n, r = t.classDefs.get("default");
697
715
  r && (n = { ...r });
698
716
  let i = t.classAssignments.get(e);
@@ -709,12 +727,12 @@ function ke(e, t) {
709
727
  ...a
710
728
  } : { ...a }), n;
711
729
  }
712
- function Ae(e) {
730
+ function Fe(e) {
713
731
  if (e) return /^-?[a-zA-Z_][a-zA-Z0-9_-]*$/.test(e) ? e : void 0;
714
732
  }
715
733
  //#endregion
716
734
  //#region packages/core/src/theme.ts
717
- var je = {
735
+ var Ie = {
718
736
  bg: "#FFFFFF",
719
737
  fg: "#27272A"
720
738
  }, J = {
@@ -729,7 +747,7 @@ var je = {
729
747
  groupHeader: 5,
730
748
  innerStroke: 12,
731
749
  keyBadge: 10
732
- }, Me = {
750
+ }, Le = {
733
751
  "zinc-light": {
734
752
  bg: "#FFFFFF",
735
753
  fg: "#27272A"
@@ -830,7 +848,7 @@ var je = {
830
848
  muted: "#5c6370"
831
849
  }
832
850
  };
833
- function Ne(e) {
851
+ function Re(e) {
834
852
  let t = e.colors ?? {}, n = e.type === "dark", r = (t) => e.tokenColors?.find((e) => Array.isArray(e.scope) ? e.scope.includes(t) : e.scope === t)?.settings?.foreground;
835
853
  return {
836
854
  bg: t["editor.background"] ?? (n ? "#1e1e1e" : "#ffffff"),
@@ -842,16 +860,16 @@ function Ne(e) {
842
860
  border: t["editorWidget.border"] ?? void 0
843
861
  };
844
862
  }
845
- var Pe = /[<>{};]/;
846
- function Fe(e) {
863
+ var Y = /[<>{};]/;
864
+ function ze(e) {
847
865
  let t = e.trim();
848
- if (!t.startsWith("var(") || !t.endsWith(")") || Pe.test(t)) return !1;
866
+ if (!t.startsWith("var(") || !t.endsWith(")") || Y.test(t)) return !1;
849
867
  let n = 0;
850
868
  for (let e of t) if (e === "(") n++;
851
869
  else if (e === ")" && (n--, n < 0)) return !1;
852
870
  return n === 0;
853
871
  }
854
- var Ie = /* @__PURE__ */ new Set([
872
+ var Be = /* @__PURE__ */ new Set([
855
873
  "sans-serif",
856
874
  "serif",
857
875
  "monospace",
@@ -866,15 +884,15 @@ var Ie = /* @__PURE__ */ new Set([
866
884
  "emoji",
867
885
  "fangsong"
868
886
  ]);
869
- function Le(e) {
887
+ function Ve(e) {
870
888
  let t = e.trim();
871
- return t.includes(",") ? !0 : Ie.has(t.toLowerCase());
889
+ return t.includes(",") ? !0 : Be.has(t.toLowerCase());
872
890
  }
873
- function Y(e) {
891
+ function X(e) {
874
892
  return e === void 0 || e.trim() === "" ? "<style>" : `<style nonce="${U(e)}">`;
875
893
  }
876
- function X(e, t, n) {
877
- let r = Fe(e), i = r ? e.trim() : e.replace(/[<>{};'"]/g, ""), a = r || Le(e) ? [] : [`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;500;600;700&amp;display=swap');`], o = `
894
+ function He(e, t, n) {
895
+ let r = ze(e), i = r ? e.trim() : e.replace(/[<>{};'"]/g, ""), a = r || Ve(e) ? [] : [`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(i)}:wght@400;500;600;700&amp;display=swap');`], o = `
878
896
  /* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
879
897
  --_text: var(--fg);
880
898
  --_text-sec: var(--muted, color-mix(in srgb, var(--fg) ${J.textSec}%, var(--bg)));
@@ -889,7 +907,7 @@ function X(e, t, n) {
889
907
  --_inner-stroke: color-mix(in srgb, var(--fg) ${J.innerStroke}%, var(--bg));
890
908
  --_key-badge: color-mix(in srgb, var(--fg) ${J.keyBadge}%, var(--bg));`;
891
909
  return [
892
- Y(n),
910
+ X(n),
893
911
  ...a.length > 0 ? [` ${a.join("\n ")}`] : [],
894
912
  ...t ? [` ${t.faceCss}`] : [],
895
913
  ` text { font-family: ${r ? i : `'${i}'`}, system-ui, sans-serif; }`,
@@ -899,20 +917,24 @@ function X(e, t, n) {
899
917
  "</style>"
900
918
  ].join("\n");
901
919
  }
902
- function Re(e, t, n) {
920
+ function Ue(e, t, n) {
903
921
  return (.299 * e + .587 * t + .114 * n) / 255;
904
922
  }
905
- function ze(e, t) {
923
+ function We(e, t) {
906
924
  if (!e) return t;
907
925
  let n = c(e);
908
- return n ? Re(...n) > .5 ? "#000000" : "#FFFFFF" : t;
926
+ return n ? Ue(...n) > .5 ? "#000000" : "#FFFFFF" : t;
909
927
  }
910
928
  var Z = 0;
911
- function Q() {
929
+ function Ge() {
912
930
  return Z += 1, `zm-title-${Z}`;
913
931
  }
914
- function Be() {
915
- Z = 0;
932
+ var Q = 0;
933
+ function Ke() {
934
+ return Q += 1, `zm-desc-${Q}`;
935
+ }
936
+ function qe() {
937
+ Z = 0, Q = 0;
916
938
  }
917
939
  function $(e, t) {
918
940
  return `${[
@@ -925,21 +947,19 @@ function $(e, t) {
925
947
  e.border ? `--border:${e.border}` : ""
926
948
  ].filter(Boolean).join(";")}${t ? "" : ";background:var(--bg)"}`;
927
949
  }
928
- function Ve(e, t, n, r, i, a, o, s = !0) {
929
- let c = s ? ` style="${$(n, r)}"` : "", l = "", u = "";
930
- if (o) {
931
- if (i) {
932
- let e = Q();
933
- l = ` aria-labelledby="${e}"`, u = `\n <title id="${e}">${H(i)}</title>`;
934
- }
935
- } else if (a) l = " aria-hidden=\"true\"";
936
- else if (l = " role=\"img\"", i) {
937
- let e = Q();
938
- l += ` aria-labelledby="${e}"`, u = `\n <title id="${e}">${H(i)}</title>`;
950
+ function Je(e, t, n, r, i, a, o, s = !0, c) {
951
+ let l = s ? ` style="${$(n, r)}"` : "", u = "", d = "", f = o || !a;
952
+ if (!o && a ? u = " aria-hidden=\"true\"" : o || (u = " role=\"img\""), f && i) {
953
+ let e = Ge();
954
+ u += ` aria-labelledby="${e}"`, d = `\n <title id="${e}">${H(i)}</title>`;
955
+ }
956
+ if (f && c) {
957
+ let e = Ke();
958
+ u += ` aria-describedby="${e}"`, d += `\n <desc id="${e}">${H(c)}</desc>`;
939
959
  }
940
- return V`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" ` + V`width="${e}" height="${t}"${l}${c}>` + u;
960
+ return R`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${e} ${t}" ` + R`width="${e}" height="${t}"${u}${l}>` + d;
941
961
  }
942
962
  //#endregion
943
- export { je as DEFAULTS, re as DIAGRAM_TYPES, B as LINE_HEIGHT_RATIO, J as MIX, Me as THEMES, Be as __resetSvgTitleIdCounterForTests, e as applyClickStatement, ce as applyInitConfig, X as buildStyleBlock, le as describeIgnored, b as detectDiagramType, U as escapeAttr, H as escapeXml, se as extractInitConfig, V as f, m as formatCssColor, Ne as fromShikiTheme, F as getCharWidth, ze as getReadableTextColor, ue as hasMeasuredAdvance, x as isDirection, r as isEdgeWithinOwnCluster, ae as isInitDirective, R as isMonospaceFont, P as isWideChar, _e as measureMultilineText, z as measureTextWidth, te as mixHexColors, f as mixSrgb, ye as normalizeBrTags, d as parseCssColor, c as parseHexColor, l as parseHexRgba, E as parseInitDirective, q as parseStyleProps, K as renderMultilineText, Ce as renderMultilineTextWithBackground, ke as resolveNodeStyle, t as safeHref, Ae as sanitizeClassName, ge as setMonospaceMetrics, Oe as splitClassShorthand, y as splitStatements, v as splitStatementsByLine, be as stripFormattingTags, Y as styleOpenTag, Ve as svgOpenTag, $ as themeStyleDeclarations, S as toDirection, Te as tryApplyClassAssignment, we as tryApplyClassDef, Ee as tryApplyCssClass, De as tryApplyStyleStatement, C as withDirectionOverride, a as withoutOwnClusterEdges };
963
+ export { Ie as DEFAULTS, re as DIAGRAM_TYPES, L as LINE_HEIGHT_RATIO, J as MIX, Le as THEMES, qe as __resetSvgTitleIdCounterForTests, e as applyClickStatement, ce as applyInitConfig, He as buildStyleBlock, V as decodeMermaidEntities, we as decodeXmlEntitiesInLabel, le as describeIgnored, ie as detectDiagramType, U as escapeAttr, H as escapeXml, se as extractInitConfig, R as f, h as formatCssColor, Re as fromShikiTheme, M as getCharWidth, We as getReadableTextColor, ue as hasMeasuredAdvance, b as isDirection, r as isEdgeWithinOwnCluster, ae as isInitDirective, F as isMonospaceFont, j as isWideChar, be as measureMultilineText, I as measureTextWidth, ee as mixHexColors, p as mixSrgb, Se as normalizeBrTags, f as parseCssColor, c as parseHexColor, l as parseHexRgba, E as parseInitDirective, q as parseStyleProps, K as renderMultilineText, Oe as renderMultilineTextWithBackground, Pe as resolveNodeStyle, t as safeHref, Fe as sanitizeClassName, ye as setMonospaceMetrics, Ne as splitClassShorthand, y as splitStatements, v as splitStatementsByLine, Te as stripFormattingTags, X as styleOpenTag, Je as svgOpenTag, $ as themeStyleDeclarations, x as toDirection, Ae as tryApplyClassAssignment, ke as tryApplyClassDef, je as tryApplyCssClass, Me as tryApplyStyleStatement, S as withDirectionOverride, a as withoutOwnClusterEdges };
944
964
 
945
965
  //# sourceMappingURL=index.js.map