@zombie-mermaid/mermaid-parser 3.2.0 → 4.1.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.cjs +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -1
- package/dist/index.d.ts +26 -1
- package/dist/index.js +684 -254
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/xychart-colors.test.ts +34 -0
- package/src/class/parser.ts +8 -13
- package/src/class/types.ts +13 -0
- package/src/flowchart-parser.ts +1324 -0
- package/src/index.ts +4 -2
- package/src/sequence/types.ts +2 -0
- package/src/xychart/colors.ts +10 -4
package/dist/index.js
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { applyClickStatement as e, detectDiagramType as t,
|
|
1
|
+
import { applyClickStatement as e, detectDiagramType as t, extractInitConfig as n, normalizeBrTags as r, parseStyleProps as i, splitClassShorthand as a, splitStatements as o, splitStatementsByLine as s, toDirection as c, toDirection as l, tryApplyClassAssignment as u, tryApplyClassDef as d, tryApplyCssClass as f, tryApplyStyleStatement as p } from "@zombie-mermaid/core";
|
|
2
2
|
//#region packages/mermaid-parser/src/architecture/parser.ts
|
|
3
|
-
var
|
|
4
|
-
function
|
|
3
|
+
var m = String.raw`[\w-]+`, h = new RegExp(String.raw`^(group|service)\s+(${m})\s*(?:\(([^)]*)\))?\s*(?:\[([^\]]*)\])?(?:\s+in\s+(${m}))?$`), g = new RegExp(String.raw`^junction\s+(${m})(?:\s+in\s+(${m}))?$`), _ = new RegExp(String.raw`^(${m})(\{group\})?:([LRTB])\s+(<)?--(>)?\s+([LRTB]):(${m})(\{group\})?$`), v = new RegExp(String.raw`^align\s+(?:row|column)\s+${m}(?:\s+${m})+$`);
|
|
4
|
+
function y(e, t) {
|
|
5
5
|
throw Error(`Architecture diagram, line ${e.line}: ${t} — "${e.text}"`);
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function b(e) {
|
|
8
8
|
return e?.trim().replace(/^"(.*)"$/, "$1") || void 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function x(e) {
|
|
11
11
|
let t = {
|
|
12
12
|
groups: [],
|
|
13
13
|
services: [],
|
|
14
14
|
junctions: [],
|
|
15
15
|
edges: []
|
|
16
|
-
},
|
|
17
|
-
|
|
16
|
+
}, n = /* @__PURE__ */ new Map(), i = [], a = [], o = (e, t, r, a) => {
|
|
17
|
+
n.has(t) && y(e, `duplicate id "${t}"`), a === t && y(e, `"${t}" cannot be inside itself`), n.set(t, r), a && i.push({
|
|
18
18
|
stmt: e,
|
|
19
19
|
parent: a
|
|
20
20
|
});
|
|
21
21
|
};
|
|
22
|
-
for (let
|
|
23
|
-
let i = e[
|
|
22
|
+
for (let n = 1; n < e.length; n++) {
|
|
23
|
+
let i = e[n], s = i.text, c = s.match(h);
|
|
24
24
|
if (c) {
|
|
25
|
-
let e = c[1],
|
|
26
|
-
o(i,
|
|
25
|
+
let e = c[1], n = c[2], a = c[4], s = c[5];
|
|
26
|
+
o(i, n, e, s);
|
|
27
27
|
let l = {
|
|
28
|
-
id:
|
|
29
|
-
icon:
|
|
30
|
-
title: a === void 0 ?
|
|
28
|
+
id: n,
|
|
29
|
+
icon: b(c[3]),
|
|
30
|
+
title: a === void 0 ? n : r(a.trim()),
|
|
31
31
|
parent: s
|
|
32
32
|
};
|
|
33
33
|
e === "group" ? t.groups.push(l) : t.services.push(l);
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
|
-
let l = s.match(
|
|
36
|
+
let l = s.match(g);
|
|
37
37
|
if (l) {
|
|
38
38
|
let e = l[1], n = l[2];
|
|
39
39
|
o(i, e, "junction", n), t.junctions.push({
|
|
@@ -42,7 +42,7 @@ function _(e) {
|
|
|
42
42
|
});
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
|
-
let u = s.match(
|
|
45
|
+
let u = s.match(_);
|
|
46
46
|
if (u) {
|
|
47
47
|
a.push({
|
|
48
48
|
stmt: i,
|
|
@@ -59,9 +59,9 @@ function _(e) {
|
|
|
59
59
|
});
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
v.test(s) || y(i, "unrecognized statement");
|
|
63
63
|
}
|
|
64
|
-
for (let { stmt: e, parent: t } of i)
|
|
64
|
+
for (let { stmt: e, parent: t } of i) n.get(t) !== "group" && y(e, `"in ${t}" must name a declared group`);
|
|
65
65
|
let s = /* @__PURE__ */ new Map();
|
|
66
66
|
for (let e of t.groups) e.parent && s.set(e.id, e.parent);
|
|
67
67
|
for (let e of t.groups) {
|
|
@@ -71,41 +71,41 @@ function _(e) {
|
|
|
71
71
|
t.add(n);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
for (let { stmt: e, edge:
|
|
75
|
-
let i = [[
|
|
76
|
-
for (let [
|
|
77
|
-
let i =
|
|
78
|
-
i ||
|
|
79
|
-
let o = [...t.services, ...t.junctions].find((e) => e.id ===
|
|
80
|
-
a && !o &&
|
|
81
|
-
}
|
|
82
|
-
t.edges.push(
|
|
74
|
+
for (let { stmt: e, edge: r } of a) {
|
|
75
|
+
let i = [[r.source, r.sourceGroup], [r.target, r.targetGroup]];
|
|
76
|
+
for (let [r, a] of i) {
|
|
77
|
+
let i = n.get(r);
|
|
78
|
+
i || y(e, `unknown id "${r}"`), i === "group" && y(e, `edges connect services or junctions, not the group "${r}"`);
|
|
79
|
+
let o = [...t.services, ...t.junctions].find((e) => e.id === r)?.parent;
|
|
80
|
+
a && !o && y(e, `"{group}" needs "${r}" to be declared inside a group`);
|
|
81
|
+
}
|
|
82
|
+
t.edges.push(r);
|
|
83
83
|
}
|
|
84
84
|
return t;
|
|
85
85
|
}
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region packages/mermaid-parser/src/architecture/to-graph.ts
|
|
88
|
-
var
|
|
88
|
+
var S = {
|
|
89
89
|
database: "cylinder",
|
|
90
90
|
disk: "cylinder",
|
|
91
91
|
cloud: "stadium",
|
|
92
92
|
internet: "circle"
|
|
93
|
-
},
|
|
94
|
-
function
|
|
93
|
+
}, C = /* @__PURE__ */ new Set(["L", "R"]);
|
|
94
|
+
function ee(e) {
|
|
95
95
|
let t = 0, n = 0;
|
|
96
|
-
for (let r of e) for (let e of [r.sourcePort, r.targetPort])
|
|
96
|
+
for (let r of e) for (let e of [r.sourcePort, r.targetPort]) C.has(e) ? t++ : n++;
|
|
97
97
|
return n > t ? "TB" : "LR";
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function te(e, t) {
|
|
100
100
|
let [n, r] = t === "LR" || t === "RL" ? ["L", "R"] : ["T", "B"];
|
|
101
101
|
return e.sourcePort === r || e.targetPort === n ? !1 : e.sourcePort === n || e.targetPort === r;
|
|
102
102
|
}
|
|
103
|
-
function
|
|
103
|
+
function ne(e) {
|
|
104
104
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
105
105
|
for (let r of e.services) t.set(r.id, {
|
|
106
106
|
id: r.id,
|
|
107
107
|
label: r.title,
|
|
108
|
-
shape: r.icon &&
|
|
108
|
+
shape: r.icon && S[r.icon] || "rectangle"
|
|
109
109
|
}), n.set(r.id, r.parent);
|
|
110
110
|
for (let r of e.junctions) t.set(r.id, {
|
|
111
111
|
id: r.id,
|
|
@@ -125,12 +125,12 @@ function S(e) {
|
|
|
125
125
|
n ? n.children.push(e) : i.push(e);
|
|
126
126
|
}
|
|
127
127
|
for (let [e, t] of n) r.get(t ?? "")?.nodeIds.push(e);
|
|
128
|
-
let a =
|
|
128
|
+
let a = ee(e.edges);
|
|
129
129
|
return {
|
|
130
130
|
direction: a,
|
|
131
131
|
nodes: t,
|
|
132
132
|
edges: e.edges.map((e) => {
|
|
133
|
-
let t = (e, t) => (t ? n.get(e) : void 0) ?? e, r = !
|
|
133
|
+
let t = (e, t) => (t ? n.get(e) : void 0) ?? e, r = !te(e, a), [i, o] = r ? [t(e.source, e.sourceGroup), t(e.target, e.targetGroup)] : [t(e.target, e.targetGroup), t(e.source, e.sourceGroup)];
|
|
134
134
|
return {
|
|
135
135
|
source: i,
|
|
136
136
|
target: o,
|
|
@@ -149,17 +149,17 @@ function S(e) {
|
|
|
149
149
|
}
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region packages/mermaid-parser/src/c4/parser.ts
|
|
152
|
-
var
|
|
152
|
+
var re = {
|
|
153
153
|
c4context: "context",
|
|
154
154
|
c4container: "container",
|
|
155
155
|
c4component: "component",
|
|
156
156
|
c4dynamic: "dynamic",
|
|
157
157
|
c4deployment: "deployment"
|
|
158
|
-
},
|
|
158
|
+
}, ie = /^(?:UpdateElementStyle|UpdateRelStyle|UpdateLayoutConfig|LAYOUT_[A-Z_]+|SHOW_LEGEND|SHOW_FLOATING_LEGEND|AddElementTag|AddRelTag|AddBoundaryTag|RoleTag)\b/, ae = /^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/, oe = /^(?:Boundary|Enterprise_Boundary|System_Boundary|Container_Boundary)$/, se = /^(?:Deployment_Node|Node|Node_L|Node_R)$/, ce = /^(Rel|BiRel|Rel_U|Rel_Up|Rel_D|Rel_Down|Rel_L|Rel_Left|Rel_R|Rel_Right|Rel_Back|RelIndex)$/, le = {
|
|
159
159
|
Enterprise_Boundary: "ENTERPRISE",
|
|
160
160
|
System_Boundary: "SYSTEM",
|
|
161
161
|
Container_Boundary: "CONTAINER"
|
|
162
|
-
},
|
|
162
|
+
}, ue = {
|
|
163
163
|
Rel_U: "up",
|
|
164
164
|
Rel_Up: "up",
|
|
165
165
|
Rel_D: "down",
|
|
@@ -169,77 +169,77 @@ var C = {
|
|
|
169
169
|
Rel_R: "right",
|
|
170
170
|
Rel_Right: "right"
|
|
171
171
|
};
|
|
172
|
-
function
|
|
173
|
-
let t = e.trim(),
|
|
174
|
-
return n
|
|
172
|
+
function de(e) {
|
|
173
|
+
let t = e.trim(), n = t.length >= 2 && t.startsWith("\"") && t.endsWith("\"") ? t.slice(1, -1) : t;
|
|
174
|
+
return r(n);
|
|
175
175
|
}
|
|
176
|
-
function
|
|
176
|
+
function fe(e) {
|
|
177
177
|
let t = [], n = "", r = !1;
|
|
178
178
|
for (let i of e) i === "\"" && (r = !r), i === "," && !r ? (t.push(n), n = "") : n += i;
|
|
179
|
-
return r ? null : (t.push(n), t.map((e) => e.trim()).filter((e) => !e.startsWith("$")).map(
|
|
179
|
+
return r ? null : (t.push(n), t.map((e) => e.trim()).filter((e) => !e.startsWith("$")).map(de));
|
|
180
180
|
}
|
|
181
|
-
var
|
|
182
|
-
function
|
|
181
|
+
var pe = /^([A-Za-z_][A-Za-z0-9_]*)\s*\((.*)\)\s*(\{)?\s*$/;
|
|
182
|
+
function w(e, t) {
|
|
183
183
|
throw Error(`C4 diagram, line ${e.line}: ${t} — "${e.text}"`);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
let t =
|
|
185
|
+
function me(e) {
|
|
186
|
+
let t = re[e[0]?.text.trim().toLowerCase() ?? ""];
|
|
187
187
|
if (!t) throw Error(`C4 diagram: expected a header of C4Context, C4Container, C4Component, C4Dynamic or C4Deployment, got "${e[0]?.text ?? ""}"`);
|
|
188
|
-
let
|
|
188
|
+
let n = {
|
|
189
189
|
variant: t,
|
|
190
190
|
elements: [],
|
|
191
191
|
boundaries: [],
|
|
192
192
|
relationships: []
|
|
193
|
-
}, i = /* @__PURE__ */ new Set(), a = [], o, s = (e, t) => (t ||
|
|
193
|
+
}, i = /* @__PURE__ */ new Set(), a = [], o, s = (e, t) => (t || w(e, "missing alias (first argument)"), i.has(t) && w(e, `duplicate alias "${t}"`), i.add(t), t);
|
|
194
194
|
for (let t = 1; t < e.length; t++) {
|
|
195
195
|
let i = e[t], c = i.text;
|
|
196
196
|
if (c === "}") {
|
|
197
|
-
a.length === 0 &&
|
|
197
|
+
a.length === 0 && w(i, "unmatched \"}\""), a.pop();
|
|
198
198
|
continue;
|
|
199
199
|
}
|
|
200
200
|
if (c === "{") {
|
|
201
|
-
o ||
|
|
201
|
+
o || w(i, "unexpected \"{\""), a.push(o), o = void 0;
|
|
202
202
|
continue;
|
|
203
203
|
}
|
|
204
204
|
o = void 0;
|
|
205
205
|
let l = c.match(/^title(?:\s+(.*))?$/i);
|
|
206
206
|
if (l) {
|
|
207
|
-
|
|
207
|
+
n.title = r((l[1] ?? "").trim());
|
|
208
208
|
continue;
|
|
209
209
|
}
|
|
210
|
-
if (
|
|
211
|
-
let u = c.match(
|
|
212
|
-
u ||
|
|
213
|
-
let d = u[1], f = u[3] === "{", p =
|
|
214
|
-
p ||
|
|
215
|
-
let m = d.match(
|
|
210
|
+
if (ie.test(c)) continue;
|
|
211
|
+
let u = c.match(pe);
|
|
212
|
+
u || w(i, "unrecognized statement");
|
|
213
|
+
let d = u[1], f = u[3] === "{", p = fe(u[2]);
|
|
214
|
+
p || w(i, "unbalanced quotes");
|
|
215
|
+
let m = d.match(ae);
|
|
216
216
|
if (m) {
|
|
217
|
-
f &&
|
|
218
|
-
let e = m[1].toLowerCase(), t = m[2] === "Db" ? "db" : m[2] === "Queue" ? "queue" : "default",
|
|
217
|
+
f && w(i, `"${d}" cannot contain a block`);
|
|
218
|
+
let e = m[1].toLowerCase(), t = m[2] === "Db" ? "db" : m[2] === "Queue" ? "queue" : "default", r = e === "container" || e === "component", o = s(i, p[0]), c = {
|
|
219
219
|
alias: o,
|
|
220
220
|
kind: e,
|
|
221
221
|
shape: t,
|
|
222
222
|
external: m[3] !== void 0,
|
|
223
223
|
label: p[1] || o
|
|
224
|
-
}, l =
|
|
225
|
-
l && (c.technology = l), u && (c.description = u),
|
|
224
|
+
}, l = r ? p[2] : void 0, u = r ? p[3] : p[2];
|
|
225
|
+
l && (c.technology = l), u && (c.description = u), n.elements.push(c), a.at(-1)?.elementAliases.push(o);
|
|
226
226
|
continue;
|
|
227
227
|
}
|
|
228
|
-
if (
|
|
229
|
-
let e =
|
|
228
|
+
if (oe.test(d) || se.test(d)) {
|
|
229
|
+
let e = se.test(d), t = s(i, p[0]), r = {
|
|
230
230
|
alias: t,
|
|
231
231
|
label: p[1] || t,
|
|
232
232
|
elementAliases: [],
|
|
233
233
|
children: []
|
|
234
234
|
};
|
|
235
|
-
|
|
235
|
+
r.type = le[d] || (p[2] && (e || d === "Boundary") ? p[2] : e ? "node" : "system"), e && p[3] && (r.description = p[3]);
|
|
236
236
|
let c = a.at(-1);
|
|
237
|
-
c ? c.children.push(
|
|
237
|
+
c ? c.children.push(r) : n.boundaries.push(r), f ? a.push(r) : o = r;
|
|
238
238
|
continue;
|
|
239
239
|
}
|
|
240
|
-
if (d.match(
|
|
240
|
+
if (d.match(ce)) {
|
|
241
241
|
let e = d === "RelIndex" ? p.slice(1) : p;
|
|
242
|
-
(!e[0] || !e[1]) &&
|
|
242
|
+
(!e[0] || !e[1]) && w(i, "a relationship needs \"from\" and \"to\" aliases");
|
|
243
243
|
let t = {
|
|
244
244
|
from: e[0],
|
|
245
245
|
to: e[1],
|
|
@@ -247,22 +247,22 @@ function le(e) {
|
|
|
247
247
|
bidirectional: d === "BiRel"
|
|
248
248
|
};
|
|
249
249
|
e[3] && (t.technology = e[3]), d === "Rel_Back" && (t.reversed = !0);
|
|
250
|
-
let
|
|
251
|
-
|
|
250
|
+
let r = ue[d];
|
|
251
|
+
r && (t.layout = r), n.relationships.push(t);
|
|
252
252
|
continue;
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
w(i, `unknown C4 macro "${d}"`);
|
|
255
255
|
}
|
|
256
256
|
if (a.length > 0) throw Error(`C4 diagram: boundary "${a.at(-1).alias}" is missing its closing "}"`);
|
|
257
|
-
|
|
257
|
+
n.variant === "dynamic" && n.relationships.forEach((e, t) => {
|
|
258
258
|
e.index = String(t + 1);
|
|
259
259
|
});
|
|
260
|
-
for (let e of
|
|
261
|
-
return
|
|
260
|
+
for (let e of n.relationships) for (let t of [e.from, e.to]) if (!i.has(t)) throw Error(`C4 diagram: relationship refers to undeclared alias "${t}"`);
|
|
261
|
+
return n;
|
|
262
262
|
}
|
|
263
263
|
//#endregion
|
|
264
264
|
//#region packages/mermaid-parser/src/c4/format.ts
|
|
265
|
-
function
|
|
265
|
+
function he(e, t) {
|
|
266
266
|
let n = [];
|
|
267
267
|
for (let r of e.split("\n")) {
|
|
268
268
|
let e = "";
|
|
@@ -271,24 +271,24 @@ function ue(e, t) {
|
|
|
271
271
|
}
|
|
272
272
|
return n;
|
|
273
273
|
}
|
|
274
|
-
var
|
|
274
|
+
var ge = {
|
|
275
275
|
person: "Person",
|
|
276
276
|
system: "Software System",
|
|
277
277
|
container: "Container",
|
|
278
278
|
component: "Component"
|
|
279
279
|
};
|
|
280
|
-
function
|
|
280
|
+
function _e(e) {
|
|
281
281
|
let t = (e.kind === "container" || e.kind === "component") && e.technology ? `: ${e.technology}` : "";
|
|
282
|
-
return `[${
|
|
282
|
+
return `[${ge[e.kind]}${t}]`;
|
|
283
283
|
}
|
|
284
|
-
function
|
|
284
|
+
function ve(e) {
|
|
285
285
|
return e.type ? `[${e.type}]` : void 0;
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ye(e) {
|
|
288
288
|
let t = [], n = [e.index ? `${e.index}:` : "", e.label].filter(Boolean).join(" ");
|
|
289
289
|
return n && t.push(n), e.technology && t.push(`[${e.technology}]`), t;
|
|
290
290
|
}
|
|
291
|
-
function
|
|
291
|
+
function be(e) {
|
|
292
292
|
switch (e.layout) {
|
|
293
293
|
case "up": return {
|
|
294
294
|
source: e.to,
|
|
@@ -324,9 +324,9 @@ function he(e) {
|
|
|
324
324
|
}
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region packages/mermaid-parser/src/class/parser.ts
|
|
327
|
-
var
|
|
328
|
-
function
|
|
329
|
-
let
|
|
327
|
+
var T = "<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--", xe = new RegExp(T);
|
|
328
|
+
function Se(t) {
|
|
329
|
+
let n = {
|
|
330
330
|
classes: [],
|
|
331
331
|
relationships: [],
|
|
332
332
|
namespaces: [],
|
|
@@ -335,53 +335,53 @@ function _e(t) {
|
|
|
335
335
|
classAssignments: /* @__PURE__ */ new Map(),
|
|
336
336
|
nodeStyles: /* @__PURE__ */ new Map(),
|
|
337
337
|
notes: []
|
|
338
|
-
},
|
|
339
|
-
for (let
|
|
340
|
-
let h = t[
|
|
341
|
-
if (
|
|
338
|
+
}, i = /* @__PURE__ */ new Map(), o = null, s = null, c = 0, l;
|
|
339
|
+
for (let a = 1; a < t.length; a++) {
|
|
340
|
+
let h = t[a], g = h.text;
|
|
341
|
+
if (s && c > 0) {
|
|
342
342
|
if (g === "}") {
|
|
343
|
-
|
|
343
|
+
c--, c === 0 && (s = null, l = void 0);
|
|
344
344
|
continue;
|
|
345
345
|
}
|
|
346
346
|
let e = g.match(/^<<(\w+)>>$/);
|
|
347
347
|
if (e) {
|
|
348
|
-
|
|
348
|
+
s.annotation = e[1];
|
|
349
349
|
continue;
|
|
350
350
|
}
|
|
351
351
|
if (g.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${g}" — expected "<<name>>" (e.g. "<<interface>>").`);
|
|
352
|
-
|
|
352
|
+
E(s, g, h.line);
|
|
353
353
|
continue;
|
|
354
354
|
}
|
|
355
355
|
if (/^click\s+/i.test(g)) {
|
|
356
|
-
e(g,
|
|
356
|
+
e(g, n.interactions);
|
|
357
357
|
continue;
|
|
358
358
|
}
|
|
359
359
|
let _ = g.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);
|
|
360
360
|
if (_) {
|
|
361
361
|
let e = _[1];
|
|
362
|
-
|
|
363
|
-
text:
|
|
362
|
+
n.notes.push({
|
|
363
|
+
text: r(_[2]),
|
|
364
364
|
...e ? { forClass: e } : {}
|
|
365
365
|
});
|
|
366
366
|
continue;
|
|
367
367
|
}
|
|
368
|
-
if (
|
|
368
|
+
if (d(g, n) || p(g, n) || f(g, n) || u(g, n)) continue;
|
|
369
369
|
let v = g.match(/^namespace\s+(\S+)\s*\{$/);
|
|
370
370
|
if (v) {
|
|
371
|
-
|
|
371
|
+
o = {
|
|
372
372
|
name: v[1],
|
|
373
373
|
classIds: []
|
|
374
374
|
};
|
|
375
375
|
continue;
|
|
376
376
|
}
|
|
377
|
-
if (g === "}" &&
|
|
378
|
-
|
|
377
|
+
if (g === "}" && o) {
|
|
378
|
+
n.namespaces.push(o), o = null;
|
|
379
379
|
continue;
|
|
380
380
|
}
|
|
381
381
|
let y = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);
|
|
382
382
|
if (y) {
|
|
383
383
|
let e = m(y[1], y[2]);
|
|
384
|
-
|
|
384
|
+
s = i.get(e) ?? null, c = 1, l = h.line;
|
|
385
385
|
continue;
|
|
386
386
|
}
|
|
387
387
|
let b = g.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);
|
|
@@ -391,44 +391,44 @@ function _e(t) {
|
|
|
391
391
|
}
|
|
392
392
|
let x = g.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);
|
|
393
393
|
if (x) {
|
|
394
|
-
let e = m(x[1], void 0), t =
|
|
394
|
+
let e = m(x[1], void 0), t = i.get(e), n = x[2], r = n.match(/^<<(\w+)>>$/);
|
|
395
395
|
if (t && r) t.annotation = r[1];
|
|
396
396
|
else if (t && n.startsWith("<<")) throw Error(`Line ${h.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);
|
|
397
|
-
else t && n &&
|
|
397
|
+
else t && n && E(t, n, h.line);
|
|
398
398
|
continue;
|
|
399
399
|
}
|
|
400
400
|
let S = g.match(/^(\S+?)\s*:\s*(.+)$/);
|
|
401
401
|
if (S) {
|
|
402
402
|
let e = S[2];
|
|
403
403
|
if (!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)) {
|
|
404
|
-
|
|
404
|
+
E(Ce(i, S[1]), e, h.line);
|
|
405
405
|
continue;
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
let C =
|
|
408
|
+
let C = Ee(g);
|
|
409
409
|
if (C) {
|
|
410
|
-
C.from = m(C.from, void 0, !1), C.to = m(C.to, void 0, !1),
|
|
410
|
+
C.from = m(C.from, void 0, !1), C.to = m(C.to, void 0, !1), n.relationships.push(C);
|
|
411
411
|
continue;
|
|
412
412
|
}
|
|
413
|
-
if (
|
|
413
|
+
if (xe.test(g)) throw Error(`Line ${h.line}: Malformed class-diagram relationship "${g}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`);
|
|
414
414
|
}
|
|
415
|
-
if (
|
|
416
|
-
return
|
|
417
|
-
function m(e, t,
|
|
418
|
-
let { id:
|
|
419
|
-
if (!
|
|
420
|
-
let e =
|
|
421
|
-
e && (
|
|
422
|
-
}
|
|
423
|
-
let d =
|
|
424
|
-
return
|
|
415
|
+
if (s !== null) throw Error(`Line ${l}: Unclosed class body for "${s.id}" — expected a closing "}" before the diagram ends.`);
|
|
416
|
+
return n.classes = [...i.values()], n;
|
|
417
|
+
function m(e, t, r = !0) {
|
|
418
|
+
let { id: s, className: c } = a(e), l = s, u = t;
|
|
419
|
+
if (!u) {
|
|
420
|
+
let e = s.match(/^(.+?)~(\w+)~$/);
|
|
421
|
+
e && (l = e[1], u = e[2]);
|
|
422
|
+
}
|
|
423
|
+
let d = Ce(i, l);
|
|
424
|
+
return u && (d.label = `${l}<${u}>`), c && n.classAssignments.set(l, c), r && o && o.classIds.push(l), l;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
function
|
|
428
|
-
let r =
|
|
427
|
+
function E(e, t, n) {
|
|
428
|
+
let r = Te(t, n);
|
|
429
429
|
r && (r.isMethod ? e.methods.push(r.member) : e.attributes.push(r.member));
|
|
430
430
|
}
|
|
431
|
-
function
|
|
431
|
+
function Ce(e, t) {
|
|
432
432
|
let n = e.get(t);
|
|
433
433
|
return n || (n = {
|
|
434
434
|
id: t,
|
|
@@ -437,11 +437,11 @@ function O(e, t) {
|
|
|
437
437
|
methods: []
|
|
438
438
|
}, e.set(t, n)), n;
|
|
439
439
|
}
|
|
440
|
-
function
|
|
440
|
+
function D(e, t) {
|
|
441
441
|
return Math.max(0, e.split(t).length - 1);
|
|
442
442
|
}
|
|
443
|
-
function
|
|
444
|
-
let t =
|
|
443
|
+
function we(e) {
|
|
444
|
+
let t = D(e, "~");
|
|
445
445
|
if (t <= 1) return e;
|
|
446
446
|
let n = e, r = !1;
|
|
447
447
|
t % 2 != 0 && n.startsWith("~") && (n = n.slice(1), r = !0);
|
|
@@ -449,26 +449,26 @@ function ve(e) {
|
|
|
449
449
|
for (; a !== -1 && o !== -1 && a !== o;) i[a] = "<", i[o] = ">", a = i.indexOf("~"), o = i.lastIndexOf("~");
|
|
450
450
|
return r && i.unshift("~"), i.join("");
|
|
451
451
|
}
|
|
452
|
-
function
|
|
452
|
+
function O(e) {
|
|
453
453
|
let t = e.split(/(,)/), n = [];
|
|
454
454
|
for (let e = 0; e < t.length; e++) {
|
|
455
455
|
let r = t[e];
|
|
456
456
|
if (r === "," && e > 0 && e + 1 < t.length) {
|
|
457
457
|
let i = t[e - 1], a = t[e + 1];
|
|
458
|
-
|
|
458
|
+
D(i, "~") === 1 && D(a, "~") === 1 && (r = `${i},${a}`, e++, n.pop());
|
|
459
459
|
}
|
|
460
|
-
n.push(
|
|
460
|
+
n.push(we(r));
|
|
461
461
|
}
|
|
462
462
|
return n.join("");
|
|
463
463
|
}
|
|
464
|
-
function
|
|
464
|
+
function Te(e, t) {
|
|
465
465
|
let n = e.trim().replace(/;$/, "");
|
|
466
466
|
if (!n) return null;
|
|
467
467
|
let r = "", i = n, a = i[0];
|
|
468
468
|
if ((a === "+" || a === "-" || a === "#" || a === "~") && (r = a, i = i.slice(1).trim()), i.includes("(") && !i.includes(")")) throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);
|
|
469
469
|
let o = i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);
|
|
470
470
|
if (o) {
|
|
471
|
-
let e =
|
|
471
|
+
let e = O(o[1].trim()), t = o[2]?.trim(), n = t ? O(t) : void 0, a = o[3]?.trim(), s = a ? O(a) : void 0, c = e.endsWith("$") || i.includes("$"), l = e.endsWith("*") || i.includes("*");
|
|
472
472
|
return {
|
|
473
473
|
member: {
|
|
474
474
|
visibility: r,
|
|
@@ -482,27 +482,25 @@ function ye(e, t) {
|
|
|
482
482
|
isMethod: !0
|
|
483
483
|
};
|
|
484
484
|
}
|
|
485
|
-
let s =
|
|
486
|
-
s.length >= 2 ? (l = s[0], c = s.slice(1).join(" ")) : c = s[0] ?? i;
|
|
487
|
-
let u = c.endsWith("$"), d = c.endsWith("*");
|
|
485
|
+
let s = O(i), c = s.endsWith("$"), l = s.endsWith("*");
|
|
488
486
|
return {
|
|
489
487
|
member: {
|
|
490
488
|
visibility: r,
|
|
491
|
-
name:
|
|
492
|
-
type:
|
|
493
|
-
isStatic:
|
|
494
|
-
isAbstract:
|
|
489
|
+
name: s.replace(/[$*]$/, ""),
|
|
490
|
+
type: void 0,
|
|
491
|
+
isStatic: c,
|
|
492
|
+
isAbstract: l,
|
|
495
493
|
isMethod: !1
|
|
496
494
|
},
|
|
497
495
|
isMethod: !1
|
|
498
496
|
};
|
|
499
497
|
}
|
|
500
|
-
function
|
|
501
|
-
let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${
|
|
498
|
+
function Ee(e) {
|
|
499
|
+
let t = e.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${T})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));
|
|
502
500
|
if (!t) return null;
|
|
503
|
-
let
|
|
501
|
+
let n = t[1], i = t[2], a = i ? r(i) : void 0, o = t[3].trim(), s = t[4], c = s ? r(s) : void 0, l = t[6] ? `${t[5]}:::${t[6]}` : t[5], u = t[7]?.trim(), d = u ? r(u) : void 0, f = De(o);
|
|
504
502
|
return f ? {
|
|
505
|
-
from:
|
|
503
|
+
from: n,
|
|
506
504
|
to: l,
|
|
507
505
|
type: f.type,
|
|
508
506
|
markerAt: f.markerAt,
|
|
@@ -511,7 +509,7 @@ function be(e) {
|
|
|
511
509
|
toCardinality: c
|
|
512
510
|
} : null;
|
|
513
511
|
}
|
|
514
|
-
function
|
|
512
|
+
function De(e) {
|
|
515
513
|
switch (e.trim()) {
|
|
516
514
|
case "<|--": return {
|
|
517
515
|
type: "inheritance",
|
|
@@ -570,51 +568,51 @@ function j(e) {
|
|
|
570
568
|
}
|
|
571
569
|
//#endregion
|
|
572
570
|
//#region packages/mermaid-parser/src/class/format.ts
|
|
573
|
-
function
|
|
571
|
+
function Oe(e) {
|
|
574
572
|
return `${e.visibility ? `${e.visibility} ` : ""}${e.isMethod ? `${e.name}(${e.params || ""})` : e.name}${e.type ? `: ${e.type}` : ""}`;
|
|
575
573
|
}
|
|
576
574
|
//#endregion
|
|
577
575
|
//#region packages/mermaid-parser/src/er/parser.ts
|
|
578
|
-
function
|
|
576
|
+
function ke(e) {
|
|
579
577
|
let t = {
|
|
580
578
|
entities: [],
|
|
581
579
|
relationships: []
|
|
582
|
-
},
|
|
583
|
-
for (let
|
|
584
|
-
let
|
|
580
|
+
}, n = /* @__PURE__ */ new Map(), i = null;
|
|
581
|
+
for (let a = 1; a < e.length; a++) {
|
|
582
|
+
let o = e[a], s = o.text;
|
|
585
583
|
if (i) {
|
|
586
|
-
if (
|
|
584
|
+
if (s === "}") {
|
|
587
585
|
i = null;
|
|
588
586
|
continue;
|
|
589
587
|
}
|
|
590
|
-
let e =
|
|
588
|
+
let e = A(s);
|
|
591
589
|
e && i.attributes.push(e);
|
|
592
590
|
continue;
|
|
593
591
|
}
|
|
594
|
-
let
|
|
595
|
-
if (
|
|
596
|
-
t.direction =
|
|
592
|
+
let c = s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
593
|
+
if (c) {
|
|
594
|
+
t.direction = l(c[1]);
|
|
597
595
|
continue;
|
|
598
596
|
}
|
|
599
|
-
let u =
|
|
597
|
+
let u = s.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);
|
|
600
598
|
if (u) {
|
|
601
|
-
let e = u[1], t = u[2], a =
|
|
599
|
+
let e = u[1], t = u[2], a = k(n, e, t === void 0 ? void 0 : r(t.trim().replace(/^["']|["']$/g, ""))), o = u[3].trim(), s = o.endsWith("}"), c = s ? o.slice(0, -1).trim() : o;
|
|
602
600
|
for (let e of c.split(";").map((e) => e.trim()).filter(Boolean)) {
|
|
603
|
-
let t =
|
|
601
|
+
let t = A(e);
|
|
604
602
|
t && a.attributes.push(t);
|
|
605
603
|
}
|
|
606
604
|
s || (i = a);
|
|
607
605
|
continue;
|
|
608
606
|
}
|
|
609
|
-
let d =
|
|
607
|
+
let d = Ae(s, o.line);
|
|
610
608
|
if (d) {
|
|
611
|
-
|
|
609
|
+
k(n, d.entity1), k(n, d.entity2), t.relationships.push(d);
|
|
612
610
|
continue;
|
|
613
611
|
}
|
|
614
612
|
}
|
|
615
|
-
return t.entities = [...
|
|
613
|
+
return t.entities = [...n.values()], t;
|
|
616
614
|
}
|
|
617
|
-
function
|
|
615
|
+
function k(e, t, n) {
|
|
618
616
|
let r = e.get(t);
|
|
619
617
|
return r ? n !== void 0 && (r.label = n) : (r = {
|
|
620
618
|
id: t,
|
|
@@ -622,27 +620,27 @@ function P(e, t, n) {
|
|
|
622
620
|
attributes: []
|
|
623
621
|
}, e.set(t, r)), r;
|
|
624
622
|
}
|
|
625
|
-
function
|
|
623
|
+
function A(e) {
|
|
626
624
|
let t = e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);
|
|
627
625
|
if (!t) return null;
|
|
628
|
-
let
|
|
629
|
-
c && (s =
|
|
626
|
+
let n = t[1], i = t[2], a = t[3]?.trim() ?? "", o = [], s, c = a.match(/"([^"]*)"/);
|
|
627
|
+
c && (s = r(c[1]));
|
|
630
628
|
let l = a.replace(/"[^"]*"/, "").trim();
|
|
631
629
|
for (let e of l.split(/\s+/)) {
|
|
632
630
|
let t = e.toUpperCase();
|
|
633
631
|
(t === "PK" || t === "FK" || t === "UK") && o.push(t);
|
|
634
632
|
}
|
|
635
633
|
return {
|
|
636
|
-
type:
|
|
634
|
+
type: n,
|
|
637
635
|
name: i,
|
|
638
636
|
keys: o,
|
|
639
637
|
comment: s
|
|
640
638
|
};
|
|
641
639
|
}
|
|
642
|
-
function
|
|
643
|
-
let
|
|
644
|
-
if (!
|
|
645
|
-
let i =
|
|
640
|
+
function Ae(e, t) {
|
|
641
|
+
let n = e.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);
|
|
642
|
+
if (!n) return null;
|
|
643
|
+
let i = n[1], a = n[2], o = n[3], s = n[4] !== void 0, c = n[4]?.trim() ?? "", l = a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/), u = l ? je(l[1]) : null, d = l ? Me(l[3]) : null;
|
|
646
644
|
if (!u || !d) throw Error(`Line ${t}: Invalid ER relationship cardinality "${a}" in "${e}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);
|
|
647
645
|
if (!s || c.length === 0) throw Error(`Line ${t}: ER relationship "${i} ${a} ${o}" is missing a ": label" — expected e.g. "${i} ${a} ${o} : label".`);
|
|
648
646
|
return {
|
|
@@ -650,40 +648,40 @@ function xe(e, t) {
|
|
|
650
648
|
entity2: o,
|
|
651
649
|
cardinality1: u,
|
|
652
650
|
cardinality2: d,
|
|
653
|
-
label:
|
|
651
|
+
label: r(c.replace(/^["']|["']$/g, "")),
|
|
654
652
|
identifying: l[2] === "--"
|
|
655
653
|
};
|
|
656
654
|
}
|
|
657
|
-
function
|
|
655
|
+
function je(e) {
|
|
658
656
|
return e === "||" ? "one" : e === "|o" ? "zero-one" : e === "}|" ? "many" : e === "}o" ? "zero-many" : null;
|
|
659
657
|
}
|
|
660
|
-
function
|
|
658
|
+
function Me(e) {
|
|
661
659
|
return e === "||" ? "one" : e === "o|" ? "zero-one" : e === "|{" ? "many" : e === "o{" ? "zero-many" : null;
|
|
662
660
|
}
|
|
663
661
|
//#endregion
|
|
664
662
|
//#region packages/mermaid-parser/src/sequence/box-color.ts
|
|
665
|
-
var
|
|
666
|
-
function
|
|
667
|
-
return
|
|
663
|
+
var Ne = new Set("aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ")), Pe = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Fe = /^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;
|
|
664
|
+
function j(e) {
|
|
665
|
+
return Ne.has(e.toLowerCase()) || Pe.test(e) || Fe.test(e);
|
|
668
666
|
}
|
|
669
|
-
function
|
|
667
|
+
function M(e) {
|
|
670
668
|
let t = e.trim(), n = t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/), r = n?.[1] ?? "", i = n?.[2]?.trim() ?? "";
|
|
671
|
-
return r.toLowerCase() === "transparent" ? { label: i } : r !== "" &&
|
|
669
|
+
return r.toLowerCase() === "transparent" ? { label: i } : r !== "" && j(r) ? {
|
|
672
670
|
color: r,
|
|
673
671
|
label: i
|
|
674
672
|
} : { label: t };
|
|
675
673
|
}
|
|
676
674
|
//#endregion
|
|
677
675
|
//#region packages/mermaid-parser/src/sequence/parser.ts
|
|
678
|
-
function
|
|
676
|
+
function N(e) {
|
|
679
677
|
return e === "loop" || e === "alt" || e === "opt" || e === "par" || e === "critical" || e === "break" || e === "rect";
|
|
680
678
|
}
|
|
681
|
-
function
|
|
682
|
-
if (!
|
|
679
|
+
function P(e) {
|
|
680
|
+
if (!N(e)) throw Error(`Invalid block type: "${e}"`);
|
|
683
681
|
return e;
|
|
684
682
|
}
|
|
685
|
-
var
|
|
686
|
-
function
|
|
683
|
+
var Ie = /^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/, Le = /^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;
|
|
684
|
+
function F(e) {
|
|
687
685
|
let t = {
|
|
688
686
|
actors: [],
|
|
689
687
|
messages: [],
|
|
@@ -691,7 +689,7 @@ function B(e) {
|
|
|
691
689
|
notes: [],
|
|
692
690
|
activations: [],
|
|
693
691
|
boxes: []
|
|
694
|
-
},
|
|
692
|
+
}, n = {
|
|
695
693
|
open: void 0,
|
|
696
694
|
membership: /* @__PURE__ */ new Map()
|
|
697
695
|
}, i = 0, a, o = /* @__PURE__ */ new Set(), s = [], c = {
|
|
@@ -702,12 +700,12 @@ function B(e) {
|
|
|
702
700
|
for (let d = 1; d < e.length; d++) {
|
|
703
701
|
let f = e[d], p = f.text, m = p.match(/^box(?:\s+(.*))?$/);
|
|
704
702
|
if (m) {
|
|
705
|
-
if (
|
|
706
|
-
let { color: e, label: o } =
|
|
707
|
-
label:
|
|
703
|
+
if (n.open !== void 0) throw Error(`Line ${f.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);
|
|
704
|
+
let { color: e, label: o } = M(m[1] ?? ""), c = {
|
|
705
|
+
label: r(o),
|
|
708
706
|
actorIds: []
|
|
709
707
|
};
|
|
710
|
-
e !== void 0 && (c.color = e), t.boxes.push(c),
|
|
708
|
+
e !== void 0 && (c.color = e), t.boxes.push(c), n.open = t.boxes.length - 1, i = s.length, a = f.line;
|
|
711
709
|
continue;
|
|
712
710
|
}
|
|
713
711
|
let h = p.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);
|
|
@@ -716,15 +714,15 @@ function B(e) {
|
|
|
716
714
|
if (o.has(i)) throw Error(`Line ${f.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);
|
|
717
715
|
o.add(i), t.actors.push({
|
|
718
716
|
id: i,
|
|
719
|
-
label:
|
|
717
|
+
label: r(h[3]?.trim() ?? i),
|
|
720
718
|
type: e
|
|
721
|
-
}),
|
|
719
|
+
}), R(t, n, i, f.line), l = i;
|
|
722
720
|
continue;
|
|
723
721
|
}
|
|
724
722
|
let g = p.match(/^destroy\s+(.+)$/);
|
|
725
723
|
if (g) {
|
|
726
724
|
let e = g[1].trim();
|
|
727
|
-
|
|
725
|
+
L(t, o, n, e, f.line), u = e;
|
|
728
726
|
continue;
|
|
729
727
|
}
|
|
730
728
|
let _ = p.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);
|
|
@@ -735,18 +733,18 @@ function B(e) {
|
|
|
735
733
|
}
|
|
736
734
|
let v = p.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);
|
|
737
735
|
if (v) {
|
|
738
|
-
let e = v[1] === "actor" ? "actor" : "participant", i = v[2], a = v[3]?.trim() ?? i, s =
|
|
736
|
+
let e = v[1] === "actor" ? "actor" : "participant", i = v[2], a = v[3]?.trim() ?? i, s = r(a);
|
|
739
737
|
o.has(i) || (o.add(i), t.actors.push({
|
|
740
738
|
id: i,
|
|
741
739
|
label: s,
|
|
742
740
|
type: e
|
|
743
|
-
})),
|
|
741
|
+
})), R(t, n, i, f.line);
|
|
744
742
|
continue;
|
|
745
743
|
}
|
|
746
744
|
let y = p.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);
|
|
747
745
|
if (y) {
|
|
748
|
-
let e = y[1].toLowerCase(), i = y[2].trim(), a =
|
|
749
|
-
for (let e of s)
|
|
746
|
+
let e = y[1].toLowerCase(), i = y[2].trim(), a = r(y[3].trim()), s = i.split(",").map((e) => e.trim());
|
|
747
|
+
for (let e of s) L(t, o, n, e, f.line);
|
|
750
748
|
let c = "over";
|
|
751
749
|
e === "left of" ? c = "left" : e === "right of" && (c = "right"), t.notes.push({
|
|
752
750
|
actorIds: s,
|
|
@@ -758,7 +756,7 @@ function B(e) {
|
|
|
758
756
|
}
|
|
759
757
|
let b = p.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);
|
|
760
758
|
if (b) {
|
|
761
|
-
let e =
|
|
759
|
+
let e = P(b[1]), n = b[2]?.trim() ?? "", i = r(n);
|
|
762
760
|
s.push({
|
|
763
761
|
type: e,
|
|
764
762
|
label: i,
|
|
@@ -770,15 +768,15 @@ function B(e) {
|
|
|
770
768
|
}
|
|
771
769
|
let x = p.match(/^(else|and)\s*(.*)$/);
|
|
772
770
|
if (x && s.length > 0) {
|
|
773
|
-
let e = x[2]?.trim() ?? "",
|
|
771
|
+
let e = x[2]?.trim() ?? "", n = r(e);
|
|
774
772
|
s[s.length - 1].dividers.push({
|
|
775
773
|
index: t.messages.length,
|
|
776
|
-
label:
|
|
774
|
+
label: n
|
|
777
775
|
});
|
|
778
776
|
continue;
|
|
779
777
|
}
|
|
780
|
-
if (p === "end" &&
|
|
781
|
-
|
|
778
|
+
if (p === "end" && n.open !== void 0 && s.length === i) {
|
|
779
|
+
n.open = void 0, a = void 0;
|
|
782
780
|
continue;
|
|
783
781
|
}
|
|
784
782
|
if (p === "end" && s.length > 0) {
|
|
@@ -796,26 +794,26 @@ function B(e) {
|
|
|
796
794
|
let S = p.match(/^(activate|deactivate)\s+(.+)$/);
|
|
797
795
|
if (S) {
|
|
798
796
|
let e = S[2].trim();
|
|
799
|
-
|
|
797
|
+
L(t, o, n, e, f.line), t.activations.push({
|
|
800
798
|
actorId: e,
|
|
801
799
|
kind: S[1] === "activate" ? "start" : "end",
|
|
802
800
|
afterIndex: t.messages.length - 1
|
|
803
801
|
});
|
|
804
802
|
continue;
|
|
805
803
|
}
|
|
806
|
-
let C = p.match(
|
|
804
|
+
let C = p.match(Ie) ?? p.match(Le);
|
|
807
805
|
if (C) {
|
|
808
|
-
let e = C[2],
|
|
809
|
-
if (
|
|
810
|
-
|
|
806
|
+
let e = C[2], r = C[4][0];
|
|
807
|
+
if (r === ">" || r === ")") throw Error(`Line ${f.line}: Malformed sequence-diagram arrow in "${p}" — "${e}${r}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);
|
|
808
|
+
Re(t, o, n, c, C[1], C[2], C[3], C[4], C[5], f.line);
|
|
811
809
|
let i = t.messages.length - 1, a = t.messages[i];
|
|
812
810
|
if (l !== void 0) {
|
|
813
811
|
if (a.to !== l) throw Error(`Line ${f.line}: The created participant ${l} does not have an associated creating message after its declaration. Please check the sequence diagram.`);
|
|
814
|
-
|
|
812
|
+
I(t, l).createdAt = i, l = void 0;
|
|
815
813
|
}
|
|
816
814
|
if (u !== void 0) {
|
|
817
815
|
if (a.from !== u && a.to !== u) throw Error(`Line ${f.line}: The destroyed participant ${u} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);
|
|
818
|
-
|
|
816
|
+
I(t, u).destroyedAt = i, u = void 0;
|
|
819
817
|
}
|
|
820
818
|
continue;
|
|
821
819
|
}
|
|
@@ -824,27 +822,27 @@ function B(e) {
|
|
|
824
822
|
let e = s[s.length - 1];
|
|
825
823
|
throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`);
|
|
826
824
|
}
|
|
827
|
-
if (
|
|
828
|
-
let e = t.boxes[
|
|
825
|
+
if (n.open !== void 0) {
|
|
826
|
+
let e = t.boxes[n.open];
|
|
829
827
|
throw Error(`Line ${a}: Sequence diagram: unclosed "box${e.label ? ` ${e.label}` : ""}" — expected a matching "end" before the diagram ends.`);
|
|
830
828
|
}
|
|
831
829
|
return t;
|
|
832
830
|
}
|
|
833
|
-
function
|
|
831
|
+
function I(e, t) {
|
|
834
832
|
let n = e.actors.find((e) => e.id === t);
|
|
835
833
|
if (n === void 0)
|
|
836
834
|
/* v8 ignore next */
|
|
837
835
|
throw Error(`Sequence diagram: unknown actor "${t}"`);
|
|
838
836
|
return n;
|
|
839
837
|
}
|
|
840
|
-
function
|
|
838
|
+
function L(e, t, n, r, i) {
|
|
841
839
|
t.has(r) || (t.add(r), e.actors.push({
|
|
842
840
|
id: r,
|
|
843
841
|
label: r,
|
|
844
842
|
type: "participant"
|
|
845
|
-
})),
|
|
843
|
+
})), R(e, n, r, i);
|
|
846
844
|
}
|
|
847
|
-
function
|
|
845
|
+
function R(e, t, n, r) {
|
|
848
846
|
let i = t.open;
|
|
849
847
|
if (i === void 0) return;
|
|
850
848
|
let a = t.membership.get(n);
|
|
@@ -856,12 +854,12 @@ function U(e, t, n, r) {
|
|
|
856
854
|
t.membership.set(n, i), e.boxes[i].actorIds.push(n);
|
|
857
855
|
}
|
|
858
856
|
}
|
|
859
|
-
function
|
|
860
|
-
|
|
857
|
+
function Re(e, t, n, i, a, o, s, c, l, u) {
|
|
858
|
+
L(e, t, n, a, u), L(e, t, n, c, u);
|
|
861
859
|
let d = o === "<<->>" || o === "<<-->>", f = d ? o === "<<-->>" ? "dashed" : "solid" : o.startsWith("--") ? "dashed" : "solid", p = o.includes(">>") || o.includes("x") ? "filled" : "open", m = o.includes("x"), h = {
|
|
862
860
|
from: a,
|
|
863
861
|
to: c,
|
|
864
|
-
label:
|
|
862
|
+
label: r(l.trim()),
|
|
865
863
|
lineStyle: f,
|
|
866
864
|
arrowHead: p
|
|
867
865
|
};
|
|
@@ -869,14 +867,14 @@ function ke(e, t, r, i, a, o, s, c, l, u) {
|
|
|
869
867
|
}
|
|
870
868
|
//#endregion
|
|
871
869
|
//#region packages/mermaid-parser/src/sequence/activation-check.ts
|
|
872
|
-
function
|
|
870
|
+
function z(e, t) {
|
|
873
871
|
if (t < 0) return "before the first message";
|
|
874
872
|
let n = e.messages[t];
|
|
875
873
|
if (!n) return "at an unresolved position";
|
|
876
874
|
let r = n.label ? `: ${n.label}` : "";
|
|
877
875
|
return `after message ${t + 1} ("${n.from} -> ${n.to}${r}")`;
|
|
878
876
|
}
|
|
879
|
-
function
|
|
877
|
+
function B(e) {
|
|
880
878
|
let t = /* @__PURE__ */ new Map();
|
|
881
879
|
for (let n of e.activations) {
|
|
882
880
|
let e = t.get(n.afterIndex) ?? [];
|
|
@@ -913,13 +911,13 @@ function G(e) {
|
|
|
913
911
|
n.pop() === void 0 && a.push({
|
|
914
912
|
code: "UNMATCHED_DEACTIVATION",
|
|
915
913
|
actorId: t.actorId,
|
|
916
|
-
message: `"deactivate ${t.actorId}" ${
|
|
914
|
+
message: `"deactivate ${t.actorId}" ${z(e, t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`
|
|
917
915
|
});
|
|
918
916
|
}
|
|
919
917
|
for (let [t, n] of i) for (let r of n) a.push({
|
|
920
918
|
code: "DANGLING_ACTIVATION",
|
|
921
919
|
actorId: t,
|
|
922
|
-
message: `"activate ${t}" opened ${
|
|
920
|
+
message: `"activate ${t}" opened ${z(e, r)} is never closed with a matching "deactivate ${t}".`
|
|
923
921
|
});
|
|
924
922
|
return {
|
|
925
923
|
ok: a.length === 0,
|
|
@@ -928,10 +926,10 @@ function G(e) {
|
|
|
928
926
|
}
|
|
929
927
|
//#endregion
|
|
930
928
|
//#region packages/mermaid-parser/src/sequence/activation-fix.ts
|
|
931
|
-
function
|
|
929
|
+
function ze(e) {
|
|
932
930
|
let n = t(e);
|
|
933
931
|
if (n !== "sequence") throw Error(`fixActivationBalance only supports sequence diagrams (source must start with "sequenceDiagram"); detected diagram type: "${n}".`);
|
|
934
|
-
let r =
|
|
932
|
+
let r = B(F(o(e)));
|
|
935
933
|
if (r.ok) return {
|
|
936
934
|
ok: !0,
|
|
937
935
|
originalDiagram: e,
|
|
@@ -939,18 +937,18 @@ function Ae(e) {
|
|
|
939
937
|
fixesApplied: [],
|
|
940
938
|
remainingIssues: []
|
|
941
939
|
};
|
|
942
|
-
let
|
|
940
|
+
let i = r.issues.filter((e) => e.code === "DANGLING_ACTIVATION"), a = r.issues.filter((e) => e.code !== "DANGLING_ACTIVATION"), s = i.map((e) => ` deactivate ${e.actorId}`).join("\n"), c = i.length === 0 ? e : `${e.replace(/\s+$/, "")}\n${s}`, l = i.map((e) => `Appended "deactivate ${e.actorId}" to close: ${e.message}`);
|
|
943
941
|
return {
|
|
944
|
-
ok:
|
|
942
|
+
ok: a.length === 0,
|
|
945
943
|
originalDiagram: e,
|
|
946
944
|
fixedDiagram: c,
|
|
947
945
|
fixesApplied: l,
|
|
948
|
-
remainingIssues:
|
|
946
|
+
remainingIssues: a
|
|
949
947
|
};
|
|
950
948
|
}
|
|
951
949
|
//#endregion
|
|
952
950
|
//#region packages/mermaid-parser/src/xychart/parser.ts
|
|
953
|
-
function
|
|
951
|
+
function Be(e) {
|
|
954
952
|
let t = {}, n = {}, r = [], i, a = !1;
|
|
955
953
|
for (let o of e) {
|
|
956
954
|
let e = o.text;
|
|
@@ -965,7 +963,7 @@ function je(e) {
|
|
|
965
963
|
}
|
|
966
964
|
let c = e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);
|
|
967
965
|
if (c) {
|
|
968
|
-
c[1] && (t.title = c[1]), t.categories =
|
|
966
|
+
c[1] && (t.title = c[1]), t.categories = Ve(c[2]).map((e) => He(e.trim()));
|
|
969
967
|
continue;
|
|
970
968
|
}
|
|
971
969
|
let l = e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);
|
|
@@ -993,7 +991,7 @@ function je(e) {
|
|
|
993
991
|
if (f) {
|
|
994
992
|
r.push({
|
|
995
993
|
type: "bar",
|
|
996
|
-
data:
|
|
994
|
+
data: V(f[1], "bar", e, o.line)
|
|
997
995
|
});
|
|
998
996
|
continue;
|
|
999
997
|
}
|
|
@@ -1001,12 +999,12 @@ function je(e) {
|
|
|
1001
999
|
if (p) {
|
|
1002
1000
|
r.push({
|
|
1003
1001
|
type: "line",
|
|
1004
|
-
data:
|
|
1002
|
+
data: V(p[1], "line", e, o.line)
|
|
1005
1003
|
});
|
|
1006
1004
|
continue;
|
|
1007
1005
|
}
|
|
1008
1006
|
let m = e.match(/^(x-axis|y-axis|bar|line|title)\b/i);
|
|
1009
|
-
if (m) throw
|
|
1007
|
+
if (m) throw We(m[1].toLowerCase(), e, o.line);
|
|
1010
1008
|
}
|
|
1011
1009
|
if (!n.range && r.length > 0) {
|
|
1012
1010
|
let e = r.flatMap((e) => e.data), t = Math.min(...e), i = Math.max(...e), a = i - t || 1;
|
|
@@ -1026,36 +1024,36 @@ function je(e) {
|
|
|
1026
1024
|
series: r
|
|
1027
1025
|
};
|
|
1028
1026
|
}
|
|
1029
|
-
function
|
|
1027
|
+
function Ve(e) {
|
|
1030
1028
|
let t = [], n = "", r = !1;
|
|
1031
1029
|
for (let i of e) i === "\"" ? (r = !r, n += i) : i === "," && !r ? (t.push(n), n = "") : n += i;
|
|
1032
1030
|
return t.push(n), t;
|
|
1033
1031
|
}
|
|
1034
|
-
function
|
|
1032
|
+
function He(e) {
|
|
1035
1033
|
return e.length >= 2 && e.startsWith("\"") && e.endsWith("\"") ? e.slice(1, -1) : e;
|
|
1036
1034
|
}
|
|
1037
|
-
function
|
|
1035
|
+
function V(e, t, n, r) {
|
|
1038
1036
|
return e.split(",").map((e, i) => {
|
|
1039
1037
|
let a = e.trim(), o = parseFloat(a);
|
|
1040
1038
|
if (a.length === 0 || Number.isNaN(o)) throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i + 1} in "${n}". Every value in a ${t} [...] list must be a number.`);
|
|
1041
1039
|
return o;
|
|
1042
1040
|
});
|
|
1043
1041
|
}
|
|
1044
|
-
var
|
|
1042
|
+
var Ue = {
|
|
1045
1043
|
"x-axis": "x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title",
|
|
1046
1044
|
"y-axis": "y-axis 0 --> 100 (numeric range) or y-axis \"Title\" (title only), optionally preceded by a quoted title before a range",
|
|
1047
1045
|
bar: "bar [10, 20, 30] — a comma-separated numeric array in square brackets",
|
|
1048
1046
|
line: "line [10, 20, 30] — a comma-separated numeric array in square brackets",
|
|
1049
1047
|
title: "title \"Chart Title\" — a double-quoted string"
|
|
1050
1048
|
};
|
|
1051
|
-
function
|
|
1052
|
-
let r =
|
|
1049
|
+
function We(e, t, n) {
|
|
1050
|
+
let r = Ue[e] ?? e;
|
|
1053
1051
|
return /* @__PURE__ */ Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`);
|
|
1054
1052
|
}
|
|
1055
1053
|
//#endregion
|
|
1056
1054
|
//#region packages/mermaid-parser/src/xychart/colors.ts
|
|
1057
|
-
var
|
|
1058
|
-
function
|
|
1055
|
+
var H = "#3b82f6";
|
|
1056
|
+
function U(e) {
|
|
1059
1057
|
let t = e.replace("#", ""), n = parseInt(t.substring(0, 2), 16) / 255, r = parseInt(t.substring(2, 4), 16) / 255, i = parseInt(t.substring(4, 6), 16) / 255, a = Math.max(n, r, i), o = Math.min(n, r, i), s = (a + o) / 2;
|
|
1060
1058
|
if (a === o) return [
|
|
1061
1059
|
0,
|
|
@@ -1069,26 +1067,26 @@ function J(e) {
|
|
|
1069
1067
|
s * 100
|
|
1070
1068
|
];
|
|
1071
1069
|
}
|
|
1072
|
-
function
|
|
1070
|
+
function Ge(e, t, n) {
|
|
1073
1071
|
let r = t / 100, i = n / 100, a = (1 - Math.abs(2 * i - 1)) * r, o = a * (1 - Math.abs(e / 60 % 2 - 1)), s = i - a / 2, c, l, u;
|
|
1074
1072
|
e < 60 ? (c = a, l = o, u = 0) : e < 120 ? (c = o, l = a, u = 0) : e < 180 ? (c = 0, l = a, u = o) : e < 240 ? (c = 0, l = o, u = a) : e < 300 ? (c = o, l = 0, u = a) : (c = a, l = 0, u = o);
|
|
1075
1073
|
let d = (e) => Math.round((e + s) * 255).toString(16).padStart(2, "0");
|
|
1076
1074
|
return `#${d(c)}${d(l)}${d(u)}`;
|
|
1077
1075
|
}
|
|
1078
|
-
function
|
|
1076
|
+
function W(e) {
|
|
1079
1077
|
return /^#[0-9a-fA-F]{6}$/.test(e);
|
|
1080
1078
|
}
|
|
1081
|
-
function
|
|
1082
|
-
return
|
|
1079
|
+
function G(e) {
|
|
1080
|
+
return U(e)[2] < 50;
|
|
1083
1081
|
}
|
|
1084
|
-
function
|
|
1082
|
+
function Ke(e, t, n) {
|
|
1085
1083
|
if (e === 0) return t;
|
|
1086
|
-
let r =
|
|
1087
|
-
return
|
|
1084
|
+
let r = W(t) ? t : H, i = n && W(n) ? n : void 0, [a, o] = U(r), s = Math.max(55, Math.min(85, o)), c = Math.ceil(e / 2), l = e % 2 == 1, u = i && G(i) ? !l : l, d = u ? Math.max(25, 48 - c * 13) : Math.min(78, 55 + c * 11);
|
|
1085
|
+
return Ge(((a + (u ? -8 : -12) * c) % 360 + 360) % 360, s, d);
|
|
1088
1086
|
}
|
|
1089
1087
|
//#endregion
|
|
1090
1088
|
//#region packages/mermaid-parser/src/expanded-shapes.ts
|
|
1091
|
-
var
|
|
1089
|
+
var K = {
|
|
1092
1090
|
rect: "rectangle",
|
|
1093
1091
|
rectangle: "rectangle",
|
|
1094
1092
|
proc: "rectangle",
|
|
@@ -1214,28 +1212,28 @@ var Z = {
|
|
|
1214
1212
|
text: "text",
|
|
1215
1213
|
anchor: "anchor"
|
|
1216
1214
|
};
|
|
1217
|
-
function
|
|
1218
|
-
return
|
|
1215
|
+
function q(e) {
|
|
1216
|
+
return K[e.trim().toLowerCase()];
|
|
1219
1217
|
}
|
|
1220
|
-
function
|
|
1221
|
-
return Object.keys(
|
|
1218
|
+
function qe() {
|
|
1219
|
+
return Object.keys(K).sort();
|
|
1222
1220
|
}
|
|
1223
|
-
function
|
|
1221
|
+
function J(e) {
|
|
1224
1222
|
let t = {};
|
|
1225
|
-
for (let n of
|
|
1223
|
+
for (let n of Je(e, ",")) {
|
|
1226
1224
|
let e = n.trim();
|
|
1227
1225
|
if (e.length === 0) continue;
|
|
1228
|
-
let r =
|
|
1226
|
+
let r = Ye(e, ":");
|
|
1229
1227
|
if (r === -1) {
|
|
1230
|
-
t.shape ??=
|
|
1228
|
+
t.shape ??= Xe(e);
|
|
1231
1229
|
continue;
|
|
1232
1230
|
}
|
|
1233
|
-
let i = e.slice(0, r).trim().toLowerCase(), a =
|
|
1231
|
+
let i = e.slice(0, r).trim().toLowerCase(), a = Xe(e.slice(r + 1).trim());
|
|
1234
1232
|
i.length > 0 && (t[i] = a);
|
|
1235
1233
|
}
|
|
1236
1234
|
return t;
|
|
1237
1235
|
}
|
|
1238
|
-
function
|
|
1236
|
+
function Je(e, t) {
|
|
1239
1237
|
let n = [], r = "", i = null;
|
|
1240
1238
|
for (let a of e) {
|
|
1241
1239
|
if (i !== null) {
|
|
@@ -1254,7 +1252,7 @@ function Be(e, t) {
|
|
|
1254
1252
|
}
|
|
1255
1253
|
return n.push(r), n;
|
|
1256
1254
|
}
|
|
1257
|
-
function
|
|
1255
|
+
function Ye(e, t) {
|
|
1258
1256
|
let n = null;
|
|
1259
1257
|
for (let r = 0; r < e.length; r++) {
|
|
1260
1258
|
let i = e[r];
|
|
@@ -1270,10 +1268,10 @@ function Ve(e, t) {
|
|
|
1270
1268
|
}
|
|
1271
1269
|
return -1;
|
|
1272
1270
|
}
|
|
1273
|
-
function
|
|
1271
|
+
function Xe(e) {
|
|
1274
1272
|
return e.length >= 2 && (e.startsWith("\"") && e.endsWith("\"") || e.startsWith("'") && e.endsWith("'")) ? e.slice(1, -1) : e;
|
|
1275
1273
|
}
|
|
1276
|
-
function
|
|
1274
|
+
function Y(e) {
|
|
1277
1275
|
if (!e.startsWith("@{")) return;
|
|
1278
1276
|
let t = 0, n = null;
|
|
1279
1277
|
for (let r = 1; r < e.length; r++) {
|
|
@@ -1297,6 +1295,438 @@ function He(e) {
|
|
|
1297
1295
|
}
|
|
1298
1296
|
}
|
|
1299
1297
|
//#endregion
|
|
1300
|
-
|
|
1298
|
+
//#region packages/mermaid-parser/src/flowchart-parser.ts
|
|
1299
|
+
function Ze(e) {
|
|
1300
|
+
let t = e.trim();
|
|
1301
|
+
return t.length >= 2 && (t[0] === "\"" && t[t.length - 1] === "\"" || t[0] === "'" && t[t.length - 1] === "'") ? t.slice(1, -1) : t;
|
|
1302
|
+
}
|
|
1303
|
+
var Qe = "\"graph <dir>\"/\"flowchart <dir>\" (dir: TD, TB, LR, BT, RL), \"stateDiagram-v2\", \"sequenceDiagram\", \"classDiagram\", \"erDiagram\", \"xychart-beta\", \"C4Context\"/\"C4Container\"/\"C4Component\"/\"C4Dynamic\"/\"C4Deployment\", \"architecture-beta\"";
|
|
1304
|
+
function $e(e) {
|
|
1305
|
+
let t = e.trim().toLowerCase();
|
|
1306
|
+
if (/^sequence/.test(t)) return "sequenceDiagram";
|
|
1307
|
+
if (/^class/.test(t)) return "classDiagram";
|
|
1308
|
+
if (/^er/.test(t)) return "erDiagram";
|
|
1309
|
+
if (/^xychart/.test(t)) return "xychart-beta";
|
|
1310
|
+
if (/^state/.test(t)) return "stateDiagram-v2";
|
|
1311
|
+
}
|
|
1312
|
+
var et = /^(?:[\w-]+@)?<?(?:-{2,}|={2,}|-\.+-?|~{3,})/;
|
|
1313
|
+
function tt(e) {
|
|
1314
|
+
let t = [];
|
|
1315
|
+
for (let n of e) n.forEach((e, n) => {
|
|
1316
|
+
if (n === 0 && t.length > 0 && et.test(e.text)) {
|
|
1317
|
+
let n = t[t.length - 1];
|
|
1318
|
+
t[t.length - 1] = {
|
|
1319
|
+
text: `${n.text} ${e.text}`,
|
|
1320
|
+
line: n.line
|
|
1321
|
+
};
|
|
1322
|
+
} else t.push(e);
|
|
1323
|
+
});
|
|
1324
|
+
return t;
|
|
1325
|
+
}
|
|
1326
|
+
function nt(e) {
|
|
1327
|
+
let t = n(e.split("\n").map((e) => e.trim())), r = tt(s(e));
|
|
1328
|
+
if (r.length === 0) throw Error("Empty mermaid diagram");
|
|
1329
|
+
let i = r[0], a = /^stateDiagram(-v2)?\s*$/i.test(i.text) ? it(r) : rt(r);
|
|
1330
|
+
return a.initConfig = t, a;
|
|
1331
|
+
}
|
|
1332
|
+
function rt(e) {
|
|
1333
|
+
let t = e[0];
|
|
1334
|
+
if (t === void 0)
|
|
1335
|
+
/* v8 ignore next */
|
|
1336
|
+
throw Error("parseFlowchart called with no lines");
|
|
1337
|
+
let n = t.text, a = n.match(/^(?:graph|flowchart)\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1338
|
+
if (!a) {
|
|
1339
|
+
let e = n.match(/^(?:graph|flowchart)\b\s*(.*)$/i);
|
|
1340
|
+
if (e) {
|
|
1341
|
+
let r = e[1].trim();
|
|
1342
|
+
throw Error(r.length > 0 ? `Line ${t.line}: Invalid direction "${r}" in header "${n}". Expected one of: TD, TB, LR, BT, RL.` : `Line ${t.line}: Missing direction in header "${n}". Expected e.g. "graph TD" or "flowchart LR" — one of: TD, TB, LR, BT, RL.`);
|
|
1343
|
+
}
|
|
1344
|
+
let r = $e(n), i = r && r.toLowerCase() !== n.trim().toLowerCase() ? ` Did you mean "${r}"?` : "";
|
|
1345
|
+
throw Error(`Line ${t.line}: Invalid mermaid header: "${n}".${i} Supported headers: ${Qe}.`);
|
|
1346
|
+
}
|
|
1347
|
+
let o = {
|
|
1348
|
+
direction: l(a[1]),
|
|
1349
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1350
|
+
edges: [],
|
|
1351
|
+
subgraphs: [],
|
|
1352
|
+
classDefs: /* @__PURE__ */ new Map(),
|
|
1353
|
+
classAssignments: /* @__PURE__ */ new Map(),
|
|
1354
|
+
nodeStyles: /* @__PURE__ */ new Map(),
|
|
1355
|
+
linkStyles: /* @__PURE__ */ new Map(),
|
|
1356
|
+
interactions: /* @__PURE__ */ new Map()
|
|
1357
|
+
}, s = [];
|
|
1358
|
+
for (let t = 1; t < e.length; t++) {
|
|
1359
|
+
let n = e[t].text;
|
|
1360
|
+
if (d(n, o) || u(n, o) || p(n, o)) continue;
|
|
1361
|
+
if (/^click\s+/i.test(n)) {
|
|
1362
|
+
mt(n, o);
|
|
1363
|
+
continue;
|
|
1364
|
+
}
|
|
1365
|
+
if (gt(n, o)) continue;
|
|
1366
|
+
let a = n.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
|
|
1367
|
+
if (a) {
|
|
1368
|
+
let e = a[1].trim(), t = i(a[2]);
|
|
1369
|
+
if (e === "default") o.linkStyles.set("default", {
|
|
1370
|
+
...o.linkStyles.get("default"),
|
|
1371
|
+
...t
|
|
1372
|
+
});
|
|
1373
|
+
else {
|
|
1374
|
+
let n = e.split(",").map((e) => parseInt(e.trim(), 10));
|
|
1375
|
+
for (let e of n) isNaN(e) || o.linkStyles.set(e, {
|
|
1376
|
+
...o.linkStyles.get(e),
|
|
1377
|
+
...t
|
|
1378
|
+
});
|
|
1379
|
+
}
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
let c = n.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1383
|
+
if (c && s.length > 0) {
|
|
1384
|
+
s[s.length - 1].direction = l(c[1]);
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
let f = n.match(/^subgraph\s+(.+)$/);
|
|
1388
|
+
if (f) {
|
|
1389
|
+
let e = f[1].trim(), t = e.match(/^([^\s[]+)\s*\[(.+)\]$/), n, i;
|
|
1390
|
+
t ? (n = t[1], i = r(Ze(t[2]))) : (i = r(Ze(e)), n = i.replace(/\s+/g, "_").replace(/[^\p{L}\p{N}_-]/gu, ""));
|
|
1391
|
+
let a = {
|
|
1392
|
+
id: n,
|
|
1393
|
+
label: i,
|
|
1394
|
+
nodeIds: [],
|
|
1395
|
+
children: []
|
|
1396
|
+
};
|
|
1397
|
+
s.push(a);
|
|
1398
|
+
continue;
|
|
1399
|
+
}
|
|
1400
|
+
if (n === "end") {
|
|
1401
|
+
let e = s.pop();
|
|
1402
|
+
e && (s.length > 0 ? s[s.length - 1].children.push(e) : o.subgraphs.push(e));
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
bt(n, o, s);
|
|
1406
|
+
}
|
|
1407
|
+
return o;
|
|
1408
|
+
}
|
|
1409
|
+
function it(e) {
|
|
1410
|
+
let t = {
|
|
1411
|
+
direction: "TD",
|
|
1412
|
+
nodes: /* @__PURE__ */ new Map(),
|
|
1413
|
+
edges: [],
|
|
1414
|
+
subgraphs: [],
|
|
1415
|
+
classDefs: /* @__PURE__ */ new Map(),
|
|
1416
|
+
classAssignments: /* @__PURE__ */ new Map(),
|
|
1417
|
+
nodeStyles: /* @__PURE__ */ new Map(),
|
|
1418
|
+
linkStyles: /* @__PURE__ */ new Map(),
|
|
1419
|
+
interactions: /* @__PURE__ */ new Map()
|
|
1420
|
+
}, n = [], a = /* @__PURE__ */ new Set(), o = 0, s = 0;
|
|
1421
|
+
for (let c = 1; c < e.length; c++) {
|
|
1422
|
+
let f = e[c].text;
|
|
1423
|
+
if (d(f, t) || u(f, t) || p(f, t)) continue;
|
|
1424
|
+
let m = f.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);
|
|
1425
|
+
if (m) {
|
|
1426
|
+
n.length > 0 ? n[n.length - 1].direction = l(m[1]) : t.direction = l(m[1]);
|
|
1427
|
+
continue;
|
|
1428
|
+
}
|
|
1429
|
+
let h = f.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);
|
|
1430
|
+
if (h) {
|
|
1431
|
+
let e = h[1].trim(), n = i(h[2]);
|
|
1432
|
+
if (e === "default") t.linkStyles.set("default", {
|
|
1433
|
+
...t.linkStyles.get("default"),
|
|
1434
|
+
...n
|
|
1435
|
+
});
|
|
1436
|
+
else {
|
|
1437
|
+
let r = e.split(",").map((e) => parseInt(e.trim(), 10));
|
|
1438
|
+
for (let e of r) isNaN(e) || t.linkStyles.set(e, {
|
|
1439
|
+
...t.linkStyles.get(e),
|
|
1440
|
+
...n
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
if (gt(f, t)) continue;
|
|
1446
|
+
let g = f.match(/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}]+)\s*\{$/u);
|
|
1447
|
+
if (g) {
|
|
1448
|
+
let e = g[1] ?? g[2], r = g[2], i = {
|
|
1449
|
+
id: r,
|
|
1450
|
+
label: e,
|
|
1451
|
+
nodeIds: [],
|
|
1452
|
+
children: []
|
|
1453
|
+
};
|
|
1454
|
+
n.push(i), a.add(r), t.nodes.delete(r);
|
|
1455
|
+
continue;
|
|
1456
|
+
}
|
|
1457
|
+
if (f === "}") {
|
|
1458
|
+
let e = n.pop();
|
|
1459
|
+
e && (n.length > 0 ? n[n.length - 1].children.push(e) : t.subgraphs.push(e));
|
|
1460
|
+
continue;
|
|
1461
|
+
}
|
|
1462
|
+
let _ = f.match(/^state\s+"([^"]+)"\s+as\s+([\w\p{L}]+)\s*$/u);
|
|
1463
|
+
if (_) {
|
|
1464
|
+
let e = r(_[1]), i = _[2];
|
|
1465
|
+
at(t, n, i, e);
|
|
1466
|
+
continue;
|
|
1467
|
+
}
|
|
1468
|
+
let v = f.match(/^(\[\*\]|[\w\p{L}-]+)(?::::([\w][\w-]*))?\s*(?:([\w-]+)@)?-->\s*(\[\*\]|[\w\p{L}-]+)(?::::([\w][\w-]*))?(?:\s*:\s*(.+))?$/u);
|
|
1469
|
+
if (v) {
|
|
1470
|
+
let e = v[1], i = v[2], c = v[3], l = v[4], u = v[5], d = v[6]?.trim(), f = d ? r(d) : void 0;
|
|
1471
|
+
e === "[*]" ? (o++, e = `_start${o > 1 ? o : ""}`, X(t, n, {
|
|
1472
|
+
id: e,
|
|
1473
|
+
label: "",
|
|
1474
|
+
shape: "state-start"
|
|
1475
|
+
})) : a.has(e) || Z(t, n, e), l === "[*]" ? (s++, l = `_end${s > 1 ? s : ""}`, X(t, n, {
|
|
1476
|
+
id: l,
|
|
1477
|
+
label: "",
|
|
1478
|
+
shape: "state-end"
|
|
1479
|
+
})) : a.has(l) || Z(t, n, l), i !== void 0 && t.classAssignments.set(e, i), u !== void 0 && t.classAssignments.set(l, u), t.edges.push({
|
|
1480
|
+
source: e,
|
|
1481
|
+
target: l,
|
|
1482
|
+
label: f,
|
|
1483
|
+
style: "solid",
|
|
1484
|
+
hasArrowStart: !1,
|
|
1485
|
+
hasArrowEnd: !0,
|
|
1486
|
+
...c === void 0 ? {} : { id: c }
|
|
1487
|
+
});
|
|
1488
|
+
continue;
|
|
1489
|
+
}
|
|
1490
|
+
let y = f.match(/^([\w\p{L}-]+):::([\w][\w-]*)\s*$/u);
|
|
1491
|
+
if (y) {
|
|
1492
|
+
let e = y[1];
|
|
1493
|
+
a.has(e) || Z(t, n, e), t.classAssignments.set(e, y[2]);
|
|
1494
|
+
continue;
|
|
1495
|
+
}
|
|
1496
|
+
let b = f.match(/^([\w\p{L}-]+)\s*:\s*(.+)$/u);
|
|
1497
|
+
if (b) {
|
|
1498
|
+
let e = b[1];
|
|
1499
|
+
at(t, n, e, r(b[2].trim()));
|
|
1500
|
+
continue;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
for (let e of t.classAssignments.keys()) !t.nodes.has(e) && !a.has(e) && Z(t, [], e);
|
|
1504
|
+
return t;
|
|
1505
|
+
}
|
|
1506
|
+
function at(e, t, n, r) {
|
|
1507
|
+
let i = e.nodes.get(n);
|
|
1508
|
+
i && (i.label = r), X(e, t, {
|
|
1509
|
+
id: n,
|
|
1510
|
+
label: r,
|
|
1511
|
+
shape: "rounded"
|
|
1512
|
+
});
|
|
1513
|
+
}
|
|
1514
|
+
function X(e, t, n) {
|
|
1515
|
+
if (e.nodes.has(n.id) || e.nodes.set(n.id, n), t.length > 0) {
|
|
1516
|
+
let e = t[t.length - 1];
|
|
1517
|
+
e.nodeIds.includes(n.id) || e.nodeIds.push(n.id);
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
function Z(e, t, n) {
|
|
1521
|
+
if (!e.nodes.has(n)) X(e, t, {
|
|
1522
|
+
id: n,
|
|
1523
|
+
label: n,
|
|
1524
|
+
shape: "rounded"
|
|
1525
|
+
});
|
|
1526
|
+
else if (t.length > 0) {
|
|
1527
|
+
let e = t[t.length - 1];
|
|
1528
|
+
e.nodeIds.includes(n) || e.nodeIds.push(n);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
var ot = /^(<|o|x)?(-{2,}|={2,}|-\.+-|~{3,})(>|o|x)?(?:\|([^|]*)\|)?/, st = /* @__PURE__ */ new Set(["--", "=="]);
|
|
1532
|
+
function Q(e) {
|
|
1533
|
+
if (e === "o") return "circle";
|
|
1534
|
+
if (e === "x") return "cross";
|
|
1535
|
+
}
|
|
1536
|
+
var ct = /^(<|o|x)?(--|-\.|==)\s+(.+?)\s+(-{2,}[>ox]|={2,}[>ox]|\.+-[>ox]|-{3,}|={3,}|-\.+-)/, lt = [
|
|
1537
|
+
{
|
|
1538
|
+
regex: /^([\w\p{L}-]+)\(\(\(((?:"[^"]*"|(?!\)\)\)).)+)\)\)\)/u,
|
|
1539
|
+
shape: "doublecircle"
|
|
1540
|
+
},
|
|
1541
|
+
{
|
|
1542
|
+
regex: /^([\w\p{L}-]+)\(\[((?:"[^"]*"|(?!\]\)).)+)\]\)/u,
|
|
1543
|
+
shape: "stadium"
|
|
1544
|
+
},
|
|
1545
|
+
{
|
|
1546
|
+
regex: /^([\w\p{L}-]+)\(\(((?:"[^"]*"|(?!\)\)).)+)\)\)/u,
|
|
1547
|
+
shape: "circle"
|
|
1548
|
+
},
|
|
1549
|
+
{
|
|
1550
|
+
regex: /^([\w\p{L}-]+)\[\[((?:"[^"]*"|(?!\]\]).)+)\]\]/u,
|
|
1551
|
+
shape: "subroutine"
|
|
1552
|
+
},
|
|
1553
|
+
{
|
|
1554
|
+
regex: /^([\w\p{L}-]+)\[\(((?:"[^"]*"|(?!\)\]).)+)\)\]/u,
|
|
1555
|
+
shape: "cylinder"
|
|
1556
|
+
},
|
|
1557
|
+
{
|
|
1558
|
+
regex: /^([\w\p{L}-]+)\[\/((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,
|
|
1559
|
+
shape: (e) => e === "\\" ? "trapezoid" : "parallelogram"
|
|
1560
|
+
},
|
|
1561
|
+
{
|
|
1562
|
+
regex: /^([\w\p{L}-]+)\[\\((?:"[^"]*"|(?![\\/]\]).)+)([\\/])\]/u,
|
|
1563
|
+
shape: (e) => e === "/" ? "trapezoid-alt" : "parallelogram-alt"
|
|
1564
|
+
},
|
|
1565
|
+
{
|
|
1566
|
+
regex: /^([\w\p{L}-]+)>((?:"[^"]*"|(?!\]).)+)\]/u,
|
|
1567
|
+
shape: "asymmetric"
|
|
1568
|
+
},
|
|
1569
|
+
{
|
|
1570
|
+
regex: /^([\w\p{L}-]+)\{\{((?:"[^"]*"|(?!\}\}).)+)\}\}/u,
|
|
1571
|
+
shape: "hexagon"
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
regex: /^([\w\p{L}-]+)\[((?:"[^"]*"|(?!\]).)+)\]/u,
|
|
1575
|
+
shape: "rectangle"
|
|
1576
|
+
},
|
|
1577
|
+
{
|
|
1578
|
+
regex: /^([\w\p{L}-]+)\(((?:"[^"]*"|(?!\)).)+)\)/u,
|
|
1579
|
+
shape: "rounded"
|
|
1580
|
+
},
|
|
1581
|
+
{
|
|
1582
|
+
regex: /^([\w\p{L}-]+)\{((?:"[^"]*"|(?!\}).)+)\}/u,
|
|
1583
|
+
shape: "diamond"
|
|
1584
|
+
}
|
|
1585
|
+
], ut = /^([\w\p{L}]+(?:-[\w\p{L}]+)*)/u, dt = /^([\w\p{L}-]+)(?=@\{)/u;
|
|
1586
|
+
function ft(e) {
|
|
1587
|
+
if (e.shape) return q(e.shape) ?? "rectangle";
|
|
1588
|
+
if (e.icon !== void 0 || e.img !== void 0) switch (e.form?.toLowerCase()) {
|
|
1589
|
+
case "circle": return "circle";
|
|
1590
|
+
case "rounded": return "rounded";
|
|
1591
|
+
default: return "rectangle";
|
|
1592
|
+
}
|
|
1593
|
+
return "rectangle";
|
|
1594
|
+
}
|
|
1595
|
+
function pt(e, t) {
|
|
1596
|
+
return t.label !== void 0 && t.label.length > 0 ? t.label : t.icon ? t.icon : t.img ? t.img : e;
|
|
1597
|
+
}
|
|
1598
|
+
function mt(t, n) {
|
|
1599
|
+
e(t, n.interactions);
|
|
1600
|
+
}
|
|
1601
|
+
var ht = /^([\w-]+)(?=@\{)/;
|
|
1602
|
+
function gt(e, t) {
|
|
1603
|
+
let n = e.match(ht);
|
|
1604
|
+
if (!n || !t.edges.some((e) => e.id === n[1])) return !1;
|
|
1605
|
+
let r = Y(e.slice(n[1].length));
|
|
1606
|
+
return r ? (_t(t, n[1], J(r.body)), !0) : !1;
|
|
1607
|
+
}
|
|
1608
|
+
function _t(e, t, n) {
|
|
1609
|
+
for (let r of e.edges) r.id === t && (n.animate !== void 0 && (r.animate = n.animate.toLowerCase() !== "false"), n.animation !== void 0 && (r.animate = !0));
|
|
1610
|
+
}
|
|
1611
|
+
var vt = /^:::([\w][\w-]*)/, yt = /^([\w\p{L}-]+):::([\w][\w-]*)/u;
|
|
1612
|
+
function bt(e, t, n) {
|
|
1613
|
+
let i = e.trim(), a = xt(i, t, n);
|
|
1614
|
+
if (!a || a.ids.length === 0) return;
|
|
1615
|
+
i = a.remaining.trim();
|
|
1616
|
+
let o = a.ids;
|
|
1617
|
+
for (; i.length > 0;) {
|
|
1618
|
+
let e, a, s, c, l, u, d, f = i.match(/^([\w-]+)@(?=[-=<~ox])/);
|
|
1619
|
+
f && (d = f[1], i = i.slice(f[0].length));
|
|
1620
|
+
let p = i.match(ot), m = p?.[2], h = p?.[1], g = p?.[3];
|
|
1621
|
+
if (p && m !== void 0 && !(h === void 0 && g === void 0 && st.has(m))) {
|
|
1622
|
+
e = h !== void 0, l = Q(h);
|
|
1623
|
+
let t = p[4]?.trim();
|
|
1624
|
+
c = t ? r(t) : void 0, i = i.slice(p[0].length).trim(), a = Tt(m), s = g !== void 0, u = Q(g);
|
|
1625
|
+
} else {
|
|
1626
|
+
let t = i.match(ct);
|
|
1627
|
+
if (!t) break;
|
|
1628
|
+
e = !!t[1], l = Q(t[1]);
|
|
1629
|
+
let n = t[3].trim();
|
|
1630
|
+
c = n ? r(n) : void 0;
|
|
1631
|
+
let o = t[2], d = t[4];
|
|
1632
|
+
i = i.slice(t[0].length).trim(), a = Et(o, d), u = Q(d.slice(-1)), s = d.endsWith(">") || u !== void 0;
|
|
1633
|
+
}
|
|
1634
|
+
let _ = xt(i, t, n);
|
|
1635
|
+
if (!_ || _.ids.length === 0) break;
|
|
1636
|
+
i = _.remaining.trim();
|
|
1637
|
+
for (let n of o) for (let r of _.ids) t.edges.push({
|
|
1638
|
+
source: n,
|
|
1639
|
+
target: r,
|
|
1640
|
+
label: c,
|
|
1641
|
+
style: a,
|
|
1642
|
+
hasArrowStart: e,
|
|
1643
|
+
hasArrowEnd: s,
|
|
1644
|
+
...l === void 0 ? {} : { startMarker: l },
|
|
1645
|
+
...u === void 0 ? {} : { endMarker: u },
|
|
1646
|
+
...d === void 0 ? {} : { id: d }
|
|
1647
|
+
});
|
|
1648
|
+
o = _.ids;
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
function xt(e, t, n) {
|
|
1652
|
+
let r = St(e, t, n);
|
|
1653
|
+
if (!r) return null;
|
|
1654
|
+
let i = [r.id], a = r.remaining.trim();
|
|
1655
|
+
for (; a.startsWith("&");) {
|
|
1656
|
+
a = a.slice(1).trim();
|
|
1657
|
+
let e = St(a, t, n);
|
|
1658
|
+
if (!e) break;
|
|
1659
|
+
i.push(e.id), a = e.remaining.trim();
|
|
1660
|
+
}
|
|
1661
|
+
return {
|
|
1662
|
+
ids: i,
|
|
1663
|
+
remaining: a
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
function St(e, t, n) {
|
|
1667
|
+
let i = null, a = e, o, s = a.match(yt);
|
|
1668
|
+
s && (o = s[2], a = s[1] + a.slice(s[0].length));
|
|
1669
|
+
let c = a.match(dt);
|
|
1670
|
+
if (c) {
|
|
1671
|
+
let e = c[1], o = Y(a.slice(e.length));
|
|
1672
|
+
if (o) {
|
|
1673
|
+
let s = J(o.body);
|
|
1674
|
+
$(t, n, {
|
|
1675
|
+
id: e,
|
|
1676
|
+
label: r(pt(e, s)),
|
|
1677
|
+
shape: ft(s)
|
|
1678
|
+
}), i = e, a = a.slice(e.length + o.length);
|
|
1679
|
+
}
|
|
1680
|
+
}
|
|
1681
|
+
if (i === null) for (let { regex: e, shape: o } of lt) {
|
|
1682
|
+
let s = a.match(e);
|
|
1683
|
+
if (s) {
|
|
1684
|
+
i = s[1];
|
|
1685
|
+
let e = r(s[2]), c = typeof o == "function" ? o(s[3] ?? "") : o;
|
|
1686
|
+
$(t, n, {
|
|
1687
|
+
id: i,
|
|
1688
|
+
label: e,
|
|
1689
|
+
shape: c
|
|
1690
|
+
}), a = a.slice(s[0].length);
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if (i === null) {
|
|
1695
|
+
let e = a.match(ut);
|
|
1696
|
+
e && (i = e[1], t.nodes.has(i) ? Ct(t, n, i) || wt(n, i) : $(t, n, {
|
|
1697
|
+
id: i,
|
|
1698
|
+
label: i,
|
|
1699
|
+
shape: "rectangle"
|
|
1700
|
+
}), a = a.slice(e[0].length));
|
|
1701
|
+
}
|
|
1702
|
+
if (i === null) return null;
|
|
1703
|
+
o && t.classAssignments.set(i, o);
|
|
1704
|
+
let l = a.match(vt);
|
|
1705
|
+
return l && (t.classAssignments.set(i, l[1]), a = a.slice(l[0].length)), {
|
|
1706
|
+
id: i,
|
|
1707
|
+
remaining: a
|
|
1708
|
+
};
|
|
1709
|
+
}
|
|
1710
|
+
function $(e, t, n) {
|
|
1711
|
+
e.nodes.has(n.id) || e.nodes.set(n.id, n), wt(t, n.id);
|
|
1712
|
+
}
|
|
1713
|
+
function Ct(e, t, n) {
|
|
1714
|
+
let r = (e) => e.nodeIds.includes(n) || e.children.some(r);
|
|
1715
|
+
return e.subgraphs.some(r) || t.some(r);
|
|
1716
|
+
}
|
|
1717
|
+
function wt(e, t) {
|
|
1718
|
+
if (e.length > 0) {
|
|
1719
|
+
let n = e[e.length - 1];
|
|
1720
|
+
n.nodeIds.includes(t) || n.nodeIds.push(t);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
function Tt(e) {
|
|
1724
|
+
return e.startsWith("~") ? "invisible" : e.includes(".") ? "dotted" : e.startsWith("=") ? "thick" : "solid";
|
|
1725
|
+
}
|
|
1726
|
+
function Et(e, t) {
|
|
1727
|
+
return e.includes(".") || t.includes(".") ? "dotted" : e.startsWith("=") || t.startsWith("=") ? "thick" : "solid";
|
|
1728
|
+
}
|
|
1729
|
+
//#endregion
|
|
1730
|
+
export { H as CHART_ACCENT_FALLBACK, ne as architectureToGraph, ve as c4BoundaryTypeLine, be as c4Placement, ye as c4RelLabelLines, _e as c4TypeLine, B as checkActivationBalance, ze as fixActivationBalance, Oe as formatClassMember, Ke as getSeriesColor, N as isBlockType, j as isCssColor, G as isDarkBackground, W as isValidHex, qe as knownShapeNames, Y as matchExpandedBlock, x as parseArchitecture, M as parseBoxHeader, me as parseC4Diagram, Se as parseClassDiagram, ke as parseErDiagram, J as parseExpandedMeta, O as parseGenericTypes, nt as parseMermaid, F as parseSequenceDiagram, Be as parseXYChart, q as resolveShapeName, P as toBlockType, c as toDirection, he as wrapC4Text };
|
|
1301
1731
|
|
|
1302
1732
|
//# sourceMappingURL=index.js.map
|