@draftably/mermaid 0.2.2 → 0.2.3
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/cdn/{font-data-DME3E71S-DQDSeeBH.mjs → font-data-DME3E71S-Blxzmvs1.mjs} +1 -1
- package/dist/cdn/{index-C8K0jvXo.mjs → index-xhN9In0x.mjs} +3182 -3119
- package/dist/cdn/{mermaid-importer-CsurIKv3.mjs → mermaid-importer-Df5wAzZF.mjs} +799 -774
- package/dist/chunks/{mermaid-importer-BHKoojYC.js → mermaid-importer-DcseMRou.js} +799 -774
- package/dist/mermaid.esm.min.mjs +1 -1
- package/dist/mermaid.js +1 -1
- package/dist/types/src/model/appearance.d.ts +8 -1
- package/package.json +2 -2
|
@@ -29,14 +29,14 @@ const _o = {
|
|
|
29
29
|
sans: "Inter, Arial, sans-serif",
|
|
30
30
|
serif: "'Source Serif 4', Georgia, serif",
|
|
31
31
|
mono: "'JetBrains Mono', Menlo, Consolas, monospace"
|
|
32
|
-
}, Vn = (e, t) => e === "serif" ? "serif-600" : e === "mono" ? "mono-500" : t ? "sans-600" : "sans-500",
|
|
32
|
+
}, Vn = (e, t) => e === "serif" ? "serif-600" : e === "mono" ? "mono-500" : t ? "sans-600" : "sans-500", Lo = (e) => `'${Qn[Vn(e, !0)].family}', ${To[e]}`;
|
|
33
33
|
function ct(e, t, s, n) {
|
|
34
34
|
const o = Vn(e, t);
|
|
35
|
-
return { role: e, face: o, family:
|
|
35
|
+
return { role: e, face: o, family: Lo(e), weight: Qn[o].weight, size: s, lineHeight: n };
|
|
36
36
|
}
|
|
37
|
-
const
|
|
37
|
+
const Ro = _o;
|
|
38
38
|
function ye(e, t) {
|
|
39
|
-
const s =
|
|
39
|
+
const s = Ro[t.face];
|
|
40
40
|
let n = 0;
|
|
41
41
|
for (const o of e) n += s.advances[o] ?? s.fallback;
|
|
42
42
|
return n * t.size / s.unitsPerEm;
|
|
@@ -109,10 +109,10 @@ function Do(e, t, s, n) {
|
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
if (!Number.isFinite(w[t][o.length])) return;
|
|
112
|
-
const
|
|
112
|
+
const p = [];
|
|
113
113
|
for (let a = t, i = o.length; a > 0; i = l[a][i], a--)
|
|
114
|
-
|
|
115
|
-
return
|
|
114
|
+
p.unshift(e.slice(l[a][i], i).join(" "));
|
|
115
|
+
return p;
|
|
116
116
|
}
|
|
117
117
|
function it(e, t, s, n = !1) {
|
|
118
118
|
const o = [];
|
|
@@ -125,7 +125,7 @@ function it(e, t, s, n = !1) {
|
|
|
125
125
|
}
|
|
126
126
|
return o.length ? o : [""];
|
|
127
127
|
}
|
|
128
|
-
const ln = ["drafting", "fieldnotes", "signal", "ink", "blueprint"], It = "drafting", Gt = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], Ve = 500, No = (e) => Ze[e]?.dark ? 950 : 50,
|
|
128
|
+
const ln = ["drafting", "fieldnotes", "signal", "ink", "blueprint"], It = "drafting", Gt = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], Ve = 500, No = (e) => Ze[e]?.dark ? 950 : 50, Fo = (e) => Ze[e]?.dark ? 900 : 100, Ht = [
|
|
129
129
|
"primary",
|
|
130
130
|
"secondary",
|
|
131
131
|
"slate",
|
|
@@ -148,7 +148,7 @@ const ln = ["drafting", "fieldnotes", "signal", "ink", "blueprint"], It = "draft
|
|
|
148
148
|
paddingX: { min: 4, max: 48 },
|
|
149
149
|
paddingY: { min: 4, max: 48 },
|
|
150
150
|
radius: { min: 0, max: 24 }
|
|
151
|
-
},
|
|
151
|
+
}, Po = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i, Ze = {
|
|
152
152
|
drafting: {
|
|
153
153
|
label: "Drafting",
|
|
154
154
|
description: "Navy ink on cool paper, with drafting blue and marker gold",
|
|
@@ -253,6 +253,32 @@ const ln = ["drafting", "fieldnotes", "signal", "ink", "blueprint"], It = "draft
|
|
|
253
253
|
primary: ["#2B3A55", 900],
|
|
254
254
|
secondary: ["#C23B22", 600]
|
|
255
255
|
},
|
|
256
|
+
// The default theme on a dark page: the same type, spacing and families as drafting, so it
|
|
257
|
+
// draws every box in the same place. Graphite surfaces, lighter than the canvas the higher
|
|
258
|
+
// they sit, with drafting blue and marker gold lifted to read on them. Not a file's theme.
|
|
259
|
+
"drafting-dark": {
|
|
260
|
+
label: "Drafting dark",
|
|
261
|
+
description: "Drafting on a graphite page, for a dark host",
|
|
262
|
+
dark: !0,
|
|
263
|
+
canvas: "#16191E",
|
|
264
|
+
text: "#E7EAEF",
|
|
265
|
+
muted: "#9BA3B0",
|
|
266
|
+
connection: "#AEB6C2",
|
|
267
|
+
node: { fill: "#21252C", stroke: "#3D4450", ink: "#E7EAEF" },
|
|
268
|
+
group: { fill: "#1B1F25", stroke: "#30363F", ink: "#C8CED8" },
|
|
269
|
+
paddingX: 12,
|
|
270
|
+
paddingY: 20,
|
|
271
|
+
radius: 4,
|
|
272
|
+
shadow: !1,
|
|
273
|
+
titleFont: "sans",
|
|
274
|
+
annotationFont: "sans",
|
|
275
|
+
titleSize: 13,
|
|
276
|
+
titleLine: 16,
|
|
277
|
+
annotationSize: 11,
|
|
278
|
+
chroma: 0.9,
|
|
279
|
+
primary: ["#7FA4E6", 300],
|
|
280
|
+
secondary: ["#F0B43C", 400]
|
|
281
|
+
},
|
|
256
282
|
blueprint: {
|
|
257
283
|
label: "Blueprint",
|
|
258
284
|
description: "White lines on blueprint blue, cyan and yellow, monospace titles",
|
|
@@ -305,11 +331,11 @@ function Yt(e) {
|
|
|
305
331
|
const [t, s, n] = to(e).map(eo);
|
|
306
332
|
return 0.2126 * t + 0.7152 * s + 0.0722 * n;
|
|
307
333
|
}
|
|
308
|
-
function
|
|
334
|
+
function Lt(e, t) {
|
|
309
335
|
const [s, n] = [Yt(e), Yt(t)].sort((o, r) => r - o);
|
|
310
336
|
return (s + 0.05) / (n + 0.05);
|
|
311
337
|
}
|
|
312
|
-
const
|
|
338
|
+
const pn = {
|
|
313
339
|
50: 0.975,
|
|
314
340
|
100: 0.945,
|
|
315
341
|
200: 0.9,
|
|
@@ -332,7 +358,7 @@ const un = {
|
|
|
332
358
|
connection: 4.5,
|
|
333
359
|
/** A group's frame against the canvas. */
|
|
334
360
|
frame: 2
|
|
335
|
-
}, St = (e) => Math.max(0.18, 1 - ((e - 0.6) / 0.42) ** 2),
|
|
361
|
+
}, St = (e) => Math.max(0.18, 1 - ((e - 0.6) / 0.42) ** 2), zo = {
|
|
336
362
|
slate: [255, 0.03],
|
|
337
363
|
stone: [70, 0.02],
|
|
338
364
|
blue: [258, 0.14],
|
|
@@ -345,31 +371,31 @@ const un = {
|
|
|
345
371
|
red: [32, 0.17],
|
|
346
372
|
rose: [358, 0.12],
|
|
347
373
|
violet: [305, 0.13]
|
|
348
|
-
},
|
|
374
|
+
}, Uo = (e) => lt([0.24, 0.035, e]), qo = "#FFFFFF";
|
|
349
375
|
function Ye(e, t, s) {
|
|
350
|
-
if (
|
|
376
|
+
if (Lt(e, t) >= s) return e;
|
|
351
377
|
const [n, o, r] = on(e), d = Yt(t) > 0.18 ? -0.01 : 0.01;
|
|
352
378
|
let h = e;
|
|
353
|
-
for (let c = n; c > 0 && c < 1 &&
|
|
379
|
+
for (let c = n; c > 0 && c < 1 && Lt(h, t) < s; c += d)
|
|
354
380
|
h = lt([c, o, r]);
|
|
355
381
|
return h;
|
|
356
382
|
}
|
|
357
|
-
function
|
|
358
|
-
const h = Bo(e, n), c = h ?
|
|
383
|
+
function un(e, t, s, n, o, r, d) {
|
|
384
|
+
const h = Bo(e, n), c = h ? Uo(n) : qo, y = sn(e) ? Ne.paleInk : Ne.darkInk;
|
|
359
385
|
let w = d ? on(d)[0] : t, l = d ?? lt([w, s * St(w), n]);
|
|
360
|
-
for (;
|
|
386
|
+
for (; Lt(l, c) < y && w > 0.05 && w < 0.995; )
|
|
361
387
|
w += h ? 5e-3 : -0.01, l = lt([w, s * St(w), n]);
|
|
362
|
-
const
|
|
363
|
-
let a = lt([
|
|
364
|
-
return
|
|
388
|
+
const p = h ? w - 0.2 : r ? w + 0.14 : w - 0.08;
|
|
389
|
+
let a = lt([p, s * St(p) * 1.1, n]);
|
|
390
|
+
return Lt(l, o) < Ne.outline && (a = Ye(a, o, Ne.outline)), { swatch: { fill: l, stroke: a, ink: c }, L: w };
|
|
365
391
|
}
|
|
366
392
|
const Go = 0.055;
|
|
367
393
|
function oo(e, t, s, n, o) {
|
|
368
394
|
const r = /* @__PURE__ */ new Map();
|
|
369
395
|
let d = 1;
|
|
370
396
|
for (const h of Gt) {
|
|
371
|
-
const c = no(e) ? jo(h, e) : void 0, y = sn(h) ?
|
|
372
|
-
let w =
|
|
397
|
+
const c = no(e) ? jo(h, e) : void 0, y = sn(h) ? pn[h] : Math.min(c ?? pn[h], d - Go);
|
|
398
|
+
let w = un(
|
|
373
399
|
h,
|
|
374
400
|
y,
|
|
375
401
|
t,
|
|
@@ -378,7 +404,7 @@ function oo(e, t, s, n, o) {
|
|
|
378
404
|
n,
|
|
379
405
|
o?.[1] === h ? o[0] : void 0
|
|
380
406
|
);
|
|
381
|
-
w.L >= d - 0.01 && (w =
|
|
407
|
+
w.L >= d - 0.01 && (w = un(h, y, t, e, s, n)), d = w.L, r.set(h, w.swatch);
|
|
382
408
|
}
|
|
383
409
|
return r;
|
|
384
410
|
}
|
|
@@ -396,7 +422,7 @@ function Ho(e, t = Ze[e].canvas) {
|
|
|
396
422
|
["primary", gn(o.primary, t, o.dark)],
|
|
397
423
|
["secondary", gn(o.secondary, t, o.dark)]
|
|
398
424
|
]);
|
|
399
|
-
for (const [r, d] of Object.entries(
|
|
425
|
+
for (const [r, d] of Object.entries(zo)) {
|
|
400
426
|
const [h, c] = o.hues?.[r] ?? d;
|
|
401
427
|
n.set(r, oo(h, c * o.chroma, t, o.dark));
|
|
402
428
|
}
|
|
@@ -405,7 +431,7 @@ function Ho(e, t = Ze[e].canvas) {
|
|
|
405
431
|
return n;
|
|
406
432
|
}
|
|
407
433
|
const Yo = (e) => Math.round(e + 32), xt = /* @__PURE__ */ new Map();
|
|
408
|
-
function
|
|
434
|
+
function pt(e) {
|
|
409
435
|
const t = e ?? Jn(), s = JSON.stringify(t), n = xt.get(s);
|
|
410
436
|
if (n) return n;
|
|
411
437
|
const o = Ze[t.theme] ?? Ze[It], r = t.overrides, d = r.titleFont ?? o.titleFont, h = r.annotationFont ?? o.annotationFont, c = r.canvas ?? o.canvas, y = new Map(
|
|
@@ -420,7 +446,7 @@ function ut(e) {
|
|
|
420
446
|
ink: a.ink ?? g.ink
|
|
421
447
|
});
|
|
422
448
|
}
|
|
423
|
-
const l = ct(d, !0, o.titleSize, o.titleLine),
|
|
449
|
+
const l = ct(d, !0, o.titleSize, o.titleLine), p = {
|
|
424
450
|
theme: t.theme,
|
|
425
451
|
dark: o.dark,
|
|
426
452
|
// Preset colors are held to the contrast targets against the actual canvas; colors the file
|
|
@@ -457,7 +483,7 @@ function ut(e) {
|
|
|
457
483
|
custom: w,
|
|
458
484
|
strikeRemoved: !!t.config?.strikeRemoved
|
|
459
485
|
};
|
|
460
|
-
return xt.size > 50 && xt.clear(), xt.set(s,
|
|
486
|
+
return xt.size > 50 && xt.clear(), xt.set(s, p), p;
|
|
461
487
|
}
|
|
462
488
|
function wn(e, t = 0) {
|
|
463
489
|
if (!e.length) return { x: 70, y: 160, w: 240, h: 160 };
|
|
@@ -466,7 +492,7 @@ function wn(e, t = 0) {
|
|
|
466
492
|
s = Math.min(s, d.x), n = Math.min(n, d.y), o = Math.max(o, d.x + d.w), r = Math.max(r, d.y + d.h);
|
|
467
493
|
return { x: s - t, y: n - t, w: o - s + t * 2, h: r - n + t * 2 };
|
|
468
494
|
}
|
|
469
|
-
const Se = 24, Wo = 48, Xt = 97, dt = 10,
|
|
495
|
+
const Se = 24, Wo = 48, Xt = 97, dt = 10, Rt = 18, so = (e, t = Wo) => ({
|
|
470
496
|
x: e.x + Se,
|
|
471
497
|
y: e.y + t
|
|
472
498
|
}), Xo = 48;
|
|
@@ -485,7 +511,7 @@ function Ot(e, t, s, n, o = !1) {
|
|
|
485
511
|
function Ko(e, t, s, n) {
|
|
486
512
|
return e === "circle" ? Math.max(s, Math.ceil(t / 0.7)) : e === "text" ? t + 2 * Math.min(n.paddingY, 11) : t + 2 * n.paddingY;
|
|
487
513
|
}
|
|
488
|
-
function
|
|
514
|
+
function ut(e, t, s) {
|
|
489
515
|
const n = e.indexOf(`
|
|
490
516
|
`), o = n < 0 ? e : e.slice(0, n), r = it(o, t, s.title, !0).map((d) => ({ text: d, detail: !1 }));
|
|
491
517
|
if (n >= 0)
|
|
@@ -498,12 +524,12 @@ function Zo(e, t, s) {
|
|
|
498
524
|
const n = t - 2 * Vo;
|
|
499
525
|
for (let o = 1; o * s.title.lineHeight < n; o++) {
|
|
500
526
|
const r = n - o * s.title.lineHeight;
|
|
501
|
-
if (r >= 40 && gt(
|
|
527
|
+
if (r >= 40 && gt(ut(e, r, s), s) <= o * s.title.lineHeight)
|
|
502
528
|
return r;
|
|
503
529
|
}
|
|
504
530
|
}
|
|
505
531
|
const yn = 3, _t = (e, t = 1) => e.groupHeader + (t - 1) * e.groupTitle.lineHeight, Jo = 168, ao = (e, t = !1) => t ? { ...e.annotation, size: e.annotation.size + 1.5, lineHeight: e.annotation.lineHeight + 2 } : e.annotation, es = 140, ts = (e, t, s = !1) => it(e, s ? Jo : es, ao(t, s)), We = { out: 36, down: 22, label: 4 };
|
|
506
|
-
function Je(e, t =
|
|
532
|
+
function Je(e, t = pt(), s = !1) {
|
|
507
533
|
const n = ao(t, s), o = ts(e, t, s), r = Math.max(...o.map((d) => ye(d, n))) + 16;
|
|
508
534
|
return {
|
|
509
535
|
w: Math.round(Math.max(36, r)),
|
|
@@ -519,17 +545,17 @@ function Mn(e, t) {
|
|
|
519
545
|
below: Math.max(We.down, We.down / 2 + n / 2)
|
|
520
546
|
};
|
|
521
547
|
}
|
|
522
|
-
const
|
|
548
|
+
const Pt = 8, xn = 16, Kt = 10, ns = 64, os = 240, Qt = (e) => Math.round(e + 14);
|
|
523
549
|
function ss(e, t) {
|
|
524
550
|
if (e.size?.height !== void 0) return { w: e.size.width, h: e.size.height };
|
|
525
551
|
if (e.size) {
|
|
526
|
-
const r = gt(
|
|
552
|
+
const r = gt(ut(e.label, e.size.width - 2 * t.paddingX, t), t);
|
|
527
553
|
return {
|
|
528
554
|
w: e.size.width,
|
|
529
555
|
h: Math.max(r + 2 * Math.min(t.paddingY, Kt), e.size.minHeight ?? 0)
|
|
530
556
|
};
|
|
531
557
|
}
|
|
532
|
-
const s = 2 * t.paddingX, n = Math.min(os, Math.max(ns, Math.ceil(ye(e.label, t.title)) + s)), o = gt(
|
|
558
|
+
const s = 2 * t.paddingX, n = Math.min(os, Math.max(ns, Math.ceil(ye(e.label, t.title)) + s)), o = gt(ut(e.label, n - s, t), t);
|
|
533
559
|
return { w: n, h: o + 2 * Math.min(t.paddingY, Kt) };
|
|
534
560
|
}
|
|
535
561
|
function is(e, t, s, n = 0) {
|
|
@@ -551,8 +577,8 @@ function is(e, t, s, n = 0) {
|
|
|
551
577
|
const { col: _, span: $ } = h.get(D.id), x = r.get(D.id).w - w.slice(_, _ + $).reduce((E, v) => E + v, 0);
|
|
552
578
|
x > 0 && (w[_ + $ - 1] += x);
|
|
553
579
|
}
|
|
554
|
-
const
|
|
555
|
-
|
|
580
|
+
const p = n - w.reduce((D, _) => D + _, 0);
|
|
581
|
+
p > 0 && (w[d - 1] += p);
|
|
556
582
|
const a = [0], i = [0];
|
|
557
583
|
for (const D of w) a.push(a.at(-1) + D);
|
|
558
584
|
for (const D of l) i.push(i.at(-1) + D);
|
|
@@ -564,10 +590,10 @@ function is(e, t, s, n = 0) {
|
|
|
564
590
|
const k = Qt(s.groupTitle.lineHeight), S = d > 1 || t.direction === "right";
|
|
565
591
|
return e.forEach((D, _) => {
|
|
566
592
|
if (!D.marker) return;
|
|
567
|
-
const $ = e.slice(_ + 1).find((v) => !v.marker), x = $ ? M.get($.id) : void 0, E =
|
|
593
|
+
const $ = e.slice(_ + 1).find((v) => !v.marker), x = $ ? M.get($.id) : void 0, E = Pt / 2;
|
|
568
594
|
M.set(
|
|
569
595
|
D.id,
|
|
570
|
-
S ? { x: (x?.x ?? g) - E, y: -k, w:
|
|
596
|
+
S ? { x: (x?.x ?? g) - E, y: -k, w: Pt, h: f + k + xn } : { x: 0, y: (x?.y ?? f) - E, w: g + xn, h: Pt }
|
|
571
597
|
);
|
|
572
598
|
}), { boxes: M, w: g, h: f };
|
|
573
599
|
}
|
|
@@ -589,10 +615,10 @@ function cs(e, t, s) {
|
|
|
589
615
|
const y = c ? h + 1 : h, w = (f) => d.get(f).reduce((M, k) => k.span > M.span ? k : M), l = Math.max(
|
|
590
616
|
0,
|
|
591
617
|
...e.map((f) => {
|
|
592
|
-
const M =
|
|
618
|
+
const M = ut(f.label, Math.max(8, w(f.id).span * o - r), s);
|
|
593
619
|
return gt(M, s) + 2 * Math.min(s.paddingY, Kt);
|
|
594
620
|
})
|
|
595
|
-
),
|
|
621
|
+
), p = (f) => ({
|
|
596
622
|
x: f.col * o,
|
|
597
623
|
y: f.row * l,
|
|
598
624
|
w: f.span * o,
|
|
@@ -600,7 +626,7 @@ function cs(e, t, s) {
|
|
|
600
626
|
}), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
601
627
|
for (const f of e) {
|
|
602
628
|
const M = w(f.id), k = d.get(f.id).filter((S) => S !== M);
|
|
603
|
-
a.set(f.id,
|
|
629
|
+
a.set(f.id, p(M)), k.length && i.set(f.id, k.map(p));
|
|
604
630
|
}
|
|
605
631
|
const g = t.ruler ? Math.round(s.annotation.lineHeight + 6) : 0;
|
|
606
632
|
return {
|
|
@@ -638,25 +664,25 @@ function ds(e, t, s) {
|
|
|
638
664
|
return it(n, t, s).map((c) => {
|
|
639
665
|
for (; d < n.length && h(d); ) d++;
|
|
640
666
|
const y = [];
|
|
641
|
-
for (const
|
|
642
|
-
if (
|
|
667
|
+
for (const p of c)
|
|
668
|
+
if (p === " " && h(d)) {
|
|
643
669
|
const a = o[d - 1];
|
|
644
670
|
for (; d < n.length && h(d); ) d++;
|
|
645
671
|
y.push(a && a === o[d] ? a : void 0);
|
|
646
672
|
} else y.push(o[d++]);
|
|
647
673
|
const w = [];
|
|
648
|
-
y.forEach((
|
|
674
|
+
y.forEach((p, a) => {
|
|
649
675
|
const i = w.at(-1);
|
|
650
|
-
i && i.href ===
|
|
676
|
+
i && i.href === p ? i.text += c[a] : w.push({ text: c[a], href: p, x: 0, w: 0 });
|
|
651
677
|
});
|
|
652
678
|
let l = 0;
|
|
653
|
-
for (const
|
|
654
|
-
|
|
679
|
+
for (const p of w)
|
|
680
|
+
p.x = l, p.w = ye(p.text, s), l += p.w;
|
|
655
681
|
return w.length ? w : [{ text: "", x: 0, w: 0 }];
|
|
656
682
|
});
|
|
657
683
|
}
|
|
658
|
-
const fs = ["below", "above", "left", "right"], ro = 280, co = { x: 12, y: 8 }, bn = co.x, hs = co.y,
|
|
659
|
-
function
|
|
684
|
+
const fs = ["below", "above", "left", "right"], ro = 280, co = { x: 12, y: 8 }, bn = co.x, hs = co.y, ps = 8;
|
|
685
|
+
function us(e, t) {
|
|
660
686
|
const s = e.annotation, n = ds(t.text, (t.width ?? ro) - bn * 2, s), o = Math.ceil(Math.max(...n.map((r) => r.reduce((d, h) => d + h.w, 0)))) + bn * 2;
|
|
661
687
|
return { note: t, lines: n, rect: { x: 0, y: 0, w: o, h: n.length * s.lineHeight + hs * 2 } };
|
|
662
688
|
}
|
|
@@ -665,8 +691,8 @@ function gs(e, t, s, { left: n, right: o, top: r }) {
|
|
|
665
691
|
for (const h of ["left", "right"]) {
|
|
666
692
|
let c = r;
|
|
667
693
|
t.map((y, w) => ({ note: y, i: w, row: s.get(y.near ?? "") })).filter((y) => y.row !== void 0 && (y.note.side ?? "right") === h).sort((y, w) => y.row - w.row).forEach(({ note: y, i: w, row: l }) => {
|
|
668
|
-
const { w:
|
|
669
|
-
d[w] = { x: h === "right" ? o : n -
|
|
694
|
+
const { w: p, h: a } = us(e, y).rect, i = Math.max(c, Math.round(l - a / 2));
|
|
695
|
+
d[w] = { x: h === "right" ? o : n - p, y: i, w: p, h: a }, c = i + a + ps;
|
|
670
696
|
});
|
|
671
697
|
}
|
|
672
698
|
return d;
|
|
@@ -710,11 +736,11 @@ function Ms(e, t, s = {}) {
|
|
|
710
736
|
return E;
|
|
711
737
|
}, [_, $] = [D(g), D(f)];
|
|
712
738
|
if (S && _ !== $) {
|
|
713
|
-
const x = (
|
|
739
|
+
const x = (F, X, B) => F === X || w(X, c(B)).some((G) => !y(F, X, G, ""));
|
|
714
740
|
if (!e.some(
|
|
715
|
-
(
|
|
741
|
+
(F) => F.parent === S.id && F !== _ && F !== $ && xs(_, $, F)
|
|
716
742
|
) && x(g, _, f) && x(f, $, g)) continue;
|
|
717
|
-
const v = Math.abs(c(_).y - c($).y) > Math.abs(c(_).x - c($).x),
|
|
743
|
+
const v = Math.abs(c(_).y - c($).y) > Math.abs(c(_).x - c($).x), u = (F, X, B) => (c(F)[B] - c(X)[B]) / Math.max(1, B === "x" ? X.w : X.h), A = v ? "x" : "y", m = u(g, _, A) + u(f, $, A), b = c($)[v ? "y" : "x"] > c(_)[v ? "y" : "x"], T = Math.abs(m) > 0.1 ? m > 0 : b;
|
|
718
744
|
h(S.id, v ? T ? "right" : "left" : T ? "bottom" : "top");
|
|
719
745
|
continue;
|
|
720
746
|
}
|
|
@@ -724,18 +750,18 @@ function Ms(e, t, s = {}) {
|
|
|
724
750
|
]) {
|
|
725
751
|
const v = x.parent === "root" ? void 0 : n.get(x.parent);
|
|
726
752
|
if (!v || S && v.id === S.id || r(E.id, v.id)) continue;
|
|
727
|
-
const
|
|
728
|
-
!
|
|
753
|
+
const u = w(v, c(E));
|
|
754
|
+
!u.length || u.some((A) => !y(x, v, A, E.id)) || (u.some((A) => A === "left" || A === "right") ? h(v.id, c(x).y < c(v).y + 24 ? "top" : "bottom") : h(v.id, c(E).x < c(x).x ? "left" : "right"));
|
|
729
755
|
}
|
|
730
756
|
}
|
|
731
|
-
const l = s.standoff ?? ys,
|
|
757
|
+
const l = s.standoff ?? ys, p = Math.max(s.edgeGap ?? vn, s.portGap ?? vn), a = (i) => i ? 2 * l + (i - 1) * p : Se;
|
|
732
758
|
return new Map(
|
|
733
759
|
[...d].map(([i, g]) => [
|
|
734
760
|
i,
|
|
735
761
|
{
|
|
736
762
|
left: a(g.left),
|
|
737
763
|
right: a(g.right),
|
|
738
|
-
top: g.top ? l + (g.top - 1) *
|
|
764
|
+
top: g.top ? l + (g.top - 1) * p : 0,
|
|
739
765
|
bottom: a(g.bottom),
|
|
740
766
|
lines: g
|
|
741
767
|
}
|
|
@@ -750,45 +776,45 @@ const kn = 20, vt = 20, bs = 12, vs = 16;
|
|
|
750
776
|
function ks(e, t, s, n, o = (r) => Je(r)) {
|
|
751
777
|
const r = /* @__PURE__ */ new Map();
|
|
752
778
|
for (const d of e.filter((h) => h.scope === "root")) {
|
|
753
|
-
const h = d.axis === "right", c = (f) => h ? f.x : f.y, y = (f) => h ? f.x + f.w : f.y + f.h, w = (f) => h ? f.y : f.x, l = (f) => h ? f.y + f.h : f.x + f.w,
|
|
779
|
+
const h = d.axis === "right", c = (f) => h ? f.x : f.y, y = (f) => h ? f.x + f.w : f.y + f.h, w = (f) => h ? f.y : f.x, l = (f) => h ? f.y + f.h : f.x + f.w, p = (f) => (c(f) + y(f)) / 2, a = (f) => (w(f) + l(f)) / 2, i = [...s.values()].filter((f) => f.parent === d.scope);
|
|
754
780
|
(d.bands?.map((f) => f.map((M) => s.get(M))) ?? [i]).forEach((f) => {
|
|
755
781
|
const M = Math.min(...f.map(w)), k = Math.max(...f.map(l)), S = Math.min(...f.map(c)), D = Math.max(...f.map(y)), _ = new Set(f.map((v) => v.id)), $ = (v) => [...s.values()].some(
|
|
756
|
-
(
|
|
782
|
+
(u) => u.parent === d.scope && !_.has(u.id) && c(u) < D && y(u) > S && (v ? l(u) <= M : w(u) >= k)
|
|
757
783
|
), x = { before: !$(!0), after: !$(!1) }, E = [];
|
|
758
784
|
for (const v of t) {
|
|
759
785
|
if (n.has(v.id) || v.from !== "auto" || v.to !== "auto") continue;
|
|
760
|
-
const
|
|
761
|
-
if (!
|
|
762
|
-
const m =
|
|
763
|
-
(O) => O !==
|
|
786
|
+
const u = s.get(v.source), A = s.get(v.target);
|
|
787
|
+
if (!u || !A || u === A || !_.has(u.id) || !_.has(A.id) || u.type === "group" || A.type === "group") continue;
|
|
788
|
+
const m = p(A) < p(u), [b, T] = m ? [A, u] : [u, A], F = Math.min(a(u), a(A)) - 8, X = Math.max(a(u), a(A)) + 8, B = f.filter(
|
|
789
|
+
(O) => O !== u && O !== A && c(O) >= y(b) - 1 && y(O) <= c(T) + 1
|
|
764
790
|
);
|
|
765
|
-
if (!B.some((O) => w(O) < X && l(O) >
|
|
766
|
-
const
|
|
791
|
+
if (!B.some((O) => w(O) < X && l(O) > F) && !(m && B.length)) continue;
|
|
792
|
+
const P = (O, C) => !f.some(
|
|
767
793
|
(V) => V !== O && c(V) < y(O) && y(V) > c(O) && (C ? l(V) <= w(O) : w(V) >= l(O))
|
|
768
|
-
),
|
|
769
|
-
if (!Number.isFinite(N) && !Number.isFinite(
|
|
770
|
-
const I = N ===
|
|
771
|
-
E.push({ id: v.id, before: I, from:
|
|
794
|
+
), R = (O) => !x[O ? "before" : "after"] || !P(u, O) || !P(A, O) ? 1 / 0 : O ? w(u) - M + (w(A) - M) : k - l(u) + (k - l(A)), [N, U] = [R(!0), R(!1)];
|
|
795
|
+
if (!Number.isFinite(N) && !Number.isFinite(U)) continue;
|
|
796
|
+
const I = N === U ? !m : N < U;
|
|
797
|
+
E.push({ id: v.id, before: I, from: p(b), to: p(T), back: m });
|
|
772
798
|
}
|
|
773
799
|
for (const v of [!0, !1]) {
|
|
774
|
-
const
|
|
775
|
-
for (const b of
|
|
800
|
+
const u = E.filter((b) => b.before === v).sort((b, T) => b.to - b.from - (T.to - T.from) || b.from - T.from), A = [], m = /* @__PURE__ */ new Set();
|
|
801
|
+
for (const b of u) {
|
|
776
802
|
const T = t.find((O) => O.id === b.id);
|
|
777
803
|
if (m.has(T.source) || m.has(T.target)) continue;
|
|
778
804
|
m.add(T.source).add(T.target);
|
|
779
|
-
let
|
|
780
|
-
for (; A[
|
|
781
|
-
(A[
|
|
782
|
-
const X = t.find((O) => O.id === b.id), B = s.get(X.target), G = v ? M - kn -
|
|
805
|
+
let F = 0;
|
|
806
|
+
for (; A[F]?.some(([O, C]) => b.from < C + vt && b.to > O - vt); ) F++;
|
|
807
|
+
(A[F] ??= []).push([b.from, b.to]);
|
|
808
|
+
const X = t.find((O) => O.id === b.id), B = s.get(X.target), G = v ? M - kn - F * vt : k + kn + F * vt, P = Es(B, f, !b.back, c, y), R = Math.min(vs, (l(B) - w(B)) / 2 - bs), N = As(B, f, !b.back, X.id, t, s, c, y, w, l), U = B.shape === "diamond" && N.length > 0 || N.some((O) => {
|
|
783
809
|
if (!O.label) return !1;
|
|
784
810
|
const { w: C, h: V } = o(O.label);
|
|
785
|
-
return (h ? V : C) / 2 + 2 >
|
|
786
|
-
}), I =
|
|
811
|
+
return (h ? V : C) / 2 + 2 > R;
|
|
812
|
+
}), I = U ? p(B) : b.back ? y(B) + P / 2 : c(B) - P / 2;
|
|
787
813
|
r.set(b.id, {
|
|
788
814
|
...h ? { y: Math.round(G) } : { x: Math.round(G) },
|
|
789
815
|
enter: Math.round(I),
|
|
790
816
|
out: !0,
|
|
791
|
-
...
|
|
817
|
+
...U ? { face: !0 } : {}
|
|
792
818
|
});
|
|
793
819
|
}
|
|
794
820
|
}
|
|
@@ -803,19 +829,19 @@ function Es(e, t, s, n, o) {
|
|
|
803
829
|
function As(e, t, s, n, o, r, d, h, c, y) {
|
|
804
830
|
const w = new Set(
|
|
805
831
|
t.filter(
|
|
806
|
-
(
|
|
807
|
-
).map((
|
|
808
|
-
), l = (
|
|
809
|
-
for (let a = r.get(
|
|
832
|
+
(p) => p !== e && (s ? h(p) <= d(e) : d(p) >= h(e)) && c(p) < y(e) && y(p) > c(e)
|
|
833
|
+
).map((p) => p.id)
|
|
834
|
+
), l = (p) => {
|
|
835
|
+
for (let a = r.get(p); a; a = r.get(a.parent)) if (w.has(a.id)) return !0;
|
|
810
836
|
return !1;
|
|
811
837
|
};
|
|
812
838
|
return o.filter(
|
|
813
|
-
(
|
|
839
|
+
(p) => p.id !== n && (p.source === e.id && l(p.target) || p.target === e.id && l(p.source))
|
|
814
840
|
);
|
|
815
841
|
}
|
|
816
842
|
const lo = { port: 16, track: 16 }, En = 12, fo = 20, Ct = 0.5;
|
|
817
843
|
function Ss(e, t, s, n, o, r = lo) {
|
|
818
|
-
const d = e === "right", h = /* @__PURE__ */ new Map(), { rectOf: c, usable: y, outPort: w, inPort: l, gaps:
|
|
844
|
+
const d = e === "right", h = /* @__PURE__ */ new Map(), { rectOf: c, usable: y, outPort: w, inPort: l, gaps: p, runs: a } = ho(
|
|
819
845
|
e,
|
|
820
846
|
t,
|
|
821
847
|
s,
|
|
@@ -828,7 +854,7 @@ function Ss(e, t, s, n, o, r = lo) {
|
|
|
828
854
|
const S = c(k);
|
|
829
855
|
S && (i[f] = Math.min(i[f] ?? 1 / 0, S.y), g[f] = Math.max(g[f] ?? -1 / 0, S.y + S.h));
|
|
830
856
|
}
|
|
831
|
-
for (const [f, { placed: M, level: k }] of
|
|
857
|
+
for (const [f, { placed: M, level: k }] of p) {
|
|
832
858
|
const S = Math.max(0, ...k) + 1, D = (i[f + 1] ?? 0) - (g[f] ?? 0), _ = S > 1 ? Math.min(r.track, Math.max(0, D - 2 * fo) / (S - 1)) : 0, $ = (g[f] ?? 0) + (D - (S - 1) * _) / 2;
|
|
833
859
|
M.forEach((x, E) => x.y = ot($ + k[E] * _));
|
|
834
860
|
}
|
|
@@ -859,38 +885,38 @@ function ho(e, t, s, n, o, r) {
|
|
|
859
885
|
const E = h(x);
|
|
860
886
|
return E ? E.x + E.w / 2 : o(x);
|
|
861
887
|
}, l = (x, E, v) => {
|
|
862
|
-
const
|
|
888
|
+
const u = h(x), A = u.x + En, m = u.x + u.w - En, b = E.length;
|
|
863
889
|
E.sort((B, G) => B.want - G.want || (B.line < G.line ? -1 : 1));
|
|
864
|
-
const T = b > 1 ? Math.min(r.port, Math.max(0, m - A) / (b - 1)) : 0,
|
|
890
|
+
const T = b > 1 ? Math.min(r.port, Math.max(0, m - A) / (b - 1)) : 0, F = [];
|
|
865
891
|
for (const [B, G] of E.entries())
|
|
866
|
-
for (
|
|
867
|
-
const
|
|
868
|
-
|
|
892
|
+
for (F.push({ sum: Math.min(m, Math.max(A, G.want)) - B * T, n: 1 }); F.length > 1 && F.at(-2).sum / F.at(-2).n > F.at(-1).sum / F.at(-1).n; ) {
|
|
893
|
+
const P = F.pop();
|
|
894
|
+
F.at(-1).sum += P.sum, F.at(-1).n += P.n;
|
|
869
895
|
}
|
|
870
896
|
const X = [];
|
|
871
|
-
for (const B of
|
|
897
|
+
for (const B of F)
|
|
872
898
|
for (let G = 0; G < B.n; G++)
|
|
873
899
|
X.push(Math.max(A, Math.min(m - (b - 1) * T, B.sum / B.n)) + X.length * T);
|
|
874
900
|
E.forEach((B, G) => v.set(B.line, ot(X[G])));
|
|
875
|
-
},
|
|
901
|
+
}, p = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
|
|
876
902
|
for (const x of y) {
|
|
877
903
|
const [E, v] = x.chain;
|
|
878
|
-
(
|
|
904
|
+
(p.get(E) ?? p.set(E, []).get(E)).push({ line: x.id, want: w(v) });
|
|
879
905
|
}
|
|
880
906
|
const i = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map();
|
|
881
|
-
for (const [x, E] of
|
|
907
|
+
for (const [x, E] of p) l(x, E, i);
|
|
882
908
|
for (const x of y) {
|
|
883
|
-
const E = x.chain.at(-1), v = x.chain.at(-2),
|
|
884
|
-
(a.get(E) ?? a.set(E, []).get(E)).push({ line: x.id, want:
|
|
909
|
+
const E = x.chain.at(-1), v = x.chain.at(-2), u = x.chain.length === 2 ? i.get(x.id) : o(v);
|
|
910
|
+
(a.get(E) ?? a.set(E, []).get(E)).push({ line: x.id, want: u });
|
|
885
911
|
}
|
|
886
912
|
for (const [x, E] of a) l(x, E, g);
|
|
887
913
|
const f = (x, E) => E === 0 ? i.get(x.id) : E === x.chain.length - 1 ? g.get(x.id) : o(x.chain[E]), M = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
|
|
888
914
|
for (const x of y) {
|
|
889
915
|
const E = [];
|
|
890
916
|
for (let v = 0; v + 1 < x.chain.length; v++) {
|
|
891
|
-
const
|
|
892
|
-
if (Math.abs(
|
|
893
|
-
const m = { line: x.id, up:
|
|
917
|
+
const u = f(x, v), A = f(x, v + 1);
|
|
918
|
+
if (Math.abs(u - A) < Ct) continue;
|
|
919
|
+
const m = { line: x.id, up: u, low: A, lo: Math.min(u, A), hi: Math.max(u, A) }, b = c.get(x.chain[v]);
|
|
894
920
|
(M.get(b) ?? M.set(b, []).get(b)).push(m), E.push(m);
|
|
895
921
|
}
|
|
896
922
|
k.set(x.id, E);
|
|
@@ -901,18 +927,18 @@ function ho(e, t, s, n, o, r) {
|
|
|
901
927
|
for (const A of [...E].sort((m, b) => m.lo - b.lo || m.hi - b.hi)) {
|
|
902
928
|
let m = 0, b = 1 / 0;
|
|
903
929
|
for (let T = 0; T <= v.length; T++) {
|
|
904
|
-
let
|
|
930
|
+
let F = 0;
|
|
905
931
|
for (let X = 0; X < v.length; X++)
|
|
906
|
-
_(A, v[X]) && (
|
|
907
|
-
|
|
932
|
+
_(A, v[X]) && (F += X < T ? D(v[X], A) : D(A, v[X]));
|
|
933
|
+
F < b && ([m, b] = [T, F]);
|
|
908
934
|
}
|
|
909
935
|
v.splice(m, 0, A);
|
|
910
936
|
}
|
|
911
|
-
const
|
|
937
|
+
const u = v.map(() => 0);
|
|
912
938
|
for (let A = 0; A < v.length; A++)
|
|
913
939
|
for (let m = 0; m < A; m++)
|
|
914
|
-
_(v[A], v[m]) && (
|
|
915
|
-
$.set(x, { placed: v, level:
|
|
940
|
+
_(v[A], v[m]) && (u[A] = Math.max(u[A], u[m] + 1));
|
|
941
|
+
$.set(x, { placed: v, level: u });
|
|
916
942
|
}
|
|
917
943
|
return { rectOf: h, usable: y, outPort: i, inPort: g, gaps: $, runs: k };
|
|
918
944
|
}
|
|
@@ -937,18 +963,18 @@ const Ts = ["vscode", "vscode-insiders", "cursor", "windsurf", "zed"], An = [
|
|
|
937
963
|
"circle",
|
|
938
964
|
"cross"
|
|
939
965
|
];
|
|
940
|
-
function
|
|
966
|
+
function po(e) {
|
|
941
967
|
return {
|
|
942
968
|
title: ct(e.title.role, !0, 20, 26),
|
|
943
969
|
subtitle: ct(e.annotation.role, !1, 13, 18)
|
|
944
970
|
};
|
|
945
971
|
}
|
|
946
|
-
const Sn = 360,
|
|
947
|
-
function
|
|
948
|
-
const s =
|
|
972
|
+
const Sn = 360, Ls = 70;
|
|
973
|
+
function Rs(e, t) {
|
|
974
|
+
const s = po(e).subtitle, n = ye("abcdefghijklmnopqrstuvwxyz ", s) / 27 * Ls;
|
|
949
975
|
return Math.round(Math.min(Math.max(t, Sn), Math.max(n, Sn)));
|
|
950
976
|
}
|
|
951
|
-
const Os =
|
|
977
|
+
const Os = po;
|
|
952
978
|
function $s(e) {
|
|
953
979
|
return [...Ns(e), ...Cs(e), ...js(e)];
|
|
954
980
|
}
|
|
@@ -977,7 +1003,7 @@ function Ns(e) {
|
|
|
977
1003
|
ids: o.map((r) => r.id)
|
|
978
1004
|
}), s;
|
|
979
1005
|
}
|
|
980
|
-
function
|
|
1006
|
+
function Fs(e, t) {
|
|
981
1007
|
if (!Tt(t)) return Ve;
|
|
982
1008
|
const s = new Map(e.objects.map((c) => [c.id, c])), n = !!Ze[e.appearance.theme]?.dark, o = (c) => {
|
|
983
1009
|
for (let y = s.get(s.get(c)?.parent ?? ""); y; y = s.get(y.parent))
|
|
@@ -990,9 +1016,9 @@ function Ps(e, t) {
|
|
|
990
1016
|
});
|
|
991
1017
|
return d.length && h ? No(e.appearance.theme) : Ve;
|
|
992
1018
|
}
|
|
993
|
-
function
|
|
1019
|
+
function Ps(e) {
|
|
994
1020
|
for (const t of e.appearance.legend ?? [])
|
|
995
|
-
t.family && t.shade === void 0 && (t.shade =
|
|
1021
|
+
t.family && t.shade === void 0 && (t.shade = Fs(e, t.family));
|
|
996
1022
|
}
|
|
997
1023
|
function Cs(e) {
|
|
998
1024
|
return (e.appearance.legend ?? []).flatMap((t, s) => {
|
|
@@ -1012,7 +1038,7 @@ function Cs(e) {
|
|
|
1012
1038
|
function js(e) {
|
|
1013
1039
|
const t = [], s = e.appearance.heading?.subtitle;
|
|
1014
1040
|
if (s) {
|
|
1015
|
-
const n =
|
|
1041
|
+
const n = pt(e.appearance), o = it(s, Rs(n, 1 / 0), Os(n).subtitle);
|
|
1016
1042
|
o.length > 1 && t.push({
|
|
1017
1043
|
level: "warning",
|
|
1018
1044
|
code: "heading-prose",
|
|
@@ -1045,12 +1071,12 @@ function Bs(e) {
|
|
|
1045
1071
|
}))
|
|
1046
1072
|
) : [];
|
|
1047
1073
|
}
|
|
1048
|
-
class
|
|
1074
|
+
class Le extends Error {
|
|
1049
1075
|
constructor(t, s = 0, n = 0) {
|
|
1050
1076
|
super((s ? `Line ${s}${n ? `, column ${n}` : ""}: ` : "") + t), this.line = s, this.column = n, this.name = "DslError";
|
|
1051
1077
|
}
|
|
1052
1078
|
}
|
|
1053
|
-
const
|
|
1079
|
+
const uo = { "+": "added", "-": "removed", "~": "changed", ".": "context" }, zs = (e) => ({ value: String(e), quoted: !1 }), Us = (e) => ({ value: e, quoted: !0 }), qs = 'A quote inside a quoted string needs a backslash: write \\" for each inner quote.';
|
|
1054
1080
|
function Gs(e, t = 0) {
|
|
1055
1081
|
const s = [], n = [];
|
|
1056
1082
|
let o = "", r = 0, d = 0, h = !1, c = !1;
|
|
@@ -1069,24 +1095,24 @@ function Gs(e, t = 0) {
|
|
|
1069
1095
|
}
|
|
1070
1096
|
if (l === '"') {
|
|
1071
1097
|
if (h && w + 1 < e.length && !/[\s#]/.test(e[w + 1]) && !e.startsWith("//", w + 1))
|
|
1072
|
-
throw new
|
|
1098
|
+
throw new Le(qs, t, w + 1);
|
|
1073
1099
|
h || (d = w), h = !h, o += l;
|
|
1074
1100
|
continue;
|
|
1075
1101
|
}
|
|
1076
|
-
const
|
|
1077
|
-
if (!h && (l === "#" ||
|
|
1102
|
+
const p = l === "/" && e[w + 1] === "/" && !/[^\s"]/.test(e[w - 1] ?? " ");
|
|
1103
|
+
if (!h && (l === "#" || p))
|
|
1078
1104
|
return y(), { tokens: s, columns: n, comment: e.slice(w).trim() };
|
|
1079
1105
|
!h && /\s/.test(l) ? y() : o += l;
|
|
1080
1106
|
}
|
|
1081
|
-
if (h) throw new
|
|
1107
|
+
if (h) throw new Le("Unclosed quoted string.", t, d + 1);
|
|
1082
1108
|
return y(), { tokens: s, columns: n };
|
|
1083
1109
|
}
|
|
1084
1110
|
function _n(e, t, s) {
|
|
1085
|
-
if (!e.startsWith('"')) return
|
|
1111
|
+
if (!e.startsWith('"')) return zs(e);
|
|
1086
1112
|
try {
|
|
1087
|
-
return
|
|
1113
|
+
return Us(JSON.parse(e));
|
|
1088
1114
|
} catch {
|
|
1089
|
-
throw new
|
|
1115
|
+
throw new Le(
|
|
1090
1116
|
'Invalid escape in a quoted string. Use \\" for a quote, \\\\ for a backslash and \\n for a line break.',
|
|
1091
1117
|
t,
|
|
1092
1118
|
s
|
|
@@ -1094,20 +1120,20 @@ function _n(e, t, s) {
|
|
|
1094
1120
|
}
|
|
1095
1121
|
}
|
|
1096
1122
|
function Hs(e) {
|
|
1097
|
-
if (typeof e != "string") throw new
|
|
1098
|
-
if (e.length > 3e5) throw new
|
|
1123
|
+
if (typeof e != "string") throw new Le("Source must be text.");
|
|
1124
|
+
if (e.length > 3e5) throw new Le("Limit: 300,000 source characters.");
|
|
1099
1125
|
return { lines: e.split(/\r?\n/).map((s, n) => {
|
|
1100
1126
|
const o = n + 1, { tokens: r, columns: d, comment: h } = Gs(s, o);
|
|
1101
1127
|
if (!r.length) return h ? { kind: "comment", text: h } : { kind: "blank" };
|
|
1102
|
-
const [c, ...y] = r, w =
|
|
1128
|
+
const [c, ...y] = r, w = uo[c[0]] && c.length > 1 ? c[0] : void 0, l = w ? c.slice(1) : c, p = [], a = [];
|
|
1103
1129
|
return y.forEach((i, g) => {
|
|
1104
1130
|
const f = i.indexOf("="), M = d[g + 1];
|
|
1105
1131
|
if (f > 0 && !i.startsWith('"')) {
|
|
1106
1132
|
const k = i.slice(0, f);
|
|
1107
|
-
if (a.some(([S]) => S === k)) throw new
|
|
1133
|
+
if (a.some(([S]) => S === k)) throw new Le(`Duplicate attribute ${k}.`, o);
|
|
1108
1134
|
a.push([k, _n(i.slice(f + 1), o, M + f + 1)]);
|
|
1109
|
-
} else
|
|
1110
|
-
}), { kind: "statement", command: l, ...w ? { mark: w } : {}, args:
|
|
1135
|
+
} else p.push(_n(i, o, M));
|
|
1136
|
+
}), { kind: "statement", command: l, ...w ? { mark: w } : {}, args: p, attrs: a, comment: h, line: o };
|
|
1111
1137
|
}) };
|
|
1112
1138
|
}
|
|
1113
1139
|
const Ys = { wide: 2, slide: 1.78, square: 1, page: 0.77, tall: 0.6 };
|
|
@@ -1129,7 +1155,7 @@ const Ws = ["near", "nudge", "stay", "pin"], In = {
|
|
|
1129
1155
|
canvas: "canvas",
|
|
1130
1156
|
text: "text",
|
|
1131
1157
|
connection: "connection"
|
|
1132
|
-
},
|
|
1158
|
+
}, Ln = [
|
|
1133
1159
|
"compound-flow",
|
|
1134
1160
|
"boundary-align",
|
|
1135
1161
|
"compound-spring",
|
|
@@ -1156,7 +1182,7 @@ const Ws = ["near", "nudge", "stay", "pin"], In = {
|
|
|
1156
1182
|
fold: { key: "fold", choices: ["auto", "never"] },
|
|
1157
1183
|
aspect: { key: "aspect", choices: ["1", "1.333", "1.6", "2", "0.75"] },
|
|
1158
1184
|
root: { key: "rootId", choices: [] }
|
|
1159
|
-
},
|
|
1185
|
+
}, Rn = {
|
|
1160
1186
|
clearance: { key: "clearance", min: 4, max: 30 },
|
|
1161
1187
|
"port-gap": { key: "portGap", min: 6, max: 28 },
|
|
1162
1188
|
"edge-gap": { key: "edgeGap", min: 4, max: 48 },
|
|
@@ -1195,30 +1221,30 @@ function Zs(e) {
|
|
|
1195
1221
|
let h = 0;
|
|
1196
1222
|
for (const c of t.lines) {
|
|
1197
1223
|
if (c.kind !== "statement") continue;
|
|
1198
|
-
const y = c.line, { command: w, args: l } = c,
|
|
1199
|
-
throw new
|
|
1224
|
+
const y = c.line, { command: w, args: l } = c, p = new Map(c.attrs), a = (m) => {
|
|
1225
|
+
throw new Le(m, y);
|
|
1200
1226
|
}, i = (m, b) => {
|
|
1201
1227
|
m || a(b);
|
|
1202
1228
|
}, g = (m) => {
|
|
1203
|
-
for (const b of
|
|
1229
|
+
for (const b of p.keys())
|
|
1204
1230
|
i(m.includes(b), `Unknown ${w} attribute: ${b}.`);
|
|
1205
1231
|
}, f = (m, b = m) => i(l.length >= m && l.length <= b, `Wrong number of arguments for ${w}.`), M = (m) => (i(
|
|
1206
1232
|
m && !m.quoted && Ks.test(m.value),
|
|
1207
1233
|
"Expected a stable identifier (letters, digits, _, . or -)."
|
|
1208
|
-
), m.value), k = (m) => m?.value ?? "", S = (m, b, T = -1e5,
|
|
1209
|
-
const X =
|
|
1234
|
+
), m.value), k = (m) => m?.value ?? "", S = (m, b, T = -1e5, F = 1e5) => {
|
|
1235
|
+
const X = p.get(m);
|
|
1210
1236
|
if (X === void 0) return b;
|
|
1211
1237
|
const B = Number(X.value);
|
|
1212
1238
|
return i(
|
|
1213
|
-
!X.quoted && Number.isFinite(B) && B >= T && B <=
|
|
1214
|
-
`Expected ${m} from ${T} to ${
|
|
1239
|
+
!X.quoted && Number.isFinite(B) && B >= T && B <= F,
|
|
1240
|
+
`Expected ${m} from ${T} to ${F}; got ${X.value}.`
|
|
1215
1241
|
), B;
|
|
1216
1242
|
}, D = (m, b) => {
|
|
1217
|
-
const T =
|
|
1243
|
+
const T = p.get(m);
|
|
1218
1244
|
return !T.quoted && Vs.test(T.value) ? T.value : S(m, b, b, 1e6);
|
|
1219
1245
|
}, _ = (m, b, T) => {
|
|
1220
|
-
const
|
|
1221
|
-
return i(T.includes(
|
|
1246
|
+
const F = p.get(m)?.value ?? b;
|
|
1247
|
+
return i(T.includes(F), `Expected ${m}=${T.join("|")}; got ${F}.`), F;
|
|
1222
1248
|
}, $ = (m) => {
|
|
1223
1249
|
const b = Number(m.value);
|
|
1224
1250
|
return i(
|
|
@@ -1226,35 +1252,35 @@ function Zs(e) {
|
|
|
1226
1252
|
`Expected shade=${Gt.join("|")}; got ${m.value}.`
|
|
1227
1253
|
), b;
|
|
1228
1254
|
}, x = (m) => {
|
|
1229
|
-
const b =
|
|
1255
|
+
const b = p.get(m);
|
|
1230
1256
|
return i(
|
|
1231
|
-
b.quoted &&
|
|
1257
|
+
b.quoted && Po.test(b.value),
|
|
1232
1258
|
`Expected ${m}="#rrggbb" in double quotes; got ${b.value || "nothing"}.`
|
|
1233
1259
|
), b.value.toUpperCase();
|
|
1234
1260
|
}, E = (m) => {
|
|
1235
1261
|
i(!d.has(m), `Duplicate declaration: ${m}. Edit the existing line instead.`), d.add(m);
|
|
1236
|
-
}, v = c.mark &&
|
|
1262
|
+
}, v = c.mark && uo[c.mark];
|
|
1237
1263
|
i(
|
|
1238
1264
|
!c.mark || ["node", "group", "edge"].includes(w),
|
|
1239
1265
|
`Only node, group and edge lines take a ${c.mark} mark.`
|
|
1240
1266
|
);
|
|
1241
|
-
const
|
|
1267
|
+
const u = () => {
|
|
1242
1268
|
for (const m of ["was", "was-shape", "was-count"])
|
|
1243
|
-
i(!
|
|
1269
|
+
i(!p.has(m) || c.mark === "~", `${m}= belongs on a changed (~) line.`);
|
|
1244
1270
|
return {
|
|
1245
|
-
...
|
|
1246
|
-
...
|
|
1247
|
-
...
|
|
1271
|
+
...p.has("was") ? { was: p.get("was").value } : {},
|
|
1272
|
+
...p.has("was-shape") ? { wasShape: _("was-shape", "box", Qs) } : {},
|
|
1273
|
+
...p.has("was-count") ? { wasCount: D("was-count", 1) } : {}
|
|
1248
1274
|
};
|
|
1249
1275
|
}, A = (m) => {
|
|
1250
1276
|
const b = {};
|
|
1251
|
-
for (const [T,
|
|
1252
|
-
|
|
1277
|
+
for (const [T, F] of Object.entries(m))
|
|
1278
|
+
p.has(T) && ("min" in F ? b[F.key] = S(T, 0, F.min, F.max) : F.choices.length ? b[F.key] = _(T, F.choices[0], F.choices) : b[F.key] = M(p.get(T)));
|
|
1253
1279
|
return b;
|
|
1254
1280
|
};
|
|
1255
1281
|
switch (w) {
|
|
1256
1282
|
case "diagram":
|
|
1257
|
-
f(1), g(["version", "width"]), i(!h, "Only one diagram declaration is allowed."), h = y, s.title = k(l[0]), S("version", 1, 1, 1), s.title && ((s.appearance.heading ??= {}).title = s.title),
|
|
1283
|
+
f(1), g(["version", "width"]), i(!h, "Only one diagram declaration is allowed."), h = y, s.title = k(l[0]), S("version", 1, 1, 1), s.title && ((s.appearance.heading ??= {}).title = s.title), p.has("width") && ((s.appearance.heading ??= {}).width = S("width", 0, 160, 8e3));
|
|
1258
1284
|
break;
|
|
1259
1285
|
case "compare": {
|
|
1260
1286
|
f(0, 2), g(["direction", "aspect"]), E("compare");
|
|
@@ -1263,18 +1289,18 @@ function Zs(e) {
|
|
|
1263
1289
|
before: k(l[0]) || "Before",
|
|
1264
1290
|
after: k(l[1]) || "After",
|
|
1265
1291
|
...m !== "auto" ? { direction: m } : {},
|
|
1266
|
-
...
|
|
1292
|
+
...p.has("aspect") ? { aspect: S("aspect", 1.6, 0.25, 8) } : {}
|
|
1267
1293
|
};
|
|
1268
1294
|
break;
|
|
1269
1295
|
}
|
|
1270
1296
|
case "config": {
|
|
1271
|
-
f(0), g(Object.keys(In)), i(
|
|
1297
|
+
f(0), g(Object.keys(In)), i(p.size, `config needs a setting: ${Object.keys(In).join(", ")}.`);
|
|
1272
1298
|
const m = s.appearance.config ??= {};
|
|
1273
|
-
for (const [b, T] of
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1299
|
+
for (const [b, T] of p) {
|
|
1300
|
+
const F = n.get(b);
|
|
1301
|
+
F && s.warnings.push({
|
|
1276
1302
|
code: "config-repeated",
|
|
1277
|
-
message: `config ${b} is also set on line ${
|
|
1303
|
+
message: `config ${b} is also set on line ${F}; this line wins.`,
|
|
1278
1304
|
line: y
|
|
1279
1305
|
}), n.set(b, y), b === "editor" ? m.editor = _("editor", "vscode", Ts) : b === "strike-removed" ? m.strikeRemoved = _(b, "off", ["on", "off"]) === "on" : (i(T.quoted, `Expected ${b}="path" in double quotes.`), m.linkBase = T.value);
|
|
1280
1306
|
}
|
|
@@ -1282,9 +1308,9 @@ function Zs(e) {
|
|
|
1282
1308
|
}
|
|
1283
1309
|
case "state": {
|
|
1284
1310
|
i(l.length >= 1, 'A state needs an ID: state write "Write path" api orders.'), g(["rest"]);
|
|
1285
|
-
const m = M(l[0]), b = l[1]?.quoted ? l[1].value : void 0, T = l.slice(b === void 0 ? 1 : 2).map((B) => M(B)),
|
|
1286
|
-
let X =
|
|
1287
|
-
X || (X = { id: m, label: b ?? m, ids: [], rest: "dim" },
|
|
1311
|
+
const m = M(l[0]), b = l[1]?.quoted ? l[1].value : void 0, T = l.slice(b === void 0 ? 1 : 2).map((B) => M(B)), F = s.appearance.states ??= [];
|
|
1312
|
+
let X = F.find((B) => B.id === m);
|
|
1313
|
+
X || (X = { id: m, label: b ?? m, ids: [], rest: "dim" }, F.push(X)), p.has("rest") && (X.rest = _("rest", "dim", ["dim", "plain"]));
|
|
1288
1314
|
for (const B of T)
|
|
1289
1315
|
i(!X.ids.includes(B), `${B} is already in state ${m}.`), X.ids.push(B), s.stateLines.set(`${m}:${B}`, y);
|
|
1290
1316
|
break;
|
|
@@ -1322,28 +1348,28 @@ function Zs(e) {
|
|
|
1322
1348
|
);
|
|
1323
1349
|
const m = M(l[0]);
|
|
1324
1350
|
i(m !== "root", "root is reserved for the outer layout scope."), i(!o.has(m), `Duplicate node/group id ${m}.`), o.add(m);
|
|
1325
|
-
const b =
|
|
1351
|
+
const b = p.get("color")?.value ?? "auto";
|
|
1326
1352
|
i(
|
|
1327
|
-
!
|
|
1353
|
+
!p.get("color")?.quoted && jt.test(b),
|
|
1328
1354
|
`Expected color=auto, a built-in color (${Ht.join(", ")}) or a theme-color name; got ${b}.`
|
|
1329
1355
|
);
|
|
1330
|
-
const T =
|
|
1356
|
+
const T = p.has("shade") ? $(p.get("shade")) : void 0;
|
|
1331
1357
|
s.objects.push({
|
|
1332
1358
|
id: m,
|
|
1333
1359
|
type: w,
|
|
1334
1360
|
label: k(l[1]),
|
|
1335
|
-
parent:
|
|
1361
|
+
parent: p.has("in") ? M(p.get("in")) : "root",
|
|
1336
1362
|
color: b,
|
|
1337
1363
|
...T !== void 0 ? { shade: T } : {},
|
|
1338
1364
|
shape: w === "node" ? _("shape", "box", go) : "box",
|
|
1339
1365
|
...c.mark ? { status: v } : {},
|
|
1340
|
-
...
|
|
1341
|
-
...
|
|
1342
|
-
...
|
|
1366
|
+
...u(),
|
|
1367
|
+
...p.has("href") ? { href: k(p.get("href")) } : {},
|
|
1368
|
+
...p.has("count") ? { count: D("count", 2) } : {},
|
|
1343
1369
|
...w === "group" && _("fold", "auto", ["auto", "never"]) === "never" ? { fold: "never" } : {},
|
|
1344
1370
|
...w === "group" && _("frame", "box", On) !== "box" ? { frame: _("frame", "box", On) } : {},
|
|
1345
|
-
...
|
|
1346
|
-
span:
|
|
1371
|
+
...p.has("span") ? {
|
|
1372
|
+
span: p.get("span").value === "var" ? "var" : S("span", 1, 1, 4096)
|
|
1347
1373
|
} : {},
|
|
1348
1374
|
line: y
|
|
1349
1375
|
});
|
|
@@ -1356,9 +1382,9 @@ function Zs(e) {
|
|
|
1356
1382
|
);
|
|
1357
1383
|
const m = M(l[0]);
|
|
1358
1384
|
i(!r.has(m), `Duplicate edge id ${m}.`), r.add(m);
|
|
1359
|
-
const b = _("directed", "true", ["true", "false"]) === "false", T = _("head", "arrow", An),
|
|
1385
|
+
const b = _("directed", "true", ["true", "false"]) === "false", T = _("head", "arrow", An), F = _("tail", "none", An);
|
|
1360
1386
|
i(
|
|
1361
|
-
!b || !(
|
|
1387
|
+
!b || !(p.has("head") || p.has("tail")),
|
|
1362
1388
|
`Edge ${m} has directed=false, so it has no ends to mark. Remove head= and tail=, or remove directed=false.`
|
|
1363
1389
|
), s.edges.push({
|
|
1364
1390
|
id: m,
|
|
@@ -1370,28 +1396,28 @@ function Zs(e) {
|
|
|
1370
1396
|
to: _("to", "auto", $n),
|
|
1371
1397
|
...b ? { directed: !1 } : {},
|
|
1372
1398
|
...T !== "arrow" ? { head: T } : {},
|
|
1373
|
-
...
|
|
1399
|
+
...F !== "none" ? { tail: F } : {},
|
|
1374
1400
|
..._("constraint", "true", ["true", "false"]) === "false" ? { constraint: !1 } : {},
|
|
1375
1401
|
...c.mark ? { status: v } : {},
|
|
1376
|
-
...
|
|
1402
|
+
...u(),
|
|
1377
1403
|
line: y
|
|
1378
1404
|
});
|
|
1379
1405
|
break;
|
|
1380
1406
|
}
|
|
1381
1407
|
case "layout": {
|
|
1382
|
-
const m = M(l[0]), b =
|
|
1408
|
+
const m = M(l[0]), b = p.get("engine")?.value, T = s.layouts.findIndex((P) => P.scope === m);
|
|
1383
1409
|
T >= 0 && (s.warnings.push({
|
|
1384
1410
|
code: "layout-repeated",
|
|
1385
1411
|
message: `layout ${m} is also set on line ${s.layouts[T].line}; this line wins.`,
|
|
1386
1412
|
line: y
|
|
1387
1413
|
}), s.layouts.splice(T, 1));
|
|
1388
|
-
const
|
|
1389
|
-
for (const
|
|
1390
|
-
|
|
1414
|
+
const F = (P) => {
|
|
1415
|
+
for (const R of [...p.keys()])
|
|
1416
|
+
P.includes(R) || (s.warnings.push({
|
|
1391
1417
|
code: "layout-attribute",
|
|
1392
|
-
message: `This layout line does not take ${
|
|
1418
|
+
message: `This layout line does not take ${R}=, so it is ignored. ${Xs(R, b !== void 0)}`,
|
|
1393
1419
|
line: y
|
|
1394
|
-
}),
|
|
1420
|
+
}), p.delete(R));
|
|
1395
1421
|
}, X = [
|
|
1396
1422
|
"direction",
|
|
1397
1423
|
"min-width",
|
|
@@ -1401,14 +1427,14 @@ function Zs(e) {
|
|
|
1401
1427
|
let B;
|
|
1402
1428
|
if (b !== void 0)
|
|
1403
1429
|
f(1), i(
|
|
1404
|
-
|
|
1405
|
-
`Unknown layout engine ${b}; use ${
|
|
1406
|
-
),
|
|
1430
|
+
Ln.includes(b),
|
|
1431
|
+
`Unknown layout engine ${b}; use ${Ln.join(", ")}.`
|
|
1432
|
+
), F(["engine", ...X, ...Object.keys(Zt)]), B = { algorithm: b, params: A(Zt) };
|
|
1407
1433
|
else {
|
|
1408
1434
|
f(2);
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
|
|
1435
|
+
const P = l[1]?.value;
|
|
1436
|
+
F(
|
|
1437
|
+
P === "cells" ? ["columns", "unit", "unit-width", "ruler", ...X] : ["gap", ...P === "flow" ? ["fold"] : [], ...X]
|
|
1412
1438
|
);
|
|
1413
1439
|
}
|
|
1414
1440
|
const G = b ? "flow" : l[1]?.value;
|
|
@@ -1427,12 +1453,12 @@ function Zs(e) {
|
|
|
1427
1453
|
...B ? { engine: B } : {},
|
|
1428
1454
|
direction: _("direction", "auto", ["auto", "right", "down"]),
|
|
1429
1455
|
fold: b ? "auto" : _("fold", "auto", ["auto", "never"]),
|
|
1430
|
-
...
|
|
1431
|
-
...
|
|
1432
|
-
...
|
|
1456
|
+
...p.has("fit") ? { fit: _("fit", "slide", Object.keys(Ys)) } : {},
|
|
1457
|
+
...p.has("columns") ? { columns: S("columns", 1, 1, 512) } : {},
|
|
1458
|
+
...p.has("unit") ? {
|
|
1433
1459
|
unit: _("unit", "byte", ["bit", "byte"]),
|
|
1434
1460
|
ruler: _("ruler", "on", ["on", "off"]) === "on",
|
|
1435
|
-
...
|
|
1461
|
+
...p.has("unit-width") ? { unitWidth: S("unit-width", 24, 8, 200) } : {}
|
|
1436
1462
|
} : {},
|
|
1437
1463
|
gap: S("gap", 28, 8, 300),
|
|
1438
1464
|
minWidth: S("min-width", 0, 0, 1e4),
|
|
@@ -1446,8 +1472,8 @@ function Zs(e) {
|
|
|
1446
1472
|
const m = l[0].value;
|
|
1447
1473
|
i(ln.includes(m), `Unknown theme ${m}; use ${ln.join(", ")}.`), s.appearance.theme = m, s.themeLine = y;
|
|
1448
1474
|
const b = s.appearance.overrides;
|
|
1449
|
-
for (const [T,
|
|
1450
|
-
|
|
1475
|
+
for (const [T, F] of Object.entries(Tn))
|
|
1476
|
+
p.has(T) && (F === "paddingX" || F === "paddingY" || F === "radius" ? b[F] = S(T, 0, fn[F].min, fn[F].max) : F === "titleFont" || F === "annotationFont" ? b[F] = _(T, "sans", Io) : b[F] = x(T));
|
|
1451
1477
|
break;
|
|
1452
1478
|
}
|
|
1453
1479
|
case "theme-color": {
|
|
@@ -1457,11 +1483,11 @@ function Zs(e) {
|
|
|
1457
1483
|
!l[0].quoted && jt.test(m) && m !== "auto",
|
|
1458
1484
|
"Expected a color family name (letters, digits, _ or -)."
|
|
1459
1485
|
);
|
|
1460
|
-
const b =
|
|
1486
|
+
const b = p.has("shade") ? $(p.get("shade")) : 500;
|
|
1461
1487
|
E(`theme-color:${m}:${b}`);
|
|
1462
1488
|
const T = { family: m, shade: b };
|
|
1463
|
-
for (const
|
|
1464
|
-
|
|
1489
|
+
for (const F of ["fill", "stroke", "ink"])
|
|
1490
|
+
p.has(F) && (T[F] = x(F));
|
|
1465
1491
|
i(
|
|
1466
1492
|
Tt(m) || T.fill && T.stroke && T.ink,
|
|
1467
1493
|
`${m} is not a built-in color, so shade ${b} needs fill, stroke and ink.`
|
|
@@ -1483,8 +1509,8 @@ function Zs(e) {
|
|
|
1483
1509
|
i(
|
|
1484
1510
|
!l[0].quoted && jt.test(m) && m !== "auto",
|
|
1485
1511
|
`Expected legend family "meaning", with a built-in color (${Ht.join(", ")}) or a theme-color name.`
|
|
1486
|
-
), E(`legend:${m}:${
|
|
1487
|
-
const b =
|
|
1512
|
+
), E(`legend:${m}:${p.get("shade")?.value ?? ""}`);
|
|
1513
|
+
const b = p.has("shade") ? $(p.get("shade")) : void 0;
|
|
1488
1514
|
i(k(l[1]).trim(), "A legend entry needs its meaning in quotes."), (s.appearance.legend ??= []).push({
|
|
1489
1515
|
family: m,
|
|
1490
1516
|
label: k(l[1]),
|
|
@@ -1493,11 +1519,11 @@ function Zs(e) {
|
|
|
1493
1519
|
break;
|
|
1494
1520
|
}
|
|
1495
1521
|
case "note": {
|
|
1496
|
-
f(1), g(["near", "side", "width"]), i(l[0].quoted && l[0].value.trim(), "A note needs its text in quotes."), i(
|
|
1522
|
+
f(1), g(["near", "side", "width"]), i(l[0].quoted && l[0].value.trim(), "A note needs its text in quotes."), i(p.has("near") || !p.has("side"), "side= places a note beside near=<id>."), (s.appearance.notes ??= []).push({
|
|
1497
1523
|
text: l[0].value,
|
|
1498
|
-
...
|
|
1499
|
-
...
|
|
1500
|
-
...
|
|
1524
|
+
...p.has("near") ? { near: M(p.get("near")) } : {},
|
|
1525
|
+
...p.has("side") ? { side: _("side", "below", fs) } : {},
|
|
1526
|
+
...p.has("width") ? { width: S("width", ro, 80, 1200) } : {}
|
|
1501
1527
|
}), s.noteLines.push(y);
|
|
1502
1528
|
break;
|
|
1503
1529
|
}
|
|
@@ -1514,7 +1540,7 @@ function Zs(e) {
|
|
|
1514
1540
|
break;
|
|
1515
1541
|
}
|
|
1516
1542
|
case "routing":
|
|
1517
|
-
f(0), g(Object.keys(
|
|
1543
|
+
f(0), g(Object.keys(Rn)), E("routing"), s.routing = A(Rn);
|
|
1518
1544
|
break;
|
|
1519
1545
|
case "order":
|
|
1520
1546
|
f(2, 300), g([]), s.hints.push({ type: "order", scope: M(l[0]), ids: l.slice(1).map(M), line: y }), E("order:" + l[0].value);
|
|
@@ -1569,16 +1595,16 @@ function Zs(e) {
|
|
|
1569
1595
|
g(["x", "y"]), s.hints.push({ type: "pin", id: m, x: S("x", 0, 0), y: S("y", 0, 0), line: y });
|
|
1570
1596
|
else {
|
|
1571
1597
|
g(["width", "height", "min-height"]);
|
|
1572
|
-
const b =
|
|
1598
|
+
const b = p.get("height")?.value === "auto";
|
|
1573
1599
|
i(
|
|
1574
|
-
b || !
|
|
1600
|
+
b || !p.has("min-height"),
|
|
1575
1601
|
"min-height is a floor under height=auto. Write height=auto, or remove min-height."
|
|
1576
1602
|
), s.hints.push({
|
|
1577
1603
|
type: "size",
|
|
1578
1604
|
id: m,
|
|
1579
1605
|
width: S("width", 164, 40, 1200),
|
|
1580
1606
|
...b ? {} : { height: S("height", 56, 24, 1200) },
|
|
1581
|
-
...
|
|
1607
|
+
...p.has("min-height") ? { minHeight: S("min-height", 24, 24, 1200) } : {},
|
|
1582
1608
|
line: y
|
|
1583
1609
|
});
|
|
1584
1610
|
}
|
|
@@ -1593,8 +1619,8 @@ function Zs(e) {
|
|
|
1593
1619
|
a(`Unknown statement ${w}.`);
|
|
1594
1620
|
}
|
|
1595
1621
|
}
|
|
1596
|
-
if (s.objects.length > 500) throw new
|
|
1597
|
-
if (s.edges.length > 1200) throw new
|
|
1622
|
+
if (s.objects.length > 500) throw new Le("Limit: 500 nodes and groups.");
|
|
1623
|
+
if (s.edges.length > 1200) throw new Le("Limit: 1,200 edges.");
|
|
1598
1624
|
return Js(s), s;
|
|
1599
1625
|
}
|
|
1600
1626
|
function st(e, t) {
|
|
@@ -1608,7 +1634,7 @@ function Js(e) {
|
|
|
1608
1634
|
`${a} is a ${t.get(a)?.frame} group, so it has no ${g} of its own. Use frame=box, or ${g === "layout" ? "set the layout of the container around it" : "place its members"}.`,
|
|
1609
1635
|
i
|
|
1610
1636
|
), n = (a) => st(t, a), o = (a, i, g) => {
|
|
1611
|
-
if (!a) throw new
|
|
1637
|
+
if (!a) throw new Le(i, g);
|
|
1612
1638
|
}, r = (a, i) => o(t.has(a), `Unknown node/group ${a}.`, i), d = (a, i) => o(a === "root" || t.get(a)?.type === "group", `Unknown container ${a}.`, i), h = /* @__PURE__ */ new Map();
|
|
1613
1639
|
for (const a of e.appearance.colors)
|
|
1614
1640
|
h.has(a.family) || h.set(a.family, /* @__PURE__ */ new Set()), h.get(a.family).add(a.shade);
|
|
@@ -1623,7 +1649,7 @@ function Js(e) {
|
|
|
1623
1649
|
});
|
|
1624
1650
|
for (const a of e.objects) {
|
|
1625
1651
|
if (a.color !== "auto" && !Tt(a.color)) {
|
|
1626
|
-
const g = h.get(a.color), f = a.shade ?? (a.type === "group" ?
|
|
1652
|
+
const g = h.get(a.color), f = a.shade ?? (a.type === "group" ? Fo(e.appearance.theme) : Ve);
|
|
1627
1653
|
o(
|
|
1628
1654
|
g,
|
|
1629
1655
|
`Unknown color ${a.color}. Define it with theme-color ${a.color} shade=… fill= stroke= ink=.`,
|
|
@@ -1732,9 +1758,9 @@ function Js(e) {
|
|
|
1732
1758
|
g
|
|
1733
1759
|
);
|
|
1734
1760
|
}
|
|
1735
|
-
const
|
|
1761
|
+
const p = new Map(e.layouts.filter((a) => a.algorithm === "cells").map((a) => [a.scope, a]));
|
|
1736
1762
|
for (const a of e.objects) {
|
|
1737
|
-
const i =
|
|
1763
|
+
const i = p.get(a.parent);
|
|
1738
1764
|
i ? (o(
|
|
1739
1765
|
a.type === "node",
|
|
1740
1766
|
`Cells are nodes; ${a.id} is a group inside cells ${a.parent}.`,
|
|
@@ -1782,10 +1808,10 @@ function Js(e) {
|
|
|
1782
1808
|
a.line
|
|
1783
1809
|
);
|
|
1784
1810
|
}
|
|
1785
|
-
const $t = { width: 1100, height: 720 }, ft = 12, ei = 56, Dn = 24, Nn = 0, ti = 56,
|
|
1811
|
+
const $t = { width: 1100, height: 720 }, ft = 12, ei = 56, Dn = 24, Nn = 0, ti = 56, Fn = { w: 260, h: 110 }, Pn = (e, t) => Math.max(t.x - e.x - e.w, e.x - t.x - t.w, t.y - e.y - e.h, e.y - t.y - t.h), re = (e) => Math.round(e);
|
|
1786
1812
|
function ni(e) {
|
|
1787
1813
|
if (!e.appearance.compare || !e.edges.some((n) => n.was)) return e;
|
|
1788
|
-
const t =
|
|
1814
|
+
const t = pt(e.appearance), s = (n) => n ? Je(n, t).w : 0;
|
|
1789
1815
|
return {
|
|
1790
1816
|
...e,
|
|
1791
1817
|
edges: e.edges.map((n) => n.was && s(n.was) > s(n.label) ? { ...n, label: n.was } : n)
|
|
@@ -1828,7 +1854,7 @@ function mo(e) {
|
|
|
1828
1854
|
I,
|
|
1829
1855
|
n.filter((O) => O.parent === I).map((O) => O.id)
|
|
1830
1856
|
)
|
|
1831
|
-
).map((I) => e.byId.get(I)).map((I) => s.has(I.id) ? I : { ...I, w: di(I, t) }), y = new Map(c.map((I, O) => [I.id, O])), w = e.model.phases.length ? Math.max(...e.model.phases.map((I) => ye(I.label, t.annotation))) + 2 * $e : 0, l = o.length ? t.groupHeader : 0,
|
|
1857
|
+
).map((I) => e.byId.get(I)).map((I) => s.has(I.id) ? I : { ...I, w: di(I, t) }), y = new Map(c.map((I, O) => [I.id, O])), w = e.model.phases.length ? Math.max(...e.model.phases.map((I) => ye(I.label, t.annotation))) + 2 * $e : 0, l = o.length ? t.groupHeader : 0, p = (I) => c[I - 1].parent !== c[I].parent, a = !!e.model.appearance.compare, i = (I) => [I.label, a ? I.was : ""].filter((O) => !!O), g = (I) => {
|
|
1832
1858
|
const O = i(I).map((C) => Je(C, t, !0));
|
|
1833
1859
|
return { w: Math.max(0, ...O.map((C) => C.w)), h: Math.max(0, ...O.map((C) => C.h)) };
|
|
1834
1860
|
}, f = (I) => {
|
|
@@ -1849,13 +1875,13 @@ function mo(e) {
|
|
|
1849
1875
|
const { right: V } = f(I);
|
|
1850
1876
|
M.set(I.source, Math.max(M.get(I.source) ?? 0, V)), O + 1 < c.length && k[O + 1].push({
|
|
1851
1877
|
from: O,
|
|
1852
|
-
room: V + jn + (
|
|
1878
|
+
room: V + jn + (p(O + 1) ? 2 * $e + c[O + 1].w / 2 : 0)
|
|
1853
1879
|
});
|
|
1854
1880
|
}
|
|
1855
1881
|
const S = [];
|
|
1856
1882
|
c.forEach((I, O) => {
|
|
1857
1883
|
if (!O) return void S.push(w + $e + I.w / 2);
|
|
1858
|
-
const C = c[O - 1].w / 2 + ri + (
|
|
1884
|
+
const C = c[O - 1].w / 2 + ri + (p(O) ? 2 * $e : 0) + I.w / 2;
|
|
1859
1885
|
S.push(Math.max(S[O - 1] + C, ...k[O].map((V) => S[V.from] + V.room)));
|
|
1860
1886
|
});
|
|
1861
1887
|
let D = l + Math.max(0, ...c.map((I) => I.h)) - ai, _ = 0;
|
|
@@ -1871,12 +1897,11 @@ function mo(e) {
|
|
|
1871
1897
|
const O = re(S[y.get(I.id)] - I.w / 2);
|
|
1872
1898
|
return [I.id, { x: O, w: I.w }];
|
|
1873
1899
|
})
|
|
1874
|
-
),
|
|
1900
|
+
), u = (I) => Math.max(v.get(I.id).x + I.w, S[y.get(I.id)] + (M.get(I.id) ?? 0)), A = e.objects.map((I) => {
|
|
1875
1901
|
if (I.type === "group") {
|
|
1876
|
-
const V = c.filter((le) => le.parent === I.id), oe = re(Math.min(...V.map((le) => v.get(le.id).x)) - $e), ae = re(Math.max(...V.map((le) =>
|
|
1902
|
+
const V = c.filter((le) => le.parent === I.id), oe = re(Math.min(...V.map((le) => v.get(le.id).x)) - $e), ae = re(Math.max(...V.map((le) => u(le))) + $e - oe);
|
|
1877
1903
|
return {
|
|
1878
1904
|
...I,
|
|
1879
|
-
shade: I.shade ?? 50,
|
|
1880
1905
|
x: oe,
|
|
1881
1906
|
y: 0,
|
|
1882
1907
|
w: ae,
|
|
@@ -1907,11 +1932,11 @@ function mo(e) {
|
|
|
1907
1932
|
y: -tt,
|
|
1908
1933
|
w: b - m + 2 * tt,
|
|
1909
1934
|
h: E + $e + 2 * tt
|
|
1910
|
-
},
|
|
1935
|
+
}, F = e.model.appearance.notes ?? [], X = new Map([...$].filter(([I]) => !e.byId.has(I))), B = gs(t, F, X, {
|
|
1911
1936
|
left: m - (w ? tt : Bn),
|
|
1912
1937
|
right: b + Bn,
|
|
1913
1938
|
top: 0
|
|
1914
|
-
}), G = B.filter((I) => I !== null),
|
|
1939
|
+
}), G = B.filter((I) => I !== null), P = G.length ? wn([T, wn(G, tt)]) : T, R = P.x < T.x ? T.x : void 0, N = e.model.phases.map((I) => {
|
|
1915
1940
|
const O = I.ids.map((C) => x.get(C));
|
|
1916
1941
|
return {
|
|
1917
1942
|
id: I.id,
|
|
@@ -1919,7 +1944,7 @@ function mo(e) {
|
|
|
1919
1944
|
from: re(Math.min(...O.map((C) => C.from))),
|
|
1920
1945
|
to: re(Math.max(...O.map((C) => C.to)))
|
|
1921
1946
|
};
|
|
1922
|
-
}).sort((I, O) => I.from - O.from),
|
|
1947
|
+
}).sort((I, O) => I.from - O.from), U = N.map(({ id: I, label: O, from: C, to: V }, oe) => ({
|
|
1923
1948
|
id: I,
|
|
1924
1949
|
label: O,
|
|
1925
1950
|
y: C,
|
|
@@ -1931,9 +1956,9 @@ function mo(e) {
|
|
|
1931
1956
|
byId: new Map(A.map((I) => [I.id, I])),
|
|
1932
1957
|
edges: e.edges.map((I) => ({ ...I, lane: void 0, row: $.get(I.id) })),
|
|
1933
1958
|
sequence: {
|
|
1934
|
-
panel:
|
|
1935
|
-
phases:
|
|
1936
|
-
...
|
|
1959
|
+
panel: P,
|
|
1960
|
+
phases: U,
|
|
1961
|
+
...R !== void 0 ? { phaseX: R } : {},
|
|
1937
1962
|
...G.length ? { notes: B, inner: T } : {}
|
|
1938
1963
|
}
|
|
1939
1964
|
};
|
|
@@ -1978,10 +2003,10 @@ function an(e, t, s = 0) {
|
|
|
1978
2003
|
h.at += r, h.ids.push(o), n.set(d, h);
|
|
1979
2004
|
}), [...n].sort(([, o], [, r]) => o.at / o.ids.length - r.at / r.ids.length).flatMap(([o, r]) => o.startsWith("\0") ? r.ids : an(r.ids, t, s + 1));
|
|
1980
2005
|
}
|
|
1981
|
-
const
|
|
2006
|
+
const pi = 8;
|
|
1982
2007
|
function Dt(e = [], t = [], s) {
|
|
1983
2008
|
const n = e.filter((r) => !t.includes(r)).length, o = t.filter((r) => !e.includes(r)).length;
|
|
1984
|
-
return !n && !o ? 0 : (n + o) * dt + (s && o ?
|
|
2009
|
+
return !n && !o ? 0 : (n + o) * dt + (s && o ? Rt : 0) + pi;
|
|
1985
2010
|
}
|
|
1986
2011
|
function wo(e, t, s, n) {
|
|
1987
2012
|
const o = new Set(e.flatMap((c) => s(c) ?? [])), r = (c, y) => (s(c) ?? []).filter((w) => !y.has(w)), d = new Set(t.flatMap((c) => s(c) ?? []));
|
|
@@ -1990,7 +2015,7 @@ function wo(e, t, s, n) {
|
|
|
1990
2015
|
for (const y of t) h = Math.max(h, Dt(r(c, d), r(y, o), n));
|
|
1991
2016
|
return h;
|
|
1992
2017
|
}
|
|
1993
|
-
const kt = (e, t) => e.x < t.x + t.w && e.x + e.w > t.x && e.y < t.y + t.h && e.y + e.h > t.y,
|
|
2018
|
+
const kt = (e, t) => e.x < t.x + t.w && e.x + e.w > t.x && e.y < t.y + t.h && e.y + e.h > t.y, ui = (e, t) => ({
|
|
1994
2019
|
x: e.x - t,
|
|
1995
2020
|
y: e.y - t,
|
|
1996
2021
|
w: e.w + 2 * t,
|
|
@@ -2014,42 +2039,42 @@ function mi(e, t) {
|
|
|
2014
2039
|
if (!s.length) return e;
|
|
2015
2040
|
const n = new Map(t.objects.map((l) => [l.id, l])), o = new Map(
|
|
2016
2041
|
e.objects.map((l) => [l.id, { ...l, parent: n.get(l.id).parent, soft: void 0 }])
|
|
2017
|
-
), r = [...e.diagnostics], d = (l,
|
|
2042
|
+
), r = [...e.diagnostics], d = (l, p) => {
|
|
2018
2043
|
for (let a = n.get(l)?.parent; a && a !== "root"; a = n.get(a)?.parent)
|
|
2019
|
-
if (a ===
|
|
2044
|
+
if (a === p) return !0;
|
|
2020
2045
|
return !1;
|
|
2021
2046
|
}, h = (l) => {
|
|
2022
|
-
let
|
|
2023
|
-
for (let a = n.get(l).parent; a !== "root"; a = n.get(a).parent)
|
|
2024
|
-
return
|
|
2025
|
-
}, c = (l) => l.frame === "soft" ? (l.hull ?? []).map((
|
|
2026
|
-
for (const l of [...s].sort((
|
|
2027
|
-
const
|
|
2047
|
+
let p = 0;
|
|
2048
|
+
for (let a = n.get(l).parent; a !== "root"; a = n.get(a).parent) p++;
|
|
2049
|
+
return p;
|
|
2050
|
+
}, c = (l) => l.frame === "soft" ? (l.hull ?? []).map((p) => ({ ...p, x: p.x + l.x, y: p.y + l.y })) : l.frame ? [] : [l];
|
|
2051
|
+
for (const l of [...s].sort((p, a) => h(a.id) - h(p.id))) {
|
|
2052
|
+
const p = [...o.values()].filter((v) => d(v.id, l.id)), a = o.get(st(n, l.id)), i = a ? so(a, _t(e.look, a.titleLines)) : { x: 0, y: 0 }, g = [...o.values()].filter(
|
|
2028
2053
|
(v) => !v.frame && !d(v.id, l.id) && !d(l.id, v.id)
|
|
2029
|
-
), f =
|
|
2054
|
+
), f = p.flatMap((v) => c(v).map((u) => ui(u, dt)));
|
|
2030
2055
|
let M = [], k = 0;
|
|
2031
2056
|
if (f.length) {
|
|
2032
2057
|
const v = f.reduce((B, G) => G.y < B.y || G.y === B.y && G.x < B.x ? G : B);
|
|
2033
|
-
v.y -=
|
|
2034
|
-
const
|
|
2035
|
-
x:
|
|
2058
|
+
v.y -= Rt, v.h += Rt, M = [v, ...f.filter((B) => B !== v)];
|
|
2059
|
+
const u = Math.min(...M.map((B) => B.x)), A = Math.min(...M.map((B) => B.y)), m = {
|
|
2060
|
+
x: u,
|
|
2036
2061
|
y: A,
|
|
2037
|
-
w: Math.max(...M.map((B) => B.x + B.w)) -
|
|
2062
|
+
w: Math.max(...M.map((B) => B.x + B.w)) - u,
|
|
2038
2063
|
h: Math.max(...M.map((B) => B.y + B.h)) - A
|
|
2039
2064
|
};
|
|
2040
2065
|
g.some((B) => kt(B, m)) || (M = [m]);
|
|
2041
|
-
const b = (B, G) => Math.max(G.x - (B.x + B.w), B.x - (G.x + G.w), G.y - (B.y + B.h), B.y - (G.y + G.h), 0), T = [M[0]],
|
|
2042
|
-
for (;
|
|
2066
|
+
const b = (B, G) => Math.max(G.x - (B.x + B.w), B.x - (G.x + G.w), G.y - (B.y + B.h), B.y - (G.y + G.h), 0), T = [M[0]], F = M.slice(1), X = [];
|
|
2067
|
+
for (; F.length; ) {
|
|
2043
2068
|
let B = { gap: 1 / 0, a: M[0], i: 0 };
|
|
2044
|
-
for (const
|
|
2045
|
-
|
|
2046
|
-
const I = b(
|
|
2047
|
-
I < B.gap && (B = { gap: I, a:
|
|
2069
|
+
for (const R of T)
|
|
2070
|
+
F.forEach((N, U) => {
|
|
2071
|
+
const I = b(R, N);
|
|
2072
|
+
I < B.gap && (B = { gap: I, a: R, i: U });
|
|
2048
2073
|
});
|
|
2049
|
-
const [G] =
|
|
2074
|
+
const [G] = F.splice(B.i, 1);
|
|
2050
2075
|
if (T.push(G), kt(B.a, G)) continue;
|
|
2051
|
-
const
|
|
2052
|
-
g.some((
|
|
2076
|
+
const P = gi(B.a, G);
|
|
2077
|
+
g.some((R) => kt(R, P)) ? k++ : X.push(P);
|
|
2053
2078
|
}
|
|
2054
2079
|
M.push(...X);
|
|
2055
2080
|
}
|
|
@@ -2067,7 +2092,7 @@ function mi(e, t) {
|
|
|
2067
2092
|
depth: h(l.id),
|
|
2068
2093
|
hull: M.map((v) => ({ x: v.x - S, y: v.y - D, w: v.w, h: v.h }))
|
|
2069
2094
|
}), l.frame !== "soft") continue;
|
|
2070
|
-
const E = g.filter((v) => M.some((
|
|
2095
|
+
const E = g.filter((v) => M.some((u) => kt(v, u)));
|
|
2071
2096
|
E.length && r.push({
|
|
2072
2097
|
level: "warning",
|
|
2073
2098
|
code: "soft-overlap",
|
|
@@ -2082,17 +2107,17 @@ function mi(e, t) {
|
|
|
2082
2107
|
ids: [l.id]
|
|
2083
2108
|
});
|
|
2084
2109
|
}
|
|
2085
|
-
const y = new Map(t.objects.map((l,
|
|
2110
|
+
const y = new Map(t.objects.map((l, p) => [l.id, p])), w = [...o.values()].sort((l, p) => y.get(l.id) - y.get(p.id));
|
|
2086
2111
|
return { ...e, model: t, objects: w, byId: new Map(w.map((l) => [l.id, l])), diagnostics: r };
|
|
2087
2112
|
}
|
|
2088
|
-
const
|
|
2113
|
+
const zn = 4, wi = /* @__PURE__ */ new Set(["slate", "stone"]);
|
|
2089
2114
|
function yi(e) {
|
|
2090
2115
|
const t = [], s = e.objects.filter((d) => d.color !== "auto"), n = [...new Set(s.map((d) => d.color))].filter((d) => !wi.has(d));
|
|
2091
|
-
n.length >
|
|
2116
|
+
n.length > zn && t.push({
|
|
2092
2117
|
level: "info",
|
|
2093
2118
|
code: "many-colors",
|
|
2094
2119
|
message: `${n.length} accent colors (${n.join(", ")}). Use two to four, each for one role, with slate or stone for the rest, and say what each one means with legend lines.`,
|
|
2095
|
-
line: s.find((d) => d.color === n[
|
|
2120
|
+
line: s.find((d) => d.color === n[zn])?.line,
|
|
2096
2121
|
ids: s.filter((d) => n.includes(d.color)).map((d) => d.id)
|
|
2097
2122
|
});
|
|
2098
2123
|
const o = new Map(e.objects.map((d) => [d.id, d])), r = s.filter((d) => o.get(d.parent)?.color === d.color);
|
|
@@ -2123,10 +2148,10 @@ function vi(e, t, s) {
|
|
|
2123
2148
|
for (; r() > yn && o < n; ) o += 8;
|
|
2124
2149
|
return { w: Math.min(o, n), lines: Math.min(r(), yn) };
|
|
2125
2150
|
}
|
|
2126
|
-
const
|
|
2151
|
+
const Un = 16, ki = 1.5, Fe = 14;
|
|
2127
2152
|
function Bt(e, t, s, n) {
|
|
2128
2153
|
const o = Je(s, n);
|
|
2129
|
-
return { a: e, b: t, w: o.w + 2 *
|
|
2154
|
+
return { a: e, b: t, w: o.w + 2 * Fe, h: o.h + 2 * Fe };
|
|
2130
2155
|
}
|
|
2131
2156
|
function Jt(e, t, s, n, o) {
|
|
2132
2157
|
let r = n;
|
|
@@ -2134,7 +2159,7 @@ function Jt(e, t, s, n, o) {
|
|
|
2134
2159
|
(d.a === t && d.b === s || d.a === s && d.b === t) && (r = Math.max(r, o ? d.w : d.h));
|
|
2135
2160
|
return r;
|
|
2136
2161
|
}
|
|
2137
|
-
function
|
|
2162
|
+
function zt(e, t) {
|
|
2138
2163
|
return e.layouts.find((s) => s.scope === t) ?? {
|
|
2139
2164
|
scope: t,
|
|
2140
2165
|
algorithm: t === "root" ? "flow" : "column",
|
|
@@ -2163,7 +2188,7 @@ function Ei(e, t, s) {
|
|
|
2163
2188
|
function Et(e, t, s) {
|
|
2164
2189
|
const n = io(e.shape);
|
|
2165
2190
|
if (e.shape === "diamond") return Ai(e, t, n, s);
|
|
2166
|
-
const o = t?.width ?? Ei(e, n, s), r = Ot(e.shape, o, t?.height ?? n.h, s), d = gt(
|
|
2191
|
+
const o = t?.width ?? Ei(e, n, s), r = Ot(e.shape, o, t?.height ?? n.h, s), d = gt(ut(e.label, r.width, s), s);
|
|
2167
2192
|
return t?.height !== void 0 ? { w: o, h: t.height, overflow: d > r.maxHeight + 0.5 } : {
|
|
2168
2193
|
w: o,
|
|
2169
2194
|
h: Math.max(
|
|
@@ -2185,30 +2210,30 @@ function Ai(e, t, s, n) {
|
|
|
2185
2210
|
}
|
|
2186
2211
|
const Si = 1.4;
|
|
2187
2212
|
function ht(e, t) {
|
|
2188
|
-
const s = new Map(e.map((
|
|
2189
|
-
for (const [
|
|
2190
|
-
|
|
2191
|
-
const n = new Set([...s.values()].flat()), o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), d = (
|
|
2192
|
-
o.set(
|
|
2193
|
-
for (const a of s.get(
|
|
2194
|
-
o.get(a) === "open" ? r.add(
|
|
2195
|
-
o.set(
|
|
2213
|
+
const s = new Map(e.map((p) => [p, []]));
|
|
2214
|
+
for (const [p, a] of t)
|
|
2215
|
+
p !== a && s.has(p) && s.has(a) && !s.get(p).includes(a) && s.get(p).push(a);
|
|
2216
|
+
const n = new Set([...s.values()].flat()), o = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(), d = (p) => {
|
|
2217
|
+
o.set(p, "open");
|
|
2218
|
+
for (const a of s.get(p))
|
|
2219
|
+
o.get(a) === "open" ? r.add(p + "\0" + a) : o.has(a) || d(a);
|
|
2220
|
+
o.set(p, "done");
|
|
2196
2221
|
};
|
|
2197
|
-
for (const
|
|
2198
|
-
const h = new Map(e.map((
|
|
2199
|
-
for (const
|
|
2200
|
-
const w = e.filter((
|
|
2222
|
+
for (const p of [...e.filter((a) => !n.has(a)), ...e]) o.has(p) || d(p);
|
|
2223
|
+
const h = new Map(e.map((p) => [p, 0])), c = new Map(e.map((p) => [p, 0])), y = (p) => s.get(p).filter((a) => !r.has(p + "\0" + a));
|
|
2224
|
+
for (const p of e) for (const a of y(p)) h.set(a, h.get(a) + 1);
|
|
2225
|
+
const w = e.filter((p) => !h.get(p));
|
|
2201
2226
|
for (; w.length; ) {
|
|
2202
|
-
const
|
|
2203
|
-
for (const a of y(
|
|
2204
|
-
c.set(a, Math.max(c.get(a), c.get(
|
|
2227
|
+
const p = w.shift();
|
|
2228
|
+
for (const a of y(p))
|
|
2229
|
+
c.set(a, Math.max(c.get(a), c.get(p) + 1)), h.set(a, h.get(a) - 1), h.get(a) || w.push(a);
|
|
2205
2230
|
}
|
|
2206
2231
|
const l = [];
|
|
2207
|
-
for (const
|
|
2232
|
+
for (const p of e) (l[c.get(p)] ||= []).push(p);
|
|
2208
2233
|
return l.filter(Boolean);
|
|
2209
2234
|
}
|
|
2210
2235
|
const yo = 3, Gn = 5, Hn = 1.25, Qe = 20, _i = 3, Ii = 2, Ti = 1;
|
|
2211
|
-
function
|
|
2236
|
+
function Li(e, t) {
|
|
2212
2237
|
const s = new Map(e.map((h) => [h, []]));
|
|
2213
2238
|
for (const [h, c] of t) s.get(h)?.push(c);
|
|
2214
2239
|
const n = (h) => {
|
|
@@ -2225,89 +2250,89 @@ function Ri(e, t) {
|
|
|
2225
2250
|
}
|
|
2226
2251
|
return r;
|
|
2227
2252
|
}
|
|
2228
|
-
function
|
|
2253
|
+
function Ut(e, t, s, n, o, r = [], d = /* @__PURE__ */ new Set(), h = t, {
|
|
2229
2254
|
aspect: c = yo,
|
|
2230
2255
|
fewest: y = 4,
|
|
2231
2256
|
room: w = s === "right" ? $t.width : $t.height
|
|
2232
2257
|
} = {}) {
|
|
2233
|
-
const l = new Map(e.map((
|
|
2234
|
-
const
|
|
2235
|
-
for (const
|
|
2236
|
-
const I =
|
|
2237
|
-
C && I < C.end ? (C.end = Math.max(C.end, O), C.ids.push(
|
|
2258
|
+
const l = new Map(e.map((P) => [P.id, P])), p = s === "right" ? "x" : "y", a = s === "right" ? "y" : "x", i = (P, R) => R === "x" ? P.w : P.h, g = (P) => {
|
|
2259
|
+
const R = [...e].sort((U, I) => P.get(U.id)[p] - P.get(I.id)[p]), N = [];
|
|
2260
|
+
for (const U of R) {
|
|
2261
|
+
const I = P.get(U.id)[p], O = I + i(U, p), C = N[N.length - 1];
|
|
2262
|
+
C && I < C.end ? (C.end = Math.max(C.end, O), C.ids.push(U.id)) : N.push({ start: I, end: O, ids: [U.id] });
|
|
2238
2263
|
}
|
|
2239
2264
|
return N;
|
|
2240
2265
|
}, f = g(t);
|
|
2241
2266
|
let M = g(h);
|
|
2242
|
-
const k = (
|
|
2267
|
+
const k = (P) => P.map((R) => [...R.ids].sort().join(",")).join("|");
|
|
2243
2268
|
k(M) !== k(f) && (h = t, M = f);
|
|
2244
|
-
const S = (
|
|
2245
|
-
const N = Math.min(...e.map((I) =>
|
|
2246
|
-
return Math.max(...e.map((I) =>
|
|
2247
|
-
}, D = (
|
|
2269
|
+
const S = (P, R) => {
|
|
2270
|
+
const N = Math.min(...e.map((I) => P.get(I.id)[R]));
|
|
2271
|
+
return Math.max(...e.map((I) => P.get(I.id)[R] + i(I, R))) - N;
|
|
2272
|
+
}, D = (P, R, N = 1) => P <= w * N || P <= c * R * N, _ = (P) => D(S(P, p), S(P, a)), $ = (P) => _(P) || S(P, p) <= w * Hn;
|
|
2248
2273
|
if (e.length < y || _(h) && $(t)) return { positions: t };
|
|
2249
|
-
const x = new Map(f.flatMap((
|
|
2250
|
-
const [
|
|
2251
|
-
return
|
|
2252
|
-
}, v = (
|
|
2253
|
-
e.map((
|
|
2274
|
+
const x = new Map(f.flatMap((P, R) => P.ids.map((N) => [N, R]))), E = (P, R, N) => {
|
|
2275
|
+
const [U, I] = [x.get(R), x.get(N)];
|
|
2276
|
+
return U !== void 0 && I !== void 0 && Math.min(U, I) < P && Math.max(U, I) >= P;
|
|
2277
|
+
}, v = (P) => o.filter(([R, N]) => E(P, R, N)).length, u = Li(
|
|
2278
|
+
e.map((P) => P.id),
|
|
2254
2279
|
o
|
|
2255
|
-
), A = (
|
|
2256
|
-
const N = (
|
|
2280
|
+
), A = (P) => _i * [...d].filter((R) => o.some((N) => N[0] === R && E(P, ...N))).length + Ii * u.filter((R) => R.some((N) => E(P, R[0], N))).length, m = (P, R) => {
|
|
2281
|
+
const N = (R ? r : []).filter((U) => E(P, U.a, U.b)).map((U) => (s === "right" ? U.h : U.w) - 2 * Fe);
|
|
2257
2282
|
return Math.max(
|
|
2258
2283
|
n + 40,
|
|
2259
2284
|
84,
|
|
2260
|
-
N.length ? Math.max(...N) + 2 *
|
|
2261
|
-
(v(
|
|
2285
|
+
N.length ? Math.max(...N) + 2 * Fe : 0,
|
|
2286
|
+
(v(P) + 1) * Qe + N.reduce((U, I) => U + I, 0)
|
|
2262
2287
|
);
|
|
2263
|
-
}, b = (
|
|
2264
|
-
const N =
|
|
2265
|
-
for (let O = 1; O <
|
|
2266
|
-
const C = (te) => o.filter((Me) => E(te, ...Me)).reduce((Me, [
|
|
2267
|
-
const [q, W] = x.get(
|
|
2268
|
-
return Me + Math.abs(I.get(q) - ae - (I.get(W) -
|
|
2269
|
-
}, 0) / (N /
|
|
2288
|
+
}, b = (P, R) => {
|
|
2289
|
+
const N = R[R.length - 1].end - R[0].start, U = [], I = new Map(R.flatMap((O) => O.ids.map((C) => [C, O.start])));
|
|
2290
|
+
for (let O = 1; O < P; O++) {
|
|
2291
|
+
const C = (te) => o.filter((Me) => E(te, ...Me)).reduce((Me, [L, j]) => {
|
|
2292
|
+
const [q, W] = x.get(L) < x.get(j) ? [L, j] : [j, L];
|
|
2293
|
+
return Me + Math.abs(I.get(q) - ae - (I.get(W) - R[te].start));
|
|
2294
|
+
}, 0) / (N / P), V = R[0].start + N * O / P, oe = (te) => v(te) + A(te) + C(te) * Ti + Math.abs(R[te].start - V) / (N / P) * 2, ae = R[U.at(-1) ?? 0].start, le = N / P, he = (te, Me, L) => R[te - 1].end - ae >= le * L && R[te - 1].end - ae <= le * (1 + Me) && R[R.length - 1].end - R[te].start <= le * (P - O) * (1 + Me), we = (te) => !A(te) && he(te, 0.25, 0.5) ? 0 : !A(te) && he(te, 0.5, 0) ? 1 : he(te, 0.25, 0.5) ? 2 : 3;
|
|
2270
2295
|
let fe = 0;
|
|
2271
|
-
for (let te = (
|
|
2296
|
+
for (let te = (U.at(-1) ?? 0) + 1; te < R.length; te++)
|
|
2272
2297
|
(!fe || we(te) < we(fe) || we(te) === we(fe) && oe(te) < oe(fe)) && (fe = te);
|
|
2273
|
-
fe &&
|
|
2298
|
+
fe && U.push(fe);
|
|
2274
2299
|
}
|
|
2275
|
-
return
|
|
2300
|
+
return U;
|
|
2276
2301
|
}, T = new Set(
|
|
2277
2302
|
f.flatMap(
|
|
2278
|
-
(
|
|
2303
|
+
(P) => P.ids.length > 1 ? P.ids.filter((R) => !o.some(([N, U]) => N === R && U !== R)) : []
|
|
2279
2304
|
)
|
|
2280
|
-
),
|
|
2305
|
+
), F = (P, R) => {
|
|
2281
2306
|
const N = [];
|
|
2282
|
-
return
|
|
2283
|
-
}, X = (
|
|
2284
|
-
const N = P
|
|
2307
|
+
return R.forEach((U, I) => I === 0 || P.includes(I) ? N.push([U]) : N.at(-1).push(U)), N;
|
|
2308
|
+
}, X = (P, R) => {
|
|
2309
|
+
const N = F(P, R), U = new Map(N.flatMap((C, V) => C.flatMap((oe) => oe.ids.map((ae) => [ae, V])))), I = new Map(R.flatMap((C) => C.ids.map((V) => [V, C.start]))), O = /* @__PURE__ */ new Map();
|
|
2285
2310
|
for (const [C, V] of N.entries()) {
|
|
2286
2311
|
if (!C) continue;
|
|
2287
2312
|
const oe = [];
|
|
2288
2313
|
for (const ae of V[0].ids) {
|
|
2289
2314
|
if (d.has(ae)) continue;
|
|
2290
|
-
const le = o.filter(([
|
|
2291
|
-
if (!le.length || le.some((
|
|
2292
|
-
const we = (
|
|
2315
|
+
const le = o.filter(([L, j]) => j === ae && L !== ae).map(([L]) => L), he = o.filter(([L, j]) => L === ae && j !== ae).map(([, L]) => L);
|
|
2316
|
+
if (!le.length || le.some((L) => U.get(L) !== C - 1)) continue;
|
|
2317
|
+
const we = (L, j) => I.get(L) - N[j][0].start, fe = (L) => le.reduce((j, q) => j + Math.abs(we(q, C - 1) - we(ae, L)), 0) + he.reduce((j, q) => j + Math.abs(we(ae, L) - we(q, U.get(q))), 0), te = (L) => (L === C - 1 ? 0 : le.length) + he.filter((j) => U.get(j) !== L).length;
|
|
2293
2318
|
if (te(C - 1) > te(C) || fe(C - 1) >= fe(C)) continue;
|
|
2294
|
-
const Me = le.reduce((
|
|
2319
|
+
const Me = le.reduce((L, j) => I.get(j) > I.get(L) ? j : L);
|
|
2295
2320
|
oe.push({ id: ae, source: Me, saves: fe(C) - fe(C - 1) });
|
|
2296
2321
|
}
|
|
2297
2322
|
oe.sort((ae, le) => le.saves - ae.saves);
|
|
2298
2323
|
for (const ae of oe.slice(0, V[0].ids.length - 1)) O.set(ae.id, ae.source);
|
|
2299
2324
|
}
|
|
2300
2325
|
return O;
|
|
2301
|
-
}, B = (
|
|
2302
|
-
const O = P
|
|
2326
|
+
}, B = (P, R, N, U, I = /* @__PURE__ */ new Map()) => {
|
|
2327
|
+
const O = F(P, R);
|
|
2303
2328
|
if (I.size) {
|
|
2304
2329
|
N = new Map(N);
|
|
2305
2330
|
const he = [];
|
|
2306
2331
|
for (const [we, fe] of I) {
|
|
2307
2332
|
const te = l.get(we);
|
|
2308
|
-
let
|
|
2309
|
-
for (const j of he)
|
|
2310
|
-
he.push({ lo:
|
|
2333
|
+
let L = N.get(fe)[a] + (i(l.get(fe), a) - i(te, a)) / 2;
|
|
2334
|
+
for (const j of he) L < j.hi + n && L + i(te, a) > j.lo && (L = j.hi + n);
|
|
2335
|
+
he.push({ lo: L, hi: L + i(te, a) }), N.set(we, { ...N.get(we), [a]: L });
|
|
2311
2336
|
}
|
|
2312
2337
|
}
|
|
2313
2338
|
const C = /* @__PURE__ */ new Map(), V = [];
|
|
@@ -2316,15 +2341,15 @@ function zt(e, t, s, n, o, r = [], d = /* @__PURE__ */ new Set(), h = t, {
|
|
|
2316
2341
|
const fe = O[he + 1]?.[0].ids ?? [], te = [
|
|
2317
2342
|
...we.flatMap((Y) => Y.ids).filter((Y) => !I.has(Y)),
|
|
2318
2343
|
...fe.filter((Y) => I.has(Y))
|
|
2319
|
-
], Me = Math.min(...te.map((Y) => N.get(Y)[
|
|
2344
|
+
], Me = Math.min(...te.map((Y) => N.get(Y)[p])), L = Math.min(...te.map((Y) => N.get(Y)[a])), j = Math.max(...te.map((Y) => N.get(Y)[a] + i(l.get(Y), a)));
|
|
2320
2345
|
for (const Y of te) {
|
|
2321
|
-
const H = N.get(Y), J = H[
|
|
2346
|
+
const H = N.get(Y), J = H[p] - Me, se = H[a] - L + oe;
|
|
2322
2347
|
C.set(Y, s === "right" ? { x: J, y: se } : { x: se, y: J });
|
|
2323
2348
|
}
|
|
2324
|
-
const q = he <
|
|
2325
|
-
oe += j -
|
|
2349
|
+
const q = he < P.length ? m(P[he], U) : 0, W = te.filter((Y) => !T.has(Y)), ee = W.length ? W : te;
|
|
2350
|
+
oe += j - L + q, le += Math.max(...ee.map((Y) => N.get(Y)[a] + i(l.get(Y), a))) - Math.min(...ee.map((Y) => N.get(Y)[a])) + q, ae = Math.max(
|
|
2326
2351
|
ae,
|
|
2327
|
-
Math.max(...te.map((Y) => N.get(Y)[
|
|
2352
|
+
Math.max(...te.map((Y) => N.get(Y)[p] + i(l.get(Y), p))) - Me
|
|
2328
2353
|
), V.push(te);
|
|
2329
2354
|
}
|
|
2330
2355
|
return {
|
|
@@ -2338,73 +2363,73 @@ function zt(e, t, s, n, o, r = [], d = /* @__PURE__ */ new Set(), h = t, {
|
|
|
2338
2363
|
};
|
|
2339
2364
|
let G = 0;
|
|
2340
2365
|
if (!_(h))
|
|
2341
|
-
for (let
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2366
|
+
for (let P = 2; P <= f.length && !G; P++) {
|
|
2367
|
+
const R = B(b(P, M), M, h, !1);
|
|
2368
|
+
R.count === P && D(R.length, R.depth) && (G = P);
|
|
2344
2369
|
}
|
|
2345
|
-
for (let
|
|
2346
|
-
const
|
|
2347
|
-
if (N.count !==
|
|
2348
|
-
const I = X(
|
|
2370
|
+
for (let P = Math.max(2, G); P <= f.length; P++) {
|
|
2371
|
+
const R = b(P, M), N = B(R, f, t, !0), U = P === G ? Hn : 1;
|
|
2372
|
+
if (N.count !== P || !D(N.length, N.depth, U)) continue;
|
|
2373
|
+
const I = X(R, M), O = I.size ? B(R, f, t, !0, I) : void 0, C = O && D(O.length, O.depth, U) ? O : N;
|
|
2349
2374
|
return { positions: C.out, fold: { bands: C.bands, axis: s } };
|
|
2350
2375
|
}
|
|
2351
2376
|
return { positions: t };
|
|
2352
2377
|
}
|
|
2353
|
-
function
|
|
2378
|
+
function Ri(e, t, s, n, o) {
|
|
2354
2379
|
const r = /* @__PURE__ */ new Map();
|
|
2355
2380
|
for (const { scope: d, fold: h } of e) {
|
|
2356
|
-
const c = h.axis === "right", y = (S) => c ? S.y : S.x, w = (S) => c ? S.y + S.h : S.x + S.w, l = (S) => c ? S.x : S.y,
|
|
2381
|
+
const c = h.axis === "right", y = (S) => c ? S.y : S.x, w = (S) => c ? S.y + S.h : S.x + S.w, l = (S) => c ? S.x : S.y, p = (S) => c ? S.x + S.w : S.y + S.h, a = (S) => (l(S) + p(S)) / 2, i = (S) => (y(S) + w(S)) / 2, g = (S, D) => l(S) < p(D) && p(S) > l(D), f = new Map(h.bands.flatMap((S, D) => S.map((_) => [_, D]))), M = (S) => f.get(n(S.id, d) ?? ""), k = (S) => [...s.values()].filter((D) => D.type !== "group" && M(D) === S);
|
|
2357
2382
|
for (let S = 0; S + 1 < h.bands.length; S++) {
|
|
2358
|
-
const D = h.bands[S].map((G) => s.get(G)), _ = h.bands[S + 1].map((G) => s.get(G)), $ = Math.max(...D.map(w)), x = Math.min(..._.map(y)), E = Math.max(...D.map(
|
|
2359
|
-
const
|
|
2360
|
-
if (M(
|
|
2383
|
+
const D = h.bands[S].map((G) => s.get(G)), _ = h.bands[S + 1].map((G) => s.get(G)), $ = Math.max(...D.map(w)), x = Math.min(..._.map(y)), E = Math.max(...D.map(p)) + Qe, v = Math.min(..._.map(l)) - Qe, [u, A] = [k(S), k(S + 1)], m = t.flatMap((G) => {
|
|
2384
|
+
const P = s.get(G.source), R = s.get(G.target);
|
|
2385
|
+
if (M(P) !== S || M(R) !== S + 1) return [];
|
|
2361
2386
|
if (G.from !== "auto" || G.to !== "auto") return [];
|
|
2362
|
-
const N =
|
|
2363
|
-
return N &&
|
|
2387
|
+
const N = u.some((O) => y(O) > y(P) && g(O, P)), U = n(G.target, d) !== G.target || A.some((O) => y(O) < y(R) && g(O, R)), I = (O, C) => y(O) < w(C) && w(O) > y(C);
|
|
2388
|
+
return N && u.some((O) => I(O, P) && l(O) >= p(P)) ? [] : U && A.some((O) => I(O, R) && p(O) <= l(R)) ? [] : [{ id: G.id, source: P, target: R, leave: N, enter: U }];
|
|
2364
2389
|
}), b = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
|
|
2365
2390
|
for (const G of m)
|
|
2366
2391
|
G.leave || T.set(G.source.id, [...T.get(G.source.id) ?? [], G]);
|
|
2367
2392
|
for (const G of T.values()) {
|
|
2368
|
-
const
|
|
2369
|
-
G.sort((
|
|
2370
|
-
const
|
|
2371
|
-
b.set(
|
|
2393
|
+
const P = (R) => Math.abs(a(R.target) - a(R.source)) + Math.abs(i(R.target) - i(R.source));
|
|
2394
|
+
G.sort((R, N) => P(R) - P(N) || (R.id < N.id ? -1 : 1)), G.forEach((R, N) => {
|
|
2395
|
+
const U = a(R.target) < a(R.source) ? -1 : 1, I = Math.ceil(N / 2) * o * (N % 2 ? U : -U);
|
|
2396
|
+
b.set(R.id, a(R.source) + I);
|
|
2372
2397
|
});
|
|
2373
2398
|
}
|
|
2374
2399
|
if (!m.length || x - $ < (m.length + 1) * Qe) continue;
|
|
2375
|
-
const
|
|
2376
|
-
const
|
|
2377
|
-
return G.map((N,
|
|
2400
|
+
const F = (G) => {
|
|
2401
|
+
const P = G.filter((N) => N.leave), R = G.filter((N) => N.enter);
|
|
2402
|
+
return G.map((N, U) => ({
|
|
2378
2403
|
w: N,
|
|
2379
|
-
at: re($ + (x - $) * (
|
|
2380
|
-
leave: N.leave ? re(E + Qe *
|
|
2381
|
-
enter: N.enter ? re(v - Qe * (
|
|
2404
|
+
at: re($ + (x - $) * (U + 1) / (G.length + 1)),
|
|
2405
|
+
leave: N.leave ? re(E + Qe * P.indexOf(N)) : void 0,
|
|
2406
|
+
enter: N.enter ? re(v - Qe * (R.length - 1 - R.indexOf(N))) : void 0
|
|
2382
2407
|
}));
|
|
2383
|
-
}, X = (G) =>
|
|
2408
|
+
}, X = (G) => F(G).map(({ w: P, at: R, leave: N, enter: U }) => [
|
|
2384
2409
|
...N !== void 0 ? [
|
|
2385
|
-
{ u:
|
|
2386
|
-
{ u: N, v: i(
|
|
2387
|
-
{ u: N, v:
|
|
2410
|
+
{ u: p(P.source), v: i(P.source) },
|
|
2411
|
+
{ u: N, v: i(P.source) },
|
|
2412
|
+
{ u: N, v: R }
|
|
2388
2413
|
] : [
|
|
2389
|
-
{ u: b.get(
|
|
2390
|
-
{ u: b.get(
|
|
2414
|
+
{ u: b.get(P.id), v: $ },
|
|
2415
|
+
{ u: b.get(P.id), v: R }
|
|
2391
2416
|
],
|
|
2392
|
-
...
|
|
2393
|
-
{ u:
|
|
2394
|
-
{ u:
|
|
2395
|
-
{ u: l(
|
|
2417
|
+
...U !== void 0 ? [
|
|
2418
|
+
{ u: U, v: R },
|
|
2419
|
+
{ u: U, v: i(P.target) },
|
|
2420
|
+
{ u: l(P.target), v: i(P.target) }
|
|
2396
2421
|
] : [
|
|
2397
|
-
{ u: a(
|
|
2398
|
-
{ u: a(
|
|
2422
|
+
{ u: a(P.target), v: R },
|
|
2423
|
+
{ u: a(P.target), v: x }
|
|
2399
2424
|
]
|
|
2400
2425
|
]), B = $i(
|
|
2401
|
-
[...m].sort((G,
|
|
2426
|
+
[...m].sort((G, P) => a(P.source) - a(G.source)),
|
|
2402
2427
|
(G) => Oi(X(G))
|
|
2403
2428
|
);
|
|
2404
|
-
for (const { w: G, at:
|
|
2429
|
+
for (const { w: G, at: P, leave: R, enter: N } of F(B))
|
|
2405
2430
|
r.set(G.id, {
|
|
2406
|
-
...c ? { y:
|
|
2407
|
-
...
|
|
2431
|
+
...c ? { y: P } : { x: P },
|
|
2432
|
+
...R !== void 0 ? { leave: R } : {},
|
|
2408
2433
|
...N !== void 0 ? { enter: N } : {}
|
|
2409
2434
|
});
|
|
2410
2435
|
}
|
|
@@ -2426,8 +2451,8 @@ function Oi(e) {
|
|
|
2426
2451
|
[r, d]
|
|
2427
2452
|
] : [];
|
|
2428
2453
|
if (!y || !w) continue;
|
|
2429
|
-
const l = w[0].u,
|
|
2430
|
-
l > Math.min(y[0].u, y[1].u) && l < Math.max(y[0].u, y[1].u) &&
|
|
2454
|
+
const l = w[0].u, p = y[0].v;
|
|
2455
|
+
l > Math.min(y[0].u, y[1].u) && l < Math.max(y[0].u, y[1].u) && p > Math.min(w[0].v, w[1].v) && p < Math.max(w[0].v, w[1].v) && s++;
|
|
2431
2456
|
}
|
|
2432
2457
|
return s;
|
|
2433
2458
|
}
|
|
@@ -2453,9 +2478,9 @@ function Di(e, t, s) {
|
|
|
2453
2478
|
let [y, w] = [e.get(c.a), e.get(c.b)];
|
|
2454
2479
|
if (!y || !w) continue;
|
|
2455
2480
|
w[n] < y[n] && ([y, w] = [w, y]);
|
|
2456
|
-
const l = y[n] + r(y, n),
|
|
2457
|
-
if (
|
|
2458
|
-
const a = (t === "right" ? c.w : c.h) - 2 *
|
|
2481
|
+
const l = y[n] + r(y, n), p = w[n];
|
|
2482
|
+
if (p <= l) continue;
|
|
2483
|
+
const a = (t === "right" ? c.w : c.h) - 2 * Fe, i = (t === "right" ? c.h : c.w) - 2 * Fe, g = l - a / 2 - Ge, f = p + a / 2 + Ge, M = y[o] + r(y, o) / 2, k = w[o] + r(w, o) / 2, S = Math.min(M, k) + Ge, D = Math.max(M, k) - Ge;
|
|
2459
2484
|
if (D - S < i) continue;
|
|
2460
2485
|
const _ = [
|
|
2461
2486
|
...[...e.values()].filter((v) => v[n] < f && v[n] + r(v, n) > g).map((v) => ({
|
|
@@ -2463,103 +2488,103 @@ function Di(e, t, s) {
|
|
|
2463
2488
|
hi: v[o] + r(v, o) + Ge
|
|
2464
2489
|
})),
|
|
2465
2490
|
...d.filter((v) => v.from < f && v.to > g)
|
|
2466
|
-
], $ = (v) => _.every((
|
|
2491
|
+
], $ = (v) => _.every((u) => v + i <= u.lo || v >= u.hi), x = (S + D - i) / 2, E = [S, x, ..._.map((v) => v.hi)].filter((v) => v >= S && v + i <= D && $(v)).sort((v, u) => Math.abs(v - x) - Math.abs(u - x))[0];
|
|
2467
2492
|
E !== void 0 && (h.add(c), d.push({ lo: E - Ge, hi: E + i + Ge, from: g, to: f }));
|
|
2468
2493
|
}
|
|
2469
2494
|
return h;
|
|
2470
2495
|
}
|
|
2471
|
-
const Ni = 96,
|
|
2472
|
-
function
|
|
2473
|
-
const r = new Map(e.flatMap((w, l) => w.map((
|
|
2474
|
-
...new Set(t.filter(([l,
|
|
2496
|
+
const Ni = 96, Fi = 1.25;
|
|
2497
|
+
function Pi(e, t, s, n, o) {
|
|
2498
|
+
const r = new Map(e.flatMap((w, l) => w.map((p) => [p, l]))), d = (w) => !t.some(([l, p]) => l === w && p !== w), h = (w) => [
|
|
2499
|
+
...new Set(t.filter(([l, p]) => p === w && l !== w).map((l) => l[0]))
|
|
2475
2500
|
], c = /* @__PURE__ */ new Set(), y = Math.max(...e.map(o));
|
|
2476
2501
|
for (const [w, l] of e.entries())
|
|
2477
2502
|
if (w)
|
|
2478
|
-
for (const
|
|
2479
|
-
const a = h(
|
|
2480
|
-
if (!s(
|
|
2503
|
+
for (const p of l) {
|
|
2504
|
+
const a = h(p);
|
|
2505
|
+
if (!s(p) || !d(p) || !a.length || a.some((M) => r.get(M) !== w - 1)) continue;
|
|
2481
2506
|
const i = [...new Set(t.filter(([M]) => a.includes(M)).map((M) => M[1]))].filter(
|
|
2482
|
-
(M) => M !==
|
|
2483
|
-
), g = [
|
|
2484
|
-
o(f) >
|
|
2507
|
+
(M) => M !== p && r.get(M) === w
|
|
2508
|
+
), g = [p, ...i].filter(d).sort((M, k) => n(k) - n(M))[0], f = [...e[w - 1], ...l.filter((M) => c.has(M)), p];
|
|
2509
|
+
o(f) > Fi * y || (i.some((M) => !d(M)) || g !== p) && c.add(p);
|
|
2485
2510
|
}
|
|
2486
2511
|
return c.size ? e.map((w, l) => [
|
|
2487
|
-
...w.filter((
|
|
2488
|
-
...(e[l + 1] ?? []).filter((
|
|
2512
|
+
...w.filter((p) => !c.has(p)),
|
|
2513
|
+
...(e[l + 1] ?? []).filter((p) => c.has(p))
|
|
2489
2514
|
]).filter((w) => w.length) : e;
|
|
2490
2515
|
}
|
|
2491
2516
|
function Ci(e, t, s, n, o, r, d = !1, h = [], c = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), w = () => {
|
|
2492
2517
|
}) {
|
|
2493
|
-
const l = new Map(e.map((
|
|
2494
|
-
const N = !k.size || k.has(
|
|
2518
|
+
const l = new Map(e.map((R) => [R.id, R])), p = e.map((R) => R.id), a = s === "right", i = (R) => a ? l.get(R).w : l.get(R).h, g = (R) => a ? l.get(R).h : l.get(R).w, f = (R) => l.get(R).type === "group", M = (R) => a ? R.y + R.h / 2 : R.x + R.w / 2, k = new Set(n.flat()), S = (R) => {
|
|
2519
|
+
const N = !k.size || k.has(R) ? [] : (c.get(R) ?? []).flatMap((I) => t.get(I) ?? []);
|
|
2495
2520
|
if (N.length) return N.reduce((I, O) => I + M(O), 0) / N.length;
|
|
2496
|
-
const
|
|
2497
|
-
return a ?
|
|
2498
|
-
}, D = (
|
|
2499
|
-
Jt(o,
|
|
2500
|
-
Dt(l.get(
|
|
2501
|
-
), _ = (
|
|
2502
|
-
ht(
|
|
2521
|
+
const U = t.get(R);
|
|
2522
|
+
return a ? U.y + l.get(R).h / 2 : U.x + l.get(R).w / 2;
|
|
2523
|
+
}, D = (R, N) => Math.max(
|
|
2524
|
+
Jt(o, R, N, f(R) || f(N) ? r.group : r.node, !a),
|
|
2525
|
+
Dt(l.get(R).soft, l.get(N).soft, a)
|
|
2526
|
+
), _ = (R) => R.reduce((N, U, I) => N + g(U) + (I ? D(R[I - 1], U) : 0), 0), $ = Pi(
|
|
2527
|
+
ht(p, n),
|
|
2503
2528
|
n,
|
|
2504
2529
|
d ? f : () => !1,
|
|
2505
2530
|
i,
|
|
2506
2531
|
_
|
|
2507
2532
|
).map(
|
|
2508
|
-
(
|
|
2509
|
-
[...
|
|
2533
|
+
(R) => an(
|
|
2534
|
+
[...R].sort((N, U) => S(N) - S(U) || p.indexOf(N) - p.indexOf(U)),
|
|
2510
2535
|
(N) => l.get(N).soft
|
|
2511
2536
|
)
|
|
2512
|
-
), x = new Map($.flatMap((
|
|
2513
|
-
for (const [
|
|
2514
|
-
x.get(N) > x.get(
|
|
2537
|
+
), x = new Map($.flatMap((R, N) => R.map((U) => [U, N]))), E = $.map(_), v = Math.max(...E), u = new Map(p.map((R) => [R, /* @__PURE__ */ new Set()])), A = new Map(p.map((R) => [R, /* @__PURE__ */ new Set()]));
|
|
2538
|
+
for (const [R, N] of n)
|
|
2539
|
+
x.get(N) > x.get(R) && (u.get(R).add(N), A.get(N).add(R));
|
|
2515
2540
|
const m = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
|
|
2516
|
-
for (const [
|
|
2517
|
-
let
|
|
2541
|
+
for (const [R, N] of $.entries()) {
|
|
2542
|
+
let U = (v - E[R]) / 2, I = -1 / 0;
|
|
2518
2543
|
for (const [O, C] of N.entries()) {
|
|
2519
|
-
const [V] = A.get(C), oe = A.get(C).size === 1 &&
|
|
2520
|
-
m.set(C, he), b.set(C, he + g(C) / 2), I = he + g(C),
|
|
2544
|
+
const [V] = A.get(C), oe = A.get(C).size === 1 && u.get(V).size === 1, ae = oe ? w(V, C) : void 0, le = ae !== void 0 ? m.get(V) + ae : oe ? b.get(V) - g(C) / 2 : U, he = O ? Math.max(le, I + D(N[O - 1], C)) : le;
|
|
2545
|
+
m.set(C, he), b.set(C, he + g(C) / 2), I = he + g(C), U = Math.max(U + g(C), I) + (N[O + 1] ? D(C, N[O + 1]) : 0);
|
|
2521
2546
|
}
|
|
2522
2547
|
}
|
|
2523
|
-
const T = $.length === 1 &&
|
|
2524
|
-
function
|
|
2525
|
-
const N =
|
|
2526
|
-
if (
|
|
2548
|
+
const T = $.length === 1 && F($[0]);
|
|
2549
|
+
function F(R) {
|
|
2550
|
+
const N = R.map((C) => y.get(C));
|
|
2551
|
+
if (R.length < 2 || N.some((C, V) => C === void 0 || V && C < N[V - 1]))
|
|
2527
2552
|
return !1;
|
|
2528
|
-
const
|
|
2553
|
+
const U = [];
|
|
2529
2554
|
let I = -1 / 0;
|
|
2530
|
-
for (const [C, V] of
|
|
2531
|
-
const oe = N[C] - N[0] + g(
|
|
2532
|
-
|
|
2555
|
+
for (const [C, V] of R.entries()) {
|
|
2556
|
+
const oe = N[C] - N[0] + g(R[0]) / 2 - g(V) / 2;
|
|
2557
|
+
U.push(C ? Math.max(oe, I + D(R[C - 1], V)) : oe), I = U[C] + g(V);
|
|
2533
2558
|
}
|
|
2534
|
-
const O = N.at(-1) - N[0] + (g(
|
|
2535
|
-
return I -
|
|
2559
|
+
const O = N.at(-1) - N[0] + (g(R[0]) + g(R.at(-1))) / 2;
|
|
2560
|
+
return I - U[0] > Math.max(E[0] * 1.25, O + 1) ? !1 : (R.forEach((C, V) => m.set(C, U[V])), !0);
|
|
2536
2561
|
}
|
|
2537
2562
|
const X = Math.min(...m.values()), B = en($, h, o, s), G = /* @__PURE__ */ new Map();
|
|
2538
|
-
let
|
|
2539
|
-
for (const [
|
|
2563
|
+
let P = 0;
|
|
2564
|
+
for (const [R, N] of $.entries()) {
|
|
2540
2565
|
for (const O of N) {
|
|
2541
2566
|
const C = re(m.get(O) - X);
|
|
2542
|
-
G.set(O, a ? { x:
|
|
2567
|
+
G.set(O, a ? { x: P, y: C } : { x: C, y: P });
|
|
2543
2568
|
}
|
|
2544
|
-
const
|
|
2545
|
-
if (!
|
|
2569
|
+
const U = $[R + 1];
|
|
2570
|
+
if (!U) break;
|
|
2546
2571
|
let I = Math.max(
|
|
2547
|
-
N.some(f) ||
|
|
2548
|
-
B[
|
|
2549
|
-
wo(N,
|
|
2572
|
+
N.some(f) || U.some(f) ? r.group : r.rank,
|
|
2573
|
+
B[R],
|
|
2574
|
+
wo(N, U, (O) => l.get(O).soft, !a)
|
|
2550
2575
|
);
|
|
2551
2576
|
for (const O of o)
|
|
2552
|
-
Math.min(x.get(O.a), x.get(O.b)) ===
|
|
2553
|
-
|
|
2577
|
+
Math.min(x.get(O.a), x.get(O.b)) === R && Math.abs(x.get(O.a) - x.get(O.b)) === 1 && (I = Math.max(I, a ? O.w : O.h));
|
|
2578
|
+
P += Math.max(...N.map(i)) + I;
|
|
2554
2579
|
}
|
|
2555
2580
|
return { positions: G, axis: s, followed: T };
|
|
2556
2581
|
}
|
|
2557
2582
|
const Nt = 20;
|
|
2558
2583
|
function en(e, t, s, n) {
|
|
2559
|
-
const o = new Map(e.flatMap((h, c) => h.map((y) => [y, c]))), r = (h) => n === "right" ? 2 *
|
|
2584
|
+
const o = new Map(e.flatMap((h, c) => h.map((y) => [y, c]))), r = (h) => n === "right" ? 2 * Fe : h.h, d = 2 * Fe;
|
|
2560
2585
|
return e.slice(0, -1).map((h, c) => {
|
|
2561
2586
|
let y = 0, w = 0;
|
|
2562
|
-
const l = [...s],
|
|
2587
|
+
const l = [...s], p = [], a = [];
|
|
2563
2588
|
for (const g of t) {
|
|
2564
2589
|
const f = g.a !== void 0 ? o.get(g.a) : void 0, M = g.b !== void 0 ? o.get(g.b) : void 0;
|
|
2565
2590
|
let k;
|
|
@@ -2574,29 +2599,29 @@ function en(e, t, s, n) {
|
|
|
2574
2599
|
if (k = f !== void 0 ? f === c : M === c + 1, !k) continue;
|
|
2575
2600
|
g.label && s.length && (w += r(g.label) - (n === "right" ? d : 0));
|
|
2576
2601
|
}
|
|
2577
|
-
y++,
|
|
2602
|
+
y++, p.push(g);
|
|
2578
2603
|
}
|
|
2579
2604
|
return a.some(
|
|
2580
|
-
(g) =>
|
|
2605
|
+
(g) => p.some((f) => !(f.a && f.b) && [f.a, f.b].some((M) => M && (M === g.a || M === g.b)))
|
|
2581
2606
|
) ? 2 * Nt + (y - 1) * Qe + w : 0;
|
|
2582
2607
|
});
|
|
2583
2608
|
}
|
|
2584
2609
|
function ji(e, t, s, n, o) {
|
|
2585
2610
|
const r = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
|
|
2586
2611
|
for (const [w, l] of t) {
|
|
2587
|
-
const
|
|
2588
|
-
if (
|
|
2589
|
-
const [i, g] =
|
|
2612
|
+
const p = s.get(w), a = s.get(l);
|
|
2613
|
+
if (p === void 0 || a === void 0 || p === a) continue;
|
|
2614
|
+
const [i, g] = p < a ? [w, l] : [l, w];
|
|
2590
2615
|
r.set(g, [...r.get(g) ?? [], i]), d.set(i, [...d.get(i) ?? [], g]);
|
|
2591
2616
|
}
|
|
2592
2617
|
const h = (w) => n.get(w) + o(w) / 2, c = (w, l) => {
|
|
2593
2618
|
if (!w.some((M) => l.get(M)?.length)) return;
|
|
2594
|
-
const
|
|
2619
|
+
const p = [];
|
|
2595
2620
|
for (const [M, k] of w.entries())
|
|
2596
|
-
|
|
2621
|
+
p.push(M ? p[M - 1] + n.get(k) - n.get(w[M - 1]) : 0);
|
|
2597
2622
|
const a = w.map((M, k) => {
|
|
2598
2623
|
const S = (l.get(M) ?? []).map(h).sort((_, $) => _ - $);
|
|
2599
|
-
return (S.length ? S[S.length - 1 >> 1] : h(M)) - o(M) / 2 -
|
|
2624
|
+
return (S.length ? S[S.length - 1 >> 1] : h(M)) - o(M) / 2 - p[k];
|
|
2600
2625
|
}), i = [], g = (M) => M[M.length >> 1];
|
|
2601
2626
|
for (const M of a)
|
|
2602
2627
|
for (i.push([M]); i.length > 1 && g(i.at(-2)) > g(i.at(-1)); ) {
|
|
@@ -2605,7 +2630,7 @@ function ji(e, t, s, n, o) {
|
|
|
2605
2630
|
}
|
|
2606
2631
|
let f = 0;
|
|
2607
2632
|
for (const M of i)
|
|
2608
|
-
for (let k = 0; k < M.length; k++, f++) n.set(w[f], re(g(M) +
|
|
2633
|
+
for (let k = 0; k < M.length; k++, f++) n.set(w[f], re(g(M) + p[f]));
|
|
2609
2634
|
};
|
|
2610
2635
|
for (const w of e.slice(1)) c(w, r);
|
|
2611
2636
|
for (const w of [...e].reverse().slice(1)) c(w, d);
|
|
@@ -2633,12 +2658,12 @@ function Bi(e, t, s, n) {
|
|
|
2633
2658
|
return c > 1 ? 2 * Nt + (c - 1) * Mo : 0;
|
|
2634
2659
|
});
|
|
2635
2660
|
}
|
|
2636
|
-
function
|
|
2661
|
+
function zi(e, t, s, n = [], o = [], r) {
|
|
2637
2662
|
const d = /* @__PURE__ */ new Map(), h = t.gap, c = nt(t);
|
|
2638
2663
|
let y;
|
|
2639
2664
|
const w = new Map(e.map((l) => [l.id, l]));
|
|
2640
2665
|
if (t.algorithm === "row" || t.algorithm === "column") {
|
|
2641
|
-
const l = t.algorithm === "row",
|
|
2666
|
+
const l = t.algorithm === "row", p = en(
|
|
2642
2667
|
e.map((i) => [i.id]),
|
|
2643
2668
|
o,
|
|
2644
2669
|
n,
|
|
@@ -2649,26 +2674,26 @@ function Ui(e, t, s, n = [], o = [], r) {
|
|
|
2649
2674
|
const f = e[i + 1]?.id ?? "";
|
|
2650
2675
|
d.set(g.id, l ? { x: a, y: 0 } : { x: 0, y: a }), a += (l ? g.w : g.h) + Math.max(
|
|
2651
2676
|
Jt(n, g.id, f, h, l),
|
|
2652
|
-
|
|
2677
|
+
p[i] ?? 0,
|
|
2653
2678
|
Dt(g.soft, e[i + 1]?.soft, !l)
|
|
2654
2679
|
);
|
|
2655
2680
|
}
|
|
2656
2681
|
} else {
|
|
2657
|
-
const l = e.map((v) => v.id),
|
|
2658
|
-
const m = [v, ...a.chains.get(A) ?? [],
|
|
2682
|
+
const l = e.map((v) => v.id), p = (v) => w.get(v).soft, a = s.length ? qi(ht(l, s), s, (v) => an(v, p)) : null, i = a ? a.layers : l.map((v) => [v]), g = !!a && a.chains.size >= Gi && a.crossings <= 2 * a.chains.size && !e.some((v) => v.soft?.length), f = g ? a.order : i, M = g ? s.flatMap(([v, u], A) => {
|
|
2683
|
+
const m = [v, ...a.chains.get(A) ?? [], u];
|
|
2659
2684
|
return m.slice(1).map((b, T) => [m[T], b]);
|
|
2660
|
-
}) : s, k = (v) => je(v) ? 0 : c === "right" ? w.get(v).w : w.get(v).h, S = (v) => je(v) ? 0 : c === "right" ? w.get(v).h : w.get(v).w, D = new Map(f.flatMap((v,
|
|
2685
|
+
}) : s, k = (v) => je(v) ? 0 : c === "right" ? w.get(v).w : w.get(v).h, S = (v) => je(v) ? 0 : c === "right" ? w.get(v).h : w.get(v).w, D = new Map(f.flatMap((v, u) => v.map((A) => [A, u]))), _ = en(i, o, n, c), $ = /* @__PURE__ */ new Map();
|
|
2661
2686
|
for (const v of f) {
|
|
2662
|
-
let
|
|
2687
|
+
let u = 0, A;
|
|
2663
2688
|
for (const [m, b] of v.entries()) {
|
|
2664
2689
|
const T = v[m - 1];
|
|
2665
|
-
T !== void 0 && je(T) ?
|
|
2666
|
-
|
|
2690
|
+
T !== void 0 && je(T) ? u += je(b) ? Mo : Nt : T !== void 0 && je(b) && (u += Nt), !je(b) && A !== void 0 && (u = Math.max(
|
|
2691
|
+
u,
|
|
2667
2692
|
$.get(A) + S(A) + Math.max(
|
|
2668
2693
|
Jt(n, A, b, h, c !== "right"),
|
|
2669
|
-
Dt(
|
|
2694
|
+
Dt(p(A), p(b), c === "right")
|
|
2670
2695
|
)
|
|
2671
|
-
)), $.set(b,
|
|
2696
|
+
)), $.set(b, u), u += S(b), je(b) || (A = b);
|
|
2672
2697
|
}
|
|
2673
2698
|
}
|
|
2674
2699
|
s.length && ji(f, M, D, $, S);
|
|
@@ -2677,23 +2702,23 @@ function Ui(e, t, s, n = [], o = [], r) {
|
|
|
2677
2702
|
c,
|
|
2678
2703
|
f,
|
|
2679
2704
|
s.flatMap(
|
|
2680
|
-
([
|
|
2705
|
+
([u, A], m) => D.get(u) < D.get(A) ? [{ id: String(m), chain: [u, ...a.chains.get(m) ?? [], A] }] : []
|
|
2681
2706
|
),
|
|
2682
|
-
(
|
|
2683
|
-
(
|
|
2707
|
+
(u) => je(u) ? void 0 : c === "right" ? { x: 0, y: $.get(u), w: k(u), h: S(u) } : { x: $.get(u), y: 0, w: S(u), h: k(u) },
|
|
2708
|
+
(u) => $.get(u),
|
|
2684
2709
|
r
|
|
2685
|
-
).forEach((
|
|
2710
|
+
).forEach((u, A) => x[A] = Math.max(x[A] ?? 0, u));
|
|
2686
2711
|
let E = 0;
|
|
2687
|
-
for (const [v,
|
|
2712
|
+
for (const [v, u] of i.entries()) {
|
|
2688
2713
|
let A = Math.max(h, _[v] ?? 0, x[v] ?? 0);
|
|
2689
|
-
for (const m of
|
|
2714
|
+
for (const m of u) {
|
|
2690
2715
|
const b = $.get(m);
|
|
2691
2716
|
d.set(m, c === "right" ? { x: E, y: b } : { x: b, y: E });
|
|
2692
2717
|
}
|
|
2693
|
-
i[v + 1] && (A = Math.max(A, wo(
|
|
2718
|
+
i[v + 1] && (A = Math.max(A, wo(u, i[v + 1], p, c === "down")));
|
|
2694
2719
|
for (const m of n)
|
|
2695
2720
|
Math.min(D.get(m.a), D.get(m.b)) === v && Math.abs(D.get(m.a) - D.get(m.b)) === 1 && (A = Math.max(A, c === "right" ? m.w : m.h));
|
|
2696
|
-
E += Math.max(...
|
|
2721
|
+
E += Math.max(...u.map(k)) + A;
|
|
2697
2722
|
}
|
|
2698
2723
|
g && (y = {
|
|
2699
2724
|
order: f,
|
|
@@ -2706,19 +2731,19 @@ function Ui(e, t, s, n = [], o = [], r) {
|
|
|
2706
2731
|
function xo(e, t, s = (n) => n) {
|
|
2707
2732
|
const n = [s(e[0])];
|
|
2708
2733
|
for (let o = 1; o < e.length; o++) {
|
|
2709
|
-
const r = new Map(n[o - 1].map((l,
|
|
2734
|
+
const r = new Map(n[o - 1].map((l, p) => [l, p])), h = e[o].map((l, p) => {
|
|
2710
2735
|
const a = t.flatMap(([i, g]) => i === l ? [g] : g === l ? [i] : []).filter((i) => r.has(i)).map((i) => r.get(i));
|
|
2711
2736
|
return {
|
|
2712
2737
|
id: l,
|
|
2713
2738
|
key: a.length ? a.reduce((i, g) => i + g, 0) / a.length : null,
|
|
2714
|
-
k:
|
|
2739
|
+
k: p
|
|
2715
2740
|
};
|
|
2716
|
-
}).filter((l) => l.key !== null), c = [...h].sort((l,
|
|
2717
|
-
c.forEach((l,
|
|
2741
|
+
}).filter((l) => l.key !== null), c = [...h].sort((l, p) => l.key - p.key || l.k - p.k), y = h.map((l) => l.k), w = [...e[o]];
|
|
2742
|
+
c.forEach((l, p) => w[y[p]] = l.id), n.push(s(w));
|
|
2718
2743
|
}
|
|
2719
2744
|
return n;
|
|
2720
2745
|
}
|
|
2721
|
-
const
|
|
2746
|
+
const Ui = 8;
|
|
2722
2747
|
function qi(e, t, s = (n) => n) {
|
|
2723
2748
|
const n = xo(e, t, s), o = new Map(n.flatMap((_, $) => _.map((x) => [x, $]))), r = n.map((_) => [..._]), d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), c = (_, $) => {
|
|
2724
2749
|
h.set(_, [...h.get(_) ?? [], $]), d.set($, [...d.get($) ?? [], _]);
|
|
@@ -2726,65 +2751,65 @@ function qi(e, t, s = (n) => n) {
|
|
|
2726
2751
|
for (const [_, [$, x]] of t.entries()) {
|
|
2727
2752
|
const E = o.get($), v = o.get(x);
|
|
2728
2753
|
if (E === void 0 || v === void 0 || E >= v) continue;
|
|
2729
|
-
let
|
|
2754
|
+
let u = $;
|
|
2730
2755
|
w.set(_, []);
|
|
2731
2756
|
for (let A = E + 1; A < v; A++) {
|
|
2732
2757
|
const m = `\0${_}:${A}`;
|
|
2733
2758
|
w.get(_).push(m);
|
|
2734
|
-
const b = r[A].indexOf(
|
|
2735
|
-
r[A].splice(b < 0 ? r[A].length : b + 1, 0, m), c(
|
|
2759
|
+
const b = r[A].indexOf(u);
|
|
2760
|
+
r[A].splice(b < 0 ? r[A].length : b + 1, 0, m), c(u, m), u = m;
|
|
2736
2761
|
}
|
|
2737
|
-
c(
|
|
2762
|
+
c(u, x);
|
|
2738
2763
|
}
|
|
2739
2764
|
if (r.length < 2) return { layers: n, order: n, chains: w, crossings: 0 };
|
|
2740
|
-
const l = (_) => s(_.filter(($) => y.has($))),
|
|
2765
|
+
const l = (_) => s(_.filter(($) => y.has($))), p = (_) => {
|
|
2741
2766
|
const $ = l(_);
|
|
2742
2767
|
let x = 0;
|
|
2743
2768
|
return _.map((E) => y.has(E) ? $[x++] : E);
|
|
2744
2769
|
}, a = (_) => {
|
|
2745
|
-
const $ = new Map(r[_ + 1].map((v,
|
|
2746
|
-
(v) => (h.get(v) ?? []).map((
|
|
2770
|
+
const $ = new Map(r[_ + 1].map((v, u) => [v, u])), x = r[_].flatMap(
|
|
2771
|
+
(v) => (h.get(v) ?? []).map((u) => $.get(u)).sort((u, A) => u - A)
|
|
2747
2772
|
);
|
|
2748
2773
|
let E = 0;
|
|
2749
2774
|
for (let v = 0; v < x.length; v++)
|
|
2750
|
-
for (let
|
|
2775
|
+
for (let u = v + 1; u < x.length; u++) x[v] > x[u] && E++;
|
|
2751
2776
|
return E;
|
|
2752
2777
|
}, i = () => r.slice(1).reduce((_, $, x) => _ + a(x), 0), g = (_, $, x, E) => {
|
|
2753
2778
|
let v = 0;
|
|
2754
|
-
for (const
|
|
2755
|
-
for (const A of x.get($) ?? []) E.get(
|
|
2779
|
+
for (const u of x.get(_) ?? [])
|
|
2780
|
+
for (const A of x.get($) ?? []) E.get(u) > E.get(A) && v++;
|
|
2756
2781
|
return v;
|
|
2757
2782
|
}, f = (_) => new Map((r[_] ?? []).map(($, x) => [$, x])), M = (_) => {
|
|
2758
|
-
const $ = r[_], x = f(_ - 1), E = f(_ + 1), v = (
|
|
2759
|
-
for (let
|
|
2760
|
-
|
|
2783
|
+
const $ = r[_], x = f(_ - 1), E = f(_ + 1), v = (u, A) => g(u, A, d, x) + g(u, A, h, E);
|
|
2784
|
+
for (let u = !0, A = 0; u && A < $.length; A++) {
|
|
2785
|
+
u = !1;
|
|
2761
2786
|
for (let m = 0; m + 1 < $.length; m++) {
|
|
2762
2787
|
const b = $[m], T = $[m + 1];
|
|
2763
2788
|
if (!(v(T, b) >= v(b, T))) {
|
|
2764
2789
|
if ([$[m], $[m + 1]] = [T, b], l($).join(`
|
|
2765
|
-
`) !== $.filter((
|
|
2790
|
+
`) !== $.filter((F) => y.has(F)).join(`
|
|
2766
2791
|
`)) {
|
|
2767
2792
|
[$[m], $[m + 1]] = [b, T];
|
|
2768
2793
|
continue;
|
|
2769
2794
|
}
|
|
2770
|
-
|
|
2795
|
+
u = !0;
|
|
2771
2796
|
}
|
|
2772
2797
|
}
|
|
2773
2798
|
}
|
|
2774
2799
|
}, k = (_, $, x) => {
|
|
2775
2800
|
const v = r[_].map((m, b) => {
|
|
2776
|
-
const T = ($.get(m) ?? []).map((
|
|
2777
|
-
return { id: m, k: b, key: T.length ? T.reduce((
|
|
2778
|
-
}).filter((m) => m.key !== null),
|
|
2779
|
-
[...v].sort((m, b) => m.key - b.key || m.k - b.k).forEach((m, b) => A[
|
|
2801
|
+
const T = ($.get(m) ?? []).map((F) => x.get(F));
|
|
2802
|
+
return { id: m, k: b, key: T.length ? T.reduce((F, X) => F + X, 0) / T.length : null };
|
|
2803
|
+
}).filter((m) => m.key !== null), u = v.map((m) => m.k), A = [...r[_]];
|
|
2804
|
+
[...v].sort((m, b) => m.key - b.key || m.k - b.k).forEach((m, b) => A[u[b]] = m.id), r[_] = p(A);
|
|
2780
2805
|
};
|
|
2781
2806
|
let S = r.map((_) => [..._]), D = i();
|
|
2782
|
-
for (let _ = 0, $ = 0; _ <
|
|
2783
|
-
const x = _ % 2 === 0, E = x ? r.map((
|
|
2784
|
-
for (const
|
|
2785
|
-
k(
|
|
2807
|
+
for (let _ = 0, $ = 0; _ < Ui && D && $ < 2; _++) {
|
|
2808
|
+
const x = _ % 2 === 0, E = x ? r.map((u, A) => A).slice(1) : r.map((u, A) => A).reverse().slice(1);
|
|
2809
|
+
for (const u of E)
|
|
2810
|
+
k(u, x ? d : h, f(x ? u - 1 : u + 1)), M(u);
|
|
2786
2811
|
const v = i();
|
|
2787
|
-
v < D ? [S, D, $] = [r.map((
|
|
2812
|
+
v < D ? [S, D, $] = [r.map((u) => [...u]), v, 0] : $++;
|
|
2788
2813
|
}
|
|
2789
2814
|
return {
|
|
2790
2815
|
layers: S.map((_) => _.filter(($) => y.has($))),
|
|
@@ -2811,92 +2836,92 @@ class Yn {
|
|
|
2811
2836
|
function Hi(e, t, s, n) {
|
|
2812
2837
|
const o = s.filter((l) => l.type === "stay");
|
|
2813
2838
|
if (!o.length) return [];
|
|
2814
|
-
const r = new Map(o.map((l) => [l.id, { x: l.x, y: l.y }])), d = /* @__PURE__ */ new Set(), h = n === "right" ? "x" : "y", c = n === "right" ? "y" : "x", y = (l,
|
|
2839
|
+
const r = new Map(o.map((l) => [l.id, { x: l.x, y: l.y }])), d = /* @__PURE__ */ new Set(), h = n === "right" ? "x" : "y", c = n === "right" ? "y" : "x", y = (l, p) => p === "x" ? l.w : l.h, w = (l, p, a, i, g) => Math.min(p[g] + y(l, g), i[g] + y(a, g)) - Math.max(p[g], i[g]);
|
|
2815
2840
|
for (let l = 0; l < e.length; l++)
|
|
2816
|
-
for (let
|
|
2817
|
-
const a = e[l], i = e[
|
|
2841
|
+
for (let p = l + 1; p < e.length; p++) {
|
|
2842
|
+
const a = e[l], i = e[p], g = r.get(a.id), f = r.get(i.id), M = t.get(a.id), k = t.get(i.id);
|
|
2818
2843
|
!g || !f || !M || !k || w(a, M, i, k, h) > 0 || w(a, g, i, f, c) > 0 && w(a, g, i, f, h) >= Math.min(y(a, h), y(i, h)) / 2 && (d.add(a.id), d.add(i.id));
|
|
2819
2844
|
}
|
|
2820
2845
|
return o.filter((l) => d.has(l.id));
|
|
2821
2846
|
}
|
|
2822
2847
|
function Yi(e, t, s, n, o, r) {
|
|
2823
|
-
const d = e.map((
|
|
2824
|
-
(
|
|
2825
|
-
), l = /* @__PURE__ */ new Map(),
|
|
2826
|
-
|
|
2848
|
+
const d = e.map((u) => u.id), h = new Map(e.map((u) => [u.id, u])), c = new Map(e.map((u) => [u.id, { ...t.get(u.id) }])), y = new Map(d.map((u) => [u, 1])), w = s.filter(
|
|
2849
|
+
(u) => "ids" in u ? u.type === "align" && u.ids.every((A) => h.has(A)) : "id" in u && h.has(u.id)
|
|
2850
|
+
), l = /* @__PURE__ */ new Map(), p = Hi(e, t, w, r);
|
|
2851
|
+
p.length && o.push({
|
|
2827
2852
|
level: "info",
|
|
2828
2853
|
code: "stale-stay",
|
|
2829
|
-
message: `The stays on ${
|
|
2830
|
-
line:
|
|
2831
|
-
ids:
|
|
2854
|
+
message: `The stays on ${p.map((u) => u.id).join(", ")} no longer fit ${n}'s arrangement, so they were ignored. Drag again to anchor the new layout.`,
|
|
2855
|
+
line: p[0].line,
|
|
2856
|
+
ids: p.map((u) => u.id)
|
|
2832
2857
|
});
|
|
2833
|
-
for (const
|
|
2834
|
-
|
|
2835
|
-
for (const
|
|
2836
|
-
if (
|
|
2837
|
-
const A = t.get(
|
|
2838
|
-
c.set(
|
|
2858
|
+
for (const u of w)
|
|
2859
|
+
u.type === "stay" && !p.includes(u) && (c.set(u.id, { x: u.x, y: u.y }), y.set(u.id, u.weight), l.set(u.id, { pos: { x: u.x, y: u.y }, hint: u }));
|
|
2860
|
+
for (const u of w)
|
|
2861
|
+
if (u.type === "nudge") {
|
|
2862
|
+
const A = t.get(u.id), m = { x: A.x + u.dx, y: A.y + u.dy };
|
|
2863
|
+
c.set(u.id, m), y.set(u.id, 4), l.set(u.id, { pos: m, hint: u });
|
|
2839
2864
|
}
|
|
2840
2865
|
const a = new Map(
|
|
2841
|
-
w.flatMap((
|
|
2842
|
-
), i = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set(), f = (
|
|
2843
|
-
const A = a.get(
|
|
2844
|
-
if (i.has(
|
|
2845
|
-
if (g.has(
|
|
2846
|
-
throw new
|
|
2866
|
+
w.flatMap((u) => u.type === "near" && h.has(u.ref) ? [[u.id, u]] : [])
|
|
2867
|
+
), i = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set(), f = (u) => {
|
|
2868
|
+
const A = a.get(u);
|
|
2869
|
+
if (i.has(u) || !A) return;
|
|
2870
|
+
if (g.has(u))
|
|
2871
|
+
throw new Le(
|
|
2847
2872
|
`Relative placement cycle in ${n}. Replace one near with nudge.`,
|
|
2848
2873
|
A.line
|
|
2849
2874
|
);
|
|
2850
|
-
g.add(
|
|
2851
|
-
const m = h.get(
|
|
2852
|
-
let
|
|
2853
|
-
A.side === "right" || A.side === "left" ? (
|
|
2875
|
+
g.add(u), f(A.ref);
|
|
2876
|
+
const m = h.get(u), b = h.get(A.ref), T = c.get(A.ref);
|
|
2877
|
+
let F = T.x + (b.w - m.w) / 2, X = T.y + (b.h - m.h) / 2;
|
|
2878
|
+
A.side === "right" || A.side === "left" ? (F = A.side === "right" ? T.x + b.w + A.gap : T.x - m.w - A.gap, X += A.offset) : (X = A.side === "below" ? T.y + b.h + A.gap : T.y - m.h - A.gap, F += A.offset), c.set(u, { x: F, y: X }), y.set(u, 5), l.set(u, { pos: { x: F, y: X }, hint: A }), g.delete(u), i.add(u);
|
|
2854
2879
|
};
|
|
2855
2880
|
d.forEach(f);
|
|
2856
|
-
for (const
|
|
2857
|
-
if (
|
|
2858
|
-
const A = h.get(
|
|
2859
|
-
for (const
|
|
2881
|
+
for (const u of w)
|
|
2882
|
+
if (u.type === "align" && u.strength === "prefer") {
|
|
2883
|
+
const A = h.get(u.ids[0]), m = c.get(A.id), b = (F) => u.axis === "x" ? F.w : F.h, T = m[u.axis] + b(A) / 2;
|
|
2884
|
+
for (const F of u.ids.slice(1)) c.get(F)[u.axis] = T - b(h.get(F)) / 2;
|
|
2860
2885
|
}
|
|
2861
|
-
const M = new Map(w.flatMap((
|
|
2862
|
-
for (const [
|
|
2863
|
-
const k = (
|
|
2864
|
-
for (const
|
|
2865
|
-
if (
|
|
2866
|
-
for (const A of
|
|
2867
|
-
const m = /* @__PURE__ */ new Set([S[
|
|
2886
|
+
const M = new Map(w.flatMap((u) => u.type === "pin" ? [[u.id, u]] : []));
|
|
2887
|
+
for (const [u, A] of M) c.set(u, { x: A.x, y: A.y });
|
|
2888
|
+
const k = (u, A) => (u === "x" ? h.get(A).w : h.get(A).h) / 2, S = { x: new Yn(d), y: new Yn(d) };
|
|
2889
|
+
for (const u of w)
|
|
2890
|
+
if (u.type === "align" && u.strength === "required")
|
|
2891
|
+
for (const A of u.ids.slice(1)) {
|
|
2892
|
+
const m = /* @__PURE__ */ new Set([S[u.axis].find(u.ids[0]), S[u.axis].find(A)]), b = d.filter((T) => M.has(T) && m.has(S[u.axis].find(T))).map((T) => c.get(T)[u.axis] + k(u.axis, T));
|
|
2868
2893
|
b.length > 1 && Math.max(...b) - Math.min(...b) > 0.01 ? o.push({
|
|
2869
2894
|
level: "error",
|
|
2870
2895
|
code: "pin-align-conflict",
|
|
2871
|
-
message: `Pins conflict with required ${
|
|
2872
|
-
line:
|
|
2873
|
-
ids:
|
|
2874
|
-
}) : S[
|
|
2896
|
+
message: `Pins conflict with required ${u.axis} alignment in ${n}. The pins were kept.`,
|
|
2897
|
+
line: u.line,
|
|
2898
|
+
ids: u.ids
|
|
2899
|
+
}) : S[u.axis].join(u.ids[0], A);
|
|
2875
2900
|
}
|
|
2876
2901
|
const D = { x: /* @__PURE__ */ new Map(), y: /* @__PURE__ */ new Map() };
|
|
2877
|
-
for (const
|
|
2902
|
+
for (const u of ["x", "y"])
|
|
2878
2903
|
for (const A of d) {
|
|
2879
|
-
const m = S[
|
|
2880
|
-
D[
|
|
2881
|
-
const T = D[
|
|
2904
|
+
const m = S[u].find(A), b = c.get(A)[u] + k(u, A);
|
|
2905
|
+
D[u].has(m) || D[u].set(m, { sum: 0, weight: 0, value: 0, fixed: null, members: [] });
|
|
2906
|
+
const T = D[u].get(m);
|
|
2882
2907
|
T.sum += b * y.get(A), T.weight += y.get(A), T.members.push(A), M.has(A) && (T.fixed = b);
|
|
2883
2908
|
}
|
|
2884
|
-
for (const
|
|
2885
|
-
for (const A of D[
|
|
2886
|
-
const _ = (
|
|
2887
|
-
const T = _(
|
|
2888
|
-
if (X <= 5e-3 || T ===
|
|
2889
|
-
if (T.fixed !== null)
|
|
2890
|
-
else if (
|
|
2909
|
+
for (const u of ["x", "y"])
|
|
2910
|
+
for (const A of D[u].values()) A.value = A.fixed ?? A.sum / A.weight;
|
|
2911
|
+
const _ = (u, A) => D[u].get(S[u].find(A)), $ = (u, A) => _(u, A).value, x = (u, A, m, b) => {
|
|
2912
|
+
const T = _(u, A), F = _(u, m), X = b - (T.value - F.value);
|
|
2913
|
+
if (X <= 5e-3 || T === F || T.fixed !== null && F.fixed !== null) return 0;
|
|
2914
|
+
if (T.fixed !== null) F.value -= X;
|
|
2915
|
+
else if (F.fixed !== null) T.value += X;
|
|
2891
2916
|
else {
|
|
2892
|
-
const B = T.weight +
|
|
2893
|
-
T.value += X *
|
|
2917
|
+
const B = T.weight + F.weight;
|
|
2918
|
+
T.value += X * F.weight / B, F.value -= X * T.weight / B;
|
|
2894
2919
|
}
|
|
2895
2920
|
return X;
|
|
2896
2921
|
}, E = w.flatMap(
|
|
2897
|
-
(
|
|
2922
|
+
(u) => u.type === "near" && u.strength === "required" && h.has(u.ref) ? [u] : []
|
|
2898
2923
|
), v = r === "right" ? "x" : "y";
|
|
2899
|
-
for (let
|
|
2924
|
+
for (let u = 0; u < 48; u++) {
|
|
2900
2925
|
let A = 0;
|
|
2901
2926
|
for (const m of E) {
|
|
2902
2927
|
const b = m.side === "right" || m.side === "left" ? "x" : "y", T = m.side === "right" || m.side === "below";
|
|
@@ -2909,62 +2934,62 @@ function Yi(e, t, s, n, o, r) {
|
|
|
2909
2934
|
}
|
|
2910
2935
|
for (let m = 0; m < e.length; m++)
|
|
2911
2936
|
for (let b = m + 1; b < e.length; b++) {
|
|
2912
|
-
const T = e[m],
|
|
2913
|
-
if (G <= 5e-3 ||
|
|
2914
|
-
const
|
|
2915
|
-
(O) => _(O, T.id) !== _(O,
|
|
2937
|
+
const T = e[m], F = e[b], X = $("x", F.id) - $("x", T.id), B = $("y", F.id) - $("y", T.id), G = (T.w + F.w) / 2 + ft - Math.abs(X), P = (T.h + F.h) / 2 + ft - Math.abs(B);
|
|
2938
|
+
if (G <= 5e-3 || P <= 5e-3) continue;
|
|
2939
|
+
const R = ["x", "y"].filter(
|
|
2940
|
+
(O) => _(O, T.id) !== _(O, F.id) && !(_(O, T.id).fixed !== null && _(O, F.id).fixed !== null)
|
|
2916
2941
|
);
|
|
2917
|
-
if (!
|
|
2918
|
-
const N = (O) => (O === "x" ? G :
|
|
2942
|
+
if (!R.length) continue;
|
|
2943
|
+
const N = (O) => (O === "x" ? G : P) + (O === v ? 0 : 3), U = [...R].sort((O, C) => N(O) - N(C))[0], I = U === "x" ? X : B;
|
|
2919
2944
|
A += x(
|
|
2920
|
-
|
|
2921
|
-
I >= 0 ?
|
|
2922
|
-
I >= 0 ? T.id :
|
|
2923
|
-
(
|
|
2945
|
+
U,
|
|
2946
|
+
I >= 0 ? F.id : T.id,
|
|
2947
|
+
I >= 0 ? T.id : F.id,
|
|
2948
|
+
(U === "x" ? T.w + F.w : T.h + F.h) / 2 + ft
|
|
2924
2949
|
);
|
|
2925
2950
|
}
|
|
2926
2951
|
if (n !== "root")
|
|
2927
2952
|
for (const m of ["x", "y"])
|
|
2928
2953
|
for (const b of D[m].values()) {
|
|
2929
|
-
const T = Math.max(...b.members.map((
|
|
2954
|
+
const T = Math.max(...b.members.map((F) => k(m, F)));
|
|
2930
2955
|
b.value < T && b.fixed === null && (A += T - b.value, b.value = T);
|
|
2931
2956
|
}
|
|
2932
2957
|
if (A < 0.01) break;
|
|
2933
2958
|
}
|
|
2934
|
-
for (const
|
|
2935
|
-
c.set(
|
|
2936
|
-
x: re($("x",
|
|
2937
|
-
y: re($("y",
|
|
2959
|
+
for (const u of e)
|
|
2960
|
+
c.set(u.id, {
|
|
2961
|
+
x: re($("x", u.id) - u.w / 2),
|
|
2962
|
+
y: re($("y", u.id) - u.h / 2)
|
|
2938
2963
|
});
|
|
2939
|
-
for (let
|
|
2940
|
-
for (let A =
|
|
2941
|
-
const m = e[
|
|
2942
|
-
T.x + m.w >
|
|
2964
|
+
for (let u = 0; u < e.length; u++)
|
|
2965
|
+
for (let A = u + 1; A < e.length; A++) {
|
|
2966
|
+
const m = e[u], b = e[A], T = c.get(m.id), F = c.get(b.id);
|
|
2967
|
+
T.x + m.w > F.x + 0.1 && F.x + b.w > T.x + 0.1 && T.y + m.h > F.y + 0.1 && F.y + b.h > T.y + 0.1 && o.push({
|
|
2943
2968
|
level: "error",
|
|
2944
2969
|
code: "overlap",
|
|
2945
2970
|
message: `${m.id} overlaps ${b.id}. Release a pin or give ${n} more room.`,
|
|
2946
2971
|
ids: [m.id, b.id]
|
|
2947
2972
|
});
|
|
2948
2973
|
}
|
|
2949
|
-
for (const
|
|
2950
|
-
const A = h.get(
|
|
2951
|
-
(
|
|
2974
|
+
for (const u of E) {
|
|
2975
|
+
const A = h.get(u.id), m = h.get(u.ref), b = c.get(A.id), T = c.get(m.id);
|
|
2976
|
+
(u.side === "right" ? b.x - T.x - m.w : u.side === "left" ? T.x - b.x - A.w : u.side === "below" ? b.y - T.y - m.h : T.y - b.y - A.h) < u.gap - 0.5 && o.push({
|
|
2952
2977
|
level: "error",
|
|
2953
2978
|
code: "unsatisfied-near",
|
|
2954
|
-
message: `Required: ${
|
|
2955
|
-
line:
|
|
2956
|
-
ids: [
|
|
2979
|
+
message: `Required: ${u.id} ${u.side} of ${u.ref} is not satisfied.`,
|
|
2980
|
+
line: u.line,
|
|
2981
|
+
ids: [u.id, u.ref]
|
|
2957
2982
|
});
|
|
2958
2983
|
}
|
|
2959
|
-
for (const [
|
|
2960
|
-
if (M.has(
|
|
2961
|
-
const b = c.get(
|
|
2984
|
+
for (const [u, { pos: A, hint: m }] of l) {
|
|
2985
|
+
if (M.has(u) || m.type === "near" && m.strength === "required") continue;
|
|
2986
|
+
const b = c.get(u), T = Math.round(Math.hypot(b.x - A.x, b.y - A.y));
|
|
2962
2987
|
T >= 2 && o.push({
|
|
2963
|
-
level: T >=
|
|
2988
|
+
level: T >= Un ? "warning" : "info",
|
|
2964
2989
|
code: "relaxed",
|
|
2965
|
-
message: `${m.type} ${
|
|
2990
|
+
message: `${m.type} ${u} gave way by ${T} px to keep ${n} clear.${T >= Un ? ` Remove line ${m.line}, or run format --drop-stale.` : ""}`,
|
|
2966
2991
|
line: m.line,
|
|
2967
|
-
ids: [
|
|
2992
|
+
ids: [u]
|
|
2968
2993
|
});
|
|
2969
2994
|
}
|
|
2970
2995
|
return c;
|
|
@@ -2979,17 +3004,17 @@ function tn(e, t, s = !1) {
|
|
|
2979
3004
|
const l = tn(
|
|
2980
3005
|
{ ...e, hints: e.hints.filter((i) => !o.includes(i)) },
|
|
2981
3006
|
t
|
|
2982
|
-
),
|
|
3007
|
+
), p = (i, g) => {
|
|
2983
3008
|
const f = l.byId.get(i);
|
|
2984
3009
|
return g === "x" ? f.x + f.w / 2 : f.y + f.h / 2;
|
|
2985
3010
|
}, a = e.hints.map((i) => {
|
|
2986
3011
|
if (!o.includes(i) || i.type !== "near") return i;
|
|
2987
3012
|
const g = Vt(n, i.id, i.ref), f = i.side === "left" || i.side === "right" ? "y" : "x";
|
|
2988
|
-
return { ...i, ref: g, offset: i.offset +
|
|
3013
|
+
return { ...i, ref: g, offset: i.offset + p(i.ref, f) - p(g, f) };
|
|
2989
3014
|
});
|
|
2990
3015
|
return tn({ ...e, hints: a }, t);
|
|
2991
3016
|
}
|
|
2992
|
-
const r = { ...e, hints: e.hints.filter((l) => l.type === "size" || l.type === "order") }, d = At(r, t), h = d, c = bo.get(h), y = (l) => (Math.max(...l.map((
|
|
3017
|
+
const r = { ...e, hints: e.hints.filter((l) => l.type === "size" || l.type === "order") }, d = At(r, t), h = d, c = bo.get(h), y = (l) => (Math.max(...l.map((p) => p.x + p.w)) - Math.min(...l.map((p) => p.x))) * (Math.max(...l.map((p) => p.y + p.h)) - Math.min(...l.map((p) => p.y))), w = ws(
|
|
2993
3018
|
Ms(h.objects, e.edges, e.routing),
|
|
2994
3019
|
y(h.objects),
|
|
2995
3020
|
(l) => y(At(r, t, !1, l, c).objects)
|
|
@@ -2998,62 +3023,62 @@ function tn(e, t, s = !1) {
|
|
|
2998
3023
|
}
|
|
2999
3024
|
const bo = /* @__PURE__ */ new WeakMap();
|
|
3000
3025
|
function At(e, t, s = !1, n, o) {
|
|
3001
|
-
const r = e.edges.filter((
|
|
3026
|
+
const r = e.edges.filter((L) => L.constraint !== !1 && L.directed !== !1), d = new Set(r.filter((L) => !L.dashed).map((L) => L.target)), h = r.filter((L) => !L.dashed || !d.has(L.target)), c = {
|
|
3002
3027
|
port: Math.max(e.routing.portGap ?? 16, e.routing.edgeGap ?? 16),
|
|
3003
3028
|
track: e.routing.edgeGap ?? 16
|
|
3004
3029
|
}, y = [], w = /* @__PURE__ */ new Map([["root", []]]);
|
|
3005
|
-
for (const
|
|
3006
|
-
w.has(
|
|
3007
|
-
const l =
|
|
3008
|
-
let q = _.get(
|
|
3030
|
+
for (const L of e.objects)
|
|
3031
|
+
w.has(L.parent) || w.set(L.parent, []), w.get(L.parent).push(L);
|
|
3032
|
+
const l = pt(e.appearance), p = l.groupHeader, a = /* @__PURE__ */ new Map(), i = l.theme === It ? l : pt({ ...e.appearance, theme: It }), g = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), M = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), _ = new Map(e.objects.map((L) => [L.id, L])), $ = /* @__PURE__ */ new Map(), x = (L, j) => {
|
|
3033
|
+
let q = _.get(L);
|
|
3009
3034
|
for (; q && q.parent !== j; ) q = _.get(q.parent);
|
|
3010
3035
|
return q?.id;
|
|
3011
|
-
}, E = [], v = [],
|
|
3036
|
+
}, E = [], v = [], u = /* @__PURE__ */ new Map(), A = new Set(o?.groups);
|
|
3012
3037
|
let m = o?.wrap ?? !1;
|
|
3013
|
-
const b = (
|
|
3038
|
+
const b = (L) => {
|
|
3014
3039
|
const j = /* @__PURE__ */ new Map();
|
|
3015
3040
|
for (const q of h) {
|
|
3016
|
-
const W = x(q.source,
|
|
3017
|
-
W && x(q.target,
|
|
3041
|
+
const W = x(q.source, L);
|
|
3042
|
+
W && x(q.target, L) !== W && j.set(W, [...j.get(W) ?? [], q]);
|
|
3018
3043
|
}
|
|
3019
3044
|
return new Set(
|
|
3020
3045
|
[...j].filter(
|
|
3021
3046
|
([q, W]) => W.length > 1 && (_.get(q).shape === "diamond" || W.filter((ee) => ee.label).length > 1)
|
|
3022
3047
|
).map(([q]) => q)
|
|
3023
3048
|
);
|
|
3024
|
-
}, T = (
|
|
3025
|
-
const W = (se) => x(se,
|
|
3049
|
+
}, T = (L) => h.map((j) => [x(j.source, L), x(j.target, L)]).filter((j) => !!j[0] && !!j[1] && j[0] !== j[1]), F = (L, j, q) => {
|
|
3050
|
+
const W = (se) => x(se, L) !== void 0, ee = e.objects.filter((se) => W(se.id)).map((se) => se.id), Y = new Map(
|
|
3026
3051
|
ht(
|
|
3027
3052
|
ee,
|
|
3028
3053
|
h.filter((se) => W(se.source) && W(se.target)).map((se) => [se.source, se.target])
|
|
3029
|
-
).flatMap((se,
|
|
3054
|
+
).flatMap((se, pe) => se.map((ve) => [ve, pe]))
|
|
3030
3055
|
), H = new Map(j.map((se) => [se, 1 / 0]));
|
|
3031
3056
|
for (const se of ee) {
|
|
3032
|
-
const
|
|
3033
|
-
H.set(
|
|
3057
|
+
const pe = x(se, L);
|
|
3058
|
+
H.set(pe, Math.min(H.get(pe), Y.get(se)));
|
|
3034
3059
|
}
|
|
3035
|
-
const J = (se,
|
|
3060
|
+
const J = (se, pe) => {
|
|
3036
3061
|
const ve = /* @__PURE__ */ new Set([se]), xe = [se];
|
|
3037
3062
|
for (; xe.length; ) {
|
|
3038
3063
|
const Be = xe.pop();
|
|
3039
|
-
if (Be ===
|
|
3040
|
-
for (const [Xe,
|
|
3041
|
-
Xe === Be && !ve.has(
|
|
3064
|
+
if (Be === pe) return !0;
|
|
3065
|
+
for (const [Xe, Re] of q)
|
|
3066
|
+
Xe === Be && !ve.has(Re) && (ve.add(Re), xe.push(Re));
|
|
3042
3067
|
}
|
|
3043
3068
|
return !1;
|
|
3044
3069
|
};
|
|
3045
|
-
return q.filter(([se,
|
|
3046
|
-
}, X = (
|
|
3047
|
-
w.get(
|
|
3070
|
+
return q.filter(([se, pe]) => !(H.get(pe) < H.get(se) && J(pe, se)));
|
|
3071
|
+
}, X = (L) => {
|
|
3072
|
+
w.get(L);
|
|
3048
3073
|
};
|
|
3049
3074
|
let B = 0, G = 0;
|
|
3050
|
-
for (const
|
|
3051
|
-
const j = X(
|
|
3075
|
+
for (const L of w.keys()) {
|
|
3076
|
+
const j = X(L);
|
|
3052
3077
|
if (!j) continue;
|
|
3053
3078
|
B = Math.max(B, j.groupGap);
|
|
3054
|
-
const q = T(
|
|
3079
|
+
const q = T(L), W = new Map(
|
|
3055
3080
|
ht(
|
|
3056
|
-
(w.get(
|
|
3081
|
+
(w.get(L) ?? []).map((Y) => Y.id),
|
|
3057
3082
|
q
|
|
3058
3083
|
).flatMap((Y, H) => Y.map((J) => [J, H]))
|
|
3059
3084
|
), ee = Math.max(0, ...W.values());
|
|
@@ -3066,155 +3091,155 @@ function At(e, t, s = !1, n, o) {
|
|
|
3066
3091
|
);
|
|
3067
3092
|
}
|
|
3068
3093
|
B = Math.min(Ni, Math.max(B, (G + 1) * (e.routing.edgeGap ?? 16)));
|
|
3069
|
-
function
|
|
3070
|
-
const j =
|
|
3094
|
+
function P(L) {
|
|
3095
|
+
const j = zt(e, L);
|
|
3071
3096
|
return j.algorithm === "row" ? "right" : j.algorithm === "column" ? "down" : nt(j);
|
|
3072
3097
|
}
|
|
3073
|
-
function L
|
|
3098
|
+
function R(L, j) {
|
|
3074
3099
|
const q = nt(j) === "right", W = Math.max(j.gap, ei), ee = /* @__PURE__ */ new Map();
|
|
3075
|
-
for (const Z of
|
|
3076
|
-
const Y = [...ee.keys()], H = (Z) => g.get(Z) ?? k.get(Z), J = (Z) => q ? H(Z).w : H(Z).h, se = (Z) => q ? H(Z).h : H(Z).w,
|
|
3100
|
+
for (const Z of L) for (const me of w.get(Z.id) ?? []) ee.set(me.id, Z.id);
|
|
3101
|
+
const Y = [...ee.keys()], H = (Z) => g.get(Z) ?? k.get(Z), J = (Z) => q ? H(Z).w : H(Z).h, se = (Z) => q ? H(Z).h : H(Z).w, pe = (Z) => {
|
|
3077
3102
|
let me = _.get(Z);
|
|
3078
3103
|
for (; me && !ee.has(me.id); ) me = _.get(me.parent);
|
|
3079
3104
|
return me?.id;
|
|
3080
|
-
}, ve = h.map((Z) => [
|
|
3081
|
-
let
|
|
3105
|
+
}, ve = h.map((Z) => [pe(Z.source), pe(Z.target)]).filter((Z) => !!Z[0] && !!Z[1] && Z[0] !== Z[1]), xe = Y.length ? xo(ht(Y, ve), ve) : [], Be = new Map(xe.flatMap((Z, me) => Z.map((ke) => [ke, me]))), Xe = xe.map((Z) => Math.max(...Z.map(J))), Re = [];
|
|
3106
|
+
let ze = 0;
|
|
3082
3107
|
for (const [Z, me] of xe.entries()) {
|
|
3083
|
-
|
|
3108
|
+
Re.push(ze);
|
|
3084
3109
|
let ke = W;
|
|
3085
3110
|
for (const Oe of e.edges) {
|
|
3086
|
-
const Ee = Be.get(
|
|
3111
|
+
const Ee = Be.get(pe(Oe.source) ?? ""), Ae = Be.get(pe(Oe.target) ?? "");
|
|
3087
3112
|
if (Oe.label && Ee !== void 0 && Ae !== void 0 && Math.min(Ee, Ae) === Z && Ee !== Ae) {
|
|
3088
3113
|
const _e = Bt("", "", Oe.label, l);
|
|
3089
3114
|
ke = Math.max(ke, q ? _e.w : _e.h);
|
|
3090
3115
|
}
|
|
3091
3116
|
}
|
|
3092
|
-
|
|
3117
|
+
ze += Xe[Z] + (me === xe.at(-1) ? 0 : ke);
|
|
3093
3118
|
}
|
|
3094
|
-
const Ie =
|
|
3095
|
-
for (const Z of
|
|
3119
|
+
const Ie = ze, mt = /* @__PURE__ */ new Map();
|
|
3120
|
+
for (const Z of L) {
|
|
3096
3121
|
const me = xe.map((Ee) => Ee.filter((Ae) => ee.get(Ae) === Z.id)), ke = (Ee) => Ee.reduce((Ae, _e, qe) => Ae + se(_e) + (qe ? Dn : 0), 0), Oe = Math.max(ti, ...me.map(ke));
|
|
3097
3122
|
mt.set(Z.id, Oe), me.forEach((Ee, Ae) => {
|
|
3098
3123
|
let _e = (Oe - ke(Ee)) / 2;
|
|
3099
3124
|
for (const qe of Ee) {
|
|
3100
|
-
const
|
|
3125
|
+
const ue = Re[Ae] + (Xe[Ae] - J(qe)) / 2, et = q ? { x: ue, y: _e } : { x: _e, y: ue };
|
|
3101
3126
|
S.set(qe, { x: re(et.x), y: re(et.y) }), D.set(qe, et), _e += se(qe) + Dn;
|
|
3102
3127
|
}
|
|
3103
3128
|
});
|
|
3104
3129
|
}
|
|
3105
|
-
const wt = (Z) => Math.ceil(ye(Z.label, l.groupTitle)) + Xt,
|
|
3130
|
+
const wt = (Z) => Math.ceil(ye(Z.label, l.groupTitle)) + Xt, Pe = Math.max(Ie + 2 * Se, ...L.map(wt));
|
|
3106
3131
|
let Ke = 0;
|
|
3107
|
-
for (const Z of
|
|
3132
|
+
for (const Z of L) {
|
|
3108
3133
|
const me = mt.get(Z.id);
|
|
3109
|
-
Z.w = q ?
|
|
3134
|
+
Z.w = q ? Pe : Math.max(me + 2 * Se, wt(Z)), Z.h = p + (q ? me : Ie) + Se;
|
|
3110
3135
|
const ke = q ? { x: 0, y: Ke } : { x: Ke, y: 0 };
|
|
3111
3136
|
S.set(Z.id, ke), D.set(Z.id, ke), Ke += (q ? Z.h : Z.w) + Nn;
|
|
3112
3137
|
}
|
|
3113
|
-
const
|
|
3114
|
-
return q ? { w:
|
|
3138
|
+
const Ue = Math.max(0, Ke - Nn);
|
|
3139
|
+
return q ? { w: L.length ? Pe : 0, h: Ue } : { w: Ue, h: L.length ? p + Ie + Se : 0 };
|
|
3115
3140
|
}
|
|
3116
|
-
function N(
|
|
3117
|
-
const q =
|
|
3141
|
+
function N(L, j) {
|
|
3142
|
+
const q = L.filter((H) => H.type === "node" && (H.shape === "box" || H.shape === "pill"));
|
|
3118
3143
|
if (q.length < 2) return;
|
|
3119
3144
|
const W = (H) => e.hints.some((J) => J.type === "size" && J.id === H.id), ee = Math.max(...q.map((H) => H.w)), Y = Math.max(...q.map((H) => j.get(H.id)?.ref.w ?? H.w));
|
|
3120
3145
|
for (const H of q) {
|
|
3121
3146
|
if (W(H) || H.w === ee) continue;
|
|
3122
3147
|
const J = Et(H, { width: ee }, l);
|
|
3123
3148
|
if (H.w = re(J.w), H.h = re(J.h), !j.get(H.id)) continue;
|
|
3124
|
-
const
|
|
3149
|
+
const pe = Et(H, { width: Y }, i);
|
|
3125
3150
|
j.set(H.id, {
|
|
3126
3151
|
look: { w: H.w, h: H.h },
|
|
3127
|
-
ref: { w: re(
|
|
3152
|
+
ref: { w: re(pe.w), h: re(pe.h) }
|
|
3128
3153
|
});
|
|
3129
3154
|
}
|
|
3130
3155
|
}
|
|
3131
|
-
function
|
|
3132
|
-
const j =
|
|
3133
|
-
let W = w.get(
|
|
3134
|
-
if (q?.type === "order" && (W = [...q.ids.flatMap((Q) => W.filter((K) => K.id === Q)), ...W.filter((Q) => !q.ids.includes(Q.id))]), j.algorithm === "cells") return I(
|
|
3135
|
-
const ee = /* @__PURE__ */ new Map(), Y = W.map((
|
|
3156
|
+
function U(L) {
|
|
3157
|
+
const j = zt(e, L), q = e.hints.find((z) => z.type === "order" && z.scope === L);
|
|
3158
|
+
let W = w.get(L) ?? [];
|
|
3159
|
+
if (q?.type === "order" && (W = [...q.ids.flatMap((Q) => W.filter((K) => K.id === Q)), ...W.filter((Q) => !q.ids.includes(Q.id))]), j.algorithm === "cells") return I(L, W, j);
|
|
3160
|
+
const ee = /* @__PURE__ */ new Map(), Y = W.map((z) => {
|
|
3136
3161
|
let Q;
|
|
3137
|
-
if (
|
|
3138
|
-
const ie = z
|
|
3162
|
+
if (z.type === "group") {
|
|
3163
|
+
const ie = U(z.id), ne = zt(e, z.id), ge = !w.get(z.id)?.length, de = f.get(z.id);
|
|
3139
3164
|
Q = de !== void 0 ? {
|
|
3140
3165
|
w: Math.max(ie.w, ne.minWidth),
|
|
3141
3166
|
h: Math.max(ie.h + de, ne.minHeight)
|
|
3142
3167
|
} : (() => {
|
|
3143
3168
|
const be = Math.max(
|
|
3144
|
-
ge ?
|
|
3145
|
-
ie.w + Se + (n?.get(
|
|
3169
|
+
ge ? Fn.w : 0,
|
|
3170
|
+
ie.w + Se + (n?.get(z.id)?.right ?? Se),
|
|
3146
3171
|
ne.minWidth
|
|
3147
|
-
), Ce = vi(
|
|
3148
|
-
return Ce.lines > 1 && a.set(
|
|
3172
|
+
), Ce = vi(z.label, be, l);
|
|
3173
|
+
return Ce.lines > 1 && a.set(z.id, Ce.lines), {
|
|
3149
3174
|
w: Math.max(be, Ce.w),
|
|
3150
3175
|
h: Math.max(
|
|
3151
|
-
ge ?
|
|
3152
|
-
ie.h + _t(l, Ce.lines) + (n?.get(
|
|
3176
|
+
ge ? Fn.h : 0,
|
|
3177
|
+
ie.h + _t(l, Ce.lines) + (n?.get(z.id)?.bottom ?? Se),
|
|
3153
3178
|
ne.minHeight
|
|
3154
3179
|
)
|
|
3155
3180
|
};
|
|
3156
3181
|
})();
|
|
3157
3182
|
} else {
|
|
3158
|
-
const ie = e.hints.find((ge) => ge.type === "size" && ge.id ===
|
|
3183
|
+
const ie = e.hints.find((ge) => ge.type === "size" && ge.id === z.id), ne = Et(z, ie?.type === "size" ? ie : void 0, l);
|
|
3159
3184
|
if (Q = ne, i !== l) {
|
|
3160
|
-
const ge = Et(
|
|
3161
|
-
ee.set(
|
|
3185
|
+
const ge = Et(z, ie?.type === "size" ? ie : void 0, i);
|
|
3186
|
+
ee.set(z.id, {
|
|
3162
3187
|
look: { w: re(ne.w), h: re(ne.h) },
|
|
3163
3188
|
ref: { w: re(ge.w), h: re(ge.h) }
|
|
3164
3189
|
});
|
|
3165
3190
|
}
|
|
3166
|
-
|
|
3191
|
+
z.shape === "diamond" && !ie && ne.w > io("diamond").w * Si && y.push({
|
|
3167
3192
|
level: "info",
|
|
3168
3193
|
code: "big-diamond",
|
|
3169
|
-
message: `${
|
|
3170
|
-
line:
|
|
3171
|
-
ids: [
|
|
3194
|
+
message: `${z.id}'s question makes its diamond ${re(ne.w)}px square, much larger than the shapes around it. Shorten the question, or move the detail onto its edges' labels.`,
|
|
3195
|
+
line: z.line,
|
|
3196
|
+
ids: [z.id]
|
|
3172
3197
|
}), ne.overflow && y.push({
|
|
3173
3198
|
level: "warning",
|
|
3174
3199
|
code: "text-overflow",
|
|
3175
|
-
message: `${
|
|
3200
|
+
message: `${z.id}'s title does not fit in its requested size. Make it larger or remove the size line.`,
|
|
3176
3201
|
line: ie?.line,
|
|
3177
|
-
ids: [
|
|
3202
|
+
ids: [z.id]
|
|
3178
3203
|
});
|
|
3179
3204
|
}
|
|
3180
|
-
const K = { ...
|
|
3181
|
-
return k.set(
|
|
3205
|
+
const K = { ...z, w: re(Q.w), h: re(Q.h) };
|
|
3206
|
+
return k.set(z.id, K), K;
|
|
3182
3207
|
});
|
|
3183
|
-
if (j.algorithm === "column" && N(Y, ee),
|
|
3184
|
-
const H = T(
|
|
3185
|
-
const Q = x(
|
|
3186
|
-
return !Q && !K || Q === K || !(Q && K) && !se ? [] : [{ a: Q, b: K, label:
|
|
3208
|
+
if (j.algorithm === "column" && N(Y, ee), L === "root" && j.algorithm === "lanes") return R(Y, j);
|
|
3209
|
+
const H = T(L), J = _.get(L)?.parent, se = J !== void 0 && P(J) === P(L), pe = (L === "root" ? [] : e.edges).flatMap((z) => {
|
|
3210
|
+
const Q = x(z.source, L), K = x(z.target, L);
|
|
3211
|
+
return !Q && !K || Q === K || !(Q && K) && !se ? [] : [{ a: Q, b: K, label: z.label && !(Q && K) ? Je(z.label, l) : void 0 }];
|
|
3187
3212
|
}), ve = /* @__PURE__ */ new Map();
|
|
3188
|
-
for (const
|
|
3189
|
-
const Q = x(
|
|
3190
|
-
Q && !K && ve.set(Q, [...ve.get(Q) ?? [],
|
|
3213
|
+
for (const z of h) {
|
|
3214
|
+
const Q = x(z.source, L), K = x(z.target, L);
|
|
3215
|
+
Q && !K && ve.set(Q, [...ve.get(Q) ?? [], z.target]), K && !Q && ve.set(K, [...ve.get(K) ?? [], z.source]);
|
|
3191
3216
|
}
|
|
3192
|
-
const xe = (
|
|
3193
|
-
const K = S.get(
|
|
3217
|
+
const xe = (z, Q) => {
|
|
3218
|
+
const K = S.get(z), ie = g.get(z) ?? k.get(z);
|
|
3194
3219
|
return Q ? K.y + ie.h / 2 : K.x + ie.w / 2;
|
|
3195
|
-
}, Be = /* @__PURE__ */ new Map(), Xe = _.get(
|
|
3196
|
-
if (Ie !== void 0 && Ie !==
|
|
3197
|
-
for (const [
|
|
3198
|
-
Be.set(Q.id, xe(
|
|
3199
|
-
const wt = (
|
|
3200
|
-
if ($.get(Q) !==
|
|
3201
|
-
const K =
|
|
3202
|
-
(de) => _.get(de.source)?.parent ===
|
|
3220
|
+
}, Be = /* @__PURE__ */ new Map(), Xe = _.get(L)?.parent, Re = Xe !== void 0 && w.get(Xe) || [], ze = Y.map((z) => ve.get(z.id) ?? []), Ie = ze[0]?.length === 1 ? _.get(ze[0][0])?.parent : void 0, mt = Re.findIndex((z) => z.id === Ie) < Re.findIndex((z) => z.id === L);
|
|
3221
|
+
if (Ie !== void 0 && Ie !== L && Re.some((z) => z.id === Ie) && mt && ze.every((z) => z.length === 1 && _.get(z[0])?.parent === Ie && S.has(z[0])))
|
|
3222
|
+
for (const [z, Q] of Y.entries())
|
|
3223
|
+
Be.set(Q.id, xe(ze[z][0], P(Ie) === "right"));
|
|
3224
|
+
const wt = (z, Q) => {
|
|
3225
|
+
if ($.get(Q) !== z) return;
|
|
3226
|
+
const K = P(L) === "right", ie = (de) => K ? _t(l, a.get(de)) : Se, ge = e.edges.filter(
|
|
3227
|
+
(de) => _.get(de.source)?.parent === z && _.get(de.target)?.parent === Q
|
|
3203
3228
|
).sort((de, be) => xe(de.target, K) - xe(be.target, K))[0];
|
|
3204
|
-
return ge ? ie(
|
|
3205
|
-
},
|
|
3206
|
-
const Q = x(
|
|
3207
|
-
if (!
|
|
3208
|
-
const ie = Bt(Q, K,
|
|
3229
|
+
return ge ? ie(z) + xe(ge.source, K) - ie(Q) - xe(ge.target, K) : void 0;
|
|
3230
|
+
}, Pe = e.edges.flatMap((z) => {
|
|
3231
|
+
const Q = x(z.source, L), K = x(z.target, L);
|
|
3232
|
+
if (!z.label || !Q || !K || Q === K) return [];
|
|
3233
|
+
const ie = Bt(Q, K, z.label, l);
|
|
3209
3234
|
if (i === l) return [ie];
|
|
3210
|
-
const ne = Bt(Q, K,
|
|
3211
|
-
return [{ a: Q, b: K, w: Math.max(ne.w, ie.w -
|
|
3212
|
-
}), Ke = t,
|
|
3213
|
-
|
|
3214
|
-
Y.map((
|
|
3235
|
+
const ne = Bt(Q, K, z.label, i);
|
|
3236
|
+
return [{ a: Q, b: K, w: Math.max(ne.w, ie.w - Fe), h: Math.max(ne.h, ie.h - Fe) }];
|
|
3237
|
+
}), Ke = t, Ue = X(L), Z = Ue ? { node: Ue.nodeGap, rank: Ue.rankGap, group: B } : void 0, me = Ue ? F(
|
|
3238
|
+
L,
|
|
3239
|
+
Y.map((z) => z.id),
|
|
3215
3240
|
H
|
|
3216
|
-
) : void 0, ke = (
|
|
3217
|
-
const K = j.algorithm === "row" ? "right" : j.algorithm === "column" ? "down" :
|
|
3241
|
+
) : void 0, ke = (z, Q) => {
|
|
3242
|
+
const K = j.algorithm === "row" ? "right" : j.algorithm === "column" ? "down" : z, ie = {
|
|
3218
3243
|
x: K === "right",
|
|
3219
3244
|
y: K === "down"
|
|
3220
3245
|
}, ne = (de) => s ? de : ee.get(de.id)?.look ?? de, ge = /* @__PURE__ */ new Map();
|
|
@@ -3232,10 +3257,10 @@ function At(e, t, s = !1, n, o) {
|
|
|
3232
3257
|
];
|
|
3233
3258
|
})
|
|
3234
3259
|
);
|
|
3235
|
-
}, Oe = (
|
|
3260
|
+
}, Oe = (z) => {
|
|
3236
3261
|
for (const ce of Y) {
|
|
3237
3262
|
const Te = ee.get(ce.id);
|
|
3238
|
-
Te && (ce.w = Math.max(Te.ref.w, Te.look.w -
|
|
3263
|
+
Te && (ce.w = Math.max(Te.ref.w, Te.look.w - z.w), ce.h = Math.max(Te.ref.h, Te.look.h - z.h));
|
|
3239
3264
|
}
|
|
3240
3265
|
const Q = (ce) => Z ? Ci(
|
|
3241
3266
|
Y,
|
|
@@ -3244,12 +3269,12 @@ function At(e, t, s = !1, n, o) {
|
|
|
3244
3269
|
me,
|
|
3245
3270
|
ce,
|
|
3246
3271
|
Z,
|
|
3247
|
-
|
|
3248
|
-
|
|
3272
|
+
L === "root",
|
|
3273
|
+
pe,
|
|
3249
3274
|
ve,
|
|
3250
3275
|
Be,
|
|
3251
3276
|
wt
|
|
3252
|
-
) :
|
|
3277
|
+
) : zi(Y, j, H, ce, pe, c), K = Pe.length ? Q([]) : void 0, ie = K ? Di(
|
|
3253
3278
|
new Map(
|
|
3254
3279
|
Y.map((ce) => {
|
|
3255
3280
|
const Te = K.positions.get(ce.id), yt = ke(K.axis, K.positions).get(ce.id);
|
|
@@ -3257,96 +3282,96 @@ function At(e, t, s = !1, n, o) {
|
|
|
3257
3282
|
})
|
|
3258
3283
|
),
|
|
3259
3284
|
K.axis,
|
|
3260
|
-
|
|
3261
|
-
) : /* @__PURE__ */ new Set(), ne = Q(
|
|
3285
|
+
Pe
|
|
3286
|
+
) : /* @__PURE__ */ new Set(), ne = Q(Pe.filter((ce) => !ie.has(ce)));
|
|
3262
3287
|
let ge;
|
|
3263
3288
|
if (j.algorithm === "flow" && j.fold === "auto") {
|
|
3264
|
-
const ce =
|
|
3289
|
+
const ce = Ut(
|
|
3265
3290
|
Y,
|
|
3266
3291
|
ne.positions,
|
|
3267
3292
|
ne.axis,
|
|
3268
3293
|
j.gap,
|
|
3269
3294
|
H,
|
|
3270
|
-
|
|
3271
|
-
b(
|
|
3295
|
+
Pe,
|
|
3296
|
+
b(L),
|
|
3272
3297
|
(K ?? ne).positions
|
|
3273
3298
|
);
|
|
3274
3299
|
ne.positions = ce.positions, ge = ce.fold;
|
|
3275
3300
|
}
|
|
3276
|
-
const de = !ge &&
|
|
3277
|
-
if (de && A.has(
|
|
3278
|
-
const ce =
|
|
3301
|
+
const de = !ge && Ue && Ke?.engine?.params.fold !== "never";
|
|
3302
|
+
if (de && A.has(L)) {
|
|
3303
|
+
const ce = Ut(
|
|
3279
3304
|
Y,
|
|
3280
3305
|
ne.positions,
|
|
3281
3306
|
ne.axis,
|
|
3282
3307
|
Z.rank,
|
|
3283
3308
|
H,
|
|
3284
|
-
|
|
3285
|
-
b(
|
|
3309
|
+
Pe,
|
|
3310
|
+
b(L),
|
|
3286
3311
|
(K ?? ne).positions,
|
|
3287
3312
|
{ fewest: 2, room: 0 }
|
|
3288
3313
|
);
|
|
3289
3314
|
ne.positions = ce.positions, ge = ce.fold;
|
|
3290
3315
|
}
|
|
3291
|
-
if (de &&
|
|
3292
|
-
const ce =
|
|
3316
|
+
if (de && L === "root" && m) {
|
|
3317
|
+
const ce = Ut(
|
|
3293
3318
|
Y,
|
|
3294
3319
|
ne.positions,
|
|
3295
3320
|
ne.axis,
|
|
3296
3321
|
Z.rank,
|
|
3297
3322
|
H,
|
|
3298
|
-
|
|
3299
|
-
b(
|
|
3323
|
+
Pe,
|
|
3324
|
+
b(L),
|
|
3300
3325
|
(K ?? ne).positions,
|
|
3301
3326
|
{ aspect: Gn, fewest: 2 }
|
|
3302
3327
|
);
|
|
3303
3328
|
ne.positions = ce.positions, ge = ce.fold;
|
|
3304
3329
|
}
|
|
3305
|
-
const be = n?.get(
|
|
3330
|
+
const be = n?.get(L);
|
|
3306
3331
|
if (be && (be.left > Se || be.top))
|
|
3307
3332
|
for (const [ce, Te] of ne.positions)
|
|
3308
3333
|
ne.positions.set(ce, { x: Te.x + be.left - Se, y: Te.y + be.top });
|
|
3309
3334
|
const Ce = ke(ne.axis, ne.positions), Ao = ee.size ? e.hints.map(
|
|
3310
3335
|
(ce) => (ce.type === "stay" || ce.type === "pin") && Ce.has(ce.id) ? { ...ce, x: ce.x - Ce.get(ce.id).x, y: ce.y - Ce.get(ce.id).y } : ce
|
|
3311
|
-
) : e.hints, So = Yi(Y, ne.positions, Ao,
|
|
3312
|
-
return "followed" in ne && ne.followed ? $.set(
|
|
3313
|
-
}, Ee = (
|
|
3314
|
-
const K = Q.pos.get(
|
|
3336
|
+
) : e.hints, So = Yi(Y, ne.positions, Ao, L, y, ne.axis);
|
|
3337
|
+
return "followed" in ne && ne.followed ? $.set(L, Ie) : $.delete(L), { base: ne, fold: ge, pos: So, off: Ce };
|
|
3338
|
+
}, Ee = (z, Q) => {
|
|
3339
|
+
const K = Q.pos.get(z.id), ie = Q.off.get(z.id);
|
|
3315
3340
|
return { x: K.x + ie.x, y: K.y + ie.y, w: ie.w, h: ie.h };
|
|
3316
|
-
}, Ae = (
|
|
3317
|
-
...Q.pos.get(
|
|
3318
|
-
w:
|
|
3319
|
-
h:
|
|
3341
|
+
}, Ae = (z, Q) => ({
|
|
3342
|
+
...Q.pos.get(z.id),
|
|
3343
|
+
w: z.w,
|
|
3344
|
+
h: z.h
|
|
3320
3345
|
}), _e = ee.size ? { w: Wn(j.gap), h: Wn(j.gap) } : { w: 0, h: 0 }, qe = y.length;
|
|
3321
|
-
let
|
|
3346
|
+
let ue = Oe(_e);
|
|
3322
3347
|
!s && (_e.w || _e.h) && Y.some(
|
|
3323
|
-
(
|
|
3324
|
-
(K) =>
|
|
3348
|
+
(z, Q) => Y.slice(Q + 1).some(
|
|
3349
|
+
(K) => Pn(Ae(z, ue), Ae(K, ue)) >= ft - 0.5 && Pn(Ee(z, ue), Ee(K, ue)) < ft - 0.5
|
|
3325
3350
|
)
|
|
3326
|
-
) && (y.length = qe,
|
|
3327
|
-
const et =
|
|
3328
|
-
et &&
|
|
3329
|
-
const Q =
|
|
3351
|
+
) && (y.length = qe, ue = Oe({ w: 0, h: 0 })), ue.fold && E.push({ scope: L, fold: ue.fold });
|
|
3352
|
+
const et = ue.base.corridors;
|
|
3353
|
+
et && L === "root" && !ue.fold && !n?.get(L) && Y.every((z) => {
|
|
3354
|
+
const Q = ue.pos.get(z.id), K = ue.base.positions.get(z.id);
|
|
3330
3355
|
return Q && K && Math.abs(Q.x - K.x) < 0.01 && Math.abs(Q.y - K.y) < 0.01;
|
|
3331
|
-
}) &&
|
|
3332
|
-
const at = Y.map((
|
|
3333
|
-
x: Math.max(0, -Math.min(...at.map((
|
|
3334
|
-
y: Math.max(0, -Math.min(...at.map((
|
|
3356
|
+
}) && u.set(L, { axis: ue.base.axis, corridors: et }), j.algorithm === "flow" && v.push({ scope: L, axis: ue.base.axis });
|
|
3357
|
+
const at = Y.map((z) => Ee(z, ue)), Ft = L === "root" ? 0 : Math.max(0, ...Y.map((z) => z.soft?.length ?? 0)), rt = L === "root" || !Y.length ? { x: 0, y: 0 } : {
|
|
3358
|
+
x: Math.max(0, -Math.min(...at.map((z) => z.x))) + Ft * dt,
|
|
3359
|
+
y: Math.max(0, -Math.min(...at.map((z) => z.y))) + Ft * (dt + Rt)
|
|
3335
3360
|
};
|
|
3336
|
-
for (const [
|
|
3337
|
-
const K = at[
|
|
3361
|
+
for (const [z, Q] of Y.entries()) {
|
|
3362
|
+
const K = at[z], ie = ue.off.get(Q.id), ne = ue.base.positions.get(Q.id);
|
|
3338
3363
|
S.set(Q.id, { x: re(K.x + rt.x), y: re(K.y + rt.y) }), D.set(Q.id, { x: ne.x + ie.x + rt.x, y: ne.y + ie.y + rt.y }), ee.has(Q.id) && g.set(Q.id, { w: re(K.w), h: re(K.h) });
|
|
3339
3364
|
}
|
|
3340
|
-
const rn = (
|
|
3365
|
+
const rn = (z, Q) => Y.length ? Math.max(
|
|
3341
3366
|
...Y.map(
|
|
3342
|
-
(K, ie) => Math.max(
|
|
3367
|
+
(K, ie) => Math.max(ue.pos.get(K.id)[z] + K[Q], at[ie][z] + at[ie][Q])
|
|
3343
3368
|
)
|
|
3344
|
-
) + rt[
|
|
3369
|
+
) + rt[z] + Ft * dt : 0;
|
|
3345
3370
|
return { w: rn("x", "w"), h: rn("y", "h") };
|
|
3346
3371
|
}
|
|
3347
|
-
function I(
|
|
3348
|
-
if (q.unit) return O(
|
|
3349
|
-
const W = Math.ceil(ye(_.get(
|
|
3372
|
+
function I(L, j, q) {
|
|
3373
|
+
if (q.unit) return O(L, j, q);
|
|
3374
|
+
const W = Math.ceil(ye(_.get(L).label, l.groupTitle)) + Xo, ee = (H) => e.hints.find((J) => J.type === "size" && J.id === H), Y = is(
|
|
3350
3375
|
j.map((H) => {
|
|
3351
3376
|
const J = ee(H.id);
|
|
3352
3377
|
return {
|
|
@@ -3364,9 +3389,9 @@ function At(e, t, s = !1, n, o) {
|
|
|
3364
3389
|
l,
|
|
3365
3390
|
W
|
|
3366
3391
|
);
|
|
3367
|
-
return C(
|
|
3392
|
+
return C(L, j, Y.boxes), f.set(L, Qt(l.groupTitle.lineHeight)), { w: Math.max(Y.w, W), h: Y.h };
|
|
3368
3393
|
}
|
|
3369
|
-
function O(
|
|
3394
|
+
function O(L, j, q) {
|
|
3370
3395
|
const W = cs(
|
|
3371
3396
|
j.map((H) => ({
|
|
3372
3397
|
id: H.id,
|
|
@@ -3383,7 +3408,7 @@ function At(e, t, s = !1, n, o) {
|
|
|
3383
3408
|
},
|
|
3384
3409
|
l
|
|
3385
3410
|
), ee = Qt(l.groupTitle.lineHeight), Y = ee + (W.ruler?.h ?? 0);
|
|
3386
|
-
return C(
|
|
3411
|
+
return C(L, j, W.boxes), f.set(L, Y), M.set(L, {
|
|
3387
3412
|
...W.ruler ? { ruler: { y: ee, ...W.ruler } } : {},
|
|
3388
3413
|
...W.pieces.size ? {
|
|
3389
3414
|
pieces: Object.fromEntries(
|
|
@@ -3393,7 +3418,7 @@ function At(e, t, s = !1, n, o) {
|
|
|
3393
3418
|
...W.open.length ? { open: W.open } : {}
|
|
3394
3419
|
}), { w: W.w, h: W.h };
|
|
3395
3420
|
}
|
|
3396
|
-
function C(
|
|
3421
|
+
function C(L, j, q) {
|
|
3397
3422
|
for (const W of j) {
|
|
3398
3423
|
const ee = q.get(W.id);
|
|
3399
3424
|
k.set(W.id, { ...W, w: re(ee.w), h: re(ee.h) }), S.set(W.id, { x: re(ee.x), y: re(ee.y) }), D.set(W.id, { x: ee.x, y: ee.y });
|
|
@@ -3403,41 +3428,41 @@ function At(e, t, s = !1, n, o) {
|
|
|
3403
3428
|
Y && y.push({
|
|
3404
3429
|
level: "warning",
|
|
3405
3430
|
code: "cell-position",
|
|
3406
|
-
message: `${W.id} is a cell of ${
|
|
3431
|
+
message: `${W.id} is a cell of ${L}, so it stays in its place. Move ${L} instead, or reorder its cells with order.`,
|
|
3407
3432
|
line: Y.line,
|
|
3408
3433
|
ids: [W.id]
|
|
3409
3434
|
});
|
|
3410
3435
|
}
|
|
3411
3436
|
}
|
|
3412
3437
|
const V = y.length, oe = X("root") && Mi(e, "root");
|
|
3413
|
-
let ae =
|
|
3438
|
+
let ae = U("root");
|
|
3414
3439
|
if (!o && oe && oe.engine?.params.fold !== "never") {
|
|
3415
|
-
let
|
|
3440
|
+
let L = function(H) {
|
|
3416
3441
|
return q(H) > yo * W(H);
|
|
3417
3442
|
};
|
|
3418
3443
|
const j = nt(oe) === "right", q = (H) => j ? H.w : H.h, W = (H) => j ? H.h : H.w, ee = j ? $t.width : $t.height, Y = (H) => q(H) > ee && q(H) > Gn * W(H);
|
|
3419
3444
|
for (; Y(ae) && !m; ) {
|
|
3420
3445
|
const H = [...k.values()].filter(
|
|
3421
|
-
(J) => J.type === "group" && !A.has(J.id) && X(J.id) &&
|
|
3446
|
+
(J) => J.type === "group" && !A.has(J.id) && X(J.id) && L(J)
|
|
3422
3447
|
).sort((J, se) => q(se) - q(J))[0];
|
|
3423
|
-
H ? A.add(H.id) : m = !0, y.length = V, E.length = v.length = 0, g.clear(), ae =
|
|
3448
|
+
H ? A.add(H.id) : m = !0, y.length = V, E.length = v.length = 0, g.clear(), ae = U("root");
|
|
3424
3449
|
}
|
|
3425
3450
|
}
|
|
3426
3451
|
if (!o && oe && nt(oe) === "down" && oe.engine?.params.fold !== "never") {
|
|
3427
|
-
const
|
|
3452
|
+
const L = (q) => q.h, j = (q) => q.w * q.h;
|
|
3428
3453
|
for (; ; ) {
|
|
3429
|
-
const q = (w.get("root") ?? []).map((H) => k.get(H.id)).filter(Boolean).sort((H, J) =>
|
|
3430
|
-
if (!W || !ee || W.type !== "group" || W.fold === "never" || A.has(W.id) || !X(W.id) ||
|
|
3454
|
+
const q = (w.get("root") ?? []).map((H) => k.get(H.id)).filter(Boolean).sort((H, J) => L(J) - L(H)), [W, ee] = q;
|
|
3455
|
+
if (!W || !ee || W.type !== "group" || W.fold === "never" || A.has(W.id) || !X(W.id) || L(W) < ki * L(ee))
|
|
3431
3456
|
break;
|
|
3432
3457
|
const Y = ae;
|
|
3433
|
-
if (A.add(W.id), y.length = V, E.length = v.length = 0, g.clear(), ae =
|
|
3434
|
-
A.delete(W.id), y.length = V, E.length = v.length = 0, g.clear(),
|
|
3458
|
+
if (A.add(W.id), y.length = V, E.length = v.length = 0, g.clear(), ae = U("root"), !(j(ae) < j(Y))) {
|
|
3459
|
+
A.delete(W.id), y.length = V, E.length = v.length = 0, g.clear(), U("root");
|
|
3435
3460
|
break;
|
|
3436
3461
|
}
|
|
3437
3462
|
}
|
|
3438
3463
|
}
|
|
3439
|
-
const le = [], he = (
|
|
3440
|
-
for (const W of w.get(
|
|
3464
|
+
const le = [], he = (L, j, q) => {
|
|
3465
|
+
for (const W of w.get(L) ?? []) {
|
|
3441
3466
|
const ee = g.get(W.id) ?? k.get(W.id), Y = S.get(W.id), H = D.get(W.id), J = {
|
|
3442
3467
|
...W,
|
|
3443
3468
|
x: j.x + Y.x,
|
|
@@ -3459,43 +3484,43 @@ function At(e, t, s = !1, n, o) {
|
|
|
3459
3484
|
}
|
|
3460
3485
|
};
|
|
3461
3486
|
he("root", { x: 0, y: 0 }, 0);
|
|
3462
|
-
const we = Ki(
|
|
3487
|
+
const we = Ki(u, le, h, x, c), fe = Ri(
|
|
3463
3488
|
E,
|
|
3464
3489
|
e.edges,
|
|
3465
|
-
new Map(le.map((
|
|
3490
|
+
new Map(le.map((L) => [L.id, L])),
|
|
3466
3491
|
x,
|
|
3467
3492
|
Math.max(e.routing.portGap ?? 16, e.routing.edgeGap ?? 16)
|
|
3468
3493
|
);
|
|
3469
|
-
for (const [
|
|
3494
|
+
for (const [L, j] of ks(
|
|
3470
3495
|
v.map((q) => ({ ...q, bands: E.find((W) => W.scope === q.scope)?.fold.bands })),
|
|
3471
3496
|
e.edges,
|
|
3472
3497
|
new Map(le.map((q) => [q.id, q])),
|
|
3473
3498
|
new Set(fe.keys()),
|
|
3474
3499
|
(q) => Je(q, l)
|
|
3475
3500
|
))
|
|
3476
|
-
fe.set(
|
|
3477
|
-
for (const
|
|
3478
|
-
const j = le.find((q) => q.id ===
|
|
3479
|
-
!j || !
|
|
3501
|
+
fe.set(L, j);
|
|
3502
|
+
for (const L of e.layouts) {
|
|
3503
|
+
const j = le.find((q) => q.id === L.scope);
|
|
3504
|
+
!j || !L.minWidth && !L.minHeight || (L.minWidth && j.w > L.minWidth + 0.5 || L.minHeight && j.h > L.minHeight + 0.5) && y.push({
|
|
3480
3505
|
level: "info",
|
|
3481
3506
|
code: "group-grew",
|
|
3482
3507
|
message: `${j.id} needs at least ${j.w}×${j.h} for its contents.`,
|
|
3483
|
-
line:
|
|
3508
|
+
line: L.line,
|
|
3484
3509
|
ids: [j.id]
|
|
3485
3510
|
});
|
|
3486
3511
|
}
|
|
3487
|
-
|
|
3488
|
-
for (const
|
|
3489
|
-
const te = new Map(e.objects.map((
|
|
3490
|
-
le.sort((
|
|
3512
|
+
Ps(e), y.push(...yi(e), ...$s(e));
|
|
3513
|
+
for (const L of e.warnings) y.push({ level: "warning", ...L, ids: [] });
|
|
3514
|
+
const te = new Map(e.objects.map((L, j) => [L.id, j]));
|
|
3515
|
+
le.sort((L, j) => te.get(L.id) - te.get(j.id));
|
|
3491
3516
|
const Me = {
|
|
3492
3517
|
model: e,
|
|
3493
3518
|
title: e.title,
|
|
3494
3519
|
objects: le,
|
|
3495
|
-
byId: new Map(le.map((
|
|
3496
|
-
edges: e.edges.map((
|
|
3497
|
-
const j = fe.get(
|
|
3498
|
-
return j ? { ...
|
|
3520
|
+
byId: new Map(le.map((L) => [L.id, L])),
|
|
3521
|
+
edges: e.edges.map((L) => {
|
|
3522
|
+
const j = fe.get(L.id), q = j ? void 0 : we.get(L.id);
|
|
3523
|
+
return j ? { ...L, lane: j } : q ? { ...L, plan: q } : L;
|
|
3499
3524
|
}),
|
|
3500
3525
|
diagnostics: y,
|
|
3501
3526
|
look: l,
|
|
@@ -3509,13 +3534,13 @@ function Ki(e, t, s, n, o) {
|
|
|
3509
3534
|
const w = s.filter((i) => {
|
|
3510
3535
|
const g = n(i.source, h), f = n(i.target, h);
|
|
3511
3536
|
return !!g && !!f && g !== f;
|
|
3512
|
-
}), l = new Map(y.order.flatMap((i, g) => i.map((f) => [f, g]))),
|
|
3537
|
+
}), l = new Map(y.order.flatMap((i, g) => i.map((f) => [f, g]))), p = (i) => {
|
|
3513
3538
|
const g = d.get(i);
|
|
3514
3539
|
return !!g && g.type === "node" && (g.shape ?? "box") === "box";
|
|
3515
3540
|
}, a = [];
|
|
3516
3541
|
for (const [i, g] of w.entries()) {
|
|
3517
3542
|
const f = g.source, M = g.target;
|
|
3518
|
-
n(f, h) !== f || n(M, h) !== M || !
|
|
3543
|
+
n(f, h) !== f || n(M, h) !== M || !p(f) || !p(M) || l.get(f) < l.get(M) && a.push({ id: g.id, chain: [f, ...y.chains.get(i) ?? [], M] });
|
|
3519
3544
|
}
|
|
3520
3545
|
for (const [i, g] of Ss(
|
|
3521
3546
|
c,
|
|
@@ -3601,30 +3626,30 @@ function Eo(e, t, s, n, o) {
|
|
|
3601
3626
|
const l = s.edges.some((i) => !i.directed) ? ["IMP-02-native-undirected"] : [];
|
|
3602
3627
|
if (n.some((i) => i.severity === "error"))
|
|
3603
3628
|
return { status: "failed", format: e, family: t, diagnostics: n, ids: o.entries, requires: l };
|
|
3604
|
-
const
|
|
3629
|
+
const p = ["diagram " + He(s.title) + " version=1"];
|
|
3605
3630
|
for (const i of s.colors)
|
|
3606
|
-
|
|
3631
|
+
p.push(
|
|
3607
3632
|
"theme-color " + i.name + " shade=500 fill=" + He(i.fill) + " stroke=" + He(i.stroke) + " ink=" + He(i.ink)
|
|
3608
3633
|
);
|
|
3609
3634
|
for (const i of s.objects) {
|
|
3610
3635
|
let g = i.kind + " " + i.id + " " + He(i.label);
|
|
3611
|
-
i.parent && (g += " in=" + i.parent), i.shape && i.shape !== "box" && i.kind === "node" && (g += " shape=" + i.shape), i.color && (g += " color=" + i.color + " shade=" + (i.shade ?? 500)),
|
|
3636
|
+
i.parent && (g += " in=" + i.parent), i.shape && i.shape !== "box" && i.kind === "node" && (g += " shape=" + i.shape), i.color && (g += " color=" + i.color + " shade=" + (i.shade ?? 500)), p.push(g);
|
|
3612
3637
|
}
|
|
3613
3638
|
for (const i of s.edges) {
|
|
3614
3639
|
let g = "edge " + i.id + " " + i.from + " -> " + i.to + " " + He(i.label);
|
|
3615
|
-
i.directed || (g += " directed=false"), i.head && i.head !== "arrow" && (g += " head=" + i.head), i.tail && i.tail !== "none" && (g += " tail=" + i.tail), i.dashed && (g += " kind=async"), i.constraint === !1 && (g += " constraint=false"), i.fromSide && (g += " from=" + i.fromSide), i.toSide && (g += " to=" + i.toSide),
|
|
3640
|
+
i.directed || (g += " directed=false"), i.head && i.head !== "arrow" && (g += " head=" + i.head), i.tail && i.tail !== "none" && (g += " tail=" + i.tail), i.dashed && (g += " kind=async"), i.constraint === !1 && (g += " constraint=false"), i.fromSide && (g += " from=" + i.fromSide), i.toSide && (g += " to=" + i.toSide), p.push(g);
|
|
3616
3641
|
}
|
|
3617
3642
|
for (const i of s.layouts)
|
|
3618
|
-
|
|
3643
|
+
p.push(
|
|
3619
3644
|
"layout " + i.scope + " " + i.kind + (i.direction ? " direction=" + i.direction : "")
|
|
3620
3645
|
);
|
|
3621
3646
|
for (const i of s.phases ?? [])
|
|
3622
|
-
|
|
3647
|
+
p.push(["phase", i.id, He(i.label), ...i.members].join(" "));
|
|
3623
3648
|
for (const i of s.notes ?? []) {
|
|
3624
3649
|
let g = "note " + He(i.text);
|
|
3625
|
-
i.near && (g += " near=" + i.near), i.side && (g += " side=" + i.side),
|
|
3650
|
+
i.near && (g += " near=" + i.near), i.side && (g += " side=" + i.side), p.push(g);
|
|
3626
3651
|
}
|
|
3627
|
-
const a =
|
|
3652
|
+
const a = p.join(`
|
|
3628
3653
|
`) + `
|
|
3629
3654
|
`;
|
|
3630
3655
|
return a.length > De.nativeSourceChars && r(
|
|
@@ -3709,7 +3734,7 @@ function ea(e, t, s, n) {
|
|
|
3709
3734
|
"create and destroy are omitted: native participants span the whole diagram."
|
|
3710
3735
|
), o.layouts.push({ scope: "root", kind: "sequence" });
|
|
3711
3736
|
const w = [], l = [];
|
|
3712
|
-
let
|
|
3737
|
+
let p = 0, a, i;
|
|
3713
3738
|
const g = (M, k) => {
|
|
3714
3739
|
const S = t(k).trim();
|
|
3715
3740
|
a = {
|
|
@@ -3727,7 +3752,7 @@ function ea(e, t, s, n) {
|
|
|
3727
3752
|
};
|
|
3728
3753
|
for (const [M, k] of e.events.entries())
|
|
3729
3754
|
if (Xn[k.kind])
|
|
3730
|
-
|
|
3755
|
+
p++, p === 1 ? g(Xn[k.kind], k.text) : h(
|
|
3731
3756
|
"MERMAID_SEQUENCE_NESTED_BLOCK",
|
|
3732
3757
|
"A nested block has no band of its own; its messages stay in the outer band."
|
|
3733
3758
|
), h(
|
|
@@ -3735,9 +3760,9 @@ function ea(e, t, s, n) {
|
|
|
3735
3760
|
"Native sequences have no fragments. Each block branch becomes a phase band, so the branch logic is only in its label."
|
|
3736
3761
|
);
|
|
3737
3762
|
else if (Kn[k.kind])
|
|
3738
|
-
|
|
3763
|
+
p === 1 && g(Kn[k.kind], k.text);
|
|
3739
3764
|
else if (Ji.includes(k.kind))
|
|
3740
|
-
|
|
3765
|
+
p--, p || (a = void 0);
|
|
3741
3766
|
else if (k.kind === "NOTE") f(k);
|
|
3742
3767
|
else if (k.kind === "ACTIVE_START" || k.kind === "ACTIVE_END")
|
|
3743
3768
|
h("MERMAID_SEQUENCE_ACTIVATION", "Activation bars are omitted.", "appearance");
|
|
@@ -3821,7 +3846,7 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
3821
3846
|
M
|
|
3822
3847
|
]);
|
|
3823
3848
|
}
|
|
3824
|
-
}, l = new Map(c.classes.map((f) => [f.id, f])),
|
|
3849
|
+
}, l = new Map(c.classes.map((f) => [f.id, f])), p = (f, M, k, S) => {
|
|
3825
3850
|
const D = [];
|
|
3826
3851
|
for (const _ of [...k ? ["default", "node"] : [], ...f]) {
|
|
3827
3852
|
const $ = l.get(_);
|
|
@@ -3945,8 +3970,8 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
3945
3970
|
let v = x;
|
|
3946
3971
|
for (; v && !E.has(v); ) {
|
|
3947
3972
|
E.add(v);
|
|
3948
|
-
const
|
|
3949
|
-
if (
|
|
3973
|
+
const u = _.get(v);
|
|
3974
|
+
if (u) return u;
|
|
3950
3975
|
v = S.get(v);
|
|
3951
3976
|
}
|
|
3952
3977
|
return D ?? "down";
|
|
@@ -3955,7 +3980,7 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
3955
3980
|
const E = k.get(x.id), v = M.get(x.id);
|
|
3956
3981
|
a(
|
|
3957
3982
|
E,
|
|
3958
|
-
|
|
3983
|
+
p([...x.classes, ...v?.classes ?? []], v?.styles ?? [], !1, x.id),
|
|
3959
3984
|
x.id
|
|
3960
3985
|
), n.layouts.push({
|
|
3961
3986
|
scope: E.id,
|
|
@@ -3983,7 +4008,7 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
3983
4008
|
}
|
|
3984
4009
|
for (const x of c.vertices) {
|
|
3985
4010
|
const E = k.get(x.id);
|
|
3986
|
-
f.has(x.id) || a(E,
|
|
4011
|
+
f.has(x.id) || a(E, p(x.classes, x.styles, !0, x.id), x.id), x.link && d(
|
|
3987
4012
|
"MERMAID_LINK_OMITTED",
|
|
3988
4013
|
"External link was omitted; the native object has no active link.",
|
|
3989
4014
|
"security",
|
|
@@ -4036,8 +4061,8 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
4036
4061
|
);
|
|
4037
4062
|
continue;
|
|
4038
4063
|
}
|
|
4039
|
-
const
|
|
4040
|
-
if (!
|
|
4064
|
+
const u = k.get(E.start), A = k.get(E.end);
|
|
4065
|
+
if (!u || !A) {
|
|
4041
4066
|
d("MERMAID_ENDPOINT", "A parsed edge has a missing endpoint.", "semantics", "error", [
|
|
4042
4067
|
E.start,
|
|
4043
4068
|
E.end
|
|
@@ -4047,7 +4072,7 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
4047
4072
|
const m = E.isUserDefinedId && E.id ? o.get("edge-id", E.id, E.id) : o.get("edge-occurrence", String(x + 1), "edge_" + (x + 1)), b = E.id ?? String(x + 1);
|
|
4048
4073
|
n.edges.push({
|
|
4049
4074
|
id: m,
|
|
4050
|
-
from:
|
|
4075
|
+
from: u.id,
|
|
4051
4076
|
to: A.id,
|
|
4052
4077
|
label: y(E.text, E.labelType, b),
|
|
4053
4078
|
directed: E.type !== "arrow_open",
|
|
@@ -4080,7 +4105,7 @@ function na(e, t, s = "Imported Mermaid") {
|
|
|
4080
4105
|
"warning",
|
|
4081
4106
|
[b]
|
|
4082
4107
|
);
|
|
4083
|
-
const T =
|
|
4108
|
+
const T = p(
|
|
4084
4109
|
E.classes,
|
|
4085
4110
|
[...c.defaultEdgeStyle, ...E.style],
|
|
4086
4111
|
!1,
|