@p10node/diagram 0.13.0 → 0.13.2
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.js +313 -290
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -129,14 +129,14 @@ function e(e, t, n, r) {
|
|
|
129
129
|
}
|
|
130
130
|
let R = new Float64Array(I), oe = () => L.forEach((e) => e.forEach((e, t) => R[e] = t));
|
|
131
131
|
oe();
|
|
132
|
-
let z = new Float64Array(I), B = new Float64Array(a),
|
|
132
|
+
let z = new Float64Array(I), B = new Float64Array(a), se = () => {
|
|
133
133
|
for (let e = 0; e < a; e++) {
|
|
134
134
|
if (N[e] > P[e]) continue;
|
|
135
135
|
let t = 0;
|
|
136
136
|
for (let n = N[e]; n <= P[e]; n++) t += R[F[e][n]] / Math.max(1, L[n].length);
|
|
137
137
|
B[e] = t / (P[e] - N[e] + 1);
|
|
138
138
|
}
|
|
139
|
-
},
|
|
139
|
+
}, V = (e, t) => {
|
|
140
140
|
if (!a) return [...e].sort((e, t) => z[e] - z[t] || R[e] - R[t]);
|
|
141
141
|
let r = {
|
|
142
142
|
node: -1,
|
|
@@ -178,7 +178,7 @@ function e(e, t, n, r) {
|
|
|
178
178
|
for (let n of e.items) n.node >= 0 ? c.push(n.node) : (c.push(F[n.cluster][t]), l(n), c.push(ie[n.cluster][t]));
|
|
179
179
|
};
|
|
180
180
|
return l(r), c;
|
|
181
|
-
},
|
|
181
|
+
}, ce = (e) => {
|
|
182
182
|
let t = 0;
|
|
183
183
|
for (let n = 0; n + 1 < e.length; n++) {
|
|
184
184
|
let r = [];
|
|
@@ -193,40 +193,40 @@ function e(e, t, n, r) {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
return t;
|
|
196
|
-
},
|
|
196
|
+
}, H = (e, t) => {
|
|
197
197
|
let n = 0, r = 0;
|
|
198
198
|
for (let [i, a] of t[e]) n += R[i] * a, r += a;
|
|
199
199
|
return r ? n / r : R[e];
|
|
200
200
|
};
|
|
201
201
|
for (let e of L) for (let t of e) z[t] = R[t];
|
|
202
|
-
|
|
203
|
-
let le = L.map((e) => [...e]),
|
|
204
|
-
for (let e = 0; e < 24 &&
|
|
205
|
-
|
|
202
|
+
se(), L = L.map((e, t) => V(e, t)), oe();
|
|
203
|
+
let le = L.map((e) => [...e]), U = ce(L);
|
|
204
|
+
for (let e = 0; e < 24 && U > 0; e++) {
|
|
205
|
+
se();
|
|
206
206
|
let t = e % 2 == 0;
|
|
207
207
|
for (let e = 1; e <= y; e++) {
|
|
208
208
|
let n = t ? e : y - e, r = t ? A : j;
|
|
209
|
-
for (let e of L[n]) z[e] =
|
|
210
|
-
L[n] =
|
|
209
|
+
for (let e of L[n]) z[e] = H(e, r);
|
|
210
|
+
L[n] = V(L[n], n), L[n].forEach((e, t) => R[e] = t);
|
|
211
211
|
}
|
|
212
|
-
let n =
|
|
213
|
-
n <
|
|
212
|
+
let n = ce(L);
|
|
213
|
+
n < U && (U = n, le = L.map((e) => [...e]));
|
|
214
214
|
}
|
|
215
215
|
L = le, oe();
|
|
216
|
-
let
|
|
217
|
-
n.forEach((e, t) => e.parent >= 0 &&
|
|
218
|
-
let
|
|
219
|
-
for (let e = 0; e < a; e++) N[e] > P[e] || (
|
|
220
|
-
let
|
|
221
|
-
for (let e = 0; e <= y; e++)
|
|
222
|
-
let
|
|
216
|
+
let ue = L.map((e) => e.reduce((e, t) => Math.max(e, C[t]), 0)), de = Array.from({ length: a }, () => []);
|
|
217
|
+
n.forEach((e, t) => e.parent >= 0 && de[e.parent].push(t));
|
|
218
|
+
let fe = (e) => n[e].pad[2] + Math.max(0, ...de[e].filter((t) => N[t] === N[e]).map(fe)), W = (e) => n[e].pad[3] + Math.max(0, ...de[e].filter((t) => P[t] === P[e]).map(W)), G = Array(y + 1).fill(0), pe = Array(y + 1).fill(0);
|
|
219
|
+
for (let e = 0; e < a; e++) N[e] > P[e] || (G[N[e]] = Math.max(G[N[e]], fe(e)), pe[P[e]] = Math.max(pe[P[e]], W(e)));
|
|
220
|
+
let me = [];
|
|
221
|
+
for (let e = 0; e <= y; e++) me[e] = e === 0 ? ue[0] / 2 + G[0] : me[e - 1] + ue[e - 1] / 2 + pe[e - 1] + r.ranksep + G[e] + ue[e] / 2;
|
|
222
|
+
let he = me[y] + ue[y] / 2 + pe[y], K = (e) => w[e] === 2 || w[e] === 3 ? 0 : S[e] / 2, ge = (e, t) => {
|
|
223
223
|
let i = D[e], a = w[e], o = w[t];
|
|
224
|
-
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep),
|
|
225
|
-
},
|
|
226
|
-
for (let e of L) for (let t = 1; t < e.length; t++)
|
|
227
|
-
let
|
|
224
|
+
return a === 2 && (i += n[O[e]].pad[0]), a === 3 && (i += r.nodesep / 2), o === 3 && (i += n[O[t]].pad[1]), o === 2 && (i += r.nodesep / 2), a < 2 && o < 2 && (i += a === 1 && o === 1 ? r.edgesep : a === 1 || o === 1 ? (r.nodesep + r.edgesep) / 2 : r.nodesep), K(e) + K(t) + i;
|
|
225
|
+
}, q = new Float64Array(I);
|
|
226
|
+
for (let e of L) for (let t = 1; t < e.length; t++) q[e[t]] = q[e[t - 1]] + ge(e[t - 1], e[t]);
|
|
227
|
+
let _e = (e, t, n) => {
|
|
228
228
|
let r = e.length, i = [0];
|
|
229
|
-
for (let t = 1; t < r; t++) i[t] = i[t - 1] +
|
|
229
|
+
for (let t = 1; t < r; t++) i[t] = i[t - 1] + ge(e[t - 1], e[t]);
|
|
230
230
|
let a = [];
|
|
231
231
|
for (let e = 0; e < r; e++) for (a.push({
|
|
232
232
|
s: e,
|
|
@@ -238,7 +238,7 @@ function e(e, t, n, r) {
|
|
|
238
238
|
if (e.wt / e.w < t.wt / t.w) break;
|
|
239
239
|
e.e = t.e, e.w += t.w, e.wt += t.wt, a.pop();
|
|
240
240
|
}
|
|
241
|
-
for (let t of a) for (let n = t.s; n <= t.e; n++)
|
|
241
|
+
for (let t of a) for (let n = t.s; n <= t.e; n++) q[e[n]] = t.wt / t.w + i[n];
|
|
242
242
|
};
|
|
243
243
|
for (let e = 0; e < 10; e++) {
|
|
244
244
|
let t = e >= 8, n = e % 2 == 0;
|
|
@@ -248,24 +248,24 @@ function e(e, t, n, r) {
|
|
|
248
248
|
let a = [], o = [];
|
|
249
249
|
for (let e of i) {
|
|
250
250
|
let r = 0, i = 0, s = (e) => {
|
|
251
|
-
for (let [t, n] of e) r +=
|
|
251
|
+
for (let [t, n] of e) r += q[t] * n, i += n;
|
|
252
252
|
};
|
|
253
|
-
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ae[e]), a.push(i ? r / i :
|
|
253
|
+
(t || n) && s(A[e]), (t || !n) && s(j[e]), s(ae[e]), a.push(i ? r / i : q[e]), o.push(i || .01);
|
|
254
254
|
}
|
|
255
|
-
|
|
255
|
+
_e(i, a, o);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
let
|
|
258
|
+
let J = I, ve = (e) => w[e] === 2 ? J + 2 * O[e] : w[e] === 3 ? J + 2 * O[e] + 1 : e;
|
|
259
259
|
if (a) {
|
|
260
260
|
let e = I + 2 * a, t = new Float64Array(e);
|
|
261
|
-
for (let e = 0; e < I; e++) t[e] =
|
|
262
|
-
for (let e = 0; e < a; e++) t[
|
|
263
|
-
for (let e = 0; e < I; e++) w[e] === 2 && (t[ve(e)] = Math.min(t[ve(e)],
|
|
261
|
+
for (let e = 0; e < I; e++) t[e] = q[e];
|
|
262
|
+
for (let e = 0; e < a; e++) t[J + 2 * e] = Infinity, t[J + 2 * e + 1] = -Infinity;
|
|
263
|
+
for (let e = 0; e < I; e++) w[e] === 2 && (t[ve(e)] = Math.min(t[ve(e)], q[e])), w[e] === 3 && (t[ve(e)] = Math.max(t[ve(e)], q[e]));
|
|
264
264
|
let r = Array.from({ length: e }, () => []), i = new Int32Array(e), o = (e, t, n) => {
|
|
265
265
|
r[e].push([t, n]), i[t]++;
|
|
266
266
|
};
|
|
267
|
-
for (let e of L) for (let t = 1; t < e.length; t++) o(ve(e[t - 1]), ve(e[t]),
|
|
268
|
-
for (let e = 0; e < a; e++) N[e] <= P[e] && o(
|
|
267
|
+
for (let e of L) for (let t = 1; t < e.length; t++) o(ve(e[t - 1]), ve(e[t]), ge(e[t - 1], e[t]));
|
|
268
|
+
for (let e = 0; e < a; e++) N[e] <= P[e] && o(J + 2 * e, J + 2 * e + 1, Math.max(n[e].minW, n[e].pad[0] + n[e].pad[1]));
|
|
269
269
|
let s = [];
|
|
270
270
|
for (let t = 0; t < e; t++) i[t] || s.push(t);
|
|
271
271
|
let c = 0, l = new Float64Array(t);
|
|
@@ -274,16 +274,16 @@ function e(e, t, n, r) {
|
|
|
274
274
|
c++;
|
|
275
275
|
for (let [t, n] of r[e]) Number.isFinite(l[e]) && (l[t] = Math.max(l[t], l[e] + n)), --i[t] || s.push(t);
|
|
276
276
|
}
|
|
277
|
-
if (c === e) for (let e = 0; e < I; e++)
|
|
277
|
+
if (c === e) for (let e = 0; e < I; e++) q[e] = l[ve(e)];
|
|
278
278
|
}
|
|
279
|
-
let
|
|
280
|
-
for (let e = 0; e < I; e++)
|
|
281
|
-
Number.isFinite(
|
|
282
|
-
for (let e = 0; e < I; e++)
|
|
279
|
+
let ye = Infinity, Y = -Infinity;
|
|
280
|
+
for (let e = 0; e < I; e++) ye = Math.min(ye, q[e] - K(e)), Y = Math.max(Y, q[e] + K(e) + D[e]);
|
|
281
|
+
Number.isFinite(ye) || (ye = Y = 0);
|
|
282
|
+
for (let e = 0; e < I; e++) q[e] -= ye;
|
|
283
283
|
let X = (e) => ({
|
|
284
|
-
x:
|
|
285
|
-
y:
|
|
286
|
-
}),
|
|
284
|
+
x: q[e],
|
|
285
|
+
y: me[E[e]]
|
|
286
|
+
}), be = /* @__PURE__ */ new Map();
|
|
287
287
|
{
|
|
288
288
|
let t = /* @__PURE__ */ new Map(), n = (e, n, r) => {
|
|
289
289
|
let i = t.get(e);
|
|
@@ -294,17 +294,17 @@ function e(e, t, n, r) {
|
|
|
294
294
|
};
|
|
295
295
|
f.forEach((t, r) => {
|
|
296
296
|
let i = M[r];
|
|
297
|
-
i && !re[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r,
|
|
297
|
+
i && !re[r] && (e[i[0]]?.spread && n(`${i[0]}:b`, r, q[i[1]]), e[i[i.length - 1]]?.spread && n(`${i[i.length - 1]}:t`, r, q[i[i.length - 2]]));
|
|
298
298
|
});
|
|
299
299
|
for (let [e, n] of t) {
|
|
300
300
|
if (n.length < 2) continue;
|
|
301
301
|
let t = Number(e.split(":")[0]);
|
|
302
302
|
n.sort((e, t) => e.nx - t.nx || e.i - t.i);
|
|
303
303
|
let r = Math.min(36, S[t] * .7 / (n.length - 1));
|
|
304
|
-
n.forEach((i, a) =>
|
|
304
|
+
n.forEach((i, a) => be.set(`${e}:${i.i}`, q[t] + (a - (n.length - 1) / 2) * r));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
let
|
|
307
|
+
let Z = f.map((e, n) => {
|
|
308
308
|
if (e.v === e.w) return null;
|
|
309
309
|
if (re[n]) {
|
|
310
310
|
let r = X(e.v), i = X(e.w), a = Math.sign(i.x - r.x) || 1, o = {
|
|
@@ -330,11 +330,11 @@ function e(e, t, n, r) {
|
|
|
330
330
|
if (!r) return null;
|
|
331
331
|
let i = [], a = [], o = X(r[0]);
|
|
332
332
|
i.push({
|
|
333
|
-
x:
|
|
333
|
+
x: be.get(`${r[0]}:b:${n}`) ?? o.x,
|
|
334
334
|
y: o.y + C[r[0]] / 2
|
|
335
335
|
});
|
|
336
336
|
for (let e = 1; e + 1 < r.length; e++) {
|
|
337
|
-
let t = X(r[e]), n =
|
|
337
|
+
let t = X(r[e]), n = ue[E[r[e]]] / 2;
|
|
338
338
|
n > .5 ? (i.push({
|
|
339
339
|
x: t.x,
|
|
340
340
|
y: t.y - n
|
|
@@ -345,7 +345,7 @@ function e(e, t, n, r) {
|
|
|
345
345
|
}
|
|
346
346
|
let s = X(r[r.length - 1]);
|
|
347
347
|
i.push({
|
|
348
|
-
x:
|
|
348
|
+
x: be.get(`${r[r.length - 1]}:t:${n}`) ?? s.x,
|
|
349
349
|
y: s.y - C[r[r.length - 1]] / 2
|
|
350
350
|
}), a.push(!1);
|
|
351
351
|
let l = i.length, u = Array(l).fill(0), d = (e) => (i[e + 1].x - i[e].x) / Math.max(.5, i[e + 1].y - i[e].y);
|
|
@@ -406,8 +406,8 @@ function e(e, t, n, r) {
|
|
|
406
406
|
}), xe = n.map((e, t) => {
|
|
407
407
|
if (N[t] > P[t]) return null;
|
|
408
408
|
let n = Infinity, r = -Infinity;
|
|
409
|
-
for (let e = N[t]; e <= P[t]; e++) n = Math.min(n,
|
|
410
|
-
let i =
|
|
409
|
+
for (let e = N[t]; e <= P[t]; e++) n = Math.min(n, q[F[t][e]]), r = Math.max(r, q[ie[t][e]]);
|
|
410
|
+
let i = me[N[t]] - ue[N[t]] / 2 - fe(t), a = me[P[t]] + ue[P[t]] / 2 + W(t);
|
|
411
411
|
return {
|
|
412
412
|
x: n,
|
|
413
413
|
y: i,
|
|
@@ -417,10 +417,10 @@ function e(e, t, n, r) {
|
|
|
417
417
|
});
|
|
418
418
|
return {
|
|
419
419
|
nodes: Array.from({ length: i }, (e, t) => X(t)),
|
|
420
|
-
edges:
|
|
420
|
+
edges: Z,
|
|
421
421
|
clusters: xe,
|
|
422
|
-
w:
|
|
423
|
-
h:
|
|
422
|
+
w: Y - ye,
|
|
423
|
+
h: he
|
|
424
424
|
};
|
|
425
425
|
}
|
|
426
426
|
// src/core/diagram/svg.ts
|
|
@@ -1304,12 +1304,12 @@ function F(t) {
|
|
|
1304
1304
|
x: t.x + re,
|
|
1305
1305
|
y: t.y + re + F
|
|
1306
1306
|
};
|
|
1307
|
-
}, B = (o ? R : oe) + 32,
|
|
1307
|
+
}, B = (o ? R : oe) + 32, se = (o ? oe : R) + 32 + F, V = (e) => {
|
|
1308
1308
|
let t = 0;
|
|
1309
1309
|
for (let n = d(e); n >= 0; n = d(n)) t++;
|
|
1310
1310
|
return t;
|
|
1311
|
-
},
|
|
1312
|
-
for (let e of
|
|
1311
|
+
}, ce = t.clusters.map((e, t) => t).sort((e, t) => V(e) - V(t)), H = t.clusters.map(() => null), le = [];
|
|
1312
|
+
for (let e of ce) {
|
|
1313
1313
|
let r = A.clusters[e];
|
|
1314
1314
|
if (!r) continue;
|
|
1315
1315
|
let a = t.clusters[e], o = z({
|
|
@@ -1319,7 +1319,7 @@ function F(t) {
|
|
|
1319
1319
|
x: r.x + r.w,
|
|
1320
1320
|
y: r.y + r.h
|
|
1321
1321
|
}), l = Math.min(o.x, c.x), d = Math.min(o.y, c.y), f = Math.abs(c.x - o.x), p = Math.abs(c.y - o.y), m = a.style ?? {};
|
|
1322
|
-
if (
|
|
1322
|
+
if (H[e] = {
|
|
1323
1323
|
x: l,
|
|
1324
1324
|
y: d,
|
|
1325
1325
|
w: f,
|
|
@@ -1340,7 +1340,7 @@ function F(t) {
|
|
|
1340
1340
|
});
|
|
1341
1341
|
}
|
|
1342
1342
|
}
|
|
1343
|
-
let
|
|
1343
|
+
let U = [];
|
|
1344
1344
|
v.forEach(({ e, v: t }, n) => {
|
|
1345
1345
|
if (e.line === "hidden") return;
|
|
1346
1346
|
let r = ne(e), i = {
|
|
@@ -1398,7 +1398,7 @@ function F(t) {
|
|
|
1398
1398
|
p: e.p
|
|
1399
1399
|
}))]), i), te(s, y, p, x, r), e.label) {
|
|
1400
1400
|
let t = a(w(e.label), b);
|
|
1401
|
-
|
|
1401
|
+
U.push({
|
|
1402
1402
|
p: o ? {
|
|
1403
1403
|
x: h.x + t.w / 2 + 4,
|
|
1404
1404
|
y: h.y
|
|
@@ -1421,7 +1421,7 @@ function F(t) {
|
|
|
1421
1421
|
}, { cv: u, cw: d } = v[n];
|
|
1422
1422
|
if (u >= 0 && !f(v[n].w, u) || d >= 0 && !f(v[n].v, d)) {
|
|
1423
1423
|
let e = I(l.start, l.segs);
|
|
1424
|
-
u >= 0 &&
|
|
1424
|
+
u >= 0 && H[u] && (e = L(e, H[u], !0)), d >= 0 && H[d] && (e = L(e, H[d], !1)), e.length > 1 && (l = {
|
|
1425
1425
|
start: e[0],
|
|
1426
1426
|
segs: e.slice(1).map((e) => ({
|
|
1427
1427
|
c: "L",
|
|
@@ -1452,14 +1452,14 @@ function F(t) {
|
|
|
1452
1452
|
p: e.p
|
|
1453
1453
|
}))]), i), p !== "none" && te(s, p, _, y, r), h !== "none" && te(s, h, C, S, r), e.label) {
|
|
1454
1454
|
let t = l.label ?? ie(l.start, _);
|
|
1455
|
-
|
|
1455
|
+
U.push({
|
|
1456
1456
|
p: t,
|
|
1457
1457
|
text: w(e.label)
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
1460
|
let D = (e, t, n) => {
|
|
1461
1461
|
let r = a(w(n), b), i = -t.y, o = t.x, s = Math.abs(i) * (r.w / 2 + 5) + Math.abs(o) * (r.h / 2 + 3);
|
|
1462
|
-
|
|
1462
|
+
U.push({
|
|
1463
1463
|
p: {
|
|
1464
1464
|
x: e.x - t.x * (16 + r.h / 2) + i * s,
|
|
1465
1465
|
y: e.y - t.y * (14 + r.h / 2) + o * s
|
|
@@ -1484,7 +1484,7 @@ function F(t) {
|
|
|
1484
1484
|
let n = z(A.nodes[t]);
|
|
1485
1485
|
k(s, e, g[t], n.x, n.y);
|
|
1486
1486
|
});
|
|
1487
|
-
for (let e of
|
|
1487
|
+
for (let e of U) {
|
|
1488
1488
|
let t = a(e.text, b);
|
|
1489
1489
|
e.plain || s.rect(e.p.x - t.w / 2 - 3, e.p.y - t.h / 2 - 1, t.w + 6, t.h + 2, {
|
|
1490
1490
|
fill: u.label,
|
|
@@ -1500,9 +1500,9 @@ function F(t) {
|
|
|
1500
1500
|
size: 16,
|
|
1501
1501
|
bold: !0
|
|
1502
1502
|
})), {
|
|
1503
|
-
svg: s.toString(B,
|
|
1503
|
+
svg: s.toString(B, se),
|
|
1504
1504
|
w: Math.ceil(B),
|
|
1505
|
-
h: Math.ceil(
|
|
1505
|
+
h: Math.ceil(se)
|
|
1506
1506
|
};
|
|
1507
1507
|
}
|
|
1508
1508
|
var ie = (e, t) => ({
|
|
@@ -1549,8 +1549,12 @@ function L(e, t, n) {
|
|
|
1549
1549
|
}, ...i.slice(a)];
|
|
1550
1550
|
return n ? d : d.reverse();
|
|
1551
1551
|
}
|
|
1552
|
-
// src/core/
|
|
1552
|
+
// src/core/dict.ts
|
|
1553
1553
|
function R(e) {
|
|
1554
|
+
return Object.assign(Object.create(null), e);
|
|
1555
|
+
}
|
|
1556
|
+
// src/core/diagram/dot.ts
|
|
1557
|
+
function oe(e) {
|
|
1554
1558
|
let t = [], n = e.length, r = 0, i = !0;
|
|
1555
1559
|
for (; r < n;) {
|
|
1556
1560
|
let a = e[r];
|
|
@@ -1614,7 +1618,7 @@ function R(e) {
|
|
|
1614
1618
|
}
|
|
1615
1619
|
return t;
|
|
1616
1620
|
}
|
|
1617
|
-
var
|
|
1621
|
+
var z = R({
|
|
1618
1622
|
box: "rect",
|
|
1619
1623
|
rect: "rect",
|
|
1620
1624
|
rectangle: "rect",
|
|
@@ -1658,7 +1662,7 @@ var oe = {
|
|
|
1658
1662
|
record: "rect",
|
|
1659
1663
|
mrecord: "round",
|
|
1660
1664
|
underlinebox: "rect"
|
|
1661
|
-
},
|
|
1665
|
+
}), B = R({
|
|
1662
1666
|
normal: "arrow",
|
|
1663
1667
|
inv: "arrow",
|
|
1664
1668
|
empty: "triangle",
|
|
@@ -1682,11 +1686,11 @@ var oe = {
|
|
|
1682
1686
|
tee: "one",
|
|
1683
1687
|
curve: "open",
|
|
1684
1688
|
icurve: "open"
|
|
1685
|
-
};
|
|
1686
|
-
function
|
|
1689
|
+
});
|
|
1690
|
+
function se(e, t) {
|
|
1687
1691
|
if (!e) return t;
|
|
1688
1692
|
let n = e.toLowerCase().replace(/^[lr](?=[a-z])/, "");
|
|
1689
|
-
return
|
|
1693
|
+
return B[n] ?? B[n.replace(/^o/, "")] ?? t;
|
|
1690
1694
|
}
|
|
1691
1695
|
function V(e) {
|
|
1692
1696
|
if (!e) return;
|
|
@@ -1713,17 +1717,17 @@ function V(e) {
|
|
|
1713
1717
|
}
|
|
1714
1718
|
return l(/^[a-z]+\d+$/.test(r) ? r.replace(/\d+$/, "") : r);
|
|
1715
1719
|
}
|
|
1716
|
-
function
|
|
1720
|
+
function ce(e) {
|
|
1717
1721
|
return h(e.replace(/<br\s*\/?>/gi, "\n").replace(/<\/tr>/gi, "\n").replace(/<\/td>\s*<td/gi, " <td").replace(/<[^>]+>/g, "").replace(/\n\s*\n/g, "\n")).split("\n").map((e) => e.trim()).filter(Boolean).join("\n");
|
|
1718
1722
|
}
|
|
1719
1723
|
function H(e, t, n = "") {
|
|
1720
1724
|
return e.replace(/\\[nlr]/g, "\n").replace(/\\N/g, t).replace(/\\G/g, n).replace(/\\(.)/g, "$1").replace(/\n$/, "");
|
|
1721
1725
|
}
|
|
1722
|
-
function
|
|
1726
|
+
function le(e, t) {
|
|
1723
1727
|
return H(e, t).replace(/<[^>]*>/g, "").split(/[|{}]/).map((e) => e.trim()).filter(Boolean);
|
|
1724
1728
|
}
|
|
1725
|
-
function
|
|
1726
|
-
let t =
|
|
1729
|
+
function U(e) {
|
|
1730
|
+
let t = oe(e), n = 0, r = (e = 0) => t[n + e], i = (e, t = 0) => r(t)?.t === "p" && r(t).v === e, a = (e) => i(e) ? (n++, !0) : !1, o = (e) => r()?.t === "id" && r().v.toLowerCase() === e, s = [];
|
|
1727
1731
|
for (; n < t.length;) {
|
|
1728
1732
|
if (o("strict") && n++, !o("graph") && !o("digraph")) {
|
|
1729
1733
|
n++;
|
|
@@ -1832,11 +1836,11 @@ function le(e) {
|
|
|
1832
1836
|
BT: "BT",
|
|
1833
1837
|
TB: "TB"
|
|
1834
1838
|
}[(m.rankdir ?? "TB").toUpperCase()] ?? "TB";
|
|
1835
|
-
l.g.dir = C, m.label && (l.g.title = m.label.startsWith("<") ?
|
|
1839
|
+
l.g.dir = C, m.label && (l.g.title = m.label.startsWith("<") ? ce(m.label.slice(1, -1)) : H(m.label, "", c));
|
|
1836
1840
|
for (let e of l.g.nodes) ue(e, u.get(e.id) ?? {});
|
|
1837
1841
|
for (let e of l.g.clusters) {
|
|
1838
1842
|
let t = h.get(e.id) ?? {};
|
|
1839
|
-
e.label = t.label ? t.label.startsWith("<") ?
|
|
1843
|
+
e.label = t.label ? t.label.startsWith("<") ? ce(t.label.slice(1, -1)) : H(t.label, "", e.id) : "";
|
|
1840
1844
|
let n = {}, r = (t.style ?? "").toLowerCase();
|
|
1841
1845
|
r.includes("filled") ? n.fill = V(t.fillcolor ?? t.color ?? t.bgcolor) ?? "#d3d3d3" : t.bgcolor && (n.fill = V(t.bgcolor)), (t.color || t.pencolor) && (n.stroke = V(t.pencolor ?? t.color)), r.includes("dashed") && (n.dash = "6 4"), r.includes("dotted") && (n.dash = "2 3"), t.fontcolor && (n.color = V(t.fontcolor)), r.includes("invis") && (n.stroke = n.fill = "none"), e.style = n;
|
|
1842
1846
|
}
|
|
@@ -1848,12 +1852,12 @@ function le(e) {
|
|
|
1848
1852
|
}
|
|
1849
1853
|
function ue(e, t) {
|
|
1850
1854
|
let n = (t.shape ?? "ellipse").toLowerCase();
|
|
1851
|
-
e.shape =
|
|
1855
|
+
e.shape = z[n] ?? "ellipse";
|
|
1852
1856
|
let r = t.label;
|
|
1853
1857
|
if (r !== void 0) {
|
|
1854
|
-
if (r.startsWith("<") && r.endsWith(">")) e.label =
|
|
1858
|
+
if (r.startsWith("<") && r.endsWith(">")) e.label = ce(r.slice(1, -1));
|
|
1855
1859
|
else if (n === "record" || n === "mrecord") {
|
|
1856
|
-
let t =
|
|
1860
|
+
let t = le(r, e.id);
|
|
1857
1861
|
e.label = t.join("\n"), t.length > 1 && (e.sections = t.map((e) => ({
|
|
1858
1862
|
rows: [[e]],
|
|
1859
1863
|
center: !0
|
|
@@ -1865,20 +1869,20 @@ function ue(e, t) {
|
|
|
1865
1869
|
a.includes("filled") || t.fillcolor ? i.fill = V(t.fillcolor ?? t.color) ?? "#d3d3d3" : e.shape !== "point" && (i.fill = "#ffffff"), i.stroke = t.color ? V(t.color) : "#000000", t.fontcolor && (i.color = V(t.fontcolor)), a.includes("dashed") && (i.dash = "6 4"), a.includes("dotted") && (i.dash = "2 3"), a.includes("bold") && (i.sw = 2.4), t.penwidth && (i.sw = Math.min(8, Number(t.penwidth) || 1)), a.includes("invis") && (i.hidden = !0), a.includes("rounded") && e.shape === "rect" && (e.shape = "round"), e.shape === "none" && (i.fill = void 0), e.style = i;
|
|
1866
1870
|
}
|
|
1867
1871
|
function de(e, t, n) {
|
|
1868
|
-
let r = (t.style ?? "").toLowerCase(), i = (t.dir ?? (n ? "forward" : "none")).toLowerCase(), a =
|
|
1872
|
+
let r = (t.style ?? "").toLowerCase(), i = (t.dir ?? (n ? "forward" : "none")).toLowerCase(), a = se(t.arrowhead, "arrow"), o = se(t.arrowtail, "arrow");
|
|
1869
1873
|
e.head = i === "forward" || i === "both" ? a : "none", e.tail = i === "back" || i === "both" ? o : "none";
|
|
1870
1874
|
let s = t.label ?? t.xlabel;
|
|
1871
|
-
return s && (e.label = s.startsWith("<") && s.endsWith(">") ?
|
|
1875
|
+
return s && (e.label = s.startsWith("<") && s.endsWith(">") ? ce(s.slice(1, -1)) : H(s, "")), t.headlabel && (e.headLabel = H(t.headlabel, "")), t.taillabel && (e.tailLabel = H(t.taillabel, "")), e.line = r.includes("invis") ? "hidden" : r.includes("dashed") ? "dashed" : r.includes("dotted") ? "dotted" : r.includes("bold") ? "thick" : "solid", e.color = V(t.color) ?? "#000000", t.penwidth && (e.sw = Math.min(8, Number(t.penwidth) || 1)), t.minlen && (e.minlen = Math.max(1, Math.min(6, Math.round(Number(t.minlen)) || 1))), e;
|
|
1872
1876
|
}
|
|
1873
1877
|
function fe(e) {
|
|
1874
|
-
return
|
|
1878
|
+
return U(e).map(F);
|
|
1875
1879
|
}
|
|
1876
1880
|
// src/core/diagram/charts.ts
|
|
1877
|
-
var
|
|
1881
|
+
var W = 16, G = (e) => Math.round(e * 100) / 100;
|
|
1878
1882
|
function pe(e) {
|
|
1879
1883
|
let t = e.slices.filter((e) => e.value > 0 && Number.isFinite(e.value));
|
|
1880
1884
|
if (!t.length) throw Error("The pie chart has no values");
|
|
1881
|
-
let n = t.reduce((e, t) => e + t.value, 0), i = new p(), a =
|
|
1885
|
+
let n = t.reduce((e, t) => e + t.value, 0), i = new p(), a = W + (e.title ? 36 : 0) + 130, o = (e) => u.series[e % u.series.length], s = -Math.PI / 2, c = (e, t) => ({
|
|
1882
1886
|
x: 146 + Math.cos(e) * t,
|
|
1883
1887
|
y: a + Math.sin(e) * t
|
|
1884
1888
|
});
|
|
@@ -1891,7 +1895,7 @@ function pe(e) {
|
|
|
1891
1895
|
});
|
|
1892
1896
|
else {
|
|
1893
1897
|
let e = c(s, 130), n = c(l, 130);
|
|
1894
|
-
i.path(`M${
|
|
1898
|
+
i.path(`M${G(146)} ${G(a)} L${G(e.x)} ${G(e.y)} A130 130 0 ${+(r > .5)} 1 ${G(n.x)} ${G(n.y)} Z`, {
|
|
1895
1899
|
fill: o(t),
|
|
1896
1900
|
stroke: "#ffffff",
|
|
1897
1901
|
sw: 2
|
|
@@ -1913,7 +1917,7 @@ function pe(e) {
|
|
|
1913
1917
|
let a = e.showData ? `${t.label} [${me(t.value)}]` : t.label;
|
|
1914
1918
|
i.rect(306, l + n * 24 - 8, 16, 16, { fill: o(n) }, 3), i.text(330, l + n * 24, a), d = Math.max(d, r(a, 14));
|
|
1915
1919
|
});
|
|
1916
|
-
let f = 330 + d +
|
|
1920
|
+
let f = 330 + d + W, m = Math.max(a + 130, l + t.length * 24) + W;
|
|
1917
1921
|
return e.title && (f = Math.max(f, r(e.title, 16, !0) + 32), i.text(f / 2, 28, e.title, {
|
|
1918
1922
|
anchor: "middle",
|
|
1919
1923
|
size: 16,
|
|
@@ -1924,15 +1928,15 @@ function pe(e) {
|
|
|
1924
1928
|
h: Math.ceil(m)
|
|
1925
1929
|
};
|
|
1926
1930
|
}
|
|
1927
|
-
var me = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100),
|
|
1928
|
-
function
|
|
1931
|
+
var me = (e) => String(Number.isInteger(e) ? e : Math.round(e * 100) / 100), he = 36e5, K = 24 * he, ge = (e) => String(e).padStart(2, "0");
|
|
1932
|
+
function q(e) {
|
|
1929
1933
|
let t = e.sections.flatMap((e) => e.tasks);
|
|
1930
1934
|
if (!t.length) throw Error("The Gantt chart has no tasks");
|
|
1931
|
-
let n = Math.min(...t.map((e) => e.start)), i = Math.max(...t.map((e) => Math.max(e.end, e.start))), a = Math.max(i - n,
|
|
1932
|
-
|
|
1933
|
-
3 *
|
|
1934
|
-
6 *
|
|
1935
|
-
12 *
|
|
1935
|
+
let n = Math.min(...t.map((e) => e.start)), i = Math.max(...t.map((e) => Math.max(e.end, e.start))), a = Math.max(i - n, he), s = Math.min(180, Math.max(0, ...e.sections.map((e) => r(e.name, 13, !0))) + 24), c = Math.max(560, Math.min(1100, t.length * 60)), l = c / a, d = e.title ? 36 : 0, f = W + s, m = W + d, h = (e) => f + (e - n) * l, g = new p(), _ = m + t.length * 28 + 24 + W + 6, v = [
|
|
1936
|
+
he,
|
|
1937
|
+
3 * he,
|
|
1938
|
+
6 * he,
|
|
1939
|
+
12 * he,
|
|
1936
1940
|
K,
|
|
1937
1941
|
2 * K,
|
|
1938
1942
|
7 * K,
|
|
@@ -1942,7 +1946,7 @@ function he(e) {
|
|
|
1942
1946
|
365 * K
|
|
1943
1947
|
].find((e) => a / e <= 12) ?? 365 * K, y = Math.ceil(n / v) * v, b = (e) => {
|
|
1944
1948
|
let t = new Date(e);
|
|
1945
|
-
return v < K ? `${
|
|
1949
|
+
return v < K ? `${ge(t.getUTCHours())}:${ge(t.getUTCMinutes())}` : v >= 365 * K ? String(t.getUTCFullYear()) : v >= 30 * K ? `${t.getUTCFullYear()}-${ge(t.getUTCMonth() + 1)}` : `${t.getUTCFullYear()}-${ge(t.getUTCMonth() + 1)}-${ge(t.getUTCDate())}`;
|
|
1946
1950
|
}, x = m + t.length * 28 + 4;
|
|
1947
1951
|
for (let e = y; e <= i; e += v) {
|
|
1948
1952
|
let t = h(e);
|
|
@@ -1958,7 +1962,7 @@ function he(e) {
|
|
|
1958
1962
|
let S = 0;
|
|
1959
1963
|
e.sections.forEach((e, t) => {
|
|
1960
1964
|
let n = u.series[t % u.series.length], i = m + S * 28;
|
|
1961
|
-
t % 2 == 0 && g.rect(
|
|
1965
|
+
t % 2 == 0 && g.rect(W, i, s + c, e.tasks.length * 28, { fill: "#f6f7fa" }), e.name && g.text(22, i + e.tasks.length * 28 / 2, o([e.name], s - 12, 13, !0), {
|
|
1962
1966
|
size: 13,
|
|
1963
1967
|
bold: !0
|
|
1964
1968
|
});
|
|
@@ -1992,8 +1996,8 @@ function he(e) {
|
|
|
1992
1996
|
S++;
|
|
1993
1997
|
}
|
|
1994
1998
|
});
|
|
1995
|
-
let C = f + c +
|
|
1996
|
-
for (let e of t) C = Math.max(C, h(e.end) + 12 + r(e.name, 12) +
|
|
1999
|
+
let C = f + c + W;
|
|
2000
|
+
for (let e of t) C = Math.max(C, h(e.end) + 12 + r(e.name, 12) + W);
|
|
1997
2001
|
return e.title && (C = Math.max(C, r(e.title, 16, !0) + 32), g.text(C / 2, 28, e.title, {
|
|
1998
2002
|
anchor: "middle",
|
|
1999
2003
|
size: 16,
|
|
@@ -2004,8 +2008,8 @@ function he(e) {
|
|
|
2004
2008
|
h: Math.ceil(_)
|
|
2005
2009
|
};
|
|
2006
2010
|
}
|
|
2007
|
-
var
|
|
2008
|
-
function
|
|
2011
|
+
var _e = 44, J = 12;
|
|
2012
|
+
function ve(e, t) {
|
|
2009
2013
|
let n = new p(), i = (e, t) => {
|
|
2010
2014
|
let n = t === 0 ? 16 : t === 1 ? 14 : 13, r = o(e.label.split("\n"), 220, n, t === 0), i = a(r, n, t === 0), s = e.shape === "circle", c = Math.max(i.w, i.h) + 20;
|
|
2011
2015
|
return {
|
|
@@ -2015,7 +2019,7 @@ function _e(e, t) {
|
|
|
2015
2019
|
fs: n
|
|
2016
2020
|
};
|
|
2017
2021
|
}, s = (e, t, n) => {
|
|
2018
|
-
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) *
|
|
2022
|
+
let r = i(e, t), a = e.children.map((e, r) => s(e, t + 1, t === 0 ? u.series[r % u.series.length] : n)), o = Math.max(r.h, a.reduce((e, t) => e + t.span, 0) + Math.max(0, a.length - 1) * J);
|
|
2019
2023
|
return {
|
|
2020
2024
|
n: e,
|
|
2021
2025
|
w: r.w,
|
|
@@ -2036,19 +2040,19 @@ function _e(e, t) {
|
|
|
2036
2040
|
} else l = c.kids;
|
|
2037
2041
|
let f = (e, t, n, r) => {
|
|
2038
2042
|
e.x = t;
|
|
2039
|
-
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) *
|
|
2040
|
-
for (let n of e.kids) f(n, t + r * (e.w / 2 +
|
|
2043
|
+
let i = n + (e.span - (e.kids.reduce((e, t) => e + t.span, 0) + Math.max(0, e.kids.length - 1) * J)) / 2;
|
|
2044
|
+
for (let n of e.kids) f(n, t + r * (e.w / 2 + _e + n.w / 2), i, r), i += n.span + J;
|
|
2041
2045
|
e.y = e.kids.length ? (e.kids[0].y + e.kids[e.kids.length - 1].y) / 2 : n + e.span / 2;
|
|
2042
|
-
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) *
|
|
2043
|
-
for (let e of l) f(e, c.w / 2 +
|
|
2046
|
+
}, h = (e) => e.reduce((e, t) => e + t.span, 0) + Math.max(0, e.length - 1) * J, g = h(l), _ = h(d), v = Math.max(c.h, g, _), y = (v - g) / 2;
|
|
2047
|
+
for (let e of l) f(e, c.w / 2 + _e + e.w / 2, y, 1), y += e.span + J;
|
|
2044
2048
|
y = (v - _) / 2;
|
|
2045
|
-
for (let e of d) f(e, -(c.w / 2 +
|
|
2049
|
+
for (let e of d) f(e, -(c.w / 2 + _e + e.w / 2), y, -1), y += e.span + J;
|
|
2046
2050
|
c.x = 0, c.y = v / 2;
|
|
2047
2051
|
let b = Infinity, x = -Infinity, S = Infinity, C = -Infinity, w = [], T = (e) => {
|
|
2048
2052
|
w.push(e), b = Math.min(b, e.x - e.w / 2), x = Math.max(x, e.x + e.w / 2), S = Math.min(S, e.y - e.h / 2), C = Math.max(C, e.y + e.h / 2), e.kids.forEach(T);
|
|
2049
2053
|
};
|
|
2050
2054
|
T(c);
|
|
2051
|
-
let E = t ? 36 : 0, D =
|
|
2055
|
+
let E = t ? 36 : 0, D = W - b, O = W + E - S, k = (e) => ({
|
|
2052
2056
|
x: e.x + D,
|
|
2053
2057
|
y: e.y + O
|
|
2054
2058
|
});
|
|
@@ -2082,7 +2086,7 @@ function _e(e, t) {
|
|
|
2082
2086
|
});
|
|
2083
2087
|
}
|
|
2084
2088
|
for (let e of w) {
|
|
2085
|
-
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color :
|
|
2089
|
+
let t = k(e), r = e.depth === 0 ? 16 : e.depth === 1 ? 14 : 13, i = t.x - e.w / 2, a = t.y - e.h / 2, o = e.n.shape ?? (e.depth, "round"), s = e.depth === 0 ? u.dark : e.depth === 1 ? e.color : ye(e.color), c = e.depth <= 1 ? "#ffffff" : u.ink;
|
|
2086
2090
|
if (o === "none") n.line(i, a + e.h, i + e.w, a + e.h, {
|
|
2087
2091
|
stroke: e.color,
|
|
2088
2092
|
sw: 1.5
|
|
@@ -2134,7 +2138,7 @@ function _e(e, t) {
|
|
|
2134
2138
|
h: Math.ceil(j)
|
|
2135
2139
|
};
|
|
2136
2140
|
}
|
|
2137
|
-
function
|
|
2141
|
+
function ye(e) {
|
|
2138
2142
|
let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
|
|
2139
2143
|
return t ? "#" + [
|
|
2140
2144
|
t[1],
|
|
@@ -2143,7 +2147,7 @@ function ve(e) {
|
|
|
2143
2147
|
].map((e) => Math.round(parseInt(e, 16) * .22 + 198.9).toString(16).padStart(2, "0")).join("") : "#f1f3f7";
|
|
2144
2148
|
}
|
|
2145
2149
|
// src/core/diagram/sequence.ts
|
|
2146
|
-
var Y = (e) => Math.round(e * 100) / 100,
|
|
2150
|
+
var Y = (e) => Math.round(e * 100) / 100, X = class {
|
|
2147
2151
|
s = {
|
|
2148
2152
|
participants: [],
|
|
2149
2153
|
events: []
|
|
@@ -2165,9 +2169,9 @@ var Y = (e) => Math.round(e * 100) / 100, ye = class {
|
|
|
2165
2169
|
push(e) {
|
|
2166
2170
|
e.t === "msg" ? (this.participant(e.from), this.participant(e.to)) : e.t === "note" ? e.who.forEach((e) => this.participant(e)) : (e.t === "act" || e.t === "destroy") && this.participant(e.who), this.s.events.push(e);
|
|
2167
2171
|
}
|
|
2168
|
-
},
|
|
2169
|
-
function
|
|
2170
|
-
let t =
|
|
2172
|
+
}, be = 14, Z = 13, xe = i(Z), Se = 16, Ce = (e) => e ? e.split("\n") : [];
|
|
2173
|
+
function we(e) {
|
|
2174
|
+
let t = Ce(e.label), n = a(t, be);
|
|
2171
2175
|
switch (e.kind) {
|
|
2172
2176
|
case "actor": return {
|
|
2173
2177
|
w: Math.max(44, n.w + 8),
|
|
@@ -2193,7 +2197,7 @@ function Ce(e) {
|
|
|
2193
2197
|
};
|
|
2194
2198
|
}
|
|
2195
2199
|
}
|
|
2196
|
-
function
|
|
2200
|
+
function Te(e, t, n, r, a) {
|
|
2197
2201
|
let o = t.fill ?? u.fill, s = {
|
|
2198
2202
|
fill: o,
|
|
2199
2203
|
stroke: u.stroke,
|
|
@@ -2202,7 +2206,7 @@ function we(e, t, n, r, a) {
|
|
|
2202
2206
|
fill: "none",
|
|
2203
2207
|
stroke: u.dark,
|
|
2204
2208
|
sw: 1.5
|
|
2205
|
-
}, l = (t) => e.text(r, t + n.text.length * i(
|
|
2209
|
+
}, l = (t) => e.text(r, t + n.text.length * i(be) / 2, n.text, { anchor: "middle" }), d = r - n.w / 2;
|
|
2206
2210
|
switch (t.kind) {
|
|
2207
2211
|
case "actor":
|
|
2208
2212
|
e.circle(r, a + 8, 7, {
|
|
@@ -2241,7 +2245,7 @@ function we(e, t, n, r, a) {
|
|
|
2241
2245
|
}
|
|
2242
2246
|
e.text(r, a + n.h / 2, n.text, { anchor: "middle" });
|
|
2243
2247
|
}
|
|
2244
|
-
function
|
|
2248
|
+
function Ee(e, t, n, r, i) {
|
|
2245
2249
|
let a = u.line;
|
|
2246
2250
|
switch (t) {
|
|
2247
2251
|
case "filled":
|
|
@@ -2280,11 +2284,11 @@ function Te(e, t, n, r, i) {
|
|
|
2280
2284
|
});
|
|
2281
2285
|
}
|
|
2282
2286
|
}
|
|
2283
|
-
function
|
|
2287
|
+
function De(e) {
|
|
2284
2288
|
let t = e.participants;
|
|
2285
2289
|
if (!t.length) throw new _("The sequence diagram has no participants");
|
|
2286
2290
|
if (t.length > 300 || e.events.length > 8e3) throw new _("The sequence diagram is too large to draw");
|
|
2287
|
-
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(
|
|
2291
|
+
let n = new Map(t.map((e, t) => [e.id, t])), i = t.map(we), o = t.length, s = Array(o).fill(0);
|
|
2288
2292
|
for (let e = 1; e < o; e++) s[e] = (i[e - 1].w + i[e].w) / 2 + 28;
|
|
2289
2293
|
let c = 0, l = 0, d = (e, t, n) => {
|
|
2290
2294
|
if (e > t && ([e, t] = [t, e]), e === t) return;
|
|
@@ -2296,10 +2300,10 @@ function Ee(e) {
|
|
|
2296
2300
|
}, f = (t) => e.autonumber ? r(String(t), 10) + 14 : 0, m = 0;
|
|
2297
2301
|
for (let t of e.events) if (t.t === "msg") {
|
|
2298
2302
|
m++;
|
|
2299
|
-
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...
|
|
2303
|
+
let e = n.get(t.from), a = n.get(t.to), s = Math.max(0, ...Ce(t.text).map((e) => r(e, Z))) + f(m);
|
|
2300
2304
|
e === a ? e + 1 < o ? d(e, e + 1, i[e + 1].w / 2 + s + 44) : l = Math.max(l, s + 44 - i[e].w / 2) : d(e, a, s + 30);
|
|
2301
2305
|
} else if (t.t === "note") {
|
|
2302
|
-
let e = a(
|
|
2306
|
+
let e = a(Ce(t.text), Z).w + 20, r = t.who.map((e) => n.get(e)), s = Math.min(...r), u = Math.max(...r);
|
|
2303
2307
|
t.pos === "over" ? s !== u && d(s, u, e - 50) : t.pos === "left" ? s > 0 ? d(s - 1, s, e + 16 + i[s - 1].w / 2) : c = Math.max(c, e + 16 - i[0].w / 2) : u + 1 < o ? d(u, u + 1, e + 16 + i[u + 1].w / 2) : l = Math.max(l, e + 16 - i[u].w / 2);
|
|
2304
2308
|
}
|
|
2305
2309
|
let h = [], g = (() => {
|
|
@@ -2307,9 +2311,9 @@ function Ee(e) {
|
|
|
2307
2311
|
for (let r of e.events) r.t === "block" ? n = Math.max(n, ++t) : r.t === "end" && (t = Math.max(0, t - 1));
|
|
2308
2312
|
return n;
|
|
2309
2313
|
})(), v = g ? 12 + g * 8 : 0;
|
|
2310
|
-
h[0] =
|
|
2314
|
+
h[0] = Se + Math.max(i[0].w / 2, c + i[0].w / 2, v + 10);
|
|
2311
2315
|
for (let e = 1; e < o; e++) h[e] = h[e - 1] + s[e];
|
|
2312
|
-
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) +
|
|
2316
|
+
let y = h[o - 1] + Math.max(i[o - 1].w / 2, l + i[o - 1].w / 2, v + 10) + Se, b = Se + (e.title ? 34 : 0), x = Math.max(...i.map((e) => e.h)), S = b + x + 18, C = new p(), w = new p(), T = new p(), E = t.map(() => []), D = [], O = [], k = [], A = /* @__PURE__ */ new Map(), j = (e, t) => {
|
|
2313
2317
|
for (let n of k) n.lo = Math.min(n.lo, e), n.hi = Math.max(n.hi, t);
|
|
2314
2318
|
}, ee = (e, t) => {
|
|
2315
2319
|
let n = E[e].length;
|
|
@@ -2327,7 +2331,7 @@ function Ee(e) {
|
|
|
2327
2331
|
for (let t of e.events) switch (t.t) {
|
|
2328
2332
|
case "msg": {
|
|
2329
2333
|
m++;
|
|
2330
|
-
let i = n.get(t.from), a = n.get(t.to), o =
|
|
2334
|
+
let i = n.get(t.from), a = n.get(t.to), o = Ce(t.text), s = o.length * xe, c = {
|
|
2331
2335
|
stroke: u.line,
|
|
2332
2336
|
sw: 1.4,
|
|
2333
2337
|
dash: t.dashed ? "6 4" : void 0
|
|
@@ -2340,17 +2344,17 @@ function Ee(e) {
|
|
|
2340
2344
|
[n + 34, S],
|
|
2341
2345
|
[n + 34, S + 20],
|
|
2342
2346
|
[n + 2, S + 20]
|
|
2343
|
-
], c, !1),
|
|
2347
|
+
], c, !1), Ee(w, t.head, n, S + 20, -1), T.text(n + 6 + l, S - 4 - s / 2, o, { size: Z }), e.autonumber && Oe(T, n, S, m), j(h[i] - 10, n + 34 + 6 + l + Math.max(...o.map((e) => r(e, Z)))), S += 20, t.activate && te(a, S), t.deactivate && M(i, S), S += 14;
|
|
2344
2348
|
break;
|
|
2345
2349
|
}
|
|
2346
2350
|
S += s + 6;
|
|
2347
2351
|
let d = a > i ? 1 : -1;
|
|
2348
2352
|
t.activate && te(a, S);
|
|
2349
2353
|
let p = ee(i, d), g = ee(a, -d);
|
|
2350
|
-
w.line(p, S, g, S, c),
|
|
2354
|
+
w.line(p, S, g, S, c), Ee(w, t.head, g, S, d), t.both && Ee(w, t.head, p, S, -d), T.text((p + g) / 2 + d * l / 2, S - 5 - s / 2, o, {
|
|
2351
2355
|
anchor: "middle",
|
|
2352
2356
|
size: Z
|
|
2353
|
-
}), e.autonumber &&
|
|
2357
|
+
}), e.autonumber && Oe(T, p, S, m), t.deactivate && M(i, S), j(Math.min(h[i], h[a]), Math.max(h[i], h[a])), S += 14;
|
|
2354
2358
|
break;
|
|
2355
2359
|
}
|
|
2356
2360
|
case "act": {
|
|
@@ -2359,7 +2363,7 @@ function Ee(e) {
|
|
|
2359
2363
|
break;
|
|
2360
2364
|
}
|
|
2361
2365
|
case "note": {
|
|
2362
|
-
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o =
|
|
2366
|
+
let e = t.who.map((e) => n.get(e)), r = Math.min(...e), i = Math.max(...e), o = Ce(t.text), s = a(o, Z), c = Math.max(s.w + 20, t.pos === "over" && r !== i ? h[i] - h[r] + 50 : 0, 60), l = s.h + 12;
|
|
2363
2367
|
S += 6;
|
|
2364
2368
|
let d = t.pos === "left" ? h[r] - 12 - c : t.pos === "right" ? h[i] + 12 : (h[r] + h[i]) / 2 - c / 2;
|
|
2365
2369
|
T.poly([
|
|
@@ -2408,18 +2412,18 @@ function Ee(e) {
|
|
|
2408
2412
|
}
|
|
2409
2413
|
case "divider": {
|
|
2410
2414
|
S += 16;
|
|
2411
|
-
let e = a(
|
|
2412
|
-
T.line(
|
|
2415
|
+
let e = a(Ce(t.text), Z);
|
|
2416
|
+
T.line(Se / 2, S - 2, y - Se / 2, S - 2, {
|
|
2413
2417
|
stroke: u.muted,
|
|
2414
2418
|
sw: 1
|
|
2415
|
-
}).line(
|
|
2419
|
+
}).line(Se / 2, S + 2, y - Se / 2, S + 2, {
|
|
2416
2420
|
stroke: u.muted,
|
|
2417
2421
|
sw: 1
|
|
2418
2422
|
}), t.text && (T.rect(y / 2 - e.w / 2 - 10, S - e.h / 2 - 4, e.w + 20, e.h + 8, {
|
|
2419
2423
|
fill: "#ffffff",
|
|
2420
2424
|
stroke: u.muted,
|
|
2421
2425
|
sw: 1
|
|
2422
|
-
}, 3), T.text(y / 2, S,
|
|
2426
|
+
}, 3), T.text(y / 2, S, Ce(t.text), {
|
|
2423
2427
|
anchor: "middle",
|
|
2424
2428
|
size: Z,
|
|
2425
2429
|
bold: !0
|
|
@@ -2427,7 +2431,7 @@ function Ee(e) {
|
|
|
2427
2431
|
break;
|
|
2428
2432
|
}
|
|
2429
2433
|
case "delay":
|
|
2430
|
-
S += 14, t.text && T.text(y / 2, S,
|
|
2434
|
+
S += 14, t.text && T.text(y / 2, S, Ce(t.text), {
|
|
2431
2435
|
anchor: "middle",
|
|
2432
2436
|
size: Z,
|
|
2433
2437
|
italic: !0,
|
|
@@ -2452,7 +2456,7 @@ function Ee(e) {
|
|
|
2452
2456
|
for (let e = 0; e < o; e++) for (; E[e].length;) M(e, S);
|
|
2453
2457
|
for (let e of k.splice(0)) e.y1 = S;
|
|
2454
2458
|
S += 14;
|
|
2455
|
-
let ne = e.footer !== !1, re = S + (ne ? x : 0) +
|
|
2459
|
+
let ne = e.footer !== !1, re = S + (ne ? x : 0) + Se;
|
|
2456
2460
|
for (let e of O) {
|
|
2457
2461
|
let t = 12 + (g - e.depth) * 8;
|
|
2458
2462
|
e.lo > e.hi && (e.lo = h[0], e.hi = h[o - 1]);
|
|
@@ -2509,7 +2513,7 @@ function Ee(e) {
|
|
|
2509
2513
|
});
|
|
2510
2514
|
}
|
|
2511
2515
|
return N.raw(w.body()), N.raw(T.body()), t.forEach((e, t) => {
|
|
2512
|
-
|
|
2516
|
+
Te(N, e, i[t], h[t], b + x - i[t].h), ne && !A.has(t) && Te(N, e, i[t], h[t], S);
|
|
2513
2517
|
}), e.title && (y = Math.max(y, r(e.title, 16, !0) + 32), N.text(y / 2, 28, e.title, {
|
|
2514
2518
|
anchor: "middle",
|
|
2515
2519
|
size: 16,
|
|
@@ -2520,7 +2524,7 @@ function Ee(e) {
|
|
|
2520
2524
|
h: Math.ceil(re)
|
|
2521
2525
|
};
|
|
2522
2526
|
}
|
|
2523
|
-
function
|
|
2527
|
+
function Oe(e, t, n, i) {
|
|
2524
2528
|
let a = Math.max(8, r(String(i), 10) / 2 + 4);
|
|
2525
2529
|
e.circle(t, n, a, { fill: u.dark }), e.text(t, n, String(i), {
|
|
2526
2530
|
anchor: "middle",
|
|
@@ -2530,25 +2534,25 @@ function De(e, t, n, i) {
|
|
|
2530
2534
|
});
|
|
2531
2535
|
}
|
|
2532
2536
|
// src/core/diagram/model.ts
|
|
2533
|
-
function
|
|
2537
|
+
function ke(e) {
|
|
2534
2538
|
switch (e.t) {
|
|
2535
2539
|
case "graph": return F(e.graph);
|
|
2536
|
-
case "sequence": return
|
|
2540
|
+
case "sequence": return De(e.seq);
|
|
2537
2541
|
case "pie": return pe(e.pie);
|
|
2538
|
-
case "gantt": return
|
|
2539
|
-
case "tree": return
|
|
2542
|
+
case "gantt": return q(e.gantt);
|
|
2543
|
+
case "tree": return ve(e.root, e.title);
|
|
2540
2544
|
}
|
|
2541
2545
|
}
|
|
2542
2546
|
// src/core/diagram/mermaid.ts
|
|
2543
|
-
function
|
|
2547
|
+
function Ae(e) {
|
|
2544
2548
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n, r = /^\s*---\n([\s\S]*?)\n---[ \t]*(\n|$)/.exec(t);
|
|
2545
2549
|
return r && (n = /^title:\s*(.+)$/m.exec(r[1])?.[1].trim().replace(/^(["'])(.*)\1$/, "$2"), t = t.slice(r[0].length)), t = t.replace(/%%\{[\s\S]*?\}%%/g, ""), {
|
|
2546
2550
|
lines: t.split("\n").filter((e) => !/^\s*%%/.test(e)),
|
|
2547
2551
|
title: n
|
|
2548
2552
|
};
|
|
2549
2553
|
}
|
|
2550
|
-
function
|
|
2551
|
-
let { lines: t, title: n } =
|
|
2554
|
+
function je(e) {
|
|
2555
|
+
let { lines: t, title: n } = Ae(e), r = t.findIndex((e) => e.trim());
|
|
2552
2556
|
if (r < 0) throw new _("The diagram is empty");
|
|
2553
2557
|
let i = t[r].trim(), a = /^[\w-]+/.exec(i)?.[0] ?? i, o = t.slice(r + 1);
|
|
2554
2558
|
switch (a) {
|
|
@@ -2556,54 +2560,54 @@ function Ae(e) {
|
|
|
2556
2560
|
case "flowchart":
|
|
2557
2561
|
case "flowchart-elk": return {
|
|
2558
2562
|
t: "graph",
|
|
2559
|
-
graph:
|
|
2563
|
+
graph: Ue(i, o, n)
|
|
2560
2564
|
};
|
|
2561
2565
|
case "sequenceDiagram": return {
|
|
2562
2566
|
t: "sequence",
|
|
2563
|
-
seq:
|
|
2567
|
+
seq: Ke(o, n)
|
|
2564
2568
|
};
|
|
2565
2569
|
case "classDiagram":
|
|
2566
2570
|
case "classDiagram-v2": return {
|
|
2567
2571
|
t: "graph",
|
|
2568
|
-
graph:
|
|
2572
|
+
graph: Ye(o, n)
|
|
2569
2573
|
};
|
|
2570
2574
|
case "stateDiagram":
|
|
2571
2575
|
case "stateDiagram-v2": return {
|
|
2572
2576
|
t: "graph",
|
|
2573
|
-
graph:
|
|
2577
|
+
graph: Xe(o, n)
|
|
2574
2578
|
};
|
|
2575
2579
|
case "erDiagram": return {
|
|
2576
2580
|
t: "graph",
|
|
2577
|
-
graph:
|
|
2581
|
+
graph: $e(o, n)
|
|
2578
2582
|
};
|
|
2579
2583
|
case "pie": return {
|
|
2580
2584
|
t: "pie",
|
|
2581
|
-
pie:
|
|
2585
|
+
pie: et(i, o, n)
|
|
2582
2586
|
};
|
|
2583
2587
|
case "gantt": return {
|
|
2584
2588
|
t: "gantt",
|
|
2585
|
-
gantt:
|
|
2589
|
+
gantt: rt(o, n)
|
|
2586
2590
|
};
|
|
2587
2591
|
case "mindmap": return {
|
|
2588
2592
|
t: "tree",
|
|
2589
|
-
root:
|
|
2593
|
+
root: at(o),
|
|
2590
2594
|
title: n
|
|
2591
2595
|
};
|
|
2592
2596
|
default: throw new _(`Mermaid “${a}” diagrams are not supported yet`);
|
|
2593
2597
|
}
|
|
2594
2598
|
}
|
|
2595
|
-
var
|
|
2599
|
+
var Me = (e) => ke(je(e)), Ne = R({
|
|
2596
2600
|
TB: "TB",
|
|
2597
2601
|
TD: "TB",
|
|
2598
2602
|
BT: "BT",
|
|
2599
2603
|
LR: "LR",
|
|
2600
2604
|
RL: "RL"
|
|
2601
|
-
};
|
|
2605
|
+
});
|
|
2602
2606
|
function Q(e) {
|
|
2603
2607
|
let t = e.trim();
|
|
2604
2608
|
return /^".*"$/s.test(t) && (t = t.slice(1, -1)), /^`.*`$/s.test(t) && (t = g(t.slice(1, -1))), t = t.replace(/\bfa[bkrs]?:fa-[\w-]+\s*/g, ""), h(t).trim();
|
|
2605
2609
|
}
|
|
2606
|
-
function
|
|
2610
|
+
function Pe(e) {
|
|
2607
2611
|
let t = {};
|
|
2608
2612
|
for (let n of e.split(/,(?![^(]*\))/)) {
|
|
2609
2613
|
let e = n.indexOf(":");
|
|
@@ -2613,12 +2617,12 @@ function Ne(e) {
|
|
|
2613
2617
|
}
|
|
2614
2618
|
return t;
|
|
2615
2619
|
}
|
|
2616
|
-
var
|
|
2620
|
+
var Fe = (e, t) => {
|
|
2617
2621
|
let n = { ...e };
|
|
2618
2622
|
for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
|
|
2619
2623
|
return n;
|
|
2620
2624
|
};
|
|
2621
|
-
function
|
|
2625
|
+
function Ie(e, t) {
|
|
2622
2626
|
let n = [], r = 0, i = "", a = "";
|
|
2623
2627
|
for (let o of e) {
|
|
2624
2628
|
if (i) o === i && (i = "");
|
|
@@ -2633,7 +2637,7 @@ function Fe(e, t) {
|
|
|
2633
2637
|
}
|
|
2634
2638
|
return n.push(a), n;
|
|
2635
2639
|
}
|
|
2636
|
-
var
|
|
2640
|
+
var Le = [
|
|
2637
2641
|
[
|
|
2638
2642
|
"(((",
|
|
2639
2643
|
[")))"],
|
|
@@ -2694,7 +2698,7 @@ var Ie = [
|
|
|
2694
2698
|
["]"],
|
|
2695
2699
|
["flag"]
|
|
2696
2700
|
]
|
|
2697
|
-
],
|
|
2701
|
+
], Re = R({
|
|
2698
2702
|
rect: "rect",
|
|
2699
2703
|
rectangle: "rect",
|
|
2700
2704
|
proc: "rect",
|
|
@@ -2752,10 +2756,10 @@ var Ie = [
|
|
|
2752
2756
|
card: "note",
|
|
2753
2757
|
"f-circ": "point",
|
|
2754
2758
|
junction: "point"
|
|
2755
|
-
},
|
|
2756
|
-
function
|
|
2759
|
+
}), ze = /^[\p{L}\p{N}_$]+(?:-[\p{L}\p{N}_$]+)*/u;
|
|
2760
|
+
function Be(e, t, n) {
|
|
2757
2761
|
for (; e[t] === " " || e[t] === " ";) t++;
|
|
2758
|
-
let r =
|
|
2762
|
+
let r = ze.exec(e.slice(t));
|
|
2759
2763
|
if (!r) return null;
|
|
2760
2764
|
let i = r[0];
|
|
2761
2765
|
t += i.length;
|
|
@@ -2764,9 +2768,9 @@ function ze(e, t, n) {
|
|
|
2764
2768
|
let n = e.indexOf("}", t);
|
|
2765
2769
|
if (n > 0) {
|
|
2766
2770
|
let r = e.slice(t + 2, n), i = /shape\s*:\s*["']?([\w-]+)/.exec(r)?.[1], o = /label\s*:\s*("([^"]*)"|'([^']*)'|[^,]+)/.exec(r);
|
|
2767
|
-
i &&
|
|
2771
|
+
i && Re[i] && (a.shape = Re[i]), o && (a.label = Q(o[2] ?? o[3] ?? o[1])), t = n + 1;
|
|
2768
2772
|
}
|
|
2769
|
-
} else for (let [n, r, i] of
|
|
2773
|
+
} else for (let [n, r, i] of Le) {
|
|
2770
2774
|
if (!e.startsWith(n, t)) continue;
|
|
2771
2775
|
let o = t + n.length, s = "";
|
|
2772
2776
|
for (; e[o] === " ";) o++;
|
|
@@ -2793,12 +2797,12 @@ function ze(e, t, n) {
|
|
|
2793
2797
|
}
|
|
2794
2798
|
return [i, t];
|
|
2795
2799
|
}
|
|
2796
|
-
var
|
|
2800
|
+
var Ve = R({
|
|
2797
2801
|
">": "arrow",
|
|
2798
2802
|
o: "circle",
|
|
2799
2803
|
x: "cross"
|
|
2800
|
-
};
|
|
2801
|
-
function
|
|
2804
|
+
});
|
|
2805
|
+
function He(e, t) {
|
|
2802
2806
|
let n = e.slice(t), r = /^\s*([<ox]?)(--|==|-\.)\s+(.+?)\s*(-{2,}|={2,}|\.+-)([>ox]?)(?=[\s\p{L}\p{N}_$"]|$)/u.exec(n), i, a = "", o = "", s = "", c = !1;
|
|
2803
2807
|
if (r) [, a, , i, o, s] = r, c = r[2] === "-.";
|
|
2804
2808
|
else {
|
|
@@ -2814,19 +2818,19 @@ function Ve(e, t) {
|
|
|
2814
2818
|
let d = o.includes("="), f = c ? (o.match(/\./g)?.length ?? 1) - 1 : o.length - (s ? 2 : 3);
|
|
2815
2819
|
return [{
|
|
2816
2820
|
label: i !== void 0 && i.trim() ? Q(i) : void 0,
|
|
2817
|
-
head:
|
|
2821
|
+
head: Ve[s] ?? "none",
|
|
2818
2822
|
tail: a === "<" ? "arrow" : a === "o" ? "circle" : a === "x" ? "cross" : "none",
|
|
2819
2823
|
line: d ? "thick" : c ? "dashed" : "solid",
|
|
2820
2824
|
minlen: 1 + Math.max(0, Math.min(f, 6))
|
|
2821
2825
|
}, t + l];
|
|
2822
2826
|
}
|
|
2823
|
-
function
|
|
2824
|
-
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(
|
|
2827
|
+
function Ue(e, t, n) {
|
|
2828
|
+
let r = /^\w+\s+(\w+)/.exec(e)?.[1]?.toUpperCase(), i = new v(Ne[r ?? "TB"] ?? "TB", "rect"), a = {
|
|
2825
2829
|
b: i,
|
|
2826
2830
|
clusters: [],
|
|
2827
2831
|
classes: /* @__PURE__ */ new Map(),
|
|
2828
2832
|
defs: /* @__PURE__ */ new Map()
|
|
2829
|
-
}, o = [], s = t.flatMap((e) =>
|
|
2833
|
+
}, o = [], s = t.flatMap((e) => Ie(e, ";")).map((e) => e.trim()).filter(Boolean), c = Ie(e, ";").slice(1).map((e) => e.trim()).filter(Boolean);
|
|
2830
2834
|
for (let e of [...c, ...s]) {
|
|
2831
2835
|
let t;
|
|
2832
2836
|
if (t = /^subgraph\s+(.*)$/.exec(e)) {
|
|
@@ -2842,7 +2846,7 @@ function He(e, t, n) {
|
|
|
2842
2846
|
}
|
|
2843
2847
|
if (/^direction\s+\w+$/.test(e)) continue;
|
|
2844
2848
|
if (t = /^classDef\s+([\w,-]+)\s+(.+)$/.exec(e)) {
|
|
2845
|
-
for (let e of t[1].split(",")) a.defs.set(e.trim(),
|
|
2849
|
+
for (let e of t[1].split(",")) a.defs.set(e.trim(), Fe(a.defs.get(e.trim()), Pe(t[2])));
|
|
2846
2850
|
continue;
|
|
2847
2851
|
}
|
|
2848
2852
|
if (t = /^class\s+([^\s]+)\s+([\w-]+)$/.exec(e)) {
|
|
@@ -2850,15 +2854,15 @@ function He(e, t, n) {
|
|
|
2850
2854
|
continue;
|
|
2851
2855
|
}
|
|
2852
2856
|
if (t = /^style\s+([^\s]+)\s+(.+)$/.exec(e)) {
|
|
2853
|
-
let e =
|
|
2857
|
+
let e = Pe(t[2]);
|
|
2854
2858
|
for (let n of t[1].split(",")) if (i.isCluster(n)) {
|
|
2855
2859
|
let t = i.g.clusters.find((e) => e.id === n);
|
|
2856
|
-
t.style =
|
|
2857
|
-
} else i.node(n).style =
|
|
2860
|
+
t.style = Fe(t.style, e);
|
|
2861
|
+
} else i.node(n).style = Fe(i.get(n)?.style, e);
|
|
2858
2862
|
continue;
|
|
2859
2863
|
}
|
|
2860
2864
|
if (t = /^linkStyle\s+([\d,\s]+|default)\s+(.+)$/.exec(e)) {
|
|
2861
|
-
o.push([t[1].trim(),
|
|
2865
|
+
o.push([t[1].trim(), Pe(t[2])]);
|
|
2862
2866
|
continue;
|
|
2863
2867
|
}
|
|
2864
2868
|
if (/^(click|accTitle|accDescr|callback)\b/.test(e)) continue;
|
|
@@ -2866,7 +2870,7 @@ function He(e, t, n) {
|
|
|
2866
2870
|
for (;;) {
|
|
2867
2871
|
let t = [];
|
|
2868
2872
|
for (;;) {
|
|
2869
|
-
let r =
|
|
2873
|
+
let r = Be(e, n, a);
|
|
2870
2874
|
if (!r) break;
|
|
2871
2875
|
t.push(r[0]), n = r[1];
|
|
2872
2876
|
let i = /^\s*&\s*/.exec(e.slice(n));
|
|
@@ -2880,19 +2884,19 @@ function He(e, t, n) {
|
|
|
2880
2884
|
to: n
|
|
2881
2885
|
});
|
|
2882
2886
|
r = t;
|
|
2883
|
-
let o =
|
|
2887
|
+
let o = He(e, n);
|
|
2884
2888
|
if (!o) break;
|
|
2885
2889
|
s = o[0], n = o[1];
|
|
2886
2890
|
}
|
|
2887
2891
|
}
|
|
2888
2892
|
let l = a.defs.get("default");
|
|
2889
2893
|
for (let e of i.g.nodes) {
|
|
2890
|
-
let t = l ?
|
|
2891
|
-
l && e.style && (t =
|
|
2892
|
-
for (let n of a.classes.get(e.id) ?? []) t =
|
|
2894
|
+
let t = l ? Fe(void 0, l) : e.style;
|
|
2895
|
+
l && e.style && (t = Fe(t, e.style));
|
|
2896
|
+
for (let n of a.classes.get(e.id) ?? []) t = Fe(t, a.defs.get(n) ?? {});
|
|
2893
2897
|
t && (e.style = t);
|
|
2894
2898
|
}
|
|
2895
|
-
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style =
|
|
2899
|
+
for (let e of i.g.clusters) for (let t of a.classes.get(e.id) ?? []) e.style = Fe(e.style, a.defs.get(t) ?? {});
|
|
2896
2900
|
for (let [e, t] of o) {
|
|
2897
2901
|
let n = e === "default" ? i.g.edges.map((e, t) => t) : e.split(",").map((e) => Number(e.trim()));
|
|
2898
2902
|
for (let e of n) {
|
|
@@ -2902,7 +2906,7 @@ function He(e, t, n) {
|
|
|
2902
2906
|
}
|
|
2903
2907
|
return i.g.title = n, i.g;
|
|
2904
2908
|
}
|
|
2905
|
-
var
|
|
2909
|
+
var We = [
|
|
2906
2910
|
[
|
|
2907
2911
|
"<<-->>",
|
|
2908
2912
|
!0,
|
|
@@ -2963,7 +2967,7 @@ var Ue = [
|
|
|
2963
2967
|
"none",
|
|
2964
2968
|
!1
|
|
2965
2969
|
]
|
|
2966
|
-
],
|
|
2970
|
+
], Ge = R({
|
|
2967
2971
|
participant: "participant",
|
|
2968
2972
|
actor: "actor",
|
|
2969
2973
|
boundary: "boundary",
|
|
@@ -2972,11 +2976,11 @@ var Ue = [
|
|
|
2972
2976
|
database: "database",
|
|
2973
2977
|
collections: "collections",
|
|
2974
2978
|
queue: "queue"
|
|
2975
|
-
};
|
|
2976
|
-
function
|
|
2977
|
-
let n = new
|
|
2979
|
+
});
|
|
2980
|
+
function Ke(e, t) {
|
|
2981
|
+
let n = new X();
|
|
2978
2982
|
n.s.title = t;
|
|
2979
|
-
let r = [], i = RegExp(`^(.+?)\\s*(${
|
|
2983
|
+
let r = [], i = RegExp(`^(.+?)\\s*(${We.map(([e]) => e.replace(/[()|]/g, "\\$&")).join("|")})\\s*([+-]?)\\s*([^:]+?)\\s*(?::(.*))?$`);
|
|
2980
2984
|
for (let t of e) {
|
|
2981
2985
|
let e = t.trim();
|
|
2982
2986
|
if (!e) continue;
|
|
@@ -2984,7 +2988,7 @@ function Ge(e, t) {
|
|
|
2984
2988
|
if (a = /^(?:create\s+)?(participant|actor)\s+(.+?)(?:@\{(.*)\})?(?:\s+as\s+(.+))?$/.exec(e)) {
|
|
2985
2989
|
let e = a[2].trim(), t = a[3] ? /"type"\s*:\s*"(\w+)"/.exec(a[3])?.[1] : void 0;
|
|
2986
2990
|
n.participant(e, {
|
|
2987
|
-
kind:
|
|
2991
|
+
kind: Ge[t ?? a[1]] ?? "participant",
|
|
2988
2992
|
label: a[4] ? Q(a[4]) : e
|
|
2989
2993
|
});
|
|
2990
2994
|
} else if (a = /^destroy\s+(.+)$/.exec(e)) n.push({
|
|
@@ -3022,7 +3026,7 @@ function Ge(e, t) {
|
|
|
3022
3026
|
});
|
|
3023
3027
|
else if (e === "end") r.pop() === "frag" && n.push({ t: "end" });
|
|
3024
3028
|
else if (a = i.exec(e)) {
|
|
3025
|
-
let e =
|
|
3029
|
+
let e = We.find(([e]) => e === a[2]);
|
|
3026
3030
|
n.push({
|
|
3027
3031
|
t: "msg",
|
|
3028
3032
|
from: a[1].trim(),
|
|
@@ -3038,7 +3042,7 @@ function Ge(e, t) {
|
|
|
3038
3042
|
}
|
|
3039
3043
|
return n.s;
|
|
3040
3044
|
}
|
|
3041
|
-
var
|
|
3045
|
+
var qe = (e) => e.replace(/~([^~]*)~/g, "<$1>"), Je = R({
|
|
3042
3046
|
"<|": "triangle",
|
|
3043
3047
|
"|>": "triangle",
|
|
3044
3048
|
"*": "diamond",
|
|
@@ -3046,17 +3050,17 @@ var Ke = (e) => e.replace(/~([^~]*)~/g, "<$1>"), qe = {
|
|
|
3046
3050
|
"<": "open",
|
|
3047
3051
|
">": "open",
|
|
3048
3052
|
"()": "ocircle"
|
|
3049
|
-
};
|
|
3050
|
-
function
|
|
3053
|
+
});
|
|
3054
|
+
function Ye(e, t) {
|
|
3051
3055
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = [], a = (e) => {
|
|
3052
3056
|
let t = e.replace(/~.*~$/, "");
|
|
3053
3057
|
return r.has(t) || r.set(t, {
|
|
3054
3058
|
attrs: [],
|
|
3055
3059
|
methods: [],
|
|
3056
|
-
label: e === t ? void 0 :
|
|
3060
|
+
label: e === t ? void 0 : qe(e)
|
|
3057
3061
|
}), n.node(t, {}, i[i.length - 1]), r.get(t);
|
|
3058
3062
|
}, o = (e, t) => {
|
|
3059
|
-
let n =
|
|
3063
|
+
let n = qe(t.trim());
|
|
3060
3064
|
if (!n) return;
|
|
3061
3065
|
let r = /^<<(.+)>>$/.exec(n);
|
|
3062
3066
|
r ? e.stereo = r[1] : n.includes("(") ? e.methods.push(n.replace(/[$*]$/, "")) : e.attrs.push(n.replace(/[$*]$/, ""));
|
|
@@ -3069,7 +3073,7 @@ function Je(e, t) {
|
|
|
3069
3073
|
continue;
|
|
3070
3074
|
}
|
|
3071
3075
|
let r;
|
|
3072
|
-
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
3076
|
+
if (r = /^direction\s+(\w+)$/.exec(e)) n.g.dir = Ne[r[1].toUpperCase()] ?? "TB";
|
|
3073
3077
|
else if (r = /^namespace\s+([\w.]+)\s*\{$/.exec(e)) n.cluster(r[1], r[1], i[i.length - 1]), i.push(r[1]);
|
|
3074
3078
|
else if (e === "}" && i.length) i.pop();
|
|
3075
3079
|
else if (r = /^class\s+([\w$~,<>.-]+?)(?:\["([^"]*)"\])?(?::::[\w-]+)?\s*(\{)?\s*(\})?$/.exec(e)) {
|
|
@@ -3097,8 +3101,8 @@ function Je(e, t) {
|
|
|
3097
3101
|
a(e), a(l), n.edge({
|
|
3098
3102
|
from: e.replace(/~.*~$/, ""),
|
|
3099
3103
|
to: l.replace(/~.*~$/, ""),
|
|
3100
|
-
tail: i ?
|
|
3101
|
-
head: s ?
|
|
3104
|
+
tail: i ? Je[i] : "none",
|
|
3105
|
+
head: s ? Je[s] : "none",
|
|
3102
3106
|
line: o === ".." ? "dashed" : "solid",
|
|
3103
3107
|
label: u ? Q(u) : void 0,
|
|
3104
3108
|
tailLabel: t || void 0,
|
|
@@ -3121,7 +3125,7 @@ function Je(e, t) {
|
|
|
3121
3125
|
}
|
|
3122
3126
|
return n.g.title = t, n.g;
|
|
3123
3127
|
}
|
|
3124
|
-
function
|
|
3128
|
+
function Xe(e, t) {
|
|
3125
3129
|
let n = new v("TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = 0, c = null, l = null, u = () => r[r.length - 1], d = (e, t) => {
|
|
3126
3130
|
let r = e.trim(), i = /:::([\w-]+)$/.exec(r);
|
|
3127
3131
|
if (i && (r = r.slice(0, i.index), o.set(r, [...o.get(r) ?? [], i[1]])), r === "[*]") {
|
|
@@ -3156,7 +3160,7 @@ function Ye(e, t) {
|
|
|
3156
3160
|
}
|
|
3157
3161
|
if (!e || e === "--") continue;
|
|
3158
3162
|
let f;
|
|
3159
|
-
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir =
|
|
3163
|
+
if (f = /^direction\s+(\w+)$/.exec(e)) r.length || (n.g.dir = Ne[f[1].toUpperCase()] ?? "TB");
|
|
3160
3164
|
else if (f = /^state\s+(?:"([^"]+)"\s+as\s+)?([\w.-]+)\s*(<<(fork|join|choice)>>)?\s*(\{)?$/.exec(e)) {
|
|
3161
3165
|
let e = f[2];
|
|
3162
3166
|
if (f[5]) {
|
|
@@ -3191,7 +3195,7 @@ function Ye(e, t) {
|
|
|
3191
3195
|
head: "none"
|
|
3192
3196
|
});
|
|
3193
3197
|
} else c = [], l = { id: e };
|
|
3194
|
-
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1],
|
|
3198
|
+
} else if (f = /^classDef\s+([\w-]+)\s+(.+)$/.exec(e)) a.set(f[1], Pe(f[2]));
|
|
3195
3199
|
else if (f = /^class\s+([\w,\s-]+?)\s+([\w-]+)$/.exec(e)) for (let e of f[1].split(",")) o.set(e.trim(), [...o.get(e.trim()) ?? [], f[2]]);
|
|
3196
3200
|
else if (f = /^(.+?)\s*-->\s*([^:]+?)\s*(?::\s*(.*))?$/.exec(e)) {
|
|
3197
3201
|
let e = d(f[1], !1), t = d(f[2], !0);
|
|
@@ -3210,11 +3214,11 @@ function Ye(e, t) {
|
|
|
3210
3214
|
bold: !0,
|
|
3211
3215
|
center: !0
|
|
3212
3216
|
}, { rows: t.map((e) => [e]) }]);
|
|
3213
|
-
for (let t of o.get(e.id) ?? []) e.style =
|
|
3217
|
+
for (let t of o.get(e.id) ?? []) e.style = Fe(e.style, a.get(t) ?? {});
|
|
3214
3218
|
}
|
|
3215
3219
|
return n.g.title = t, n.g;
|
|
3216
3220
|
}
|
|
3217
|
-
var
|
|
3221
|
+
var Ze = R({
|
|
3218
3222
|
"|o": "zero-one",
|
|
3219
3223
|
"o|": "zero-one",
|
|
3220
3224
|
"||": "one",
|
|
@@ -3222,7 +3226,7 @@ var Xe = {
|
|
|
3222
3226
|
"o{": "zero-many",
|
|
3223
3227
|
"}|": "one-many",
|
|
3224
3228
|
"|{": "one-many"
|
|
3225
|
-
},
|
|
3229
|
+
}), Qe = R({
|
|
3226
3230
|
"one or zero": "zero-one",
|
|
3227
3231
|
"zero or one": "zero-one",
|
|
3228
3232
|
"one or more": "one-many",
|
|
@@ -3235,12 +3239,12 @@ var Xe = {
|
|
|
3235
3239
|
"0+": "zero-many",
|
|
3236
3240
|
"only one": "one",
|
|
3237
3241
|
1: "one"
|
|
3238
|
-
};
|
|
3239
|
-
function
|
|
3242
|
+
});
|
|
3243
|
+
function $e(e, t) {
|
|
3240
3244
|
let n = new v("TB", "rect"), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = null, o = (e) => {
|
|
3241
3245
|
let t = /^([\w-]+)(?:\[\s*"?([^"\]]*)"?\s*\])?$/.exec(e.trim().replace(/^"(.*)"$/, "$1")), a = t ? t[1] : e.trim().replace(/^"(.*)"$/, "$1");
|
|
3242
3246
|
return t?.[2] && i.set(a, t[2]), n.node(a), r.has(a) || r.set(a, []), a;
|
|
3243
|
-
}, s = Object.keys(
|
|
3247
|
+
}, s = Object.keys(Qe).sort((e, t) => t.length - e.length).map((e) => e.replace(/[()+]/g, "\\$&")).join("|"), c = /^(\S+)\s+(\|o|\|\||\}o|\}\|)(--|\.\.)(o\||\|\||o\{|\|\{)\s+(\S+)\s*:\s*(.*)$/, l = RegExp(`^(\\S+)\\s+(${s})\\s+(to|optionally to)\\s+(${s})\\s+(\\S+)\\s*:\\s*(.*)$`, "i");
|
|
3244
3248
|
for (let t of e) {
|
|
3245
3249
|
let e = t.trim();
|
|
3246
3250
|
if (!e) continue;
|
|
@@ -3259,15 +3263,15 @@ function Qe(e, t) {
|
|
|
3259
3263
|
continue;
|
|
3260
3264
|
}
|
|
3261
3265
|
let i;
|
|
3262
|
-
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir =
|
|
3266
|
+
if (i = /^direction\s+(\w+)$/.exec(e)) n.g.dir = Ne[i[1].toUpperCase()] ?? "TB";
|
|
3263
3267
|
else if (i = /^(.+?)\s*\{$/.exec(e)) a = o(i[1]);
|
|
3264
3268
|
else if (i = c.exec(e)) {
|
|
3265
3269
|
let e = o(i[1]), t = o(i[5]);
|
|
3266
3270
|
n.edge({
|
|
3267
3271
|
from: e,
|
|
3268
3272
|
to: t,
|
|
3269
|
-
tail:
|
|
3270
|
-
head:
|
|
3273
|
+
tail: Ze[i[2]],
|
|
3274
|
+
head: Ze[i[4]],
|
|
3271
3275
|
line: i[3] === ".." ? "dashed" : "solid",
|
|
3272
3276
|
label: Q(i[6]) || void 0
|
|
3273
3277
|
});
|
|
@@ -3276,8 +3280,8 @@ function Qe(e, t) {
|
|
|
3276
3280
|
n.edge({
|
|
3277
3281
|
from: e,
|
|
3278
3282
|
to: t,
|
|
3279
|
-
tail:
|
|
3280
|
-
head:
|
|
3283
|
+
tail: Qe[i[2].toLowerCase()],
|
|
3284
|
+
head: Qe[i[4].toLowerCase()],
|
|
3281
3285
|
line: i[3].toLowerCase() === "to" ? "solid" : "dashed",
|
|
3282
3286
|
label: Q(i[6]) || void 0
|
|
3283
3287
|
});
|
|
@@ -3293,7 +3297,7 @@ function Qe(e, t) {
|
|
|
3293
3297
|
}
|
|
3294
3298
|
return n.g.title = t, n.g;
|
|
3295
3299
|
}
|
|
3296
|
-
function
|
|
3300
|
+
function et(e, t, n) {
|
|
3297
3301
|
let r = /\bshowData\b/.test(e), i = /\btitle\s+(.+)$/.exec(e)?.[1] ?? n, a = [];
|
|
3298
3302
|
for (let e of t) {
|
|
3299
3303
|
let t = e.trim(), n;
|
|
@@ -3308,7 +3312,7 @@ function $e(e, t, n) {
|
|
|
3308
3312
|
slices: a
|
|
3309
3313
|
};
|
|
3310
3314
|
}
|
|
3311
|
-
var
|
|
3315
|
+
var tt = R({
|
|
3312
3316
|
ms: 1,
|
|
3313
3317
|
s: 1e3,
|
|
3314
3318
|
m: 6e4,
|
|
@@ -3317,8 +3321,8 @@ var et = {
|
|
|
3317
3321
|
w: 6048e5,
|
|
3318
3322
|
M: 2592e6,
|
|
3319
3323
|
y: 31536e6
|
|
3320
|
-
};
|
|
3321
|
-
function
|
|
3324
|
+
});
|
|
3325
|
+
function nt(e, t) {
|
|
3322
3326
|
if (e = e.trim(), t === "X") return Number(e) * 1e3;
|
|
3323
3327
|
if (t === "x") return Number(e);
|
|
3324
3328
|
let n = [], r = t.replace(/YYYY|YY|MM|M|DD|D|HH|H|mm|ss|SSS|[.*+?^${}()|[\]\\]/g, (e) => /^[.*+?^${}()|[\]\\]$/.test(e) ? "\\" + e : (n.push(e), e === "YYYY" ? "(\\d{4})" : e === "SSS" ? "(\\d{3})" : e.length === 1 ? "(\\d{1,2})" : "(\\d{2})")), i = RegExp(`^${r}$`).exec(e);
|
|
@@ -3331,7 +3335,7 @@ function tt(e, t) {
|
|
|
3331
3335
|
let o = a.Y === void 0 ? 1970 : n.includes("YY") ? 2e3 + a.Y : a.Y;
|
|
3332
3336
|
return Date.UTC(o, (a.M ?? 1) - 1, a.D ?? 1, a.H ?? 0, a.m ?? 0, a.s ?? 0, a.S ?? 0);
|
|
3333
3337
|
}
|
|
3334
|
-
function
|
|
3338
|
+
function rt(e, t) {
|
|
3335
3339
|
let n = "YYYY-MM-DD", r = t, i = [], a = /* @__PURE__ */ new Map(), o, s = (() => {
|
|
3336
3340
|
let e = /* @__PURE__ */ new Date();
|
|
3337
3341
|
return Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate());
|
|
@@ -3360,17 +3364,17 @@ function nt(e, t) {
|
|
|
3360
3364
|
let l;
|
|
3361
3365
|
t.length >= 3 && (l = t.shift());
|
|
3362
3366
|
let u, d;
|
|
3363
|
-
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) &&
|
|
3367
|
+
t.length >= 2 ? [u, d] = t : d = t[0], t.length === 2 && !/^after\s/.test(u) && nt(u, n) === void 0 && !/^\d/.test(u) && (l = u, u = void 0), r.start = ((e) => {
|
|
3364
3368
|
if (!e) return o ? o.end : s;
|
|
3365
3369
|
let t = /^after\s+(.+)$/.exec(e);
|
|
3366
3370
|
if (t) {
|
|
3367
3371
|
let e = t[1].split(/\s+/).map((e) => a.get(e)?.end).filter((e) => e !== void 0);
|
|
3368
3372
|
return e.length ? Math.max(...e) : o ? o.end : s;
|
|
3369
3373
|
}
|
|
3370
|
-
return
|
|
3374
|
+
return nt(e, n) ?? (o ? o.end : s);
|
|
3371
3375
|
})(u);
|
|
3372
3376
|
let f = d && /^([\d.]+)\s*(ms|s|m|h|d|w|M|y)$/.exec(d), p = d && /^until\s+(.+)$/.exec(d);
|
|
3373
|
-
r.end = f ? r.start + Number(f[1]) *
|
|
3377
|
+
r.end = f ? r.start + Number(f[1]) * tt[f[2]] : p ? a.get(p[1].trim())?.start ?? r.start : d ? nt(d, n) ?? r.start + 864e5 : r.start + 864e5, r.milestone && (r.end = r.start), l && a.set(l, r), i.length || i.push({
|
|
3374
3378
|
name: "",
|
|
3375
3379
|
tasks: []
|
|
3376
3380
|
}), i[i.length - 1].tasks.push(r), o = r;
|
|
@@ -3381,7 +3385,7 @@ function nt(e, t) {
|
|
|
3381
3385
|
sections: i
|
|
3382
3386
|
};
|
|
3383
3387
|
}
|
|
3384
|
-
var
|
|
3388
|
+
var it = [
|
|
3385
3389
|
[/^[\w-]*\(\((.*)\)\)$/, "circle"],
|
|
3386
3390
|
[/^[\w-]*\)\)(.*)\(\($/, "cloud"],
|
|
3387
3391
|
[/^[\w-]*\)(.*)\($/, "cloud"],
|
|
@@ -3389,14 +3393,14 @@ var rt = [
|
|
|
3389
3393
|
[/^[\w-]*\[(.*)\]$/, "rect"],
|
|
3390
3394
|
[/^[\w-]*\((.*)\)$/, "round"]
|
|
3391
3395
|
];
|
|
3392
|
-
function
|
|
3396
|
+
function at(e) {
|
|
3393
3397
|
let t = [], n;
|
|
3394
3398
|
for (let r of e) {
|
|
3395
3399
|
if (!r.trim()) continue;
|
|
3396
3400
|
let e = r.trim().replace(/:::[\w\s-]+$/, "").trim();
|
|
3397
3401
|
if (/^::icon\(/.test(e) || !e) continue;
|
|
3398
3402
|
let i = r.replace(/\t/g, " ").search(/\S/), a = e, o;
|
|
3399
|
-
for (let [t, n] of
|
|
3403
|
+
for (let [t, n] of it) {
|
|
3400
3404
|
let r = t.exec(e);
|
|
3401
3405
|
if (r) {
|
|
3402
3406
|
a = r[1], o = n;
|
|
@@ -3424,7 +3428,7 @@ function it(e) {
|
|
|
3424
3428
|
return n;
|
|
3425
3429
|
}
|
|
3426
3430
|
// src/core/diagram/plantuml.ts
|
|
3427
|
-
function
|
|
3431
|
+
function ot(e) {
|
|
3428
3432
|
let t = e.replace(/^/, "").replace(/\r\n?/g, "\n"), n = [], r = /^[ \t]*@start(\w+)[^\n]*\n([\s\S]*?)^[ \t]*@end\1\b/gm, i;
|
|
3429
3433
|
for (; i = r.exec(t);) n.push({
|
|
3430
3434
|
kind: i[1].toLowerCase(),
|
|
@@ -3435,52 +3439,52 @@ function at(e) {
|
|
|
3435
3439
|
lines: t.split("\n")
|
|
3436
3440
|
}), n;
|
|
3437
3441
|
}
|
|
3438
|
-
function
|
|
3439
|
-
return
|
|
3442
|
+
function st(e) {
|
|
3443
|
+
return ot(e).map(({ kind: e, lines: t }) => lt(e, t));
|
|
3440
3444
|
}
|
|
3441
|
-
var
|
|
3442
|
-
function
|
|
3445
|
+
var ct = (e) => st(e).map(ke);
|
|
3446
|
+
function lt(e, t) {
|
|
3443
3447
|
if (e === "dot") return {
|
|
3444
3448
|
t: "graph",
|
|
3445
|
-
graph:
|
|
3449
|
+
graph: U(t.join("\n"))[0]
|
|
3446
3450
|
};
|
|
3447
|
-
let { lines: n, title: r, dir: i } =
|
|
3451
|
+
let { lines: n, title: r, dir: i } = ut(t);
|
|
3448
3452
|
switch (e) {
|
|
3449
3453
|
case "uml": break;
|
|
3450
3454
|
case "mindmap":
|
|
3451
3455
|
case "wbs": return {
|
|
3452
3456
|
t: "tree",
|
|
3453
|
-
root:
|
|
3457
|
+
root: wt(n, e === "wbs"),
|
|
3454
3458
|
title: r
|
|
3455
3459
|
};
|
|
3456
3460
|
default: throw new _(`PlantUML @start${e} diagrams are not supported yet`);
|
|
3457
3461
|
}
|
|
3458
|
-
switch (
|
|
3462
|
+
switch (dt(n)) {
|
|
3459
3463
|
case "activity": return {
|
|
3460
3464
|
t: "graph",
|
|
3461
3465
|
graph: {
|
|
3462
|
-
...
|
|
3466
|
+
...Ct(n),
|
|
3463
3467
|
title: r
|
|
3464
3468
|
}
|
|
3465
3469
|
};
|
|
3466
3470
|
case "sequence": return {
|
|
3467
3471
|
t: "sequence",
|
|
3468
3472
|
seq: {
|
|
3469
|
-
...
|
|
3473
|
+
...pt(n),
|
|
3470
3474
|
title: r
|
|
3471
3475
|
}
|
|
3472
3476
|
};
|
|
3473
3477
|
case "state": return {
|
|
3474
3478
|
t: "graph",
|
|
3475
3479
|
graph: {
|
|
3476
|
-
...
|
|
3480
|
+
...St(n, i),
|
|
3477
3481
|
title: r
|
|
3478
3482
|
}
|
|
3479
3483
|
};
|
|
3480
3484
|
default: return {
|
|
3481
3485
|
t: "graph",
|
|
3482
3486
|
graph: {
|
|
3483
|
-
...
|
|
3487
|
+
...xt(n, i),
|
|
3484
3488
|
title: r
|
|
3485
3489
|
}
|
|
3486
3490
|
};
|
|
@@ -3489,7 +3493,7 @@ function ct(e, t) {
|
|
|
3489
3493
|
function $(e) {
|
|
3490
3494
|
return h(e.trim().replace(/^"(.*)"$/s, "$1").replace(/\*\*(.+?)\*\*|\/\/(.+?)\/\/|""(.+?)""|__(.+?)__|~~(.+?)~~|--(.+?)--/g, (...e) => e.slice(1, 7).find((e) => e !== void 0) ?? "").replace(/<\/?(?:b|i|u|s|font|color|size|back|code|plain|strike|w|sub|sup)\b[^>]*>/gi, "").replace(/<&[\w-]+>/g, "").replace(/\\t/g, " "));
|
|
3491
3495
|
}
|
|
3492
|
-
function
|
|
3496
|
+
function ut(e) {
|
|
3493
3497
|
let t = [], n, r, i = null, a = null, o = !1;
|
|
3494
3498
|
for (let s of e) {
|
|
3495
3499
|
if (o) {
|
|
@@ -3519,11 +3523,11 @@ function lt(e) {
|
|
|
3519
3523
|
dir: r
|
|
3520
3524
|
};
|
|
3521
3525
|
}
|
|
3522
|
-
function
|
|
3526
|
+
function dt(e) {
|
|
3523
3527
|
let t = (t) => e.some((e) => t.test(e));
|
|
3524
3528
|
return t(/^(start|stop)$/) || t(/^:[\s\S]*[;|<>/\]}]$/) || t(/^:/) || t(/^(if\s*\(.*\)\s*then|while\s*\(|repeat\b|fork$|endif$)/) ? "activity" : t(/\[\*\]/) || t(/^state\s/) ? "state" : t(/^(participant|boundary|control|collections|queue|autonumber|activate|deactivate|alt|loop|return|ref\s+over)\b/) || t(/^(==.*==|\.\.\.|\|\|\d*\|\|)$/) ? "sequence" : t(/^(abstract|class|interface|enum|annotation|struct|protocol|object|map|json|usecase|component|node|cloud|package|namespace|folder|frame|rectangle|artifact|storage|card|file|agent|person|hexagon|together)\b/) || t(/\([^)]*\)|\[[^\]*]+\]|<\|--|--\|>|\*--|o--|\.\.>/) ? "description" : t(/^(actor|database|entity)\b/) || t(/^\S+\s*<?-{1,2}>?>?\s*\S+\s*:/) ? "sequence" : "description";
|
|
3525
3529
|
}
|
|
3526
|
-
var
|
|
3530
|
+
var ft = R({
|
|
3527
3531
|
participant: "participant",
|
|
3528
3532
|
actor: "actor",
|
|
3529
3533
|
boundary: "boundary",
|
|
@@ -3532,9 +3536,9 @@ var dt = {
|
|
|
3532
3536
|
database: "database",
|
|
3533
3537
|
collections: "collections",
|
|
3534
3538
|
queue: "queue"
|
|
3535
|
-
};
|
|
3536
|
-
function
|
|
3537
|
-
let t = new
|
|
3539
|
+
});
|
|
3540
|
+
function pt(e) {
|
|
3541
|
+
let t = new X(), n = [], r = null, i = null, a = null, o = (e) => e.trim().replace(/^"(.*)"$/, "$1");
|
|
3538
3542
|
for (let s of e) {
|
|
3539
3543
|
if (r) {
|
|
3540
3544
|
/^end\s*(note|ref|rnote|hnote)$/i.test(s) ? (i && i.who.length && t.push({
|
|
@@ -3551,7 +3555,7 @@ function ft(e) {
|
|
|
3551
3555
|
r && (n = n.slice(0, r.index).trim()), n = n.replace(/<<[^>]*>>/g, "").trim();
|
|
3552
3556
|
let i = n, a = n, s = /^"([^"]+)"\s+as\s+(\S+)$/.exec(n), c = /^(\S+)\s+as\s+"?([^"]+)"?$/.exec(n);
|
|
3553
3557
|
s ? [i, a] = [s[2], s[1]] : c ? [i, a] = [c[1], c[2]] : i = a = o(n), t.participant(i, {
|
|
3554
|
-
kind:
|
|
3558
|
+
kind: ft[e[1].toLowerCase()],
|
|
3555
3559
|
label: $(a),
|
|
3556
3560
|
fill: r ? l(r[1].slice(1)) ?? l(r[1]) : void 0
|
|
3557
3561
|
});
|
|
@@ -3658,7 +3662,7 @@ function ft(e) {
|
|
|
3658
3662
|
});
|
|
3659
3663
|
continue;
|
|
3660
3664
|
}
|
|
3661
|
-
let c =
|
|
3665
|
+
let c = ht(s);
|
|
3662
3666
|
if (c) {
|
|
3663
3667
|
let { from: e, to: r, dashed: i, head: o, both: s, act: l, text: u } = c;
|
|
3664
3668
|
t.push({
|
|
@@ -3685,9 +3689,9 @@ function ft(e) {
|
|
|
3685
3689
|
}
|
|
3686
3690
|
return t.s;
|
|
3687
3691
|
}
|
|
3688
|
-
var
|
|
3689
|
-
function
|
|
3690
|
-
let t =
|
|
3692
|
+
var mt = /^(\[|\]|[\w.$À-]+|"[^"]+")?\s*(<<?|[\\/]{1,2})?(-{1,2}|\.{1,2})(?:\[[^\]]*\])?(-?)(>>?|[\\/]{1,2})?\s*([ox])?\s*(\[|\]|[\w.$À-]+|"[^"]+")?\s*(\+\+|--|\*\*|!!)?\s*(?::\s*(.*))?$/u;
|
|
3693
|
+
function ht(e) {
|
|
3694
|
+
let t = mt.exec(e.replace(/^(\S+)\s*([ox])(?=<|-)/, "$1 "));
|
|
3691
3695
|
if (!t) return null;
|
|
3692
3696
|
let [, n, r, i, , a, , o, s, c] = t;
|
|
3693
3697
|
if (!r && !a || !n || !o) return null;
|
|
@@ -3704,7 +3708,7 @@ function mt(e) {
|
|
|
3704
3708
|
text: $(c ?? "")
|
|
3705
3709
|
};
|
|
3706
3710
|
}
|
|
3707
|
-
var
|
|
3711
|
+
var gt = R({
|
|
3708
3712
|
actor: "actor",
|
|
3709
3713
|
person: "actor",
|
|
3710
3714
|
usecase: "ellipse",
|
|
@@ -3742,7 +3746,7 @@ var ht = {
|
|
|
3742
3746
|
json: "rect",
|
|
3743
3747
|
diamond: "diamond",
|
|
3744
3748
|
state: "round"
|
|
3745
|
-
},
|
|
3749
|
+
}), _t = /* @__PURE__ */ new Set([
|
|
3746
3750
|
"class",
|
|
3747
3751
|
"abstract",
|
|
3748
3752
|
"abstract class",
|
|
@@ -3758,7 +3762,7 @@ var ht = {
|
|
|
3758
3762
|
"object",
|
|
3759
3763
|
"map",
|
|
3760
3764
|
"json"
|
|
3761
|
-
]),
|
|
3765
|
+
]), vt = R({
|
|
3762
3766
|
">": "arrow",
|
|
3763
3767
|
"<": "arrow",
|
|
3764
3768
|
"|>": "triangle",
|
|
@@ -3780,8 +3784,8 @@ var ht = {
|
|
|
3780
3784
|
"o{": "zero-many",
|
|
3781
3785
|
"}|": "one-many",
|
|
3782
3786
|
"|{": "one-many"
|
|
3783
|
-
},
|
|
3784
|
-
function
|
|
3787
|
+
}), yt = String.raw`\[\*\]|\[[^\]]+\]|\([^)]*\)|:[^:]+:|"[^"]+"|\(\)\s*"[^"]+"|\(\)\s*[\w.]+|[\w.$À--]+`, bt = new RegExp(String.raw`^(${yt})\s*(?:"([^"]*)"\s*)?((?:<\||<<|\}o|\}\||\|o|\|\||[<*o#x+^}])?)([-.=~]+)(?:\[([^\]]*)\])?((?:up|down|left|right|u|d|l|r|le|ri|do)?)([-.=~]*)(?:\[([^\]]*)\])?((?:\|>|>>|o\{|\|\{|o\||\|\||[>*#+^{]|[ox](?=\s|\[|\(|"|:|$))?)\s*(?:"([^"]*)"\s*)?(${yt})\s*(?::\s*(.*))?$`, "u");
|
|
3788
|
+
function xt(e, t) {
|
|
3785
3789
|
let n = new v(t ?? "TB", "rect"), r = /* @__PURE__ */ new Map(), i = [], a = [], o = null, s = null, c, u = "", d = 0, f = 0, p = () => i[i.length - 1], m = (e) => {
|
|
3786
3790
|
let t = e.trim(), r;
|
|
3787
3791
|
return t === "(*)" ? "start" : (r = /^\[(.+)\]$/.exec(t)) ? h(r[1], "component") : (r = /^\((.*)\)$/.exec(t)) ? h(r[1], "ellipse") : (r = /^:(.+):$/.exec(t)) ? h(r[1], "actor") : (r = /^\(\)\s*"?([^"]+)"?$/.exec(t)) ? h(r[1], "circle") : (t = t.replace(/^"(.*)"$/, "$1"), !n.has(t) && !n.isCluster(t) && n.node(t, { label: $(t) }, p()), t);
|
|
@@ -3849,7 +3853,7 @@ function bt(e, t) {
|
|
|
3849
3853
|
fill: "none",
|
|
3850
3854
|
stroke: "none"
|
|
3851
3855
|
}), i.push(o), a.push(t);
|
|
3852
|
-
} else if ((e = /^(abstract\s+class|abstract|class|interface|enum|annotation|struct|protocol|entity|exception|metaclass|stereotype|object|map|json)\s+(?:"([^"]+)"\s+as\s+(\S+)|(\S+)\s+as\s+"([^"]+)"|([^\s{<#]+))(?:\s*<([^>]+)>)?\s*(<<.+?>>)?\s*(#\S+)?\s*(\{)?\s*(\})?$/.exec(t)) &&
|
|
3856
|
+
} else if ((e = /^(abstract\s+class|abstract|class|interface|enum|annotation|struct|protocol|entity|exception|metaclass|stereotype|object|map|json)\s+(?:"([^"]+)"\s+as\s+(\S+)|(\S+)\s+as\s+"([^"]+)"|([^\s{<#]+))(?:\s*<([^>]+)>)?\s*(<<.+?>>)?\s*(#\S+)?\s*(\{)?\s*(\})?$/.exec(t)) && _t.has(e[1].toLowerCase().replace(/\s+/, " "))) {
|
|
3853
3857
|
let t = e[1].toLowerCase().replace(/\s+/, " "), i = e[3] ?? e[4] ?? e[6], a = e[2] ?? e[5] ?? i, s = e[7] ? `<${e[7]}>` : "";
|
|
3854
3858
|
n.node(i, {
|
|
3855
3859
|
label: $(a) + s,
|
|
@@ -3876,7 +3880,7 @@ function bt(e, t) {
|
|
|
3876
3880
|
/^["([:]/.test(e) ? [s, o] = [e, t] : [o, s] = [e, t];
|
|
3877
3881
|
}
|
|
3878
3882
|
s = s.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3"), o = o.replace(/^\((.*)\)$|^\[(.*)\]$|^:(.*):$/, "$1$2$3").replace(/^"(.*)"$/, "$1");
|
|
3879
|
-
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" :
|
|
3883
|
+
let u = t === "usecase" ? "ellipse" : t === "actor" ? "actor" : gt[t] ?? "rect", d = n.node(o, {
|
|
3880
3884
|
label: $(s) + (a ? `\n«${a[1]}»` : ""),
|
|
3881
3885
|
shape: u
|
|
3882
3886
|
}, p()), f = i ? l(i[1].slice(1)) ?? l(i[1]) : void 0;
|
|
@@ -3893,8 +3897,8 @@ function bt(e, t) {
|
|
|
3893
3897
|
shape: r.shape
|
|
3894
3898
|
}, p()), n.g.nodes.splice(n.g.nodes.indexOf(r), 1);
|
|
3895
3899
|
}
|
|
3896
|
-
} else if (e =
|
|
3897
|
-
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ?
|
|
3900
|
+
} else if (e = bt.exec(t)) {
|
|
3901
|
+
let [, t, r, i, a, , o, s, , c, l, u, d] = e, f = m(t), p = m(u), h = a + s, g = i ? vt[i] ?? "none" : "none", _ = c ? vt[c] ?? "none" : "none", v = r, y = l;
|
|
3898
3902
|
/^(up|u|left|l|le)$/i.test(o) && ([f, p] = [p, f], [g, _] = [_, g], [v, y] = [y, v]);
|
|
3899
3903
|
let b = {
|
|
3900
3904
|
from: f,
|
|
@@ -3942,7 +3946,7 @@ function bt(e, t) {
|
|
|
3942
3946
|
}
|
|
3943
3947
|
return n.g;
|
|
3944
3948
|
}
|
|
3945
|
-
function
|
|
3949
|
+
function St(e, t) {
|
|
3946
3950
|
let n = new v(t ?? "TB", "round"), r = [], i = /* @__PURE__ */ new Map(), a = 0, o = null, s, c = () => r[r.length - 1], u = (e, t) => {
|
|
3947
3951
|
let r = e.trim().replace(/^"(.*)"$/, "$1");
|
|
3948
3952
|
if (r === "[*]") {
|
|
@@ -4029,7 +4033,7 @@ function xt(e, t) {
|
|
|
4029
4033
|
}
|
|
4030
4034
|
return n.g;
|
|
4031
4035
|
}
|
|
4032
|
-
function
|
|
4036
|
+
function Ct(e) {
|
|
4033
4037
|
let t = new v("TB", "round"), n = [];
|
|
4034
4038
|
for (let t = 0; t < e.length; t++) {
|
|
4035
4039
|
let r = e[t];
|
|
@@ -4169,7 +4173,7 @@ function St(e) {
|
|
|
4169
4173
|
};
|
|
4170
4174
|
return u([], /^\u0000$/), t.g;
|
|
4171
4175
|
}
|
|
4172
|
-
function
|
|
4176
|
+
function wt(e, t) {
|
|
4173
4177
|
let n = [], r;
|
|
4174
4178
|
for (let i = 0; i < e.length; i++) {
|
|
4175
4179
|
let a = e[i], o = /^([*+\-#]+)(_)?\s*(?:\[#[\w]+\])?\s*(.*)$/.exec(a);
|
|
@@ -4201,22 +4205,41 @@ function Ct(e, t) {
|
|
|
4201
4205
|
let i = (e, t) => e.children.forEach((e) => (t || (e.side = void 0), i(e, !1)));
|
|
4202
4206
|
return i(r, !0), r;
|
|
4203
4207
|
}
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4208
|
+
R({
|
|
4209
|
+
mmd: "mermaid",
|
|
4210
|
+
mermaid: "mermaid",
|
|
4211
|
+
puml: "plantuml",
|
|
4212
|
+
plantuml: "plantuml",
|
|
4213
|
+
pu: "plantuml",
|
|
4214
|
+
iuml: "plantuml",
|
|
4215
|
+
wsd: "plantuml",
|
|
4216
|
+
dot: "graphviz",
|
|
4217
|
+
gv: "graphviz"
|
|
4218
|
+
}), R({
|
|
4219
|
+
mermaid: "mermaid",
|
|
4220
|
+
mmd: "mermaid",
|
|
4221
|
+
plantuml: "plantuml",
|
|
4222
|
+
puml: "plantuml",
|
|
4223
|
+
uml: "plantuml",
|
|
4224
|
+
dot: "graphviz",
|
|
4225
|
+
graphviz: "graphviz",
|
|
4226
|
+
gv: "graphviz"
|
|
4227
|
+
});
|
|
4228
|
+
var Tt = /^(?:(?:graph|flowchart)(?:\s+(?:TB|TD|BT|RL|LR))?\s*(?:;.*)?|(?:sequenceDiagram|classDiagram(?:-v2)?|stateDiagram(?:-v2)?|erDiagram|gantt|mindmap|journey|gitGraph|timeline|quadrantChart|requirementDiagram|C4Context|C4Container|C4Component|C4Dynamic|C4Deployment|sankey-beta|xychart-beta|block-beta|packet-beta|kanban|architecture-beta)\s*|pie(?:\s+showData)?(?:\s+title\s+.*)?\s*)$/, Et = /^(strict\s+)?(di)?graph(\s+("[^"]*"|[\w.]+))?\s*\{/i;
|
|
4229
|
+
function Dt(e) {
|
|
4207
4230
|
if (/^\s*@start(uml|mindmap|wbs|dot|salt|gantt|json|yaml)\b/m.test(e.slice(0, 2e3))) return "plantuml";
|
|
4208
4231
|
let t = e.replace(/^/, "").replace(/^\s*---\r?\n[\s\S]*?\r?\n---[ \t]*\r?\n/, "").replace(/%%\{[\s\S]*?\}%%/g, "").split(/\r?\n/).map((e) => e.trim()), n = e.replace(/\/\*[\s\S]*?\*\//g, "").split(/\r?\n/).map((e) => e.trim()).find((e) => e && !e.startsWith("//") && !e.startsWith("#"));
|
|
4209
|
-
if (n && (
|
|
4232
|
+
if (n && (Et.test(n) || /^(strict\s+)?(di)?graph(\s+("[^"]*"|[\w.]+))?\s*$/i.test(n) && /^\s*\{/m.test(e) && !Tt.test(n))) return "graphviz";
|
|
4210
4233
|
let r = t.find((e) => e && !e.startsWith("%%"));
|
|
4211
|
-
return r &&
|
|
4234
|
+
return r && Tt.test(r) ? "mermaid" : null;
|
|
4212
4235
|
}
|
|
4213
|
-
var
|
|
4214
|
-
function
|
|
4215
|
-
if (t.length >
|
|
4236
|
+
var Ot = 2e6;
|
|
4237
|
+
function kt(e, t) {
|
|
4238
|
+
if (t.length > Ot) throw new _("The diagram is too large to draw");
|
|
4216
4239
|
try {
|
|
4217
4240
|
switch (e) {
|
|
4218
|
-
case "mermaid": return [
|
|
4219
|
-
case "plantuml": return
|
|
4241
|
+
case "mermaid": return [Me(t)];
|
|
4242
|
+
case "plantuml": return ct(t);
|
|
4220
4243
|
case "graphviz": return fe(t);
|
|
4221
4244
|
}
|
|
4222
4245
|
} catch (e) {
|
|
@@ -4224,7 +4247,7 @@ function Ot(e, t) {
|
|
|
4224
4247
|
}
|
|
4225
4248
|
}
|
|
4226
4249
|
// packages/diagram/src/dom.ts
|
|
4227
|
-
async function
|
|
4250
|
+
async function At(e, t = 2) {
|
|
4228
4251
|
let n = (t) => Number(RegExp(`<svg[^>]*\\s${t}="([\\d.]+)"`).exec(e)?.[1] ?? 0), r = n("width"), i = n("height");
|
|
4229
4252
|
if (!r || !i) throw Error("Not a picture with a size");
|
|
4230
4253
|
let a = new Image();
|
|
@@ -4235,39 +4258,39 @@ async function kt(e, t = 2) {
|
|
|
4235
4258
|
if (!s) throw Error("No 2D canvas");
|
|
4236
4259
|
return s.scale(t, t), s.drawImage(a, 0, 0, r, i), new Promise((e, t) => o.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("PNG export failed")), "image/png"));
|
|
4237
4260
|
}
|
|
4238
|
-
function
|
|
4261
|
+
function jt(e, t) {
|
|
4239
4262
|
e.innerHTML = t.join("");
|
|
4240
4263
|
}
|
|
4241
4264
|
// packages/diagram/src/index.ts
|
|
4242
|
-
var
|
|
4265
|
+
var Mt = class extends Error {
|
|
4243
4266
|
constructor(e) {
|
|
4244
4267
|
super(e), this.name = "DiagramError";
|
|
4245
4268
|
}
|
|
4246
4269
|
};
|
|
4247
|
-
function
|
|
4248
|
-
return
|
|
4270
|
+
function Nt(e) {
|
|
4271
|
+
return Dt(e);
|
|
4249
4272
|
}
|
|
4250
|
-
function
|
|
4251
|
-
let n = t ??
|
|
4252
|
-
if (!n) throw new
|
|
4273
|
+
function Pt(e, t) {
|
|
4274
|
+
let n = t ?? Dt(e);
|
|
4275
|
+
if (!n) throw new Mt("Not a Mermaid, PlantUML or Graphviz diagram");
|
|
4253
4276
|
try {
|
|
4254
|
-
return
|
|
4277
|
+
return kt(n, e).map((e) => ({
|
|
4255
4278
|
svg: e.svg,
|
|
4256
4279
|
width: e.w,
|
|
4257
4280
|
height: e.h
|
|
4258
4281
|
}));
|
|
4259
4282
|
} catch (e) {
|
|
4260
|
-
throw new
|
|
4283
|
+
throw new Mt(e.message);
|
|
4261
4284
|
}
|
|
4262
4285
|
}
|
|
4263
|
-
function
|
|
4264
|
-
return
|
|
4286
|
+
function Ft(e, t) {
|
|
4287
|
+
return Pt(e, t)[0];
|
|
4265
4288
|
}
|
|
4266
|
-
function
|
|
4267
|
-
let r =
|
|
4268
|
-
return
|
|
4289
|
+
function It(e, t, n) {
|
|
4290
|
+
let r = Pt(t, n);
|
|
4291
|
+
return jt(e, r.map((e) => e.svg)), r;
|
|
4269
4292
|
}
|
|
4270
|
-
var
|
|
4293
|
+
var Lt = [
|
|
4271
4294
|
[".mermaid", "mermaid"],
|
|
4272
4295
|
[".language-mermaid", "mermaid"],
|
|
4273
4296
|
[".plantuml", "plantuml"],
|
|
@@ -4278,23 +4301,23 @@ var It = [
|
|
|
4278
4301
|
[".language-dot", "graphviz"],
|
|
4279
4302
|
[".diagram", null]
|
|
4280
4303
|
];
|
|
4281
|
-
function
|
|
4304
|
+
function Rt(e = document) {
|
|
4282
4305
|
let t = 0;
|
|
4283
|
-
for (let [n, r] of
|
|
4306
|
+
for (let [n, r] of Lt) for (let i of Array.from(e.querySelectorAll(n))) {
|
|
4284
4307
|
if (!i.isConnected || i.hasAttribute("data-diagram-error") || i.closest("figure.diagram")) continue;
|
|
4285
4308
|
let e = i.tagName === "CODE" && i.parentElement?.tagName === "PRE" ? i.parentElement : i, n = i.textContent ?? "";
|
|
4286
4309
|
try {
|
|
4287
|
-
let a =
|
|
4288
|
-
o.className = `diagram diagram-${r ??
|
|
4310
|
+
let a = Pt(n, r ?? void 0), o = i.ownerDocument.createElement("figure");
|
|
4311
|
+
o.className = `diagram diagram-${r ?? Dt(n)}`, jt(o, a.map((e) => e.svg)), e.replaceWith(o), t++;
|
|
4289
4312
|
} catch (e) {
|
|
4290
4313
|
i.setAttribute("data-diagram-error", e.message);
|
|
4291
4314
|
}
|
|
4292
4315
|
}
|
|
4293
4316
|
return t;
|
|
4294
4317
|
}
|
|
4295
|
-
function
|
|
4296
|
-
return
|
|
4318
|
+
function zt(e, t = 2) {
|
|
4319
|
+
return At(e, t);
|
|
4297
4320
|
}
|
|
4298
|
-
export {
|
|
4321
|
+
export { Mt as DiagramError, Nt as detect, Ft as render, Pt as renderEach, Rt as renderPage, It as renderTo, zt as toPng };
|
|
4299
4322
|
|
|
4300
4323
|
//# sourceMappingURL=index.js.map
|