schematex 0.2.5 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/ai/ai-sdk.cjs +25 -25
- package/dist/ai/ai-sdk.d.cts +2 -2
- package/dist/ai/ai-sdk.d.ts +2 -2
- package/dist/ai/ai-sdk.js +20 -20
- package/dist/ai/index.cjs +28 -28
- package/dist/ai/index.d.cts +3 -3
- package/dist/ai/index.d.ts +3 -3
- package/dist/ai/index.js +20 -20
- package/dist/{api-bQZ98gkJ.d.cts → api-BuFilDQB.d.cts} +1 -1
- package/dist/{api-bQZ98gkJ.d.ts → api-BuFilDQB.d.ts} +1 -1
- package/dist/browser.cjs +22 -22
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +20 -20
- package/dist/{chunk-J2LVOWVY.js → chunk-2J2QWNGI.js} +46 -24
- package/dist/chunk-2J2QWNGI.js.map +1 -0
- package/dist/{chunk-MCFQAUQV.cjs → chunk-2UJAVPA4.cjs} +58 -39
- package/dist/chunk-2UJAVPA4.cjs.map +1 -0
- package/dist/{chunk-5AEN2PLB.cjs → chunk-3YXXZ4LT.cjs} +33 -33
- package/dist/{chunk-5AEN2PLB.cjs.map → chunk-3YXXZ4LT.cjs.map} +1 -1
- package/dist/{chunk-RP5UATRA.js → chunk-56LXBM45.js} +4 -4
- package/dist/{chunk-RP5UATRA.js.map → chunk-56LXBM45.js.map} +1 -1
- package/dist/{chunk-OC22GGQN.js → chunk-6BKUD5EJ.js} +54 -4
- package/dist/chunk-6BKUD5EJ.js.map +1 -0
- package/dist/{chunk-ULYRO2KY.cjs → chunk-75BMFCP5.cjs} +44 -44
- package/dist/{chunk-ULYRO2KY.cjs.map → chunk-75BMFCP5.cjs.map} +1 -1
- package/dist/{chunk-ZNDIGQJD.js → chunk-7BEJHG43.js} +3 -3
- package/dist/{chunk-ZNDIGQJD.js.map → chunk-7BEJHG43.js.map} +1 -1
- package/dist/{chunk-WYFXOXVK.cjs → chunk-7MVDN5UC.cjs} +35 -35
- package/dist/{chunk-WYFXOXVK.cjs.map → chunk-7MVDN5UC.cjs.map} +1 -1
- package/dist/{chunk-JDTB7IKL.js → chunk-BJ65PKDU.js} +3 -3
- package/dist/{chunk-JDTB7IKL.js.map → chunk-BJ65PKDU.js.map} +1 -1
- package/dist/{chunk-FE6GAUNW.js → chunk-BJWMPPEA.js} +5 -5
- package/dist/{chunk-FE6GAUNW.js.map → chunk-BJWMPPEA.js.map} +1 -1
- package/dist/{chunk-MJGDP3CS.cjs → chunk-BUN3CRMP.cjs} +488 -109
- package/dist/chunk-BUN3CRMP.cjs.map +1 -0
- package/dist/{chunk-COLTVQWR.cjs → chunk-C3IVD7DI.cjs} +25 -25
- package/dist/{chunk-COLTVQWR.cjs.map → chunk-C3IVD7DI.cjs.map} +1 -1
- package/dist/{chunk-3YZ6FPQW.cjs → chunk-EYHD7LV3.cjs} +131 -131
- package/dist/{chunk-3YZ6FPQW.cjs.map → chunk-EYHD7LV3.cjs.map} +1 -1
- package/dist/{chunk-UGCUNADI.js → chunk-F6OROIHS.js} +35 -16
- package/dist/chunk-F6OROIHS.js.map +1 -0
- package/dist/{chunk-UAGSCTYI.cjs → chunk-GYTWJ6VB.cjs} +85 -63
- package/dist/chunk-GYTWJ6VB.cjs.map +1 -0
- package/dist/{chunk-MR5HU5WU.js → chunk-H4CJTKEH.js} +50 -4
- package/dist/chunk-H4CJTKEH.js.map +1 -0
- package/dist/{chunk-45KP67RR.js → chunk-HIQPEAL7.js} +5 -5
- package/dist/chunk-HIQPEAL7.js.map +1 -0
- package/dist/{chunk-LR4X4ZRG.js → chunk-IT2TVXC7.js} +20 -16
- package/dist/chunk-IT2TVXC7.js.map +1 -0
- package/dist/{chunk-2JDVJRR3.cjs → chunk-K5QG53GT.cjs} +28 -28
- package/dist/chunk-K5QG53GT.cjs.map +1 -0
- package/dist/{chunk-B37IKTI7.cjs → chunk-KUXOHLGC.cjs} +97 -47
- package/dist/chunk-KUXOHLGC.cjs.map +1 -0
- package/dist/{chunk-A5D2IMOX.cjs → chunk-L2KUGWFR.cjs} +47 -47
- package/dist/{chunk-A5D2IMOX.cjs.map → chunk-L2KUGWFR.cjs.map} +1 -1
- package/dist/{chunk-HDKDQAEQ.cjs → chunk-LFZZ4NCP.cjs} +14 -2
- package/dist/chunk-LFZZ4NCP.cjs.map +1 -0
- package/dist/{chunk-U6L3FAML.js → chunk-M3R6RCXY.js} +3 -3
- package/dist/{chunk-U6L3FAML.js.map → chunk-M3R6RCXY.js.map} +1 -1
- package/dist/{chunk-5YYAYW67.js → chunk-M5ZC3LFJ.js} +3 -3
- package/dist/{chunk-5YYAYW67.js.map → chunk-M5ZC3LFJ.js.map} +1 -1
- package/dist/{chunk-B6INLQBU.cjs → chunk-MKKFIPKU.cjs} +46 -46
- package/dist/{chunk-B6INLQBU.cjs.map → chunk-MKKFIPKU.cjs.map} +1 -1
- package/dist/{chunk-M5B2UUNW.js → chunk-NFT6VW73.js} +4 -4
- package/dist/{chunk-M5B2UUNW.js.map → chunk-NFT6VW73.js.map} +1 -1
- package/dist/{chunk-X7RPFTTR.cjs → chunk-OK5RYX55.cjs} +26 -26
- package/dist/{chunk-X7RPFTTR.cjs.map → chunk-OK5RYX55.cjs.map} +1 -1
- package/dist/{chunk-VPKCW4PB.js → chunk-RNGYXGHS.js} +2854 -42
- package/dist/chunk-RNGYXGHS.js.map +1 -0
- package/dist/{chunk-DPQYGWCT.cjs → chunk-RODV6PC4.cjs} +52 -6
- package/dist/chunk-RODV6PC4.cjs.map +1 -0
- package/dist/{chunk-H2OEUBPO.js → chunk-SE23X5OE.js} +441 -62
- package/dist/chunk-SE23X5OE.js.map +1 -0
- package/dist/{chunk-FCGHV6ZK.js → chunk-SFSZUOFT.js} +4 -4
- package/dist/{chunk-FCGHV6ZK.js.map → chunk-SFSZUOFT.js.map} +1 -1
- package/dist/{chunk-E65ITQXV.cjs → chunk-UK7JF5QB.cjs} +52 -48
- package/dist/chunk-UK7JF5QB.cjs.map +1 -0
- package/dist/{chunk-QSQX77S2.cjs → chunk-W7GIQTJV.cjs} +21 -21
- package/dist/{chunk-QSQX77S2.cjs.map → chunk-W7GIQTJV.cjs.map} +1 -1
- package/dist/{chunk-KLJEK547.js → chunk-WHJXRLFD.js} +14 -3
- package/dist/chunk-WHJXRLFD.js.map +1 -0
- package/dist/{chunk-YQANC7HQ.js → chunk-X4F6VVEJ.js} +3 -3
- package/dist/{chunk-YQANC7HQ.js.map → chunk-X4F6VVEJ.js.map} +1 -1
- package/dist/{chunk-ZNOD4VZT.cjs → chunk-XI6JOG76.cjs} +46 -46
- package/dist/{chunk-ZNOD4VZT.cjs.map → chunk-XI6JOG76.cjs.map} +1 -1
- package/dist/{chunk-4S2WILLW.cjs → chunk-XUEROLSB.cjs} +72 -19
- package/dist/chunk-XUEROLSB.cjs.map +1 -0
- package/dist/{chunk-MSYBSOU2.cjs → chunk-YTEEZV6J.cjs} +3055 -241
- package/dist/chunk-YTEEZV6J.cjs.map +1 -0
- package/dist/{chunk-PGALHQFF.js → chunk-ZNLEUL7T.js} +60 -7
- package/dist/chunk-ZNLEUL7T.js.map +1 -0
- package/dist/{chunk-DNZFOCV7.js → chunk-ZTSO3S4P.js} +3 -3
- package/dist/{chunk-DNZFOCV7.js.map → chunk-ZTSO3S4P.js.map} +1 -1
- package/dist/diagrams/blockdiagram/index.cjs +6 -6
- package/dist/diagrams/blockdiagram/index.d.cts +1 -1
- package/dist/diagrams/blockdiagram/index.d.ts +1 -1
- package/dist/diagrams/blockdiagram/index.js +2 -2
- package/dist/diagrams/circuit/index.cjs +8 -8
- package/dist/diagrams/circuit/index.d.cts +1 -1
- package/dist/diagrams/circuit/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.js +2 -2
- package/dist/diagrams/ecomap/index.cjs +8 -8
- package/dist/diagrams/ecomap/index.d.cts +1 -1
- package/dist/diagrams/ecomap/index.d.ts +1 -1
- package/dist/diagrams/ecomap/index.js +3 -3
- package/dist/diagrams/entity/index.cjs +6 -6
- package/dist/diagrams/entity/index.d.cts +1 -1
- package/dist/diagrams/entity/index.d.ts +1 -1
- package/dist/diagrams/entity/index.js +2 -2
- package/dist/diagrams/fishbone/index.cjs +8 -8
- package/dist/diagrams/fishbone/index.d.cts +1 -1
- package/dist/diagrams/fishbone/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.js +2 -2
- package/dist/diagrams/flowchart/index.cjs +8 -8
- package/dist/diagrams/flowchart/index.d.cts +2 -2
- package/dist/diagrams/flowchart/index.d.ts +2 -2
- package/dist/diagrams/flowchart/index.js +2 -2
- package/dist/diagrams/genogram/index.cjs +10 -10
- package/dist/diagrams/genogram/index.d.cts +1 -1
- package/dist/diagrams/genogram/index.d.ts +1 -1
- package/dist/diagrams/genogram/index.js +3 -3
- package/dist/diagrams/ladder/index.cjs +6 -6
- package/dist/diagrams/ladder/index.d.cts +1 -1
- package/dist/diagrams/ladder/index.d.ts +1 -1
- package/dist/diagrams/ladder/index.js +2 -2
- package/dist/diagrams/logic/index.cjs +6 -6
- package/dist/diagrams/logic/index.d.cts +1 -1
- package/dist/diagrams/logic/index.d.ts +1 -1
- package/dist/diagrams/logic/index.js +2 -2
- package/dist/diagrams/orgchart/index.cjs +7 -7
- package/dist/diagrams/orgchart/index.d.cts +1 -1
- package/dist/diagrams/orgchart/index.d.ts +1 -1
- package/dist/diagrams/orgchart/index.js +2 -2
- package/dist/diagrams/pedigree/index.cjs +8 -8
- package/dist/diagrams/pedigree/index.d.cts +1 -1
- package/dist/diagrams/pedigree/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.js +3 -3
- package/dist/diagrams/phylo/index.cjs +7 -7
- package/dist/diagrams/phylo/index.d.cts +1 -1
- package/dist/diagrams/phylo/index.d.ts +1 -1
- package/dist/diagrams/phylo/index.js +2 -2
- package/dist/diagrams/sld/index.cjs +6 -6
- package/dist/diagrams/sld/index.d.cts +1 -1
- package/dist/diagrams/sld/index.d.ts +1 -1
- package/dist/diagrams/sld/index.js +2 -2
- package/dist/diagrams/sociogram/index.cjs +7 -7
- package/dist/diagrams/sociogram/index.d.cts +1 -1
- package/dist/diagrams/sociogram/index.d.ts +1 -1
- package/dist/diagrams/sociogram/index.js +3 -3
- package/dist/diagrams/timing/index.cjs +5 -5
- package/dist/diagrams/timing/index.d.cts +1 -1
- package/dist/diagrams/timing/index.d.ts +1 -1
- package/dist/diagrams/timing/index.js +2 -2
- package/dist/diagrams/venn/index.cjs +9 -9
- package/dist/diagrams/venn/index.d.cts +1 -1
- package/dist/diagrams/venn/index.d.ts +1 -1
- package/dist/diagrams/venn/index.js +2 -2
- package/dist/{index-BTZEka65.d.cts → index-BrLxEzSQ.d.cts} +1 -1
- package/dist/{index-DcU88F9i.d.ts → index-dWDwG6BW.d.ts} +1 -1
- package/dist/index.cjs +47 -39
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +19 -19
- package/dist/react.cjs +20 -20
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +19 -19
- package/dist/react.js.map +1 -1
- package/dist/{types-C4LnMEcB.d.cts → types-BtiUg7Gx.d.cts} +25 -4
- package/dist/{types-C4LnMEcB.d.ts → types-BtiUg7Gx.d.ts} +25 -4
- package/package.json +2 -2
- package/dist/chunk-2JDVJRR3.cjs.map +0 -1
- package/dist/chunk-45KP67RR.js.map +0 -1
- package/dist/chunk-4S2WILLW.cjs.map +0 -1
- package/dist/chunk-B37IKTI7.cjs.map +0 -1
- package/dist/chunk-DPQYGWCT.cjs.map +0 -1
- package/dist/chunk-E65ITQXV.cjs.map +0 -1
- package/dist/chunk-H2OEUBPO.js.map +0 -1
- package/dist/chunk-HDKDQAEQ.cjs.map +0 -1
- package/dist/chunk-J2LVOWVY.js.map +0 -1
- package/dist/chunk-KLJEK547.js.map +0 -1
- package/dist/chunk-LR4X4ZRG.js.map +0 -1
- package/dist/chunk-MCFQAUQV.cjs.map +0 -1
- package/dist/chunk-MJGDP3CS.cjs.map +0 -1
- package/dist/chunk-MR5HU5WU.js.map +0 -1
- package/dist/chunk-MSYBSOU2.cjs.map +0 -1
- package/dist/chunk-OC22GGQN.js.map +0 -1
- package/dist/chunk-PGALHQFF.js.map +0 -1
- package/dist/chunk-UAGSCTYI.cjs.map +0 -1
- package/dist/chunk-UGCUNADI.js.map +0 -1
- package/dist/chunk-VPKCW4PB.js.map +0 -1
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
3
|
+
var chunkL2KUGWFR_cjs = require('./chunk-L2KUGWFR.cjs');
|
|
4
|
+
var chunkXUEROLSB_cjs = require('./chunk-XUEROLSB.cjs');
|
|
5
|
+
var chunk2UJAVPA4_cjs = require('./chunk-2UJAVPA4.cjs');
|
|
6
|
+
var chunkMKKFIPKU_cjs = require('./chunk-MKKFIPKU.cjs');
|
|
7
|
+
var chunkEYHD7LV3_cjs = require('./chunk-EYHD7LV3.cjs');
|
|
8
|
+
var chunkXI6JOG76_cjs = require('./chunk-XI6JOG76.cjs');
|
|
9
|
+
var chunk3YXXZ4LT_cjs = require('./chunk-3YXXZ4LT.cjs');
|
|
10
|
+
var chunkW7GIQTJV_cjs = require('./chunk-W7GIQTJV.cjs');
|
|
11
|
+
var chunkGYTWJ6VB_cjs = require('./chunk-GYTWJ6VB.cjs');
|
|
12
|
+
var chunkBUN3CRMP_cjs = require('./chunk-BUN3CRMP.cjs');
|
|
13
|
+
var chunkUK7JF5QB_cjs = require('./chunk-UK7JF5QB.cjs');
|
|
14
|
+
var chunkKUXOHLGC_cjs = require('./chunk-KUXOHLGC.cjs');
|
|
15
|
+
var chunkOK5RYX55_cjs = require('./chunk-OK5RYX55.cjs');
|
|
16
|
+
var chunkC3IVD7DI_cjs = require('./chunk-C3IVD7DI.cjs');
|
|
17
|
+
var chunkK5QG53GT_cjs = require('./chunk-K5QG53GT.cjs');
|
|
18
|
+
var chunk7MVDN5UC_cjs = require('./chunk-7MVDN5UC.cjs');
|
|
19
19
|
var chunkD7EHZFK4_cjs = require('./chunk-D7EHZFK4.cjs');
|
|
20
|
-
var
|
|
20
|
+
var chunkLFZZ4NCP_cjs = require('./chunk-LFZZ4NCP.cjs');
|
|
21
21
|
|
|
22
22
|
// src/diagrams/decisiontree/parser.ts
|
|
23
23
|
var DTreeParseError = class extends Error {
|
|
@@ -623,7 +623,7 @@ function layoutDecisionTree(ast) {
|
|
|
623
623
|
enforceSibGap(root, sibH, sibGap);
|
|
624
624
|
const levelOffsets = computeLevelOffsets(root, sibH, levelGap);
|
|
625
625
|
setFinal(root, sibH, levelOffsets);
|
|
626
|
-
const
|
|
626
|
+
const PADDING3 = 40;
|
|
627
627
|
const extraLeft = ast.mode === "decision" && !sibH ? 110 : 0;
|
|
628
628
|
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
629
629
|
for (const n of all) {
|
|
@@ -648,8 +648,8 @@ function layoutDecisionTree(ast) {
|
|
|
648
648
|
maxX = Math.max(maxX, n.xFinal + n.size.w / 2);
|
|
649
649
|
}
|
|
650
650
|
}
|
|
651
|
-
const offsetX =
|
|
652
|
-
const offsetY =
|
|
651
|
+
const offsetX = PADDING3 + extraLeft - minX;
|
|
652
|
+
const offsetY = PADDING3 - minY;
|
|
653
653
|
const layoutNodes = all.map((w) => ({
|
|
654
654
|
node: w.node,
|
|
655
655
|
x: w.xFinal + offsetX,
|
|
@@ -710,8 +710,8 @@ function layoutDecisionTree(ast) {
|
|
|
710
710
|
for (const n of layoutNodes) if (n.node.kind === "end") endX = Math.max(endX, n.x + n.width / 2);
|
|
711
711
|
payoffColumnX = endX + payoffColGap;
|
|
712
712
|
}
|
|
713
|
-
const width = Math.ceil(maxX - minX +
|
|
714
|
-
const height = Math.ceil(maxY - minY +
|
|
713
|
+
const width = Math.ceil(maxX - minX + PADDING3 * 2 + extraRight + extraLeft);
|
|
714
|
+
const height = Math.ceil(maxY - minY + PADDING3 * 2);
|
|
715
715
|
return {
|
|
716
716
|
width,
|
|
717
717
|
height,
|
|
@@ -787,7 +787,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
787
787
|
const parts = [];
|
|
788
788
|
const sibH = layout.direction === "top-down";
|
|
789
789
|
if (n.kind === "decision") {
|
|
790
|
-
parts.push(
|
|
790
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({
|
|
791
791
|
x: ln.x - ln.width / 2,
|
|
792
792
|
y: ln.y - ln.height / 2,
|
|
793
793
|
width: ln.width,
|
|
@@ -798,14 +798,14 @@ function renderDecisionNode(ln, layout) {
|
|
|
798
798
|
}));
|
|
799
799
|
if (n.label) {
|
|
800
800
|
if (sibH) {
|
|
801
|
-
parts.push(
|
|
801
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
802
802
|
x: ln.x,
|
|
803
803
|
y: ln.y - ln.height / 2 - 8,
|
|
804
804
|
class: "lt-dtree-node-label",
|
|
805
805
|
"text-anchor": "middle"
|
|
806
806
|
}, n.label));
|
|
807
807
|
} else {
|
|
808
|
-
parts.push(
|
|
808
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
809
809
|
x: ln.x - ln.width / 2 - 8,
|
|
810
810
|
y: ln.y + 4,
|
|
811
811
|
class: "lt-dtree-node-label",
|
|
@@ -814,7 +814,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
814
814
|
}
|
|
815
815
|
}
|
|
816
816
|
if (n.ev !== void 0) {
|
|
817
|
-
parts.push(
|
|
817
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
818
818
|
x: ln.x,
|
|
819
819
|
y: ln.y + ln.height / 2 + 13,
|
|
820
820
|
class: "lt-dtree-ev",
|
|
@@ -822,7 +822,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
822
822
|
}, `EV=${formatNum(n.ev)}`));
|
|
823
823
|
}
|
|
824
824
|
} else if (n.kind === "chance") {
|
|
825
|
-
parts.push(
|
|
825
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({
|
|
826
826
|
cx: ln.x,
|
|
827
827
|
cy: ln.y,
|
|
828
828
|
r: ln.width / 2,
|
|
@@ -830,14 +830,14 @@ function renderDecisionNode(ln, layout) {
|
|
|
830
830
|
}));
|
|
831
831
|
if (n.label) {
|
|
832
832
|
if (sibH) {
|
|
833
|
-
parts.push(
|
|
833
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
834
834
|
x: ln.x,
|
|
835
835
|
y: ln.y - ln.height / 2 - 8,
|
|
836
836
|
class: "lt-dtree-node-label",
|
|
837
837
|
"text-anchor": "middle"
|
|
838
838
|
}, n.label));
|
|
839
839
|
} else {
|
|
840
|
-
parts.push(
|
|
840
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
841
841
|
x: ln.x,
|
|
842
842
|
y: ln.y - ln.height / 2 - 6,
|
|
843
843
|
class: "lt-dtree-node-label",
|
|
@@ -846,7 +846,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
848
|
if (n.ev !== void 0) {
|
|
849
|
-
parts.push(
|
|
849
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
850
850
|
x: ln.x,
|
|
851
851
|
y: ln.y + ln.height / 2 + 13,
|
|
852
852
|
class: n.optimal ? "lt-dtree-ev-optimal" : "lt-dtree-ev",
|
|
@@ -861,19 +861,19 @@ function renderDecisionNode(ln, layout) {
|
|
|
861
861
|
`${ln.x + halfW},${ln.y}`,
|
|
862
862
|
`${ln.x - halfW},${ln.y + halfH}`
|
|
863
863
|
].join(" ");
|
|
864
|
-
parts.push(
|
|
864
|
+
parts.push(chunkLFZZ4NCP_cjs.polygon({ points: pts, class: "lt-dtree-outcome" }));
|
|
865
865
|
const colX = layout.payoffColumnX;
|
|
866
866
|
const tipX = ln.x + halfW;
|
|
867
867
|
const textY = ln.y + 4;
|
|
868
868
|
const payoffCls = n.payoff !== void 0 && n.payoff < 0 ? "lt-dtree-payoff-neg" : "lt-dtree-payoff";
|
|
869
869
|
const payoffStr = n.payoff !== void 0 ? formatPayoff(n.payoff) : "";
|
|
870
870
|
if (colX !== void 0 && colX > tipX + 20) {
|
|
871
|
-
parts.push(
|
|
871
|
+
parts.push(chunkLFZZ4NCP_cjs.path({
|
|
872
872
|
d: `M ${tipX + 2} ${ln.y} L ${colX - 6} ${ln.y}`,
|
|
873
873
|
class: "lt-dtree-edge-leader"
|
|
874
874
|
}));
|
|
875
875
|
if (n.label) {
|
|
876
|
-
parts.push(
|
|
876
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
877
877
|
x: (tipX + colX) / 2,
|
|
878
878
|
y: ln.y - 6,
|
|
879
879
|
class: "lt-dtree-edge-label",
|
|
@@ -881,7 +881,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
881
881
|
}, n.label));
|
|
882
882
|
}
|
|
883
883
|
if (payoffStr) {
|
|
884
|
-
parts.push(
|
|
884
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
885
885
|
x: colX,
|
|
886
886
|
y: textY,
|
|
887
887
|
class: payoffCls,
|
|
@@ -893,7 +893,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
893
893
|
if (payoffStr) labelParts.push(payoffStr);
|
|
894
894
|
if (n.label) labelParts.push(n.label);
|
|
895
895
|
if (labelParts.length > 0) {
|
|
896
|
-
parts.push(
|
|
896
|
+
parts.push(chunkLFZZ4NCP_cjs.text({
|
|
897
897
|
x: tipX + 8,
|
|
898
898
|
y: textY,
|
|
899
899
|
class: payoffCls
|
|
@@ -901,7 +901,7 @@ function renderDecisionNode(ln, layout) {
|
|
|
901
901
|
}
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
|
-
return
|
|
904
|
+
return chunkLFZZ4NCP_cjs.group({
|
|
905
905
|
"data-node-id": n.id,
|
|
906
906
|
"data-node-kind": n.kind,
|
|
907
907
|
"data-ev": n.ev !== void 0 ? String(n.ev) : ""
|
|
@@ -944,7 +944,7 @@ function renderMlNode(ln, ast) {
|
|
|
944
944
|
const parts = [];
|
|
945
945
|
const x = ln.x - ln.width / 2;
|
|
946
946
|
const y = ln.y - ln.height / 2;
|
|
947
|
-
parts.push(
|
|
947
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({
|
|
948
948
|
x,
|
|
949
949
|
y,
|
|
950
950
|
width: ln.width,
|
|
@@ -959,25 +959,25 @@ function renderMlNode(ln, ast) {
|
|
|
959
959
|
const lineH = 14;
|
|
960
960
|
if (n.kind === "split" && n.feature) {
|
|
961
961
|
const thresh = typeof n.threshold === "number" ? formatNum(n.threshold) : n.threshold ?? "";
|
|
962
|
-
parts.push(
|
|
962
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
963
963
|
{ x: textX, y: textY, class: "lt-dtree-ml-line-1", "text-anchor": "middle" },
|
|
964
964
|
`${n.feature} ${n.op ?? ""} ${thresh}`
|
|
965
965
|
));
|
|
966
966
|
textY += lineH;
|
|
967
967
|
} else if (n.label) {
|
|
968
|
-
parts.push(
|
|
968
|
+
parts.push(chunkLFZZ4NCP_cjs.text({ x: textX, y: textY, class: "lt-dtree-ml-line-1", "text-anchor": "middle" }, n.label));
|
|
969
969
|
textY += lineH;
|
|
970
970
|
}
|
|
971
971
|
if (n.impurity !== void 0) {
|
|
972
972
|
const impName = ast.impurityName ?? "gini";
|
|
973
|
-
parts.push(
|
|
973
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
974
974
|
{ x: textX, y: textY, class: "lt-dtree-ml-line-muted", "text-anchor": "middle" },
|
|
975
975
|
`${impName} = ${formatNum(n.impurity)}`
|
|
976
976
|
));
|
|
977
977
|
textY += lineH;
|
|
978
978
|
}
|
|
979
979
|
if (n.samples !== void 0) {
|
|
980
|
-
parts.push(
|
|
980
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
981
981
|
{ x: textX, y: textY, class: "lt-dtree-ml-line-muted", "text-anchor": "middle" },
|
|
982
982
|
`samples = ${n.samples}`
|
|
983
983
|
));
|
|
@@ -985,7 +985,7 @@ function renderMlNode(ln, ast) {
|
|
|
985
985
|
}
|
|
986
986
|
if (n.value !== void 0) {
|
|
987
987
|
const vStr = Array.isArray(n.value) ? `value = [${n.value.join(", ")}]` : `value = ${formatNum(n.value)}`;
|
|
988
|
-
parts.push(
|
|
988
|
+
parts.push(chunkLFZZ4NCP_cjs.text({ x: textX, y: textY, class: "lt-dtree-ml-mono", "text-anchor": "middle" }, vStr));
|
|
989
989
|
textY += lineH;
|
|
990
990
|
}
|
|
991
991
|
if (n.className) {
|
|
@@ -994,13 +994,13 @@ function renderMlNode(ln, ast) {
|
|
|
994
994
|
const idx = ast.classes.indexOf(n.className);
|
|
995
995
|
if (idx >= 0) colorIdx = idx;
|
|
996
996
|
}
|
|
997
|
-
parts.push(
|
|
997
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
998
998
|
{ x: textX, y: textY, class: "lt-dtree-ml-class", "text-anchor": "middle", fill: classColor(colorIdx) },
|
|
999
999
|
`class = ${n.className}`
|
|
1000
1000
|
));
|
|
1001
1001
|
textY += lineH;
|
|
1002
1002
|
} else if (typeof n.value === "number") {
|
|
1003
|
-
parts.push(
|
|
1003
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
1004
1004
|
{ x: textX, y: textY, class: "lt-dtree-ml-class", "text-anchor": "middle", fill: "#0f172a" },
|
|
1005
1005
|
`predicted = ${formatNum(n.value)}`
|
|
1006
1006
|
));
|
|
@@ -1017,13 +1017,13 @@ function renderMlNode(ln, ast) {
|
|
|
1017
1017
|
for (let i = 0; i < arr.length; i++) {
|
|
1018
1018
|
const seg = arr[i] / sum * barW;
|
|
1019
1019
|
if (seg > 0) {
|
|
1020
|
-
parts.push(
|
|
1020
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({ x: cursor, y: barY, width: seg, height: 5, fill: classColor(i), stroke: "none" }));
|
|
1021
1021
|
}
|
|
1022
1022
|
cursor += seg;
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
|
-
return
|
|
1026
|
+
return chunkLFZZ4NCP_cjs.group({
|
|
1027
1027
|
"data-node-id": n.id,
|
|
1028
1028
|
"data-node-kind": n.kind,
|
|
1029
1029
|
"data-samples": n.samples !== void 0 ? String(n.samples) : "",
|
|
@@ -1035,7 +1035,7 @@ function renderTaxonomyNode(ln) {
|
|
|
1035
1035
|
const isLeaf = n.kind === "answer" || n.children.length === 0;
|
|
1036
1036
|
const cls = isLeaf ? "lt-dtree-taxon-leaf" : "lt-dtree-taxon";
|
|
1037
1037
|
const parts = [];
|
|
1038
|
-
parts.push(
|
|
1038
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({
|
|
1039
1039
|
x: ln.x - ln.width / 2,
|
|
1040
1040
|
y: ln.y - ln.height / 2,
|
|
1041
1041
|
width: ln.width,
|
|
@@ -1048,10 +1048,10 @@ function renderTaxonomyNode(ln) {
|
|
|
1048
1048
|
const totalH = lines.length * 14;
|
|
1049
1049
|
let ty = ln.y - totalH / 2 + 11;
|
|
1050
1050
|
for (const line2 of lines) {
|
|
1051
|
-
parts.push(
|
|
1051
|
+
parts.push(chunkLFZZ4NCP_cjs.text({ x: ln.x, y: ty, class: "lt-dtree-taxon-label" }, line2));
|
|
1052
1052
|
ty += 14;
|
|
1053
1053
|
}
|
|
1054
|
-
return
|
|
1054
|
+
return chunkLFZZ4NCP_cjs.group({
|
|
1055
1055
|
"data-node-id": n.id,
|
|
1056
1056
|
"data-node-kind": n.kind,
|
|
1057
1057
|
"data-leaf": isLeaf ? "true" : "false"
|
|
@@ -1084,18 +1084,18 @@ function renderDecisionTree(ast, config) {
|
|
|
1084
1084
|
const width = Math.ceil(layout.width);
|
|
1085
1085
|
const height = Math.ceil(layout.height + titleOffset);
|
|
1086
1086
|
const children = [];
|
|
1087
|
-
children.push(
|
|
1088
|
-
children.push(
|
|
1089
|
-
children.push(
|
|
1087
|
+
children.push(chunkLFZZ4NCP_cjs.title(ast.title ?? "Decision Tree"));
|
|
1088
|
+
children.push(chunkLFZZ4NCP_cjs.desc(`Decision tree (${ast.mode} mode) with ${layout.nodes.length} nodes and ${layout.edges.length} edges`));
|
|
1089
|
+
children.push(chunkLFZZ4NCP_cjs.el("style", {}, buildCss(t)));
|
|
1090
1090
|
if (ast.title) {
|
|
1091
|
-
children.push(
|
|
1091
|
+
children.push(chunkLFZZ4NCP_cjs.text({ x: 20, y: 24, class: "lt-dtree-title" }, ast.title));
|
|
1092
1092
|
}
|
|
1093
1093
|
const inner = [];
|
|
1094
1094
|
for (const e of layout.edges) {
|
|
1095
1095
|
const cls = e.isOptimal ? "lt-dtree-edge-optimal" : "lt-dtree-edge";
|
|
1096
1096
|
const attrs = { d: e.path, class: cls, "data-edge": `${e.from}->${e.to}` };
|
|
1097
1097
|
if (e.strokeWidth !== void 0 && !e.isOptimal) attrs["stroke-width"] = e.strokeWidth;
|
|
1098
|
-
inner.push(
|
|
1098
|
+
inner.push(chunkLFZZ4NCP_cjs.path(attrs));
|
|
1099
1099
|
}
|
|
1100
1100
|
const anchors = layout.labelAnchors ?? {};
|
|
1101
1101
|
for (const e of layout.edges) {
|
|
@@ -1119,7 +1119,7 @@ function renderDecisionTree(ast, config) {
|
|
|
1119
1119
|
const charW = isProb ? 5.5 : 6.2;
|
|
1120
1120
|
const w = Math.max(e.label.length * charW + 10, 18);
|
|
1121
1121
|
const h = 14;
|
|
1122
|
-
inner.push(
|
|
1122
|
+
inner.push(chunkLFZZ4NCP_cjs.rect({
|
|
1123
1123
|
x: lx - w / 2,
|
|
1124
1124
|
y: ly - h / 2,
|
|
1125
1125
|
width: w,
|
|
@@ -1128,18 +1128,18 @@ function renderDecisionTree(ast, config) {
|
|
|
1128
1128
|
rx: 3,
|
|
1129
1129
|
ry: 3
|
|
1130
1130
|
}));
|
|
1131
|
-
inner.push(
|
|
1131
|
+
inner.push(chunkLFZZ4NCP_cjs.text({ x: lx, y: ly, class: labelClass }, e.label));
|
|
1132
1132
|
}
|
|
1133
1133
|
for (const ln of layout.nodes) {
|
|
1134
1134
|
if (ast.mode === "decision") inner.push(renderDecisionNode(ln, layout));
|
|
1135
1135
|
else if (ast.mode === "ml") inner.push(renderMlNode(ln, ast));
|
|
1136
1136
|
else inner.push(renderTaxonomyNode(ln));
|
|
1137
1137
|
}
|
|
1138
|
-
children.push(
|
|
1139
|
-
return
|
|
1138
|
+
children.push(chunkLFZZ4NCP_cjs.group({ transform: `translate(0, ${titleOffset})`, "data-mode": ast.mode }, inner));
|
|
1139
|
+
return chunkLFZZ4NCP_cjs.svgRoot({
|
|
1140
1140
|
class: "lt-dtree",
|
|
1141
1141
|
role: "img",
|
|
1142
|
-
"aria-label":
|
|
1142
|
+
"aria-label": chunkLFZZ4NCP_cjs.escapeXml(ast.title ?? `Decision tree (${ast.mode})`),
|
|
1143
1143
|
width,
|
|
1144
1144
|
height,
|
|
1145
1145
|
viewBox: `0 0 ${width} ${height}`
|
|
@@ -1399,23 +1399,35 @@ function parseTimeline(src) {
|
|
|
1399
1399
|
i++;
|
|
1400
1400
|
continue;
|
|
1401
1401
|
}
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1402
|
+
const isTrack = /^track\b/i.test(text2);
|
|
1403
|
+
const isSection = /^section\b/i.test(text2);
|
|
1404
|
+
if (isTrack || isSection) {
|
|
1405
|
+
const keyword = isTrack ? "track" : "section";
|
|
1406
|
+
const body = text2.replace(new RegExp(`^${keyword}\\s+`, "i"), "");
|
|
1407
|
+
let name;
|
|
1408
|
+
if (body.startsWith('"')) {
|
|
1409
|
+
const [n] = readQuoted(body, L.line);
|
|
1410
|
+
name = n;
|
|
1411
|
+
} else {
|
|
1412
|
+
name = body.replace(/:\s*$/, "").trim();
|
|
1413
|
+
if (!name) {
|
|
1414
|
+
throw new TimelineParseError(`Expected name after '${keyword}'`, L.line);
|
|
1415
|
+
}
|
|
1407
1416
|
}
|
|
1408
1417
|
const trackId = nextId2("track");
|
|
1409
1418
|
ast.tracks.push({ id: trackId, label: name });
|
|
1410
1419
|
i++;
|
|
1411
|
-
|
|
1420
|
+
const baseIndent = L.indent;
|
|
1421
|
+
while (i < lines.length) {
|
|
1412
1422
|
const child = lines[i];
|
|
1423
|
+
if (child.indent <= baseIndent && /^(section|track)\b/i.test(child.text)) break;
|
|
1424
|
+
if (isTrack && child.indent <= baseIndent) break;
|
|
1413
1425
|
if (/^note\s*:/i.test(child.text)) {
|
|
1414
1426
|
i++;
|
|
1415
1427
|
continue;
|
|
1416
1428
|
}
|
|
1417
1429
|
const parsed2 = parseEventLine(child.text, child.line, nextId2);
|
|
1418
|
-
if (!parsed2) throw new TimelineParseError(`Unrecognized line in
|
|
1430
|
+
if (!parsed2) throw new TimelineParseError(`Unrecognized line in ${keyword}: ${child.text}`, child.line);
|
|
1419
1431
|
parsed2.event.trackId = trackId;
|
|
1420
1432
|
ast.events.push(parsed2.event);
|
|
1421
1433
|
i++;
|
|
@@ -2108,13 +2120,13 @@ function renderTimeline(src, config) {
|
|
|
2108
2120
|
const theme = chunkD7EHZFK4_cjs.resolveTimelineTheme(config?.theme ?? "default");
|
|
2109
2121
|
const styleBlock = styleForTheme(theme, config?.fontFamily);
|
|
2110
2122
|
const children = [
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2123
|
+
chunkLFZZ4NCP_cjs.title(ast.title ? `Timeline \u2014 ${ast.title}` : "Timeline"),
|
|
2124
|
+
chunkLFZZ4NCP_cjs.desc("Schematex timeline diagram"),
|
|
2125
|
+
chunkLFZZ4NCP_cjs.defs([`<style>${styleBlock}</style>`])
|
|
2114
2126
|
];
|
|
2115
2127
|
if (ast.title) {
|
|
2116
2128
|
children.push(
|
|
2117
|
-
|
|
2129
|
+
chunkLFZZ4NCP_cjs.text(
|
|
2118
2130
|
{ x: layout.width / 2, y: 26, "text-anchor": "middle", class: "st-title" },
|
|
2119
2131
|
ast.title
|
|
2120
2132
|
)
|
|
@@ -2134,7 +2146,7 @@ function renderTimeline(src, config) {
|
|
|
2134
2146
|
break;
|
|
2135
2147
|
}
|
|
2136
2148
|
children.push(renderAxis(layout));
|
|
2137
|
-
return
|
|
2149
|
+
return chunkLFZZ4NCP_cjs.svgRoot(
|
|
2138
2150
|
{
|
|
2139
2151
|
viewBox: `0 0 ${layout.width} ${layout.height}`,
|
|
2140
2152
|
width: layout.width,
|
|
@@ -2224,7 +2236,7 @@ function renderEras(layout, theme) {
|
|
|
2224
2236
|
const stripX = isLeftmost ? Math.min(e.x, layout.plotX) : e.x;
|
|
2225
2237
|
const stripEnd = isRightmost ? Math.max(e.x + e.width, plotEnd) : e.x + e.width;
|
|
2226
2238
|
return [
|
|
2227
|
-
|
|
2239
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
2228
2240
|
x: e.x,
|
|
2229
2241
|
y,
|
|
2230
2242
|
width: e.width,
|
|
@@ -2233,7 +2245,7 @@ function renderEras(layout, theme) {
|
|
|
2233
2245
|
class: "st-era-rect",
|
|
2234
2246
|
"data-era-id": e.era.id
|
|
2235
2247
|
}),
|
|
2236
|
-
|
|
2248
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
2237
2249
|
x: stripX,
|
|
2238
2250
|
y: layout.plotY,
|
|
2239
2251
|
width: stripEnd - stripX,
|
|
@@ -2241,24 +2253,24 @@ function renderEras(layout, theme) {
|
|
|
2241
2253
|
fill,
|
|
2242
2254
|
class: "st-era-strip"
|
|
2243
2255
|
}),
|
|
2244
|
-
|
|
2256
|
+
chunkLFZZ4NCP_cjs.text(
|
|
2245
2257
|
{ x: labelX, y: y + 12, class: "st-era-label" },
|
|
2246
2258
|
truncate(e.era.label, Math.max(4, Math.floor(e.width / 7)))
|
|
2247
2259
|
)
|
|
2248
2260
|
].join("");
|
|
2249
2261
|
});
|
|
2250
|
-
return
|
|
2262
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-eras" }, items);
|
|
2251
2263
|
}
|
|
2252
2264
|
function renderAxis(layout) {
|
|
2253
2265
|
const ax = layout.axisY;
|
|
2254
2266
|
const items = [
|
|
2255
|
-
|
|
2267
|
+
chunkLFZZ4NCP_cjs.line({ x1: layout.plotX, y1: ax, x2: layout.plotX + layout.plotW, y2: ax, class: "st-axis-line" })
|
|
2256
2268
|
];
|
|
2257
2269
|
for (const t of layout.ticks) {
|
|
2258
|
-
items.push(
|
|
2259
|
-
items.push(
|
|
2270
|
+
items.push(chunkLFZZ4NCP_cjs.line({ x1: t.x, y1: ax, x2: t.x, y2: ax + 5, class: "st-axis-tick" }));
|
|
2271
|
+
items.push(chunkLFZZ4NCP_cjs.text({ x: t.x, y: ax + 18, "text-anchor": "middle", class: "st-axis-label" }, t.label));
|
|
2260
2272
|
}
|
|
2261
|
-
return
|
|
2273
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-axis" }, items);
|
|
2262
2274
|
}
|
|
2263
2275
|
function renderSwimlane(layout, theme) {
|
|
2264
2276
|
const parts = [];
|
|
@@ -2271,16 +2283,16 @@ function renderSwimlane(layout, theme) {
|
|
|
2271
2283
|
return parts.join("");
|
|
2272
2284
|
}
|
|
2273
2285
|
function renderTrackLabels(layout) {
|
|
2274
|
-
const items = layout.lanes.filter((l) => l.label).map((l) =>
|
|
2286
|
+
const items = layout.lanes.filter((l) => l.label).map((l) => chunkLFZZ4NCP_cjs.text(
|
|
2275
2287
|
{ x: layout.plotX - 12, y: l.y + l.height / 2 + 4, "text-anchor": "end", class: "st-track-label" },
|
|
2276
2288
|
l.label
|
|
2277
2289
|
));
|
|
2278
|
-
return
|
|
2290
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-track-labels" }, items);
|
|
2279
2291
|
}
|
|
2280
2292
|
function renderLaneStripes(layout) {
|
|
2281
2293
|
const items = layout.lanes.map((l, i) => {
|
|
2282
2294
|
if (i % 2 !== 0) return "";
|
|
2283
|
-
return
|
|
2295
|
+
return chunkLFZZ4NCP_cjs.rect({
|
|
2284
2296
|
x: layout.plotX,
|
|
2285
2297
|
y: l.y,
|
|
2286
2298
|
width: layout.plotW,
|
|
@@ -2288,7 +2300,7 @@ function renderLaneStripes(layout) {
|
|
|
2288
2300
|
class: "st-lane-stripe"
|
|
2289
2301
|
});
|
|
2290
2302
|
}).filter(Boolean);
|
|
2291
|
-
return
|
|
2303
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-lanes" }, items);
|
|
2292
2304
|
}
|
|
2293
2305
|
function renderSwimlaneRanges(layout, theme) {
|
|
2294
2306
|
const items = [];
|
|
@@ -2298,7 +2310,7 @@ function renderSwimlaneRanges(layout, theme) {
|
|
|
2298
2310
|
if (ev.event.kind !== "range") continue;
|
|
2299
2311
|
const idx = trackOrder.indexOf(ev.event.trackId);
|
|
2300
2312
|
const fill = ev.event.color ?? palette[(idx < 0 ? 0 : idx) % palette.length];
|
|
2301
|
-
items.push(
|
|
2313
|
+
items.push(chunkLFZZ4NCP_cjs.rect({
|
|
2302
2314
|
x: ev.x,
|
|
2303
2315
|
y: ev.y,
|
|
2304
2316
|
width: ev.w ?? 4,
|
|
@@ -2311,18 +2323,18 @@ function renderSwimlaneRanges(layout, theme) {
|
|
|
2311
2323
|
}));
|
|
2312
2324
|
const w = ev.w ?? 0;
|
|
2313
2325
|
if (w >= 60) {
|
|
2314
|
-
items.push(
|
|
2326
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2315
2327
|
{ x: ev.labelX, y: ev.labelY, "text-anchor": "middle", class: "st-range-label" },
|
|
2316
2328
|
truncate(ev.event.label, Math.floor(w / 6))
|
|
2317
2329
|
));
|
|
2318
2330
|
} else if (w > 0) {
|
|
2319
|
-
items.push(
|
|
2331
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2320
2332
|
{ x: ev.x + w + 4, y: ev.labelY, "text-anchor": "start", class: "st-event-label" },
|
|
2321
2333
|
ev.event.label
|
|
2322
2334
|
));
|
|
2323
2335
|
}
|
|
2324
2336
|
}
|
|
2325
|
-
return
|
|
2337
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-ranges" }, items);
|
|
2326
2338
|
}
|
|
2327
2339
|
function renderSwimlanePoints(layout, theme) {
|
|
2328
2340
|
const items = [];
|
|
@@ -2333,7 +2345,7 @@ function renderSwimlanePoints(layout, theme) {
|
|
|
2333
2345
|
const shape = ev.event.shape ?? (isMilestone ? "star" : "circle");
|
|
2334
2346
|
items.push(renderMarker(ev, color, shape, isMilestone));
|
|
2335
2347
|
}
|
|
2336
|
-
return
|
|
2348
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-points" }, items);
|
|
2337
2349
|
}
|
|
2338
2350
|
function renderMarker(ev, color, shape, isMilestone) {
|
|
2339
2351
|
const x = ev.x;
|
|
@@ -2342,16 +2354,16 @@ function renderMarker(ev, color, shape, isMilestone) {
|
|
|
2342
2354
|
const klass = isMilestone ? "st-milestone" : "st-event-dot";
|
|
2343
2355
|
switch (shape) {
|
|
2344
2356
|
case "square":
|
|
2345
|
-
return
|
|
2357
|
+
return chunkLFZZ4NCP_cjs.rect({ x: x - r, y: y - r, width: r * 2, height: r * 2, fill: color, class: klass, "data-event-id": ev.event.id });
|
|
2346
2358
|
case "diamond":
|
|
2347
|
-
return
|
|
2359
|
+
return chunkLFZZ4NCP_cjs.path({ d: `M ${x},${y - r} L ${x + r},${y} L ${x},${y + r} L ${x - r},${y} Z`, fill: color, class: klass, "data-event-id": ev.event.id });
|
|
2348
2360
|
case "star":
|
|
2349
|
-
return
|
|
2361
|
+
return chunkLFZZ4NCP_cjs.path({ d: starPath(x, y, r + 2, (r + 2) / 2.5, 5), fill: color, class: klass, "data-event-id": ev.event.id });
|
|
2350
2362
|
case "flag":
|
|
2351
|
-
return
|
|
2363
|
+
return chunkLFZZ4NCP_cjs.path({ d: `M ${x - r},${y + r} L ${x - r},${y - r - 4} L ${x + r + 4},${y - r - 1} L ${x - r},${y + 2}`, fill: color, class: klass, "data-event-id": ev.event.id });
|
|
2352
2364
|
case "circle":
|
|
2353
2365
|
default:
|
|
2354
|
-
return
|
|
2366
|
+
return chunkLFZZ4NCP_cjs.circle({ cx: x, cy: y, r, fill: color, class: klass, "data-event-id": ev.event.id });
|
|
2355
2367
|
}
|
|
2356
2368
|
}
|
|
2357
2369
|
function renderLabels(layout) {
|
|
@@ -2364,14 +2376,14 @@ function renderLabels(layout) {
|
|
|
2364
2376
|
if (Math.abs(dy) > 22) {
|
|
2365
2377
|
const y1 = dy < 0 ? ev.y - 6 : ev.y + 6;
|
|
2366
2378
|
const y2 = dy < 0 ? ev.labelY + 3 : ev.labelY - 10;
|
|
2367
|
-
items.push(
|
|
2379
|
+
items.push(chunkLFZZ4NCP_cjs.line({ x1: ev.x, y1, x2: ev.x, y2, class: "st-label-leader" }));
|
|
2368
2380
|
}
|
|
2369
|
-
items.push(
|
|
2381
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2370
2382
|
{ x: ev.labelX, y: ev.labelY, "text-anchor": ev.labelAnchor, class: cls },
|
|
2371
2383
|
text2
|
|
2372
2384
|
));
|
|
2373
2385
|
}
|
|
2374
|
-
return
|
|
2386
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-labels" }, items);
|
|
2375
2387
|
}
|
|
2376
2388
|
function renderNotes(layout) {
|
|
2377
2389
|
const items = [];
|
|
@@ -2381,15 +2393,15 @@ function renderNotes(layout) {
|
|
|
2381
2393
|
const ny = ev.noteY ?? ev.y + 18;
|
|
2382
2394
|
const nx = ev.noteX ?? x + 10;
|
|
2383
2395
|
const wrapped = wrapText2(ev.event.note, 46);
|
|
2384
|
-
items.push(
|
|
2396
|
+
items.push(chunkLFZZ4NCP_cjs.path({ d: `M ${x} ${ev.y + 6} Q ${x + 4} ${ny - 4} ${nx} ${ny}`, class: "st-callout-line" }));
|
|
2385
2397
|
wrapped.forEach((ln, i) => {
|
|
2386
|
-
items.push(
|
|
2398
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2387
2399
|
{ x: nx, y: ny + i * 13, class: "st-callout-text" },
|
|
2388
2400
|
ln
|
|
2389
2401
|
));
|
|
2390
2402
|
});
|
|
2391
2403
|
}
|
|
2392
|
-
return
|
|
2404
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-notes" }, items);
|
|
2393
2405
|
}
|
|
2394
2406
|
function renderGantt(layout, theme) {
|
|
2395
2407
|
const parts = [];
|
|
@@ -2405,7 +2417,7 @@ function renderGanttLanes(layout) {
|
|
|
2405
2417
|
const items = [];
|
|
2406
2418
|
layout.lanes.forEach((l, i) => {
|
|
2407
2419
|
if (i % 2 === 0) {
|
|
2408
|
-
items.push(
|
|
2420
|
+
items.push(chunkLFZZ4NCP_cjs.rect({
|
|
2409
2421
|
x: layout.plotX,
|
|
2410
2422
|
y: l.y,
|
|
2411
2423
|
width: layout.plotW,
|
|
@@ -2413,14 +2425,14 @@ function renderGanttLanes(layout) {
|
|
|
2413
2425
|
class: "st-lane-stripe"
|
|
2414
2426
|
}));
|
|
2415
2427
|
}
|
|
2416
|
-
items.push(
|
|
2428
|
+
items.push(chunkLFZZ4NCP_cjs.text({
|
|
2417
2429
|
x: layout.plotX - 10,
|
|
2418
2430
|
y: l.y + l.height / 2 + 4,
|
|
2419
2431
|
"text-anchor": "end",
|
|
2420
2432
|
class: "st-lane-label"
|
|
2421
2433
|
}, l.label));
|
|
2422
2434
|
});
|
|
2423
|
-
return
|
|
2435
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-gantt-lanes" }, items);
|
|
2424
2436
|
}
|
|
2425
2437
|
function renderGanttBars(layout, theme) {
|
|
2426
2438
|
const items = [];
|
|
@@ -2431,7 +2443,7 @@ function renderGanttBars(layout, theme) {
|
|
|
2431
2443
|
const cat = ev.event.category ?? layout.lanes[0]?.label ?? "";
|
|
2432
2444
|
const color = ev.event.color ?? legendByLabel.get(cat) ?? theme.categoryPalette[0];
|
|
2433
2445
|
const w = ev.w ?? 4;
|
|
2434
|
-
items.push(
|
|
2446
|
+
items.push(chunkLFZZ4NCP_cjs.rect({
|
|
2435
2447
|
x: ev.x,
|
|
2436
2448
|
y: ev.y,
|
|
2437
2449
|
width: w,
|
|
@@ -2444,20 +2456,20 @@ function renderGanttBars(layout, theme) {
|
|
|
2444
2456
|
"data-category": cat
|
|
2445
2457
|
}));
|
|
2446
2458
|
if (w >= 60) {
|
|
2447
|
-
items.push(
|
|
2459
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2448
2460
|
{ x: ev.labelX, y: ev.labelY, "text-anchor": "middle", class: "st-range-label" },
|
|
2449
2461
|
truncate(ev.event.label, Math.floor(w / 6))
|
|
2450
2462
|
));
|
|
2451
2463
|
} else if (w > 0) {
|
|
2452
2464
|
const lane = laneByCat.get(cat);
|
|
2453
2465
|
const ly = lane ? lane.y + lane.height / 2 + 4 : ev.labelY;
|
|
2454
|
-
items.push(
|
|
2466
|
+
items.push(chunkLFZZ4NCP_cjs.text(
|
|
2455
2467
|
{ x: ev.x + w + 4, y: ly, "text-anchor": "start", class: "st-event-label" },
|
|
2456
2468
|
ev.event.label
|
|
2457
2469
|
));
|
|
2458
2470
|
}
|
|
2459
2471
|
}
|
|
2460
|
-
return
|
|
2472
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-gantt-bars" }, items);
|
|
2461
2473
|
}
|
|
2462
2474
|
function renderGanttPins(layout) {
|
|
2463
2475
|
const pins = layout.pins ?? [];
|
|
@@ -2466,20 +2478,20 @@ function renderGanttPins(layout) {
|
|
|
2466
2478
|
for (const p of pins) {
|
|
2467
2479
|
items.push(renderPin(p));
|
|
2468
2480
|
}
|
|
2469
|
-
return
|
|
2481
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-gantt-pins" }, items);
|
|
2470
2482
|
}
|
|
2471
2483
|
function renderPin(p) {
|
|
2472
2484
|
const isMilestone = p.event.kind === "milestone";
|
|
2473
|
-
const shaft =
|
|
2485
|
+
const shaft = chunkLFZZ4NCP_cjs.path({
|
|
2474
2486
|
d: `M ${p.x} ${p.labelY + 2} L ${p.x} ${p.axisY - 4}`,
|
|
2475
2487
|
class: "st-pin-shaft"
|
|
2476
2488
|
});
|
|
2477
|
-
const head = isMilestone ?
|
|
2489
|
+
const head = isMilestone ? chunkLFZZ4NCP_cjs.path({
|
|
2478
2490
|
d: starPath(p.x, p.axisY - 6, 7, 3, 5),
|
|
2479
2491
|
fill: p.color,
|
|
2480
2492
|
class: "st-pin-head",
|
|
2481
2493
|
"data-event-id": p.event.id
|
|
2482
|
-
}) :
|
|
2494
|
+
}) : chunkLFZZ4NCP_cjs.circle({
|
|
2483
2495
|
cx: p.x,
|
|
2484
2496
|
cy: p.axisY - 6,
|
|
2485
2497
|
r: 5,
|
|
@@ -2488,7 +2500,7 @@ function renderPin(p) {
|
|
|
2488
2500
|
"data-event-id": p.event.id
|
|
2489
2501
|
});
|
|
2490
2502
|
const txt = p.event.icon ? `${p.event.icon} ${p.event.label}` : p.event.label;
|
|
2491
|
-
const label =
|
|
2503
|
+
const label = chunkLFZZ4NCP_cjs.text(
|
|
2492
2504
|
{ x: p.x, y: p.labelY, "text-anchor": "middle", class: "st-pin-label" },
|
|
2493
2505
|
txt
|
|
2494
2506
|
);
|
|
@@ -2504,15 +2516,15 @@ function renderLegend(layout) {
|
|
|
2504
2516
|
const x = layout.width - boxW - 16;
|
|
2505
2517
|
const y = layout.plotY;
|
|
2506
2518
|
const items = [
|
|
2507
|
-
|
|
2508
|
-
|
|
2519
|
+
chunkLFZZ4NCP_cjs.rect({ x, y, width: boxW, height: h, rx: 6, ry: 6, class: "st-legend-box" }),
|
|
2520
|
+
chunkLFZZ4NCP_cjs.text({ x: x + padding, y: y + padding + 12, class: "st-legend-title" }, "Teams")
|
|
2509
2521
|
];
|
|
2510
2522
|
legend.forEach((it, i) => {
|
|
2511
2523
|
const rowY = y + padding + 18 + i * rowH + 8;
|
|
2512
|
-
items.push(
|
|
2513
|
-
items.push(
|
|
2524
|
+
items.push(chunkLFZZ4NCP_cjs.rect({ x: x + padding, y: rowY - 7, width: 12, height: 12, rx: 2, ry: 2, fill: it.color }));
|
|
2525
|
+
items.push(chunkLFZZ4NCP_cjs.text({ x: x + padding + 20, y: rowY + 3, class: "st-legend-label" }, truncate(it.label, 14)));
|
|
2514
2526
|
});
|
|
2515
|
-
return
|
|
2527
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-legend" }, items);
|
|
2516
2528
|
}
|
|
2517
2529
|
function renderLollipop(layout, theme) {
|
|
2518
2530
|
const parts = [];
|
|
@@ -2525,7 +2537,7 @@ function renderLollipopRanges(layout, theme) {
|
|
|
2525
2537
|
for (const ev of layout.events) {
|
|
2526
2538
|
if (ev.event.kind !== "range") continue;
|
|
2527
2539
|
const color = ev.event.color ?? theme.categoryPalette[0];
|
|
2528
|
-
items.push(
|
|
2540
|
+
items.push(chunkLFZZ4NCP_cjs.rect({
|
|
2529
2541
|
x: ev.x,
|
|
2530
2542
|
y: ev.y,
|
|
2531
2543
|
width: ev.w ?? 4,
|
|
@@ -2537,7 +2549,7 @@ function renderLollipopRanges(layout, theme) {
|
|
|
2537
2549
|
"data-event-id": ev.event.id
|
|
2538
2550
|
}));
|
|
2539
2551
|
}
|
|
2540
|
-
return
|
|
2552
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-lp-ranges" }, items);
|
|
2541
2553
|
}
|
|
2542
2554
|
function renderLollipopCards(layout, theme) {
|
|
2543
2555
|
const cards = layout.cards ?? [];
|
|
@@ -2546,14 +2558,14 @@ function renderLollipopCards(layout, theme) {
|
|
|
2546
2558
|
for (const c of cards) {
|
|
2547
2559
|
items.push(renderLollipopCard(c, theme));
|
|
2548
2560
|
}
|
|
2549
|
-
return
|
|
2561
|
+
return chunkLFZZ4NCP_cjs.group({ class: "st-lp-cards" }, items);
|
|
2550
2562
|
}
|
|
2551
2563
|
function renderLollipopCard(c, theme) {
|
|
2552
2564
|
const parts = [];
|
|
2553
|
-
parts.push(
|
|
2554
|
-
parts.push(
|
|
2555
|
-
parts.push(
|
|
2556
|
-
parts.push(
|
|
2565
|
+
parts.push(chunkLFZZ4NCP_cjs.path({ d: `M ${c.x} ${c.stemY1} L ${c.x} ${c.stemY2}`, class: "st-stem" }));
|
|
2566
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: c.x, cy: c.axisY, r: 7, fill: theme.markerFill, stroke: c.color, class: "st-lp-marker-ring" }));
|
|
2567
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: c.x, cy: c.axisY, r: 3.2, fill: c.color, class: "st-lp-marker-core" }));
|
|
2568
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({
|
|
2557
2569
|
x: c.cardX,
|
|
2558
2570
|
y: c.cardY,
|
|
2559
2571
|
width: c.cardW,
|
|
@@ -2562,7 +2574,7 @@ function renderLollipopCard(c, theme) {
|
|
|
2562
2574
|
ry: 8,
|
|
2563
2575
|
class: "st-card"
|
|
2564
2576
|
}));
|
|
2565
|
-
parts.push(
|
|
2577
|
+
parts.push(chunkLFZZ4NCP_cjs.rect({
|
|
2566
2578
|
x: c.cardX,
|
|
2567
2579
|
y: c.cardY,
|
|
2568
2580
|
width: 4,
|
|
@@ -2573,11 +2585,11 @@ function renderLollipopCard(c, theme) {
|
|
|
2573
2585
|
}));
|
|
2574
2586
|
const padX = c.cardX + 14;
|
|
2575
2587
|
const titleText = c.event.icon ? `${c.event.icon} ${c.event.label}` : c.event.label;
|
|
2576
|
-
parts.push(
|
|
2588
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
2577
2589
|
{ x: padX, y: c.cardY + 22, class: "st-card-title" },
|
|
2578
2590
|
truncate(titleText, 26)
|
|
2579
2591
|
));
|
|
2580
|
-
parts.push(
|
|
2592
|
+
parts.push(chunkLFZZ4NCP_cjs.text(
|
|
2581
2593
|
{ x: padX, y: c.cardY + 40, class: "st-card-date" },
|
|
2582
2594
|
c.event.start.raw
|
|
2583
2595
|
));
|
|
@@ -2628,6 +2640,2804 @@ var timeline = {
|
|
|
2628
2640
|
}
|
|
2629
2641
|
};
|
|
2630
2642
|
|
|
2643
|
+
// src/diagrams/state/parser.ts
|
|
2644
|
+
var StateParseError = class extends Error {
|
|
2645
|
+
constructor(message, line2) {
|
|
2646
|
+
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
2647
|
+
this.line = line2;
|
|
2648
|
+
this.name = "StateParseError";
|
|
2649
|
+
}
|
|
2650
|
+
line;
|
|
2651
|
+
};
|
|
2652
|
+
var PSEUDO_KEYWORDS = {
|
|
2653
|
+
initial: "initial",
|
|
2654
|
+
final: "final",
|
|
2655
|
+
choice: "choice",
|
|
2656
|
+
junction: "junction",
|
|
2657
|
+
fork: "fork",
|
|
2658
|
+
join: "join",
|
|
2659
|
+
history: "history",
|
|
2660
|
+
dhistory: "dhistory",
|
|
2661
|
+
terminate: "terminate",
|
|
2662
|
+
entry_point: "entry_point",
|
|
2663
|
+
exit_point: "exit_point"
|
|
2664
|
+
};
|
|
2665
|
+
var MERMAID_STEREOTYPE = {
|
|
2666
|
+
choice: "choice",
|
|
2667
|
+
fork: "fork",
|
|
2668
|
+
join: "join",
|
|
2669
|
+
end: "final"
|
|
2670
|
+
};
|
|
2671
|
+
function preprocess3(src) {
|
|
2672
|
+
const out = [];
|
|
2673
|
+
const lines = src.split(/\r?\n/);
|
|
2674
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2675
|
+
const raw = lines[i];
|
|
2676
|
+
if (raw === void 0) continue;
|
|
2677
|
+
const trimmed = raw.trim();
|
|
2678
|
+
if (!trimmed) continue;
|
|
2679
|
+
if (trimmed.startsWith("#") || trimmed.startsWith("//") || trimmed.startsWith("%%")) continue;
|
|
2680
|
+
const indent = raw.length - raw.replace(/^\s+/, "").length;
|
|
2681
|
+
out.push({ indent, text: trimmed, line: i + 1 });
|
|
2682
|
+
}
|
|
2683
|
+
return out;
|
|
2684
|
+
}
|
|
2685
|
+
function unquote2(s) {
|
|
2686
|
+
if (s.length >= 2 && s.startsWith('"') && s.endsWith('"')) {
|
|
2687
|
+
return s.slice(1, -1);
|
|
2688
|
+
}
|
|
2689
|
+
return s;
|
|
2690
|
+
}
|
|
2691
|
+
function parseProps(s) {
|
|
2692
|
+
const out = {};
|
|
2693
|
+
const inner = s.replace(/^\[/, "").replace(/\]$/, "");
|
|
2694
|
+
if (!inner.trim()) return out;
|
|
2695
|
+
for (const part of inner.split(",")) {
|
|
2696
|
+
const idx = part.indexOf(":");
|
|
2697
|
+
if (idx < 0) continue;
|
|
2698
|
+
out[part.slice(0, idx).trim()] = unquote2(part.slice(idx + 1).trim());
|
|
2699
|
+
}
|
|
2700
|
+
return out;
|
|
2701
|
+
}
|
|
2702
|
+
function parseTransitionLabel(label) {
|
|
2703
|
+
const out = {};
|
|
2704
|
+
let rest = label.trim();
|
|
2705
|
+
if (!rest) return out;
|
|
2706
|
+
let depth = 0;
|
|
2707
|
+
let slashIdx = -1;
|
|
2708
|
+
for (let i = 0; i < rest.length; i++) {
|
|
2709
|
+
const c = rest[i];
|
|
2710
|
+
if (c === "[") depth++;
|
|
2711
|
+
else if (c === "]") depth--;
|
|
2712
|
+
else if (c === "/" && depth === 0) {
|
|
2713
|
+
slashIdx = i;
|
|
2714
|
+
break;
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
if (slashIdx >= 0) {
|
|
2718
|
+
out.action = rest.slice(slashIdx + 1).trim();
|
|
2719
|
+
rest = rest.slice(0, slashIdx).trim();
|
|
2720
|
+
}
|
|
2721
|
+
const gMatch = rest.match(/^(?<trig>[^[]*?)\s*\[(?<guard>[^\]]*)\]\s*$/);
|
|
2722
|
+
if (gMatch?.groups) {
|
|
2723
|
+
out.guard = gMatch.groups.guard.trim();
|
|
2724
|
+
const trig = gMatch.groups.trig.trim();
|
|
2725
|
+
if (trig) out.trigger = trig;
|
|
2726
|
+
} else if (rest.length) {
|
|
2727
|
+
out.trigger = rest;
|
|
2728
|
+
}
|
|
2729
|
+
return out;
|
|
2730
|
+
}
|
|
2731
|
+
function parseActivityLine(text2) {
|
|
2732
|
+
const match = text2.match(/^(entry|exit|do)\s*\/\s*(.*)$/);
|
|
2733
|
+
if (match) {
|
|
2734
|
+
return { kind: match[1], action: match[2].trim() };
|
|
2735
|
+
}
|
|
2736
|
+
const parsed = parseTransitionLabel(text2);
|
|
2737
|
+
if (!parsed.trigger && !parsed.guard && !parsed.action) return void 0;
|
|
2738
|
+
return {
|
|
2739
|
+
kind: "internal",
|
|
2740
|
+
trigger: parsed.trigger,
|
|
2741
|
+
guard: parsed.guard,
|
|
2742
|
+
action: parsed.action
|
|
2743
|
+
};
|
|
2744
|
+
}
|
|
2745
|
+
function newPseudoId(ctx, kind) {
|
|
2746
|
+
ctx.pseudoCounter += 1;
|
|
2747
|
+
return `__${kind}_${ctx.pseudoCounter}`;
|
|
2748
|
+
}
|
|
2749
|
+
function ensureInitialAlias(ctx, parent) {
|
|
2750
|
+
if (!parent) {
|
|
2751
|
+
if (ctx.initialAlias) {
|
|
2752
|
+
const existing = ctx.byId.get(ctx.initialAlias);
|
|
2753
|
+
if (existing) return existing;
|
|
2754
|
+
}
|
|
2755
|
+
const node2 = {
|
|
2756
|
+
id: newPseudoId(ctx, "initial"),
|
|
2757
|
+
label: "",
|
|
2758
|
+
kind: "pseudo",
|
|
2759
|
+
pseudoKind: "initial",
|
|
2760
|
+
activities: [],
|
|
2761
|
+
children: []
|
|
2762
|
+
};
|
|
2763
|
+
ctx.initialAlias = node2.id;
|
|
2764
|
+
ctx.byId.set(node2.id, node2);
|
|
2765
|
+
ctx.states.push(node2);
|
|
2766
|
+
return node2;
|
|
2767
|
+
}
|
|
2768
|
+
for (const child of parent.children) {
|
|
2769
|
+
if (child.id.startsWith("__initial_") && child.label === "") return child;
|
|
2770
|
+
}
|
|
2771
|
+
const node = {
|
|
2772
|
+
id: newPseudoId(ctx, "initial"),
|
|
2773
|
+
label: "",
|
|
2774
|
+
kind: "pseudo",
|
|
2775
|
+
pseudoKind: "initial",
|
|
2776
|
+
activities: [],
|
|
2777
|
+
children: [],
|
|
2778
|
+
parent: parent.id
|
|
2779
|
+
};
|
|
2780
|
+
ctx.byId.set(node.id, node);
|
|
2781
|
+
parent.children.push(node);
|
|
2782
|
+
return node;
|
|
2783
|
+
}
|
|
2784
|
+
function ensureFinalAlias(ctx, parent) {
|
|
2785
|
+
if (!parent) {
|
|
2786
|
+
if (ctx.finalAlias) {
|
|
2787
|
+
const existing = ctx.byId.get(ctx.finalAlias);
|
|
2788
|
+
if (existing) return existing;
|
|
2789
|
+
}
|
|
2790
|
+
const node2 = {
|
|
2791
|
+
id: newPseudoId(ctx, "final"),
|
|
2792
|
+
label: "",
|
|
2793
|
+
kind: "pseudo",
|
|
2794
|
+
pseudoKind: "final",
|
|
2795
|
+
activities: [],
|
|
2796
|
+
children: []
|
|
2797
|
+
};
|
|
2798
|
+
ctx.finalAlias = node2.id;
|
|
2799
|
+
ctx.byId.set(node2.id, node2);
|
|
2800
|
+
ctx.states.push(node2);
|
|
2801
|
+
return node2;
|
|
2802
|
+
}
|
|
2803
|
+
for (const child of parent.children) {
|
|
2804
|
+
if (child.id.startsWith("__final_") && child.label === "") return child;
|
|
2805
|
+
}
|
|
2806
|
+
const node = {
|
|
2807
|
+
id: newPseudoId(ctx, "final"),
|
|
2808
|
+
label: "",
|
|
2809
|
+
kind: "pseudo",
|
|
2810
|
+
pseudoKind: "final",
|
|
2811
|
+
activities: [],
|
|
2812
|
+
children: [],
|
|
2813
|
+
parent: parent.id
|
|
2814
|
+
};
|
|
2815
|
+
ctx.byId.set(node.id, node);
|
|
2816
|
+
parent.children.push(node);
|
|
2817
|
+
return node;
|
|
2818
|
+
}
|
|
2819
|
+
function ensureSimpleState(ctx, id, parent) {
|
|
2820
|
+
const existing = ctx.byId.get(id);
|
|
2821
|
+
if (existing) return existing;
|
|
2822
|
+
const node = {
|
|
2823
|
+
id,
|
|
2824
|
+
label: id,
|
|
2825
|
+
kind: "simple",
|
|
2826
|
+
activities: [],
|
|
2827
|
+
children: [],
|
|
2828
|
+
parent: parent?.id
|
|
2829
|
+
};
|
|
2830
|
+
ctx.byId.set(id, node);
|
|
2831
|
+
if (parent) parent.children.push(node);
|
|
2832
|
+
else ctx.states.push(node);
|
|
2833
|
+
return node;
|
|
2834
|
+
}
|
|
2835
|
+
function isIdent(tok) {
|
|
2836
|
+
return /^[A-Za-z_][A-Za-z0-9_]*$/.test(tok);
|
|
2837
|
+
}
|
|
2838
|
+
function parseStateDiagram(src) {
|
|
2839
|
+
const lines = preprocess3(src);
|
|
2840
|
+
if (lines.length === 0) {
|
|
2841
|
+
throw new StateParseError("Empty document");
|
|
2842
|
+
}
|
|
2843
|
+
const header = lines[0];
|
|
2844
|
+
const headerTok = header.text.match(/^(stateDiagram-v2|stateDiagram|state)\b/i);
|
|
2845
|
+
if (!headerTok) {
|
|
2846
|
+
throw new StateParseError(
|
|
2847
|
+
`Expected 'state' or 'stateDiagram' header, got '${header.text}'`,
|
|
2848
|
+
header.line
|
|
2849
|
+
);
|
|
2850
|
+
}
|
|
2851
|
+
let title2;
|
|
2852
|
+
let direction = "TB";
|
|
2853
|
+
const headerRest = header.text.slice(headerTok[0].length).trim();
|
|
2854
|
+
const propsMatch = headerRest.match(/\[[^\]]*\]\s*$/);
|
|
2855
|
+
let beforeProps = headerRest;
|
|
2856
|
+
if (propsMatch) {
|
|
2857
|
+
const props = parseProps(propsMatch[0]);
|
|
2858
|
+
if (props.direction === "TB" || props.direction === "LR") direction = props.direction;
|
|
2859
|
+
beforeProps = headerRest.slice(0, propsMatch.index).trim();
|
|
2860
|
+
}
|
|
2861
|
+
if (beforeProps.startsWith('"')) title2 = unquote2(beforeProps);
|
|
2862
|
+
else if (beforeProps.length > 0) title2 = beforeProps;
|
|
2863
|
+
const ctx = {
|
|
2864
|
+
states: [],
|
|
2865
|
+
transitions: [],
|
|
2866
|
+
notes: [],
|
|
2867
|
+
pseudoCounter: 0,
|
|
2868
|
+
noteCounter: 0,
|
|
2869
|
+
transCounter: 0,
|
|
2870
|
+
byId: /* @__PURE__ */ new Map()
|
|
2871
|
+
};
|
|
2872
|
+
const compositeStack = [{ parent: void 0, regionMode: false }];
|
|
2873
|
+
let i = 1;
|
|
2874
|
+
while (i < lines.length) {
|
|
2875
|
+
const ln = lines[i];
|
|
2876
|
+
const text2 = ln.text;
|
|
2877
|
+
const ctxTop = compositeStack[compositeStack.length - 1];
|
|
2878
|
+
const parent = ctxTop.parent;
|
|
2879
|
+
if (text2 === "}") {
|
|
2880
|
+
if (compositeStack.length <= 1) {
|
|
2881
|
+
throw new StateParseError("Unexpected '}'", ln.line);
|
|
2882
|
+
}
|
|
2883
|
+
compositeStack.pop();
|
|
2884
|
+
i++;
|
|
2885
|
+
continue;
|
|
2886
|
+
}
|
|
2887
|
+
if (text2 === "---" || text2 === "--") {
|
|
2888
|
+
if (!parent) {
|
|
2889
|
+
throw new StateParseError(
|
|
2890
|
+
"Region separator only allowed inside a composite",
|
|
2891
|
+
ln.line
|
|
2892
|
+
);
|
|
2893
|
+
}
|
|
2894
|
+
ctxTop.regionMode = true;
|
|
2895
|
+
if (!parent.regions) parent.regions = [];
|
|
2896
|
+
const lastIdx = parent.regions.reduce((s, r) => s + r.length, 0);
|
|
2897
|
+
const slice = parent.children.slice(lastIdx);
|
|
2898
|
+
parent.regions.push(slice);
|
|
2899
|
+
i++;
|
|
2900
|
+
continue;
|
|
2901
|
+
}
|
|
2902
|
+
const dirMatch = text2.match(/^direction\s+(TB|BT|LR|RL)\s*$/);
|
|
2903
|
+
if (dirMatch) {
|
|
2904
|
+
const d = dirMatch[1];
|
|
2905
|
+
direction = d === "BT" ? "TB" : d === "RL" ? "LR" : d;
|
|
2906
|
+
i++;
|
|
2907
|
+
continue;
|
|
2908
|
+
}
|
|
2909
|
+
const compMatch = text2.match(/^(?:composite|state)\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{?\s*$/);
|
|
2910
|
+
const isCompositeWithBrace = compMatch && text2.endsWith("{");
|
|
2911
|
+
if (isCompositeWithBrace) {
|
|
2912
|
+
const id = compMatch[1];
|
|
2913
|
+
const node = ensureSimpleState(ctx, id, parent);
|
|
2914
|
+
node.kind = "composite";
|
|
2915
|
+
compositeStack.push({ parent: node, regionMode: false });
|
|
2916
|
+
i++;
|
|
2917
|
+
continue;
|
|
2918
|
+
}
|
|
2919
|
+
const aliasMatch = text2.match(/^state\s+"([^"]*)"\s+as\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/);
|
|
2920
|
+
if (aliasMatch) {
|
|
2921
|
+
const node = ensureSimpleState(ctx, aliasMatch[2], parent);
|
|
2922
|
+
node.label = aliasMatch[1];
|
|
2923
|
+
i++;
|
|
2924
|
+
continue;
|
|
2925
|
+
}
|
|
2926
|
+
const stereoMatch = text2.match(/^state\s+([A-Za-z_][A-Za-z0-9_]*)\s+<<\s*(choice|fork|join|end)\s*>>\s*$/);
|
|
2927
|
+
if (stereoMatch) {
|
|
2928
|
+
const id = stereoMatch[1];
|
|
2929
|
+
const kind = MERMAID_STEREOTYPE[stereoMatch[2]];
|
|
2930
|
+
const node = {
|
|
2931
|
+
id,
|
|
2932
|
+
label: "",
|
|
2933
|
+
kind: "pseudo",
|
|
2934
|
+
pseudoKind: kind,
|
|
2935
|
+
activities: [],
|
|
2936
|
+
children: [],
|
|
2937
|
+
parent: parent?.id
|
|
2938
|
+
};
|
|
2939
|
+
ctx.byId.set(id, node);
|
|
2940
|
+
if (parent) parent.children.push(node);
|
|
2941
|
+
else ctx.states.push(node);
|
|
2942
|
+
i++;
|
|
2943
|
+
continue;
|
|
2944
|
+
}
|
|
2945
|
+
const stateLabelMatch = text2.match(/^state\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.+)$/);
|
|
2946
|
+
if (stateLabelMatch) {
|
|
2947
|
+
const node = ensureSimpleState(ctx, stateLabelMatch[1], parent);
|
|
2948
|
+
node.label = unquote2(stateLabelMatch[2].trim());
|
|
2949
|
+
i++;
|
|
2950
|
+
continue;
|
|
2951
|
+
}
|
|
2952
|
+
const pseudoMatch = text2.match(
|
|
2953
|
+
/^(initial|final|choice|junction|fork|join|history|dhistory|terminate|entry_point|exit_point)\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/
|
|
2954
|
+
);
|
|
2955
|
+
if (pseudoMatch) {
|
|
2956
|
+
const kindKw = pseudoMatch[1];
|
|
2957
|
+
const id = pseudoMatch[2];
|
|
2958
|
+
const pkind = PSEUDO_KEYWORDS[kindKw];
|
|
2959
|
+
const node = {
|
|
2960
|
+
id,
|
|
2961
|
+
label: "",
|
|
2962
|
+
kind: "pseudo",
|
|
2963
|
+
pseudoKind: pkind,
|
|
2964
|
+
activities: [],
|
|
2965
|
+
children: [],
|
|
2966
|
+
parent: parent?.id
|
|
2967
|
+
};
|
|
2968
|
+
ctx.byId.set(id, node);
|
|
2969
|
+
if (parent) parent.children.push(node);
|
|
2970
|
+
else ctx.states.push(node);
|
|
2971
|
+
i++;
|
|
2972
|
+
continue;
|
|
2973
|
+
}
|
|
2974
|
+
if (parent) {
|
|
2975
|
+
const activity = parseActivityLine(text2);
|
|
2976
|
+
if (activity && (activity.kind === "entry" || activity.kind === "exit" || activity.kind === "do")) {
|
|
2977
|
+
parent.activities.push(activity);
|
|
2978
|
+
i++;
|
|
2979
|
+
continue;
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
const noteSimple = text2.match(
|
|
2983
|
+
/^note\s+(left[_ ]of|right[_ ]of)\s+([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.*)$/
|
|
2984
|
+
);
|
|
2985
|
+
if (noteSimple) {
|
|
2986
|
+
const side = noteSimple[1].startsWith("left") ? "left" : "right";
|
|
2987
|
+
const target = noteSimple[2];
|
|
2988
|
+
ctx.noteCounter += 1;
|
|
2989
|
+
ctx.notes.push({
|
|
2990
|
+
id: `__note_${ctx.noteCounter}`,
|
|
2991
|
+
target,
|
|
2992
|
+
side,
|
|
2993
|
+
text: noteSimple[3].trim()
|
|
2994
|
+
});
|
|
2995
|
+
i++;
|
|
2996
|
+
continue;
|
|
2997
|
+
}
|
|
2998
|
+
const noteBlockMermaid = text2.match(
|
|
2999
|
+
/^note\s+(left[_ ]of|right[_ ]of)\s+([A-Za-z_][A-Za-z0-9_]*)\s*$/
|
|
3000
|
+
);
|
|
3001
|
+
if (noteBlockMermaid) {
|
|
3002
|
+
const side = noteBlockMermaid[1].startsWith("left") ? "left" : "right";
|
|
3003
|
+
const target = noteBlockMermaid[2];
|
|
3004
|
+
const buf = [];
|
|
3005
|
+
i++;
|
|
3006
|
+
while (i < lines.length) {
|
|
3007
|
+
const t = lines[i].text;
|
|
3008
|
+
if (t === "end note" || t === "}") break;
|
|
3009
|
+
buf.push(t);
|
|
3010
|
+
i++;
|
|
3011
|
+
}
|
|
3012
|
+
if (i >= lines.length) {
|
|
3013
|
+
throw new StateParseError("Unterminated note block", ln.line);
|
|
3014
|
+
}
|
|
3015
|
+
i++;
|
|
3016
|
+
ctx.noteCounter += 1;
|
|
3017
|
+
ctx.notes.push({
|
|
3018
|
+
id: `__note_${ctx.noteCounter}`,
|
|
3019
|
+
target,
|
|
3020
|
+
side,
|
|
3021
|
+
text: buf.join("\n")
|
|
3022
|
+
});
|
|
3023
|
+
continue;
|
|
3024
|
+
}
|
|
3025
|
+
const noteBlockSchematex = text2.match(
|
|
3026
|
+
/^note\s+(left[_ ]of\s+|right[_ ]of\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*\{\s*$/
|
|
3027
|
+
);
|
|
3028
|
+
if (noteBlockSchematex) {
|
|
3029
|
+
const side = noteBlockSchematex[1]?.startsWith("left") ? "left" : "right";
|
|
3030
|
+
const target = noteBlockSchematex[2];
|
|
3031
|
+
const buf = [];
|
|
3032
|
+
i++;
|
|
3033
|
+
while (i < lines.length && lines[i].text !== "}") {
|
|
3034
|
+
buf.push(lines[i].text);
|
|
3035
|
+
i++;
|
|
3036
|
+
}
|
|
3037
|
+
if (i >= lines.length) {
|
|
3038
|
+
throw new StateParseError("Unterminated note block", ln.line);
|
|
3039
|
+
}
|
|
3040
|
+
i++;
|
|
3041
|
+
ctx.noteCounter += 1;
|
|
3042
|
+
ctx.notes.push({
|
|
3043
|
+
id: `__note_${ctx.noteCounter}`,
|
|
3044
|
+
target,
|
|
3045
|
+
side,
|
|
3046
|
+
text: buf.join("\n")
|
|
3047
|
+
});
|
|
3048
|
+
continue;
|
|
3049
|
+
}
|
|
3050
|
+
const transMatch = text2.match(
|
|
3051
|
+
/^(\[\*\]|[A-Za-z_][A-Za-z0-9_]*)\s*-+>\s*(\[\*\]|[A-Za-z_][A-Za-z0-9_]*)\s*(?::\s*(.*))?$/
|
|
3052
|
+
);
|
|
3053
|
+
if (transMatch) {
|
|
3054
|
+
const fromTok = transMatch[1];
|
|
3055
|
+
const toTok = transMatch[2];
|
|
3056
|
+
const labelRaw = transMatch[3];
|
|
3057
|
+
const resolveTok = (tok, position) => {
|
|
3058
|
+
if (tok === "[*]") {
|
|
3059
|
+
if (position === "from") return ensureInitialAlias(ctx, parent).id;
|
|
3060
|
+
return ensureFinalAlias(ctx, parent).id;
|
|
3061
|
+
}
|
|
3062
|
+
return ensureSimpleState(ctx, tok, parent).id;
|
|
3063
|
+
};
|
|
3064
|
+
const fromId = resolveTok(fromTok, "from");
|
|
3065
|
+
const toId = resolveTok(toTok, "to");
|
|
3066
|
+
ctx.transCounter += 1;
|
|
3067
|
+
const tid = `t${ctx.transCounter}`;
|
|
3068
|
+
const parsedLabel = labelRaw ? parseTransitionLabel(labelRaw) : {};
|
|
3069
|
+
ctx.transitions.push({
|
|
3070
|
+
id: tid,
|
|
3071
|
+
from: fromId,
|
|
3072
|
+
to: toId,
|
|
3073
|
+
trigger: parsedLabel.trigger,
|
|
3074
|
+
guard: parsedLabel.guard,
|
|
3075
|
+
action: parsedLabel.action
|
|
3076
|
+
});
|
|
3077
|
+
i++;
|
|
3078
|
+
continue;
|
|
3079
|
+
}
|
|
3080
|
+
const labelOnlyMatch = text2.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*:\s*(.+)$/);
|
|
3081
|
+
if (labelOnlyMatch && isIdent(labelOnlyMatch[1])) {
|
|
3082
|
+
const node = ensureSimpleState(ctx, labelOnlyMatch[1], parent);
|
|
3083
|
+
node.label = unquote2(labelOnlyMatch[2].trim());
|
|
3084
|
+
i++;
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
const bareIdent = text2.match(/^([A-Za-z_][A-Za-z0-9_]*)\s*$/);
|
|
3088
|
+
if (bareIdent) {
|
|
3089
|
+
ensureSimpleState(ctx, bareIdent[1], parent);
|
|
3090
|
+
i++;
|
|
3091
|
+
continue;
|
|
3092
|
+
}
|
|
3093
|
+
throw new StateParseError(`Unparseable line: ${text2}`, ln.line);
|
|
3094
|
+
}
|
|
3095
|
+
if (compositeStack.length > 1) {
|
|
3096
|
+
throw new StateParseError("Unclosed composite block (expected '}')");
|
|
3097
|
+
}
|
|
3098
|
+
function finalizeRegions(node) {
|
|
3099
|
+
if (node.regions) {
|
|
3100
|
+
const consumed = node.regions.reduce((s, r) => s + r.length, 0);
|
|
3101
|
+
if (node.children.length > consumed) {
|
|
3102
|
+
node.regions.push(node.children.slice(consumed));
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
for (const child of node.children) finalizeRegions(child);
|
|
3106
|
+
}
|
|
3107
|
+
for (const s of ctx.states) finalizeRegions(s);
|
|
3108
|
+
return {
|
|
3109
|
+
type: "state",
|
|
3110
|
+
title: title2,
|
|
3111
|
+
direction,
|
|
3112
|
+
states: ctx.states,
|
|
3113
|
+
transitions: ctx.transitions,
|
|
3114
|
+
notes: ctx.notes
|
|
3115
|
+
};
|
|
3116
|
+
}
|
|
3117
|
+
|
|
3118
|
+
// src/diagrams/state/layout.ts
|
|
3119
|
+
var PSEUDO_BBOX = {
|
|
3120
|
+
initial: { w: 22, h: 22 },
|
|
3121
|
+
final: { w: 28, h: 28 },
|
|
3122
|
+
choice: { w: 32, h: 32 },
|
|
3123
|
+
junction: { w: 16, h: 16 },
|
|
3124
|
+
fork: { w: 100, h: 8 },
|
|
3125
|
+
// horizontal bar — rotated for LR direction below
|
|
3126
|
+
join: { w: 100, h: 8 },
|
|
3127
|
+
history: { w: 26, h: 26 },
|
|
3128
|
+
dhistory: { w: 30, h: 30 },
|
|
3129
|
+
terminate: { w: 22, h: 22 },
|
|
3130
|
+
entry_point: { w: 18, h: 18 },
|
|
3131
|
+
exit_point: { w: 18, h: 18 }
|
|
3132
|
+
};
|
|
3133
|
+
var NOTE_W = 180;
|
|
3134
|
+
var NOTE_LINE_H = 14;
|
|
3135
|
+
function shapeForState(node) {
|
|
3136
|
+
if (node.kind === "simple") return "round";
|
|
3137
|
+
if (node.kind === "composite") return "round";
|
|
3138
|
+
switch (node.pseudoKind) {
|
|
3139
|
+
case "initial":
|
|
3140
|
+
case "final":
|
|
3141
|
+
case "junction":
|
|
3142
|
+
case "history":
|
|
3143
|
+
case "dhistory":
|
|
3144
|
+
case "terminate":
|
|
3145
|
+
case "entry_point":
|
|
3146
|
+
case "exit_point":
|
|
3147
|
+
return "circle";
|
|
3148
|
+
case "choice":
|
|
3149
|
+
return "diamond";
|
|
3150
|
+
case "fork":
|
|
3151
|
+
case "join":
|
|
3152
|
+
return "rect";
|
|
3153
|
+
default:
|
|
3154
|
+
return "round";
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
function buildLabel(t) {
|
|
3158
|
+
const parts = [];
|
|
3159
|
+
if (t.trigger) parts.push(t.trigger);
|
|
3160
|
+
if (t.guard) parts.push(`[${t.guard}]`);
|
|
3161
|
+
let s = parts.join(" ");
|
|
3162
|
+
if (t.action) s = s ? `${s} / ${t.action}` : `/ ${t.action}`;
|
|
3163
|
+
return s.trim() || void 0;
|
|
3164
|
+
}
|
|
3165
|
+
function convertToFlowchart(ast) {
|
|
3166
|
+
const fcNodes = [];
|
|
3167
|
+
const fcSubgraphs = [];
|
|
3168
|
+
const pseudoSizes = /* @__PURE__ */ new Map();
|
|
3169
|
+
const compositeEntryFor = /* @__PURE__ */ new Map();
|
|
3170
|
+
const compositeExitFor = /* @__PURE__ */ new Map();
|
|
3171
|
+
const visit = (s, parentId) => {
|
|
3172
|
+
if (s.kind === "composite") {
|
|
3173
|
+
const childIds = [];
|
|
3174
|
+
const childSgIds = [];
|
|
3175
|
+
for (const child of s.children) {
|
|
3176
|
+
if (child.kind === "composite") childSgIds.push(child.id);
|
|
3177
|
+
else childIds.push(child.id);
|
|
3178
|
+
}
|
|
3179
|
+
let entryChild;
|
|
3180
|
+
let exitChild;
|
|
3181
|
+
for (const child of s.children) {
|
|
3182
|
+
if (child.kind === "pseudo" && child.pseudoKind === "initial" && !entryChild) {
|
|
3183
|
+
entryChild = child.id;
|
|
3184
|
+
}
|
|
3185
|
+
if (child.kind === "pseudo" && child.pseudoKind === "final") {
|
|
3186
|
+
exitChild = child.id;
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
if (!entryChild) entryChild = s.children[0]?.id;
|
|
3190
|
+
if (!exitChild) exitChild = s.children[s.children.length - 1]?.id;
|
|
3191
|
+
if (entryChild) compositeEntryFor.set(s.id, entryChild);
|
|
3192
|
+
if (exitChild) compositeExitFor.set(s.id, exitChild);
|
|
3193
|
+
fcSubgraphs.push({
|
|
3194
|
+
id: s.id,
|
|
3195
|
+
label: s.label || s.id,
|
|
3196
|
+
direction: ast.direction,
|
|
3197
|
+
children: childIds,
|
|
3198
|
+
subgraphs: childSgIds
|
|
3199
|
+
});
|
|
3200
|
+
for (const child of s.children) visit(child, s.id);
|
|
3201
|
+
return;
|
|
3202
|
+
}
|
|
3203
|
+
const node = {
|
|
3204
|
+
id: s.id,
|
|
3205
|
+
label: labelForFlowchart(s),
|
|
3206
|
+
shape: shapeForState(s),
|
|
3207
|
+
parent: parentId
|
|
3208
|
+
};
|
|
3209
|
+
fcNodes.push(node);
|
|
3210
|
+
if (s.kind === "pseudo" && s.pseudoKind) {
|
|
3211
|
+
pseudoSizes.set(s.id, { ...PSEUDO_BBOX[s.pseudoKind] });
|
|
3212
|
+
}
|
|
3213
|
+
};
|
|
3214
|
+
for (const s of ast.states) visit(s, void 0);
|
|
3215
|
+
const fcEdges = ast.transitions.map((t) => {
|
|
3216
|
+
let from = t.from;
|
|
3217
|
+
let to = t.to;
|
|
3218
|
+
const fromExit = compositeExitFor.get(t.from);
|
|
3219
|
+
if (fromExit) from = fromExit;
|
|
3220
|
+
const toEntry = compositeEntryFor.get(t.to);
|
|
3221
|
+
if (toEntry) to = toEntry;
|
|
3222
|
+
return {
|
|
3223
|
+
id: t.id,
|
|
3224
|
+
from,
|
|
3225
|
+
to,
|
|
3226
|
+
kind: "solid",
|
|
3227
|
+
label: buildLabel(t)
|
|
3228
|
+
};
|
|
3229
|
+
});
|
|
3230
|
+
const fc = {
|
|
3231
|
+
type: "flowchart",
|
|
3232
|
+
title: ast.title,
|
|
3233
|
+
direction: ast.direction === "LR" ? "LR" : "TB",
|
|
3234
|
+
nodes: fcNodes,
|
|
3235
|
+
edges: fcEdges,
|
|
3236
|
+
subgraphs: fcSubgraphs,
|
|
3237
|
+
classDefs: [],
|
|
3238
|
+
linkStyles: /* @__PURE__ */ new Map()
|
|
3239
|
+
};
|
|
3240
|
+
return { ast: fc, pseudoSizes };
|
|
3241
|
+
}
|
|
3242
|
+
function labelForFlowchart(s) {
|
|
3243
|
+
if (s.kind === "pseudo") return "";
|
|
3244
|
+
if (s.activities.length === 0) return s.label || s.id;
|
|
3245
|
+
const activityWidth = s.activities.map((a) => activityText(a).length).reduce((m, n) => Math.max(m, n), 0);
|
|
3246
|
+
const label = s.label || s.id;
|
|
3247
|
+
return label.length >= activityWidth ? label : "x".repeat(activityWidth);
|
|
3248
|
+
}
|
|
3249
|
+
function activityText(a) {
|
|
3250
|
+
if (a.kind === "entry" || a.kind === "exit" || a.kind === "do") {
|
|
3251
|
+
return `${a.kind} / ${a.action ?? ""}`;
|
|
3252
|
+
}
|
|
3253
|
+
const parts = [];
|
|
3254
|
+
if (a.trigger) parts.push(a.trigger);
|
|
3255
|
+
if (a.guard) parts.push(`[${a.guard}]`);
|
|
3256
|
+
let s = parts.join(" ");
|
|
3257
|
+
if (a.action) s = s ? `${s} / ${a.action}` : `/ ${a.action}`;
|
|
3258
|
+
return s;
|
|
3259
|
+
}
|
|
3260
|
+
function wrapNoteText(text2, charsPerLine = 28) {
|
|
3261
|
+
const out = [];
|
|
3262
|
+
for (const para of text2.split(/\n/)) {
|
|
3263
|
+
const words = para.split(/\s+/);
|
|
3264
|
+
let cur = "";
|
|
3265
|
+
for (const w of words) {
|
|
3266
|
+
if (!cur) cur = w;
|
|
3267
|
+
else if (cur.length + w.length + 1 <= charsPerLine) cur += ` ${w}`;
|
|
3268
|
+
else {
|
|
3269
|
+
out.push(cur);
|
|
3270
|
+
cur = w;
|
|
3271
|
+
}
|
|
3272
|
+
}
|
|
3273
|
+
if (cur) out.push(cur);
|
|
3274
|
+
if (para === "") out.push("");
|
|
3275
|
+
}
|
|
3276
|
+
return out.length ? out : [""];
|
|
3277
|
+
}
|
|
3278
|
+
function selfLoopPath(cx, cy, w, h) {
|
|
3279
|
+
const startX = cx + w / 2;
|
|
3280
|
+
const startY = cy - h * 0.15;
|
|
3281
|
+
const endX = cx + w * 0.15;
|
|
3282
|
+
const endY = cy - h / 2;
|
|
3283
|
+
const c1x = startX + 28;
|
|
3284
|
+
const c1y = startY - 12;
|
|
3285
|
+
const c2x = endX + 28;
|
|
3286
|
+
const c2y = endY - 28;
|
|
3287
|
+
const path2 = `M ${startX} ${startY} C ${c1x} ${c1y}, ${c2x} ${c2y}, ${endX} ${endY}`;
|
|
3288
|
+
return { path: path2, labelX: startX + 28, labelY: startY - 18 };
|
|
3289
|
+
}
|
|
3290
|
+
function layoutStateDiagram(ast) {
|
|
3291
|
+
const { ast: fcAst, pseudoSizes } = convertToFlowchart(ast);
|
|
3292
|
+
const selfLoops = [];
|
|
3293
|
+
fcAst.edges = fcAst.edges.filter((e) => {
|
|
3294
|
+
if (e.from === e.to) {
|
|
3295
|
+
const t = ast.transitions.find((tr) => tr.id === e.id);
|
|
3296
|
+
if (t) selfLoops.push(t);
|
|
3297
|
+
return false;
|
|
3298
|
+
}
|
|
3299
|
+
return true;
|
|
3300
|
+
});
|
|
3301
|
+
const fcResult = chunkGYTWJ6VB_cjs.layoutFlowchart(fcAst);
|
|
3302
|
+
const stateById = /* @__PURE__ */ new Map();
|
|
3303
|
+
const collectStates = (s) => {
|
|
3304
|
+
stateById.set(s.id, s);
|
|
3305
|
+
for (const c of s.children) collectStates(c);
|
|
3306
|
+
};
|
|
3307
|
+
for (const s of ast.states) collectStates(s);
|
|
3308
|
+
const stateNodes = [];
|
|
3309
|
+
for (const fcNode of fcResult.nodes) {
|
|
3310
|
+
if (fcNode.isDummy) continue;
|
|
3311
|
+
const s = stateById.get(fcNode.node.id);
|
|
3312
|
+
if (!s) continue;
|
|
3313
|
+
if (s.kind === "composite") continue;
|
|
3314
|
+
const cx = fcNode.x + fcNode.width / 2;
|
|
3315
|
+
const cy = fcNode.y + fcNode.height / 2;
|
|
3316
|
+
let w = fcNode.width;
|
|
3317
|
+
let h = fcNode.height;
|
|
3318
|
+
if (s.kind === "pseudo" && s.pseudoKind) {
|
|
3319
|
+
const ps = pseudoSizes.get(s.id);
|
|
3320
|
+
if (ps) {
|
|
3321
|
+
if ((s.pseudoKind === "fork" || s.pseudoKind === "join") && ast.direction === "LR") {
|
|
3322
|
+
w = 8;
|
|
3323
|
+
h = 100;
|
|
3324
|
+
} else {
|
|
3325
|
+
w = ps.w;
|
|
3326
|
+
h = ps.h;
|
|
3327
|
+
}
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
stateNodes.push({
|
|
3331
|
+
id: s.id,
|
|
3332
|
+
x: cx - w / 2,
|
|
3333
|
+
y: cy - h / 2,
|
|
3334
|
+
width: w,
|
|
3335
|
+
height: h,
|
|
3336
|
+
cx,
|
|
3337
|
+
cy,
|
|
3338
|
+
layer: fcNode.layer,
|
|
3339
|
+
node: s,
|
|
3340
|
+
parent: s.parent
|
|
3341
|
+
});
|
|
3342
|
+
}
|
|
3343
|
+
const clusters = fcResult.clusters.map((c) => {
|
|
3344
|
+
const s = stateById.get(c.subgraph.id);
|
|
3345
|
+
if (!s) {
|
|
3346
|
+
return {
|
|
3347
|
+
id: c.subgraph.id,
|
|
3348
|
+
state: { id: c.subgraph.id, label: c.subgraph.label, kind: "composite", activities: [], children: [] },
|
|
3349
|
+
x: c.x,
|
|
3350
|
+
y: c.y,
|
|
3351
|
+
width: c.width,
|
|
3352
|
+
height: c.height
|
|
3353
|
+
};
|
|
3354
|
+
}
|
|
3355
|
+
return {
|
|
3356
|
+
id: c.subgraph.id,
|
|
3357
|
+
state: s,
|
|
3358
|
+
x: c.x,
|
|
3359
|
+
y: c.y,
|
|
3360
|
+
width: c.width,
|
|
3361
|
+
height: c.height
|
|
3362
|
+
};
|
|
3363
|
+
});
|
|
3364
|
+
const stateById2 = new Map(stateNodes.map((n) => [n.id, n]));
|
|
3365
|
+
const stateEdges = [];
|
|
3366
|
+
for (const fcEdge of fcResult.edges) {
|
|
3367
|
+
const t = ast.transitions.find((tr) => tr.id === fcEdge.edge.id);
|
|
3368
|
+
if (!t) continue;
|
|
3369
|
+
let path2 = fcEdge.path;
|
|
3370
|
+
const sourceNode = stateById2.get(fcEdge.edge.from);
|
|
3371
|
+
const targetNode = stateById2.get(fcEdge.edge.to);
|
|
3372
|
+
if (sourceNode && sourceNode.node.kind === "pseudo") {
|
|
3373
|
+
path2 = trimPathStart(path2, sourceNode.cx, sourceNode.cy, symbolRadius(sourceNode));
|
|
3374
|
+
}
|
|
3375
|
+
if (targetNode && targetNode.node.kind === "pseudo") {
|
|
3376
|
+
path2 = trimPathEnd(path2, targetNode.cx, targetNode.cy, symbolRadius(targetNode));
|
|
3377
|
+
}
|
|
3378
|
+
stateEdges.push({
|
|
3379
|
+
id: t.id,
|
|
3380
|
+
from: t.from,
|
|
3381
|
+
to: t.to,
|
|
3382
|
+
path: path2,
|
|
3383
|
+
label: buildLabel(t),
|
|
3384
|
+
labelX: fcEdge.labelAnchor?.x ?? 0,
|
|
3385
|
+
labelY: fcEdge.labelAnchor?.y ?? 0,
|
|
3386
|
+
labelAnchor: fcEdge.labelAnchor?.textAnchor ?? "middle"
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
for (const sl of selfLoops) {
|
|
3390
|
+
const host = stateById2.get(sl.from);
|
|
3391
|
+
if (!host) continue;
|
|
3392
|
+
const { path: path2, labelX, labelY } = selfLoopPath(host.cx, host.cy, host.width, host.height);
|
|
3393
|
+
stateEdges.push({
|
|
3394
|
+
id: sl.id,
|
|
3395
|
+
from: sl.from,
|
|
3396
|
+
to: sl.to,
|
|
3397
|
+
path: path2,
|
|
3398
|
+
label: buildLabel(sl),
|
|
3399
|
+
labelX,
|
|
3400
|
+
labelY,
|
|
3401
|
+
labelAnchor: "start",
|
|
3402
|
+
selfLoop: true
|
|
3403
|
+
});
|
|
3404
|
+
}
|
|
3405
|
+
const notes = [];
|
|
3406
|
+
for (const note of ast.notes) {
|
|
3407
|
+
const target = stateById2.get(note.target);
|
|
3408
|
+
if (!target) continue;
|
|
3409
|
+
const lines = wrapNoteText(note.text);
|
|
3410
|
+
const w = NOTE_W;
|
|
3411
|
+
const h = lines.length * NOTE_LINE_H + 14;
|
|
3412
|
+
let x;
|
|
3413
|
+
let y;
|
|
3414
|
+
let leaderX1;
|
|
3415
|
+
let leaderX2;
|
|
3416
|
+
if (note.side === "left") {
|
|
3417
|
+
x = target.x - w - 24;
|
|
3418
|
+
y = target.cy - h / 2;
|
|
3419
|
+
leaderX1 = target.x;
|
|
3420
|
+
leaderX2 = x + w;
|
|
3421
|
+
} else {
|
|
3422
|
+
x = target.x + target.width + 24;
|
|
3423
|
+
y = target.cy - h / 2;
|
|
3424
|
+
leaderX1 = target.x + target.width;
|
|
3425
|
+
leaderX2 = x;
|
|
3426
|
+
}
|
|
3427
|
+
notes.push({
|
|
3428
|
+
note,
|
|
3429
|
+
x,
|
|
3430
|
+
y,
|
|
3431
|
+
width: w,
|
|
3432
|
+
height: h,
|
|
3433
|
+
lines,
|
|
3434
|
+
leader: { x1: leaderX1, y1: target.cy, x2: leaderX2, y2: y + h / 2 }
|
|
3435
|
+
});
|
|
3436
|
+
}
|
|
3437
|
+
let maxX = fcResult.width;
|
|
3438
|
+
let maxY = fcResult.height;
|
|
3439
|
+
let minX = 0;
|
|
3440
|
+
for (const n of notes) {
|
|
3441
|
+
maxX = Math.max(maxX, n.x + n.width + 8);
|
|
3442
|
+
maxY = Math.max(maxY, n.y + n.height + 8);
|
|
3443
|
+
minX = Math.min(minX, n.x - 8);
|
|
3444
|
+
}
|
|
3445
|
+
if (minX < 0) {
|
|
3446
|
+
const dx = -minX;
|
|
3447
|
+
for (const n of stateNodes) {
|
|
3448
|
+
n.x += dx;
|
|
3449
|
+
n.cx += dx;
|
|
3450
|
+
}
|
|
3451
|
+
for (const c of clusters) {
|
|
3452
|
+
c.x += dx;
|
|
3453
|
+
}
|
|
3454
|
+
for (const e of stateEdges) {
|
|
3455
|
+
e.path = shiftPathX(e.path, dx);
|
|
3456
|
+
e.labelX += dx;
|
|
3457
|
+
}
|
|
3458
|
+
for (const n of notes) {
|
|
3459
|
+
n.x += dx;
|
|
3460
|
+
n.leader.x1 += dx;
|
|
3461
|
+
n.leader.x2 += dx;
|
|
3462
|
+
}
|
|
3463
|
+
maxX += dx;
|
|
3464
|
+
}
|
|
3465
|
+
for (const e of stateEdges) {
|
|
3466
|
+
if (!e.selfLoop) continue;
|
|
3467
|
+
maxX = Math.max(maxX, e.labelX + 60);
|
|
3468
|
+
maxY = Math.max(maxY, e.labelY + 60);
|
|
3469
|
+
}
|
|
3470
|
+
const titleOffset = ast.title ? 28 : 0;
|
|
3471
|
+
if (titleOffset) {
|
|
3472
|
+
for (const n of stateNodes) {
|
|
3473
|
+
n.y += titleOffset;
|
|
3474
|
+
n.cy += titleOffset;
|
|
3475
|
+
}
|
|
3476
|
+
for (const c of clusters) {
|
|
3477
|
+
c.y += titleOffset;
|
|
3478
|
+
}
|
|
3479
|
+
for (const e of stateEdges) {
|
|
3480
|
+
e.path = shiftPathY(e.path, titleOffset);
|
|
3481
|
+
e.labelY += titleOffset;
|
|
3482
|
+
}
|
|
3483
|
+
for (const n of notes) {
|
|
3484
|
+
n.y += titleOffset;
|
|
3485
|
+
n.leader.y1 += titleOffset;
|
|
3486
|
+
n.leader.y2 += titleOffset;
|
|
3487
|
+
}
|
|
3488
|
+
maxY += titleOffset;
|
|
3489
|
+
}
|
|
3490
|
+
return {
|
|
3491
|
+
width: maxX,
|
|
3492
|
+
height: maxY,
|
|
3493
|
+
nodes: stateNodes,
|
|
3494
|
+
edges: stateEdges,
|
|
3495
|
+
clusters,
|
|
3496
|
+
notes,
|
|
3497
|
+
title: ast.title,
|
|
3498
|
+
direction: ast.direction
|
|
3499
|
+
};
|
|
3500
|
+
}
|
|
3501
|
+
function symbolRadius(node) {
|
|
3502
|
+
const k = node.node.pseudoKind;
|
|
3503
|
+
switch (k) {
|
|
3504
|
+
case "initial":
|
|
3505
|
+
return 8;
|
|
3506
|
+
case "final":
|
|
3507
|
+
return 11;
|
|
3508
|
+
case "choice":
|
|
3509
|
+
return 14;
|
|
3510
|
+
case "junction":
|
|
3511
|
+
return 6;
|
|
3512
|
+
case "history":
|
|
3513
|
+
return 12;
|
|
3514
|
+
case "dhistory":
|
|
3515
|
+
return 13;
|
|
3516
|
+
case "terminate":
|
|
3517
|
+
return 8;
|
|
3518
|
+
case "entry_point":
|
|
3519
|
+
case "exit_point":
|
|
3520
|
+
return 7;
|
|
3521
|
+
case "fork":
|
|
3522
|
+
case "join":
|
|
3523
|
+
return Math.min(node.width, node.height) / 2;
|
|
3524
|
+
default:
|
|
3525
|
+
return Math.min(node.width, node.height) / 2;
|
|
3526
|
+
}
|
|
3527
|
+
}
|
|
3528
|
+
function parsePathPoints(d) {
|
|
3529
|
+
if (/[CSQTA]/.test(d)) return null;
|
|
3530
|
+
const tokens = d.match(/[ML]\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/g) ?? [];
|
|
3531
|
+
const out = [];
|
|
3532
|
+
for (const tok of tokens) {
|
|
3533
|
+
const m = tok.match(/[ML]\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/);
|
|
3534
|
+
if (!m) continue;
|
|
3535
|
+
out.push({ x: parseFloat(m[1]), y: parseFloat(m[2]) });
|
|
3536
|
+
}
|
|
3537
|
+
return out;
|
|
3538
|
+
}
|
|
3539
|
+
function pointsToPath(pts) {
|
|
3540
|
+
if (pts.length === 0) return "";
|
|
3541
|
+
const head = `M ${pts[0].x} ${pts[0].y}`;
|
|
3542
|
+
const rest = pts.slice(1).map((p) => `L ${p.x} ${p.y}`).join(" ");
|
|
3543
|
+
return rest ? `${head} ${rest}` : head;
|
|
3544
|
+
}
|
|
3545
|
+
function trimPathStart(d, cx, cy, r) {
|
|
3546
|
+
const pts = parsePathPoints(d);
|
|
3547
|
+
if (!pts || pts.length < 2) return d;
|
|
3548
|
+
const p0 = pts[0];
|
|
3549
|
+
const p1 = pts[1];
|
|
3550
|
+
const newP0 = projectOnPerimeter(p0, p1, cx, cy, r);
|
|
3551
|
+
pts[0] = newP0;
|
|
3552
|
+
return pointsToPath(pts);
|
|
3553
|
+
}
|
|
3554
|
+
function trimPathEnd(d, cx, cy, r) {
|
|
3555
|
+
const pts = parsePathPoints(d);
|
|
3556
|
+
if (!pts || pts.length < 2) return d;
|
|
3557
|
+
const last = pts[pts.length - 1];
|
|
3558
|
+
const prev = pts[pts.length - 2];
|
|
3559
|
+
const newLast = projectOnPerimeter(last, prev, cx, cy, r);
|
|
3560
|
+
pts[pts.length - 1] = newLast;
|
|
3561
|
+
return pointsToPath(pts);
|
|
3562
|
+
}
|
|
3563
|
+
function projectOnPerimeter(endpoint, neighbor, cx, cy, r) {
|
|
3564
|
+
const dx = endpoint.x - neighbor.x;
|
|
3565
|
+
const dy = endpoint.y - neighbor.y;
|
|
3566
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
3567
|
+
const sign2 = dx >= 0 ? 1 : -1;
|
|
3568
|
+
return { x: cx - sign2 * r, y: cy };
|
|
3569
|
+
}
|
|
3570
|
+
const sign = dy >= 0 ? 1 : -1;
|
|
3571
|
+
return { x: cx, y: cy - sign * r };
|
|
3572
|
+
}
|
|
3573
|
+
function shiftPathX(d, dx) {
|
|
3574
|
+
return d.replace(/([MLCQ])\s*((?:-?\d+(?:\.\d+)?\s+){1,5}-?\d+(?:\.\d+)?)/g, (_, cmd, args) => {
|
|
3575
|
+
const nums = args.trim().split(/\s+/).map(Number);
|
|
3576
|
+
const out = [];
|
|
3577
|
+
for (let i = 0; i < nums.length; i++) {
|
|
3578
|
+
out.push(i % 2 === 0 ? nums[i] + dx : nums[i]);
|
|
3579
|
+
}
|
|
3580
|
+
return `${cmd} ${out.join(" ")}`;
|
|
3581
|
+
});
|
|
3582
|
+
}
|
|
3583
|
+
function shiftPathY(d, dy) {
|
|
3584
|
+
return d.replace(/([MLCQ])\s*((?:-?\d+(?:\.\d+)?\s+){1,5}-?\d+(?:\.\d+)?)/g, (_, cmd, args) => {
|
|
3585
|
+
const nums = args.trim().split(/\s+/).map(Number);
|
|
3586
|
+
const out = [];
|
|
3587
|
+
for (let i = 0; i < nums.length; i++) {
|
|
3588
|
+
out.push(i % 2 === 1 ? nums[i] + dy : nums[i]);
|
|
3589
|
+
}
|
|
3590
|
+
return `${cmd} ${out.join(" ")}`;
|
|
3591
|
+
});
|
|
3592
|
+
}
|
|
3593
|
+
|
|
3594
|
+
// src/diagrams/state/renderer.ts
|
|
3595
|
+
var ARROW_MARKER_ID = "lt-state-arrow";
|
|
3596
|
+
var STYLE = `
|
|
3597
|
+
.lt-state-body { fill: #ffffff; stroke: #2a2a2a; stroke-width: 1.6; }
|
|
3598
|
+
.lt-state-name { font: 600 12px system-ui, sans-serif; fill: #1a1a1a; }
|
|
3599
|
+
.lt-state-div { stroke: #2a2a2a; stroke-width: 1; }
|
|
3600
|
+
.lt-state-activity { font: 11px ui-monospace, monospace; fill: #444; }
|
|
3601
|
+
|
|
3602
|
+
.lt-composite-body { fill: #fafafa; stroke: #2a2a2a; stroke-width: 1.6; }
|
|
3603
|
+
.lt-composite-title { font: 600 12px system-ui, sans-serif; fill: #1a1a1a; }
|
|
3604
|
+
.lt-composite-titlebar { fill: #f0f0f0; stroke: #2a2a2a; stroke-width: 1; }
|
|
3605
|
+
.lt-region-div { stroke: #888; stroke-width: 1; stroke-dasharray: 6 4; }
|
|
3606
|
+
|
|
3607
|
+
.lt-ps-initial { fill: #1a1a1a; }
|
|
3608
|
+
.lt-ps-final-outer { fill: #ffffff; stroke: #1a1a1a; stroke-width: 1.6; }
|
|
3609
|
+
.lt-ps-final-inner { fill: #1a1a1a; }
|
|
3610
|
+
.lt-ps-choice { fill: #ffffff; stroke: #1a1a1a; stroke-width: 1.6; }
|
|
3611
|
+
.lt-ps-junction { fill: #1a1a1a; }
|
|
3612
|
+
.lt-ps-bar { fill: #1a1a1a; }
|
|
3613
|
+
.lt-ps-history-body { fill: #ffffff; stroke: #1a1a1a; stroke-width: 1.6; }
|
|
3614
|
+
.lt-ps-history-text { font: 600 11px serif; fill: #1a1a1a; }
|
|
3615
|
+
.lt-ps-terminate { stroke: #1a1a1a; stroke-width: 2; }
|
|
3616
|
+
.lt-ps-entrypoint { fill: #ffffff; stroke: #1a1a1a; stroke-width: 1.6; }
|
|
3617
|
+
.lt-ps-exitpoint { fill: #ffffff; stroke: #1a1a1a; stroke-width: 1.6; }
|
|
3618
|
+
|
|
3619
|
+
.lt-transition { stroke: #2a2a2a; stroke-width: 1.4; fill: none; }
|
|
3620
|
+
.lt-transition-label { font: 11px system-ui, sans-serif; fill: #1a1a1a; }
|
|
3621
|
+
.lt-transition-label-bg { fill: #ffffff; opacity: 0.92; }
|
|
3622
|
+
|
|
3623
|
+
.lt-note-body { fill: #fff8c5; stroke: #b79400; stroke-width: 1; }
|
|
3624
|
+
.lt-note-text { font: 11px system-ui, sans-serif; fill: #2a2a2a; }
|
|
3625
|
+
.lt-note-leader { stroke: #b79400; stroke-width: 1; stroke-dasharray: 3 3; fill: none; }
|
|
3626
|
+
|
|
3627
|
+
.lt-title { font: 600 14px system-ui, sans-serif; fill: #1a1a1a; }
|
|
3628
|
+
`;
|
|
3629
|
+
function renderArrowMarker() {
|
|
3630
|
+
return chunkLFZZ4NCP_cjs.el(
|
|
3631
|
+
"marker",
|
|
3632
|
+
{
|
|
3633
|
+
id: ARROW_MARKER_ID,
|
|
3634
|
+
markerWidth: 10,
|
|
3635
|
+
markerHeight: 10,
|
|
3636
|
+
refX: 9,
|
|
3637
|
+
refY: 3,
|
|
3638
|
+
orient: "auto",
|
|
3639
|
+
markerUnits: "strokeWidth"
|
|
3640
|
+
},
|
|
3641
|
+
[chunkLFZZ4NCP_cjs.polygon({ points: "0,0 10,3 0,6", fill: "#2a2a2a" })]
|
|
3642
|
+
);
|
|
3643
|
+
}
|
|
3644
|
+
function activityText2(a) {
|
|
3645
|
+
if (a.kind === "entry" || a.kind === "exit" || a.kind === "do") {
|
|
3646
|
+
return `${a.kind} / ${a.action ?? ""}`;
|
|
3647
|
+
}
|
|
3648
|
+
const parts = [];
|
|
3649
|
+
if (a.trigger) parts.push(a.trigger);
|
|
3650
|
+
if (a.guard) parts.push(`[${a.guard}]`);
|
|
3651
|
+
let s = parts.join(" ");
|
|
3652
|
+
if (a.action) s = s ? `${s} / ${a.action}` : `/ ${a.action}`;
|
|
3653
|
+
return s;
|
|
3654
|
+
}
|
|
3655
|
+
function renderSimple(node) {
|
|
3656
|
+
const { x, y, width, height } = node;
|
|
3657
|
+
const children = [
|
|
3658
|
+
chunkLFZZ4NCP_cjs.rect({ x, y, width, height, rx: 8, ry: 8, class: "lt-state-body" })
|
|
3659
|
+
];
|
|
3660
|
+
const label = node.node.label || node.id;
|
|
3661
|
+
if (node.node.activities.length === 0) {
|
|
3662
|
+
children.push(
|
|
3663
|
+
chunkLFZZ4NCP_cjs.text(
|
|
3664
|
+
{ x: x + width / 2, y: y + height / 2 + 4, "text-anchor": "middle", class: "lt-state-name" },
|
|
3665
|
+
label
|
|
3666
|
+
)
|
|
3667
|
+
);
|
|
3668
|
+
} else {
|
|
3669
|
+
children.push(
|
|
3670
|
+
chunkLFZZ4NCP_cjs.text(
|
|
3671
|
+
{ x: x + width / 2, y: y + 16, "text-anchor": "middle", class: "lt-state-name" },
|
|
3672
|
+
label
|
|
3673
|
+
)
|
|
3674
|
+
);
|
|
3675
|
+
children.push(
|
|
3676
|
+
chunkLFZZ4NCP_cjs.line({ x1: x, y1: y + 22, x2: x + width, y2: y + 22, class: "lt-state-div" })
|
|
3677
|
+
);
|
|
3678
|
+
let cy = y + 36;
|
|
3679
|
+
for (const a of node.node.activities) {
|
|
3680
|
+
children.push(chunkLFZZ4NCP_cjs.text({ x: x + 8, y: cy, class: "lt-state-activity" }, activityText2(a)));
|
|
3681
|
+
cy += 14;
|
|
3682
|
+
}
|
|
3683
|
+
}
|
|
3684
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-state lt-simple", "data-id": node.id }, children);
|
|
3685
|
+
}
|
|
3686
|
+
function renderComposite(c) {
|
|
3687
|
+
const { x, y, width, height } = c;
|
|
3688
|
+
const titleBarH = 22;
|
|
3689
|
+
const acts = c.state.activities;
|
|
3690
|
+
const actsH = acts.length ? acts.length * 14 + 6 : 0;
|
|
3691
|
+
const parts = [
|
|
3692
|
+
chunkLFZZ4NCP_cjs.rect({ x, y, width, height, rx: 10, ry: 10, class: "lt-composite-body" }),
|
|
3693
|
+
// Title bar background — only the top strip
|
|
3694
|
+
chunkLFZZ4NCP_cjs.path({
|
|
3695
|
+
d: `M ${x + 1} ${y + titleBarH} L ${x + width - 1} ${y + titleBarH}`,
|
|
3696
|
+
class: "lt-state-div"
|
|
3697
|
+
}),
|
|
3698
|
+
chunkLFZZ4NCP_cjs.text(
|
|
3699
|
+
{ x: x + 12, y: y + 16, class: "lt-composite-title" },
|
|
3700
|
+
c.state.label || c.state.id
|
|
3701
|
+
)
|
|
3702
|
+
];
|
|
3703
|
+
if (acts.length) {
|
|
3704
|
+
let cy = y + titleBarH + 14;
|
|
3705
|
+
for (const a of acts) {
|
|
3706
|
+
parts.push(chunkLFZZ4NCP_cjs.text({ x: x + 12, y: cy, class: "lt-state-activity" }, activityText2(a)));
|
|
3707
|
+
cy += 14;
|
|
3708
|
+
}
|
|
3709
|
+
parts.push(
|
|
3710
|
+
chunkLFZZ4NCP_cjs.path({
|
|
3711
|
+
d: `M ${x + 1} ${y + titleBarH + actsH} L ${x + width - 1} ${y + titleBarH + actsH}`,
|
|
3712
|
+
class: "lt-state-div"
|
|
3713
|
+
})
|
|
3714
|
+
);
|
|
3715
|
+
}
|
|
3716
|
+
if (c.regionDividers) {
|
|
3717
|
+
for (const yy of c.regionDividers) {
|
|
3718
|
+
parts.push(
|
|
3719
|
+
chunkLFZZ4NCP_cjs.line({ x1: x + 1, y1: yy, x2: x + width - 1, y2: yy, class: "lt-region-div" })
|
|
3720
|
+
);
|
|
3721
|
+
}
|
|
3722
|
+
}
|
|
3723
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3724
|
+
{ class: "lt-state lt-composite", "data-id": c.id },
|
|
3725
|
+
parts
|
|
3726
|
+
);
|
|
3727
|
+
}
|
|
3728
|
+
function renderPseudo(node) {
|
|
3729
|
+
const cx = node.cx;
|
|
3730
|
+
const cy = node.cy;
|
|
3731
|
+
const k = node.node.pseudoKind;
|
|
3732
|
+
switch (k) {
|
|
3733
|
+
case "initial":
|
|
3734
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3735
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "initial" },
|
|
3736
|
+
[chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 8, class: "lt-ps-initial" })]
|
|
3737
|
+
);
|
|
3738
|
+
case "final":
|
|
3739
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3740
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "final" },
|
|
3741
|
+
[
|
|
3742
|
+
chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 11, class: "lt-ps-final-outer" }),
|
|
3743
|
+
chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 6, class: "lt-ps-final-inner" })
|
|
3744
|
+
]
|
|
3745
|
+
);
|
|
3746
|
+
case "choice": {
|
|
3747
|
+
const r = 14;
|
|
3748
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3749
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "choice" },
|
|
3750
|
+
[
|
|
3751
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
3752
|
+
points: `${cx},${cy - r} ${cx + r},${cy} ${cx},${cy + r} ${cx - r},${cy}`,
|
|
3753
|
+
class: "lt-ps-choice"
|
|
3754
|
+
})
|
|
3755
|
+
]
|
|
3756
|
+
);
|
|
3757
|
+
}
|
|
3758
|
+
case "junction":
|
|
3759
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3760
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "junction" },
|
|
3761
|
+
[chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 6, class: "lt-ps-junction" })]
|
|
3762
|
+
);
|
|
3763
|
+
case "fork":
|
|
3764
|
+
case "join":
|
|
3765
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3766
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": k },
|
|
3767
|
+
[chunkLFZZ4NCP_cjs.rect({ x: node.x, y: node.y, width: node.width, height: node.height, rx: 2, ry: 2, class: "lt-ps-bar" })]
|
|
3768
|
+
);
|
|
3769
|
+
case "history":
|
|
3770
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3771
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "history" },
|
|
3772
|
+
[
|
|
3773
|
+
chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 12, class: "lt-ps-history-body" }),
|
|
3774
|
+
chunkLFZZ4NCP_cjs.text({ x: cx, y: cy + 4, "text-anchor": "middle", class: "lt-ps-history-text" }, "H")
|
|
3775
|
+
]
|
|
3776
|
+
);
|
|
3777
|
+
case "dhistory":
|
|
3778
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3779
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "dhistory" },
|
|
3780
|
+
[
|
|
3781
|
+
chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 13, class: "lt-ps-history-body" }),
|
|
3782
|
+
chunkLFZZ4NCP_cjs.text({ x: cx, y: cy + 4, "text-anchor": "middle", class: "lt-ps-history-text" }, "H*")
|
|
3783
|
+
]
|
|
3784
|
+
);
|
|
3785
|
+
case "terminate":
|
|
3786
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3787
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "terminate" },
|
|
3788
|
+
[
|
|
3789
|
+
chunkLFZZ4NCP_cjs.line({ x1: cx - 8, y1: cy - 8, x2: cx + 8, y2: cy + 8, class: "lt-ps-terminate" }),
|
|
3790
|
+
chunkLFZZ4NCP_cjs.line({ x1: cx + 8, y1: cy - 8, x2: cx - 8, y2: cy + 8, class: "lt-ps-terminate" })
|
|
3791
|
+
]
|
|
3792
|
+
);
|
|
3793
|
+
case "entry_point":
|
|
3794
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3795
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "entry_point" },
|
|
3796
|
+
[chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 7, class: "lt-ps-entrypoint" })]
|
|
3797
|
+
);
|
|
3798
|
+
case "exit_point":
|
|
3799
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3800
|
+
{ class: "lt-state lt-pseudo", "data-id": node.id, "data-kind": "exit_point" },
|
|
3801
|
+
[
|
|
3802
|
+
chunkLFZZ4NCP_cjs.circle({ cx, cy, r: 7, class: "lt-ps-exitpoint" }),
|
|
3803
|
+
chunkLFZZ4NCP_cjs.line({ x1: cx - 4, y1: cy - 4, x2: cx + 4, y2: cy + 4, class: "lt-ps-terminate" }),
|
|
3804
|
+
chunkLFZZ4NCP_cjs.line({ x1: cx + 4, y1: cy - 4, x2: cx - 4, y2: cy + 4, class: "lt-ps-terminate" })
|
|
3805
|
+
]
|
|
3806
|
+
);
|
|
3807
|
+
default:
|
|
3808
|
+
return "";
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
function renderNode(node) {
|
|
3812
|
+
if (node.node.kind === "pseudo") return renderPseudo(node);
|
|
3813
|
+
return renderSimple(node);
|
|
3814
|
+
}
|
|
3815
|
+
function renderEdge(edge) {
|
|
3816
|
+
const parts = [
|
|
3817
|
+
chunkLFZZ4NCP_cjs.path({
|
|
3818
|
+
d: edge.path,
|
|
3819
|
+
class: "lt-transition",
|
|
3820
|
+
"marker-end": `url(#${ARROW_MARKER_ID})`,
|
|
3821
|
+
"data-from": edge.from,
|
|
3822
|
+
"data-to": edge.to
|
|
3823
|
+
})
|
|
3824
|
+
];
|
|
3825
|
+
if (edge.label) {
|
|
3826
|
+
const w = Math.max(20, edge.label.length * 6.4 + 8);
|
|
3827
|
+
const anchor = edge.labelAnchor ?? "middle";
|
|
3828
|
+
const dx = anchor === "start" ? 0 : anchor === "end" ? -w : -w / 2;
|
|
3829
|
+
parts.push(
|
|
3830
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
3831
|
+
x: edge.labelX + dx,
|
|
3832
|
+
y: edge.labelY - 10,
|
|
3833
|
+
width: w,
|
|
3834
|
+
height: 14,
|
|
3835
|
+
rx: 2,
|
|
3836
|
+
ry: 2,
|
|
3837
|
+
class: "lt-transition-label-bg"
|
|
3838
|
+
})
|
|
3839
|
+
);
|
|
3840
|
+
parts.push(
|
|
3841
|
+
chunkLFZZ4NCP_cjs.text(
|
|
3842
|
+
{
|
|
3843
|
+
x: edge.labelX,
|
|
3844
|
+
y: edge.labelY,
|
|
3845
|
+
"text-anchor": anchor,
|
|
3846
|
+
class: "lt-transition-label"
|
|
3847
|
+
},
|
|
3848
|
+
edge.label
|
|
3849
|
+
)
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-edge", "data-edge-id": edge.id }, parts);
|
|
3853
|
+
}
|
|
3854
|
+
function renderNote(n) {
|
|
3855
|
+
const parts = [
|
|
3856
|
+
chunkLFZZ4NCP_cjs.line({
|
|
3857
|
+
x1: n.leader.x1,
|
|
3858
|
+
y1: n.leader.y1,
|
|
3859
|
+
x2: n.leader.x2,
|
|
3860
|
+
y2: n.leader.y2,
|
|
3861
|
+
class: "lt-note-leader"
|
|
3862
|
+
}),
|
|
3863
|
+
chunkLFZZ4NCP_cjs.rect({ x: n.x, y: n.y, width: n.width, height: n.height, rx: 4, ry: 4, class: "lt-note-body" })
|
|
3864
|
+
];
|
|
3865
|
+
let yy = n.y + 14;
|
|
3866
|
+
for (const ln of n.lines) {
|
|
3867
|
+
parts.push(chunkLFZZ4NCP_cjs.text({ x: n.x + 8, y: yy, class: "lt-note-text" }, ln));
|
|
3868
|
+
yy += 14;
|
|
3869
|
+
}
|
|
3870
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-note", "data-target": n.note.target }, parts);
|
|
3871
|
+
}
|
|
3872
|
+
function renderStateDiagram(ast, _config) {
|
|
3873
|
+
const layout = layoutStateDiagram(ast);
|
|
3874
|
+
return renderLayout(layout);
|
|
3875
|
+
}
|
|
3876
|
+
function renderLayout(layout) {
|
|
3877
|
+
const titleNode = layout.title ? chunkLFZZ4NCP_cjs.text({ x: 16, y: 22, class: "lt-title" }, layout.title) : "";
|
|
3878
|
+
return chunkLFZZ4NCP_cjs.svgRoot(
|
|
3879
|
+
{
|
|
3880
|
+
width: layout.width,
|
|
3881
|
+
height: layout.height,
|
|
3882
|
+
viewBox: `0 0 ${layout.width} ${layout.height}`,
|
|
3883
|
+
class: "lt-state",
|
|
3884
|
+
"data-diagram-type": "state"
|
|
3885
|
+
},
|
|
3886
|
+
[
|
|
3887
|
+
chunkLFZZ4NCP_cjs.el("title", {}, chunkLFZZ4NCP_cjs.escapeXml(`State Diagram${layout.title ? " \u2014 " + layout.title : ""}`)),
|
|
3888
|
+
chunkLFZZ4NCP_cjs.el("desc", {}, "UML 2.5 / Harel statechart rendered by Schematex"),
|
|
3889
|
+
chunkLFZZ4NCP_cjs.defs([renderArrowMarker(), chunkLFZZ4NCP_cjs.el("style", {}, STYLE)]),
|
|
3890
|
+
titleNode,
|
|
3891
|
+
// Composite clusters first so simple-state bodies sit on top.
|
|
3892
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-clusters" }, layout.clusters.map(renderComposite)),
|
|
3893
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-state-bodies" }, layout.nodes.map(renderNode)),
|
|
3894
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-edges" }, layout.edges.map(renderEdge)),
|
|
3895
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-notes" }, layout.notes.map(renderNote))
|
|
3896
|
+
]
|
|
3897
|
+
);
|
|
3898
|
+
}
|
|
3899
|
+
|
|
3900
|
+
// src/diagrams/state/index.ts
|
|
3901
|
+
var state = {
|
|
3902
|
+
type: "state",
|
|
3903
|
+
detect(text2) {
|
|
3904
|
+
return /^\s*state\b/i.test(text2);
|
|
3905
|
+
},
|
|
3906
|
+
parse: parseStateDiagram,
|
|
3907
|
+
render(text2, config) {
|
|
3908
|
+
const ast = parseStateDiagram(text2);
|
|
3909
|
+
return renderStateDiagram(ast);
|
|
3910
|
+
}
|
|
3911
|
+
};
|
|
3912
|
+
|
|
3913
|
+
// src/diagrams/pid/parser.ts
|
|
3914
|
+
var PidParseError = class extends Error {
|
|
3915
|
+
constructor(message, line2) {
|
|
3916
|
+
super(line2 !== void 0 ? `Line ${line2}: ${message}` : message);
|
|
3917
|
+
this.line = line2;
|
|
3918
|
+
this.name = "PidParseError";
|
|
3919
|
+
}
|
|
3920
|
+
line;
|
|
3921
|
+
};
|
|
3922
|
+
var EQUIP_TYPES = /* @__PURE__ */ new Set([
|
|
3923
|
+
"tank_atm",
|
|
3924
|
+
"tank_cone_roof",
|
|
3925
|
+
"vessel_v",
|
|
3926
|
+
"vessel_h",
|
|
3927
|
+
"sphere",
|
|
3928
|
+
"column_tray",
|
|
3929
|
+
"column_packed",
|
|
3930
|
+
"hx_shell_tube",
|
|
3931
|
+
"hx_air_cooled",
|
|
3932
|
+
"reboiler",
|
|
3933
|
+
"condenser",
|
|
3934
|
+
"pump_centrifugal",
|
|
3935
|
+
"pump_pd",
|
|
3936
|
+
"compressor",
|
|
3937
|
+
"blower",
|
|
3938
|
+
"reactor_cstr",
|
|
3939
|
+
"reactor_pfr",
|
|
3940
|
+
"filter",
|
|
3941
|
+
"cyclone",
|
|
3942
|
+
"flare",
|
|
3943
|
+
"cooling_tower",
|
|
3944
|
+
"valve_gate",
|
|
3945
|
+
"valve_ball",
|
|
3946
|
+
"valve_globe",
|
|
3947
|
+
"valve_butterfly",
|
|
3948
|
+
"valve_check",
|
|
3949
|
+
"valve_control",
|
|
3950
|
+
"valve_psv"
|
|
3951
|
+
]);
|
|
3952
|
+
var LINE_TYPES = /* @__PURE__ */ new Set([
|
|
3953
|
+
"process",
|
|
3954
|
+
"process_minor",
|
|
3955
|
+
"pneumatic",
|
|
3956
|
+
"electric",
|
|
3957
|
+
"hydraulic",
|
|
3958
|
+
"capillary",
|
|
3959
|
+
"software",
|
|
3960
|
+
"mechanical"
|
|
3961
|
+
]);
|
|
3962
|
+
var INST_CATEGORIES = /* @__PURE__ */ new Set([
|
|
3963
|
+
"field_discrete",
|
|
3964
|
+
"field_shared",
|
|
3965
|
+
"field_computer",
|
|
3966
|
+
"field_plc",
|
|
3967
|
+
"cr_discrete",
|
|
3968
|
+
"cr_shared",
|
|
3969
|
+
"cr_computer",
|
|
3970
|
+
"cr_plc",
|
|
3971
|
+
"local_discrete",
|
|
3972
|
+
"local_shared"
|
|
3973
|
+
]);
|
|
3974
|
+
function preprocess4(src) {
|
|
3975
|
+
const out = [];
|
|
3976
|
+
const lines = src.split(/\r?\n/);
|
|
3977
|
+
for (let i = 0; i < lines.length; i++) {
|
|
3978
|
+
const raw = lines[i];
|
|
3979
|
+
if (raw === void 0) continue;
|
|
3980
|
+
let stripped = "";
|
|
3981
|
+
let inQuote = false;
|
|
3982
|
+
for (const ch of raw) {
|
|
3983
|
+
if (ch === '"') inQuote = !inQuote;
|
|
3984
|
+
if (ch === "#" && !inQuote) break;
|
|
3985
|
+
stripped += ch;
|
|
3986
|
+
}
|
|
3987
|
+
const trimmed = stripped.trim();
|
|
3988
|
+
if (!trimmed) continue;
|
|
3989
|
+
const indent = stripped.length - stripped.replace(/^\s+/, "").length;
|
|
3990
|
+
out.push({ text: trimmed, indent, line: i + 1 });
|
|
3991
|
+
}
|
|
3992
|
+
return out;
|
|
3993
|
+
}
|
|
3994
|
+
function unquote3(s) {
|
|
3995
|
+
const t = s.trim();
|
|
3996
|
+
if (t.length >= 2 && t.startsWith('"') && t.endsWith('"')) {
|
|
3997
|
+
return t.slice(1, -1).replace(/\\"/g, '"');
|
|
3998
|
+
}
|
|
3999
|
+
return t;
|
|
4000
|
+
}
|
|
4001
|
+
function parseAttrList(inside) {
|
|
4002
|
+
const out = {};
|
|
4003
|
+
const parts = [];
|
|
4004
|
+
let depth = 0;
|
|
4005
|
+
let inQuote = false;
|
|
4006
|
+
let cur = "";
|
|
4007
|
+
for (const ch of inside) {
|
|
4008
|
+
if (ch === '"') inQuote = !inQuote;
|
|
4009
|
+
if (!inQuote && ch === "[") depth++;
|
|
4010
|
+
if (!inQuote && ch === "]") depth--;
|
|
4011
|
+
if (!inQuote && depth === 0 && ch === ",") {
|
|
4012
|
+
parts.push(cur);
|
|
4013
|
+
cur = "";
|
|
4014
|
+
} else {
|
|
4015
|
+
cur += ch;
|
|
4016
|
+
}
|
|
4017
|
+
}
|
|
4018
|
+
if (cur.trim()) parts.push(cur);
|
|
4019
|
+
for (const p of parts) {
|
|
4020
|
+
const idx = p.indexOf(":");
|
|
4021
|
+
if (idx < 0) continue;
|
|
4022
|
+
const key = p.slice(0, idx).trim();
|
|
4023
|
+
const val = unquote3(p.slice(idx + 1).trim());
|
|
4024
|
+
out[key] = val;
|
|
4025
|
+
}
|
|
4026
|
+
return out;
|
|
4027
|
+
}
|
|
4028
|
+
function extractAttrs(text2) {
|
|
4029
|
+
let depth = 0;
|
|
4030
|
+
let inQuote = false;
|
|
4031
|
+
let openIdx = -1;
|
|
4032
|
+
for (let i = 0; i < text2.length; i++) {
|
|
4033
|
+
const ch = text2[i];
|
|
4034
|
+
if (ch === '"') inQuote = !inQuote;
|
|
4035
|
+
if (inQuote) continue;
|
|
4036
|
+
if (ch === "[") {
|
|
4037
|
+
if (depth === 0) openIdx = i;
|
|
4038
|
+
depth++;
|
|
4039
|
+
} else if (ch === "]") {
|
|
4040
|
+
depth--;
|
|
4041
|
+
if (depth === 0 && i === text2.length - 1) {
|
|
4042
|
+
const inside = text2.slice(openIdx + 1, i);
|
|
4043
|
+
return {
|
|
4044
|
+
rest: text2.slice(0, openIdx).trim(),
|
|
4045
|
+
attrs: parseAttrList(inside)
|
|
4046
|
+
};
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
return { rest: text2, attrs: {} };
|
|
4051
|
+
}
|
|
4052
|
+
function parseAnchor(tok) {
|
|
4053
|
+
const dot = tok.indexOf(".");
|
|
4054
|
+
if (dot < 0) return { id: tok };
|
|
4055
|
+
return { id: tok.slice(0, dot), port: tok.slice(dot + 1) };
|
|
4056
|
+
}
|
|
4057
|
+
function parsePid(src) {
|
|
4058
|
+
const lines = preprocess4(src);
|
|
4059
|
+
if (lines.length === 0) {
|
|
4060
|
+
throw new PidParseError("Empty document");
|
|
4061
|
+
}
|
|
4062
|
+
const header = lines[0];
|
|
4063
|
+
if (!/^pid\b/i.test(header.text)) {
|
|
4064
|
+
throw new PidParseError(`Expected 'pid' header, got '${header.text}'`, header.line);
|
|
4065
|
+
}
|
|
4066
|
+
let title2;
|
|
4067
|
+
let direction = "LR";
|
|
4068
|
+
const headerRest = header.text.replace(/^pid\b/i, "").trim();
|
|
4069
|
+
const { rest, attrs: headerAttrs } = extractAttrs(headerRest);
|
|
4070
|
+
if (headerAttrs.direction === "TB") direction = "TB";
|
|
4071
|
+
if (headerAttrs.direction === "LR") direction = "LR";
|
|
4072
|
+
if (rest) title2 = unquote3(rest);
|
|
4073
|
+
const equipment = [];
|
|
4074
|
+
const linesAst = [];
|
|
4075
|
+
const instruments = [];
|
|
4076
|
+
let currentInst;
|
|
4077
|
+
for (let idx = 1; idx < lines.length; idx++) {
|
|
4078
|
+
const ln = lines[idx];
|
|
4079
|
+
const text2 = ln.text;
|
|
4080
|
+
const measuresMatch = text2.match(/^measures\s+(.+)$/);
|
|
4081
|
+
if (measuresMatch && currentInst) {
|
|
4082
|
+
currentInst.measures = measuresMatch[1].trim();
|
|
4083
|
+
continue;
|
|
4084
|
+
}
|
|
4085
|
+
const controlsMatch = text2.match(/^controls\s+(.+)$/);
|
|
4086
|
+
if (controlsMatch && currentInst) {
|
|
4087
|
+
currentInst.controls = controlsMatch[1].trim();
|
|
4088
|
+
continue;
|
|
4089
|
+
}
|
|
4090
|
+
currentInst = void 0;
|
|
4091
|
+
const equipMatch = text2.match(/^equip\s+([A-Za-z][A-Za-z0-9_-]*)\s*:\s*(.+)$/);
|
|
4092
|
+
if (equipMatch) {
|
|
4093
|
+
const id = equipMatch[1];
|
|
4094
|
+
const tail = equipMatch[2];
|
|
4095
|
+
const { rest: typeRest, attrs } = extractAttrs(tail);
|
|
4096
|
+
const equipType = typeRest.trim();
|
|
4097
|
+
if (!EQUIP_TYPES.has(equipType)) {
|
|
4098
|
+
throw new PidParseError(`Unknown equipment type '${equipType}'`, ln.line);
|
|
4099
|
+
}
|
|
4100
|
+
equipment.push({
|
|
4101
|
+
id,
|
|
4102
|
+
equipType,
|
|
4103
|
+
tag: attrs.tag ?? id,
|
|
4104
|
+
attrs
|
|
4105
|
+
});
|
|
4106
|
+
continue;
|
|
4107
|
+
}
|
|
4108
|
+
const lineMatch = text2.match(/^line\s+([A-Za-z0-9_-]+)\s+from\s+(\S+)\s+to\s+(\S+)\s*(.*)$/);
|
|
4109
|
+
if (lineMatch) {
|
|
4110
|
+
const id = lineMatch[1];
|
|
4111
|
+
const fromTok = lineMatch[2];
|
|
4112
|
+
const toTok = lineMatch[3];
|
|
4113
|
+
const tail = lineMatch[4];
|
|
4114
|
+
const { attrs } = extractAttrs(tail);
|
|
4115
|
+
const lt = attrs.type ?? "process";
|
|
4116
|
+
if (!LINE_TYPES.has(lt)) {
|
|
4117
|
+
throw new PidParseError(`Unknown line type '${lt}'`, ln.line);
|
|
4118
|
+
}
|
|
4119
|
+
linesAst.push({
|
|
4120
|
+
id,
|
|
4121
|
+
from: parseAnchor(fromTok),
|
|
4122
|
+
to: parseAnchor(toTok),
|
|
4123
|
+
lineType: lt,
|
|
4124
|
+
tag: attrs.tag,
|
|
4125
|
+
size: attrs.size,
|
|
4126
|
+
service: attrs.service,
|
|
4127
|
+
attrs
|
|
4128
|
+
});
|
|
4129
|
+
continue;
|
|
4130
|
+
}
|
|
4131
|
+
const instMatch = text2.match(/^inst\s+([A-Z][A-Z0-9]*-[A-Za-z0-9]+)\s*:\s*(.+)$/);
|
|
4132
|
+
if (instMatch) {
|
|
4133
|
+
const tag = instMatch[1];
|
|
4134
|
+
const { rest: catRest, attrs } = extractAttrs(instMatch[2]);
|
|
4135
|
+
const category = catRest.trim();
|
|
4136
|
+
if (!INST_CATEGORIES.has(category)) {
|
|
4137
|
+
throw new PidParseError(`Unknown instrument category '${category}'`, ln.line);
|
|
4138
|
+
}
|
|
4139
|
+
const inst = {
|
|
4140
|
+
tag,
|
|
4141
|
+
category,
|
|
4142
|
+
attrs
|
|
4143
|
+
};
|
|
4144
|
+
instruments.push(inst);
|
|
4145
|
+
currentInst = inst;
|
|
4146
|
+
continue;
|
|
4147
|
+
}
|
|
4148
|
+
throw new PidParseError(`Unparseable line: ${text2}`, ln.line);
|
|
4149
|
+
}
|
|
4150
|
+
return {
|
|
4151
|
+
type: "pid",
|
|
4152
|
+
title: title2,
|
|
4153
|
+
direction,
|
|
4154
|
+
equipment,
|
|
4155
|
+
lines: linesAst,
|
|
4156
|
+
instruments
|
|
4157
|
+
};
|
|
4158
|
+
}
|
|
4159
|
+
|
|
4160
|
+
// src/diagrams/pid/symbols.ts
|
|
4161
|
+
var GEOMETRY = {
|
|
4162
|
+
// ── Tanks & vessels ─────────────────────────────────────
|
|
4163
|
+
tank_atm: {
|
|
4164
|
+
width: 90,
|
|
4165
|
+
height: 90,
|
|
4166
|
+
ports: {
|
|
4167
|
+
top: { x: 0, y: -45 },
|
|
4168
|
+
bottom: { x: 0, y: 45 },
|
|
4169
|
+
left: { x: -45, y: 0 },
|
|
4170
|
+
right: { x: 45, y: 0 },
|
|
4171
|
+
in: { x: -45, y: 0 },
|
|
4172
|
+
out: { x: 45, y: 0 }
|
|
4173
|
+
}
|
|
4174
|
+
},
|
|
4175
|
+
tank_cone_roof: {
|
|
4176
|
+
width: 90,
|
|
4177
|
+
height: 100,
|
|
4178
|
+
ports: {
|
|
4179
|
+
top: { x: 0, y: -50 },
|
|
4180
|
+
bottom: { x: 0, y: 50 },
|
|
4181
|
+
left: { x: -45, y: 0 },
|
|
4182
|
+
right: { x: 45, y: 0 }
|
|
4183
|
+
}
|
|
4184
|
+
},
|
|
4185
|
+
vessel_v: {
|
|
4186
|
+
width: 70,
|
|
4187
|
+
height: 130,
|
|
4188
|
+
ports: {
|
|
4189
|
+
top: { x: 0, y: -65 },
|
|
4190
|
+
bottom: { x: 0, y: 65 },
|
|
4191
|
+
left: { x: -35, y: 0 },
|
|
4192
|
+
right: { x: 35, y: 0 },
|
|
4193
|
+
in: { x: -35, y: -25 },
|
|
4194
|
+
out: { x: 35, y: 25 }
|
|
4195
|
+
}
|
|
4196
|
+
},
|
|
4197
|
+
vessel_h: {
|
|
4198
|
+
width: 130,
|
|
4199
|
+
height: 70,
|
|
4200
|
+
ports: {
|
|
4201
|
+
top: { x: 0, y: -35 },
|
|
4202
|
+
bottom: { x: 0, y: 35 },
|
|
4203
|
+
left: { x: -65, y: 0 },
|
|
4204
|
+
right: { x: 65, y: 0 },
|
|
4205
|
+
in: { x: -65, y: 0 },
|
|
4206
|
+
out: { x: 65, y: 0 }
|
|
4207
|
+
}
|
|
4208
|
+
},
|
|
4209
|
+
sphere: {
|
|
4210
|
+
width: 90,
|
|
4211
|
+
height: 90,
|
|
4212
|
+
ports: {
|
|
4213
|
+
top: { x: 0, y: -45 },
|
|
4214
|
+
bottom: { x: 0, y: 45 },
|
|
4215
|
+
left: { x: -45, y: 0 },
|
|
4216
|
+
right: { x: 45, y: 0 }
|
|
4217
|
+
}
|
|
4218
|
+
},
|
|
4219
|
+
column_tray: {
|
|
4220
|
+
width: 60,
|
|
4221
|
+
height: 180,
|
|
4222
|
+
ports: {
|
|
4223
|
+
top: { x: 0, y: -90 },
|
|
4224
|
+
bottom: { x: 0, y: 90 },
|
|
4225
|
+
feed: { x: -30, y: 0 },
|
|
4226
|
+
reflux: { x: 0, y: -90 },
|
|
4227
|
+
bottom_return: { x: -30, y: 70 },
|
|
4228
|
+
vapor_out: { x: 0, y: -90 },
|
|
4229
|
+
liquid_out: { x: 0, y: 90 }
|
|
4230
|
+
}
|
|
4231
|
+
},
|
|
4232
|
+
column_packed: {
|
|
4233
|
+
width: 60,
|
|
4234
|
+
height: 180,
|
|
4235
|
+
ports: {
|
|
4236
|
+
top: { x: 0, y: -90 },
|
|
4237
|
+
bottom: { x: 0, y: 90 },
|
|
4238
|
+
feed: { x: -30, y: 0 }
|
|
4239
|
+
}
|
|
4240
|
+
},
|
|
4241
|
+
hx_shell_tube: {
|
|
4242
|
+
width: 130,
|
|
4243
|
+
height: 60,
|
|
4244
|
+
ports: {
|
|
4245
|
+
shell_in: { x: 0, y: -30 },
|
|
4246
|
+
shell_out: { x: 0, y: 30 },
|
|
4247
|
+
tube_in: { x: -65, y: 0 },
|
|
4248
|
+
tube_out: { x: 65, y: 0 },
|
|
4249
|
+
in: { x: -65, y: 0 },
|
|
4250
|
+
out: { x: 65, y: 0 }
|
|
4251
|
+
}
|
|
4252
|
+
},
|
|
4253
|
+
hx_air_cooled: {
|
|
4254
|
+
width: 130,
|
|
4255
|
+
height: 80,
|
|
4256
|
+
ports: {
|
|
4257
|
+
in: { x: -65, y: 10 },
|
|
4258
|
+
out: { x: 65, y: 10 }
|
|
4259
|
+
}
|
|
4260
|
+
},
|
|
4261
|
+
reboiler: {
|
|
4262
|
+
width: 110,
|
|
4263
|
+
height: 60,
|
|
4264
|
+
ports: {
|
|
4265
|
+
in: { x: -55, y: 0 },
|
|
4266
|
+
out: { x: 55, y: 0 },
|
|
4267
|
+
bottom: { x: 0, y: 30 }
|
|
4268
|
+
}
|
|
4269
|
+
},
|
|
4270
|
+
condenser: {
|
|
4271
|
+
width: 130,
|
|
4272
|
+
height: 60,
|
|
4273
|
+
ports: {
|
|
4274
|
+
shell_in: { x: -50, y: -30 },
|
|
4275
|
+
shell_out: { x: 50, y: 30 },
|
|
4276
|
+
tube_in: { x: -65, y: 0 },
|
|
4277
|
+
tube_out: { x: 65, y: 0 },
|
|
4278
|
+
in: { x: -65, y: 0 },
|
|
4279
|
+
out: { x: 65, y: 0 }
|
|
4280
|
+
}
|
|
4281
|
+
},
|
|
4282
|
+
pump_centrifugal: {
|
|
4283
|
+
width: 70,
|
|
4284
|
+
height: 60,
|
|
4285
|
+
ports: {
|
|
4286
|
+
in: { x: -30, y: 0 },
|
|
4287
|
+
out: { x: 28, y: -22 },
|
|
4288
|
+
top: { x: 28, y: -22 },
|
|
4289
|
+
left: { x: -30, y: 0 },
|
|
4290
|
+
right: { x: 28, y: -22 }
|
|
4291
|
+
}
|
|
4292
|
+
},
|
|
4293
|
+
pump_pd: {
|
|
4294
|
+
width: 70,
|
|
4295
|
+
height: 60,
|
|
4296
|
+
ports: {
|
|
4297
|
+
in: { x: -35, y: 0 },
|
|
4298
|
+
out: { x: 35, y: 0 }
|
|
4299
|
+
}
|
|
4300
|
+
},
|
|
4301
|
+
compressor: {
|
|
4302
|
+
width: 90,
|
|
4303
|
+
height: 60,
|
|
4304
|
+
ports: {
|
|
4305
|
+
in: { x: -45, y: 0 },
|
|
4306
|
+
out: { x: 45, y: 0 }
|
|
4307
|
+
}
|
|
4308
|
+
},
|
|
4309
|
+
blower: {
|
|
4310
|
+
width: 70,
|
|
4311
|
+
height: 60,
|
|
4312
|
+
ports: {
|
|
4313
|
+
in: { x: -35, y: 0 },
|
|
4314
|
+
out: { x: 35, y: 0 }
|
|
4315
|
+
}
|
|
4316
|
+
},
|
|
4317
|
+
reactor_cstr: {
|
|
4318
|
+
width: 90,
|
|
4319
|
+
height: 110,
|
|
4320
|
+
ports: {
|
|
4321
|
+
top: { x: 0, y: -55 },
|
|
4322
|
+
bottom: { x: 0, y: 55 },
|
|
4323
|
+
in: { x: -45, y: -10 },
|
|
4324
|
+
out: { x: 0, y: 55 }
|
|
4325
|
+
}
|
|
4326
|
+
},
|
|
4327
|
+
reactor_pfr: {
|
|
4328
|
+
width: 130,
|
|
4329
|
+
height: 50,
|
|
4330
|
+
ports: {
|
|
4331
|
+
in: { x: -65, y: 0 },
|
|
4332
|
+
out: { x: 65, y: 0 }
|
|
4333
|
+
}
|
|
4334
|
+
},
|
|
4335
|
+
filter: {
|
|
4336
|
+
width: 70,
|
|
4337
|
+
height: 70,
|
|
4338
|
+
ports: {
|
|
4339
|
+
in: { x: -35, y: 0 },
|
|
4340
|
+
out: { x: 35, y: 0 }
|
|
4341
|
+
}
|
|
4342
|
+
},
|
|
4343
|
+
cyclone: {
|
|
4344
|
+
width: 70,
|
|
4345
|
+
height: 100,
|
|
4346
|
+
ports: {
|
|
4347
|
+
top: { x: 0, y: -50 },
|
|
4348
|
+
in: { x: -35, y: -30 },
|
|
4349
|
+
bottom: { x: 0, y: 50 },
|
|
4350
|
+
out: { x: 0, y: -50 }
|
|
4351
|
+
}
|
|
4352
|
+
},
|
|
4353
|
+
flare: {
|
|
4354
|
+
width: 30,
|
|
4355
|
+
height: 110,
|
|
4356
|
+
ports: {
|
|
4357
|
+
top: { x: 0, y: -55 },
|
|
4358
|
+
bottom: { x: 0, y: 55 },
|
|
4359
|
+
in: { x: 0, y: 55 }
|
|
4360
|
+
}
|
|
4361
|
+
},
|
|
4362
|
+
cooling_tower: {
|
|
4363
|
+
width: 100,
|
|
4364
|
+
height: 90,
|
|
4365
|
+
ports: {
|
|
4366
|
+
top: { x: 0, y: -45 },
|
|
4367
|
+
in: { x: -50, y: 0 },
|
|
4368
|
+
out: { x: 50, y: 0 }
|
|
4369
|
+
}
|
|
4370
|
+
},
|
|
4371
|
+
// ── Valves (in-line) ──────────────────────────────────
|
|
4372
|
+
valve_gate: {
|
|
4373
|
+
width: 36,
|
|
4374
|
+
height: 22,
|
|
4375
|
+
ports: { in: { x: -18, y: 0 }, out: { x: 18, y: 0 }, left: { x: -18, y: 0 }, right: { x: 18, y: 0 } }
|
|
4376
|
+
},
|
|
4377
|
+
valve_ball: {
|
|
4378
|
+
width: 36,
|
|
4379
|
+
height: 22,
|
|
4380
|
+
ports: { in: { x: -18, y: 0 }, out: { x: 18, y: 0 } }
|
|
4381
|
+
},
|
|
4382
|
+
valve_globe: {
|
|
4383
|
+
width: 36,
|
|
4384
|
+
height: 28,
|
|
4385
|
+
ports: { in: { x: -18, y: 0 }, out: { x: 18, y: 0 } }
|
|
4386
|
+
},
|
|
4387
|
+
valve_butterfly: {
|
|
4388
|
+
width: 36,
|
|
4389
|
+
height: 22,
|
|
4390
|
+
ports: { in: { x: -18, y: 0 }, out: { x: 18, y: 0 } }
|
|
4391
|
+
},
|
|
4392
|
+
valve_check: {
|
|
4393
|
+
width: 36,
|
|
4394
|
+
height: 22,
|
|
4395
|
+
ports: { in: { x: -18, y: 0 }, out: { x: 18, y: 0 } }
|
|
4396
|
+
},
|
|
4397
|
+
valve_control: {
|
|
4398
|
+
width: 36,
|
|
4399
|
+
height: 60,
|
|
4400
|
+
ports: { in: { x: -18, y: 12 }, out: { x: 18, y: 12 }, top: { x: 0, y: -22 } }
|
|
4401
|
+
},
|
|
4402
|
+
valve_psv: {
|
|
4403
|
+
width: 36,
|
|
4404
|
+
height: 60,
|
|
4405
|
+
ports: { in: { x: -18, y: 12 }, out: { x: 18, y: -8 } }
|
|
4406
|
+
}
|
|
4407
|
+
};
|
|
4408
|
+
var STROKE_BLACK = "#1d1d1d";
|
|
4409
|
+
var FILL_WHITE = "#ffffff";
|
|
4410
|
+
function bowtie() {
|
|
4411
|
+
return chunkLFZZ4NCP_cjs.polygon({
|
|
4412
|
+
points: "-18,-11 0,0 -18,11 18,11 0,0 18,-11",
|
|
4413
|
+
class: "lt-pid-valve-body"
|
|
4414
|
+
});
|
|
4415
|
+
}
|
|
4416
|
+
function renderEquip(type, label) {
|
|
4417
|
+
switch (type) {
|
|
4418
|
+
case "tank_atm": {
|
|
4419
|
+
const w = 90;
|
|
4420
|
+
const h = 90;
|
|
4421
|
+
const cylTop = -h / 2 + 14;
|
|
4422
|
+
const parts = [
|
|
4423
|
+
// dome top
|
|
4424
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4425
|
+
d: `M ${-w / 2} ${cylTop} A ${w / 2} 14 0 0 1 ${w / 2} ${cylTop}`,
|
|
4426
|
+
class: "lt-pid-equip"
|
|
4427
|
+
}),
|
|
4428
|
+
// body
|
|
4429
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4430
|
+
x: -w / 2,
|
|
4431
|
+
y: cylTop,
|
|
4432
|
+
width: w,
|
|
4433
|
+
height: h - 14,
|
|
4434
|
+
class: "lt-pid-equip"
|
|
4435
|
+
}),
|
|
4436
|
+
// tag
|
|
4437
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4438
|
+
{ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4439
|
+
label
|
|
4440
|
+
)
|
|
4441
|
+
];
|
|
4442
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-pid-equip-group" }, parts);
|
|
4443
|
+
}
|
|
4444
|
+
case "tank_cone_roof": {
|
|
4445
|
+
const w = 90;
|
|
4446
|
+
const h = 100;
|
|
4447
|
+
const roofH = 18;
|
|
4448
|
+
const top = -h / 2;
|
|
4449
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4450
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4451
|
+
points: `${-w / 2},${top + roofH} 0,${top} ${w / 2},${top + roofH}`,
|
|
4452
|
+
class: "lt-pid-equip"
|
|
4453
|
+
}),
|
|
4454
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4455
|
+
x: -w / 2,
|
|
4456
|
+
y: top + roofH,
|
|
4457
|
+
width: w,
|
|
4458
|
+
height: h - roofH,
|
|
4459
|
+
class: "lt-pid-equip"
|
|
4460
|
+
}),
|
|
4461
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4462
|
+
]);
|
|
4463
|
+
}
|
|
4464
|
+
case "vessel_v": {
|
|
4465
|
+
const w = 70;
|
|
4466
|
+
const h = 130;
|
|
4467
|
+
const headH = 16;
|
|
4468
|
+
const top = -h / 2;
|
|
4469
|
+
const bot = h / 2;
|
|
4470
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4471
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4472
|
+
d: `M ${-w / 2} ${top + headH}
|
|
4473
|
+
A ${w / 2} ${headH} 0 0 1 ${w / 2} ${top + headH}
|
|
4474
|
+
L ${w / 2} ${bot - headH}
|
|
4475
|
+
A ${w / 2} ${headH} 0 0 1 ${-w / 2} ${bot - headH}
|
|
4476
|
+
Z`,
|
|
4477
|
+
class: "lt-pid-equip"
|
|
4478
|
+
}),
|
|
4479
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4480
|
+
{ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4481
|
+
label
|
|
4482
|
+
)
|
|
4483
|
+
]);
|
|
4484
|
+
}
|
|
4485
|
+
case "vessel_h": {
|
|
4486
|
+
const w = 130;
|
|
4487
|
+
const h = 70;
|
|
4488
|
+
const headW = 14;
|
|
4489
|
+
const left = -w / 2;
|
|
4490
|
+
const right = w / 2;
|
|
4491
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4492
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4493
|
+
d: `M ${left + headW} ${-h / 2}
|
|
4494
|
+
L ${right - headW} ${-h / 2}
|
|
4495
|
+
A ${headW} ${h / 2} 0 0 1 ${right - headW} ${h / 2}
|
|
4496
|
+
L ${left + headW} ${h / 2}
|
|
4497
|
+
A ${headW} ${h / 2} 0 0 1 ${left + headW} ${-h / 2}
|
|
4498
|
+
Z`,
|
|
4499
|
+
class: "lt-pid-equip"
|
|
4500
|
+
}),
|
|
4501
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4502
|
+
{ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4503
|
+
label
|
|
4504
|
+
)
|
|
4505
|
+
]);
|
|
4506
|
+
}
|
|
4507
|
+
case "sphere": {
|
|
4508
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4509
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r: 45, class: "lt-pid-equip" }),
|
|
4510
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4511
|
+
]);
|
|
4512
|
+
}
|
|
4513
|
+
case "column_tray": {
|
|
4514
|
+
const w = 60;
|
|
4515
|
+
const h = 180;
|
|
4516
|
+
const headH = 12;
|
|
4517
|
+
const trays = 12;
|
|
4518
|
+
const inner = h - headH * 2;
|
|
4519
|
+
const traySpacing = inner / (trays + 1);
|
|
4520
|
+
const trayLines = [];
|
|
4521
|
+
for (let i = 1; i <= trays; i++) {
|
|
4522
|
+
const y = -h / 2 + headH + traySpacing * i;
|
|
4523
|
+
trayLines.push(
|
|
4524
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4525
|
+
x1: -w / 2 + 6,
|
|
4526
|
+
y1: y,
|
|
4527
|
+
x2: w / 2 - 6,
|
|
4528
|
+
y2: y,
|
|
4529
|
+
class: "lt-pid-tray-line"
|
|
4530
|
+
})
|
|
4531
|
+
);
|
|
4532
|
+
}
|
|
4533
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4534
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4535
|
+
d: `M ${-w / 2} ${-h / 2 + headH}
|
|
4536
|
+
A ${w / 2} ${headH} 0 0 1 ${w / 2} ${-h / 2 + headH}
|
|
4537
|
+
L ${w / 2} ${h / 2 - headH}
|
|
4538
|
+
A ${w / 2} ${headH} 0 0 1 ${-w / 2} ${h / 2 - headH}
|
|
4539
|
+
Z`,
|
|
4540
|
+
class: "lt-pid-equip"
|
|
4541
|
+
}),
|
|
4542
|
+
...trayLines,
|
|
4543
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4544
|
+
{
|
|
4545
|
+
x: 0,
|
|
4546
|
+
y: -h / 2 - 6,
|
|
4547
|
+
"text-anchor": "middle",
|
|
4548
|
+
class: "lt-pid-equip-tag"
|
|
4549
|
+
},
|
|
4550
|
+
label
|
|
4551
|
+
)
|
|
4552
|
+
]);
|
|
4553
|
+
}
|
|
4554
|
+
case "column_packed": {
|
|
4555
|
+
const w = 60;
|
|
4556
|
+
const h = 180;
|
|
4557
|
+
const headH = 12;
|
|
4558
|
+
const packing = chunkLFZZ4NCP_cjs.path({
|
|
4559
|
+
d: `M ${-w / 2 + 6} ${-h / 2 + headH + 6}
|
|
4560
|
+
L ${w / 2 - 6} ${h / 2 - headH - 6}
|
|
4561
|
+
M ${w / 2 - 6} ${-h / 2 + headH + 6}
|
|
4562
|
+
L ${-w / 2 + 6} ${h / 2 - headH - 6}`,
|
|
4563
|
+
class: "lt-pid-tray-line"
|
|
4564
|
+
});
|
|
4565
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4566
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4567
|
+
d: `M ${-w / 2} ${-h / 2 + headH}
|
|
4568
|
+
A ${w / 2} ${headH} 0 0 1 ${w / 2} ${-h / 2 + headH}
|
|
4569
|
+
L ${w / 2} ${h / 2 - headH}
|
|
4570
|
+
A ${w / 2} ${headH} 0 0 1 ${-w / 2} ${h / 2 - headH}
|
|
4571
|
+
Z`,
|
|
4572
|
+
class: "lt-pid-equip"
|
|
4573
|
+
}),
|
|
4574
|
+
packing,
|
|
4575
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4576
|
+
{
|
|
4577
|
+
x: 0,
|
|
4578
|
+
y: -h / 2 - 6,
|
|
4579
|
+
"text-anchor": "middle",
|
|
4580
|
+
class: "lt-pid-equip-tag"
|
|
4581
|
+
},
|
|
4582
|
+
label
|
|
4583
|
+
)
|
|
4584
|
+
]);
|
|
4585
|
+
}
|
|
4586
|
+
case "hx_shell_tube": {
|
|
4587
|
+
const w = 130;
|
|
4588
|
+
const h = 60;
|
|
4589
|
+
const headW = 12;
|
|
4590
|
+
const left = -w / 2;
|
|
4591
|
+
const right = w / 2;
|
|
4592
|
+
const tubes = [];
|
|
4593
|
+
for (let yy = -h / 2 + 12; yy <= h / 2 - 12; yy += 8) {
|
|
4594
|
+
tubes.push(
|
|
4595
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4596
|
+
x1: left + headW + 4,
|
|
4597
|
+
y1: yy,
|
|
4598
|
+
x2: right - headW - 4,
|
|
4599
|
+
y2: yy,
|
|
4600
|
+
class: "lt-pid-tray-line"
|
|
4601
|
+
})
|
|
4602
|
+
);
|
|
4603
|
+
}
|
|
4604
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4605
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4606
|
+
d: `M ${left + headW} ${-h / 2}
|
|
4607
|
+
L ${right - headW} ${-h / 2}
|
|
4608
|
+
A ${headW} ${h / 2} 0 0 1 ${right - headW} ${h / 2}
|
|
4609
|
+
L ${left + headW} ${h / 2}
|
|
4610
|
+
A ${headW} ${h / 2} 0 0 1 ${left + headW} ${-h / 2}
|
|
4611
|
+
Z`,
|
|
4612
|
+
class: "lt-pid-equip"
|
|
4613
|
+
}),
|
|
4614
|
+
...tubes,
|
|
4615
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4616
|
+
{
|
|
4617
|
+
x: 0,
|
|
4618
|
+
y: h / 2 + 14,
|
|
4619
|
+
"text-anchor": "middle",
|
|
4620
|
+
class: "lt-pid-equip-tag"
|
|
4621
|
+
},
|
|
4622
|
+
label
|
|
4623
|
+
)
|
|
4624
|
+
]);
|
|
4625
|
+
}
|
|
4626
|
+
case "hx_air_cooled": {
|
|
4627
|
+
const w = 130;
|
|
4628
|
+
const h = 80;
|
|
4629
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4630
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4631
|
+
x: -w / 2,
|
|
4632
|
+
y: -h / 2 + 18,
|
|
4633
|
+
width: w,
|
|
4634
|
+
height: h - 18,
|
|
4635
|
+
class: "lt-pid-equip"
|
|
4636
|
+
}),
|
|
4637
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: -h / 2 + 14, r: 18, class: "lt-pid-equip" }),
|
|
4638
|
+
// 3-blade fan
|
|
4639
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4640
|
+
d: `M 0 ${-h / 2 + 14} L 14 ${-h / 2 + 6}
|
|
4641
|
+
M 0 ${-h / 2 + 14} L -14 ${-h / 2 + 6}
|
|
4642
|
+
M 0 ${-h / 2 + 14} L 0 ${-h / 2 + 30}`,
|
|
4643
|
+
class: "lt-pid-tray-line"
|
|
4644
|
+
}),
|
|
4645
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4646
|
+
{ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4647
|
+
label
|
|
4648
|
+
)
|
|
4649
|
+
]);
|
|
4650
|
+
}
|
|
4651
|
+
case "reboiler": {
|
|
4652
|
+
const w = 110;
|
|
4653
|
+
const h = 60;
|
|
4654
|
+
const headW = 14;
|
|
4655
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4656
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4657
|
+
d: `M ${-w / 2 + headW} ${-h / 2}
|
|
4658
|
+
L ${w / 2 - headW} ${-h / 2}
|
|
4659
|
+
A ${headW} ${h / 2} 0 0 1 ${w / 2 - headW} ${h / 2}
|
|
4660
|
+
L ${-w / 2 + headW} ${h / 2}
|
|
4661
|
+
A ${headW} ${h / 2} 0 0 1 ${-w / 2 + headW} ${-h / 2}
|
|
4662
|
+
Z`,
|
|
4663
|
+
class: "lt-pid-equip"
|
|
4664
|
+
}),
|
|
4665
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4666
|
+
x1: -w / 2 + headW + 4,
|
|
4667
|
+
y1: -10,
|
|
4668
|
+
x2: w / 2 - headW - 4,
|
|
4669
|
+
y2: -10,
|
|
4670
|
+
class: "lt-pid-tray-line"
|
|
4671
|
+
}),
|
|
4672
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4673
|
+
x1: -w / 2 + headW + 4,
|
|
4674
|
+
y1: 0,
|
|
4675
|
+
x2: w / 2 - headW - 4,
|
|
4676
|
+
y2: 0,
|
|
4677
|
+
class: "lt-pid-tray-line"
|
|
4678
|
+
}),
|
|
4679
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4680
|
+
x1: -w / 2 + headW + 4,
|
|
4681
|
+
y1: 10,
|
|
4682
|
+
x2: w / 2 - headW - 4,
|
|
4683
|
+
y2: 10,
|
|
4684
|
+
class: "lt-pid-tray-line"
|
|
4685
|
+
}),
|
|
4686
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4687
|
+
]);
|
|
4688
|
+
}
|
|
4689
|
+
case "condenser": {
|
|
4690
|
+
const w = 130;
|
|
4691
|
+
const h = 60;
|
|
4692
|
+
const headW = 12;
|
|
4693
|
+
const left = -w / 2;
|
|
4694
|
+
const right = w / 2;
|
|
4695
|
+
const tubes = [];
|
|
4696
|
+
for (let yy = -h / 2 + 12; yy <= h / 2 - 12; yy += 10) {
|
|
4697
|
+
tubes.push(
|
|
4698
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4699
|
+
x1: left + headW + 4,
|
|
4700
|
+
y1: yy,
|
|
4701
|
+
x2: right - headW - 4,
|
|
4702
|
+
y2: yy,
|
|
4703
|
+
class: "lt-pid-tray-line"
|
|
4704
|
+
})
|
|
4705
|
+
);
|
|
4706
|
+
}
|
|
4707
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4708
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4709
|
+
d: `M ${left + headW} ${-h / 2}
|
|
4710
|
+
L ${right - headW} ${-h / 2}
|
|
4711
|
+
A ${headW} ${h / 2} 0 0 1 ${right - headW} ${h / 2}
|
|
4712
|
+
L ${left + headW} ${h / 2}
|
|
4713
|
+
A ${headW} ${h / 2} 0 0 1 ${left + headW} ${-h / 2}
|
|
4714
|
+
Z`,
|
|
4715
|
+
class: "lt-pid-equip"
|
|
4716
|
+
}),
|
|
4717
|
+
...tubes,
|
|
4718
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4719
|
+
]);
|
|
4720
|
+
}
|
|
4721
|
+
case "pump_centrifugal": {
|
|
4722
|
+
const r = 22;
|
|
4723
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4724
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-pid-equip" }),
|
|
4725
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4726
|
+
points: `${r * 0.4},${-r * 0.9} ${r + 6},${-r * 0.9} ${r * 0.4},${0}`,
|
|
4727
|
+
class: "lt-pid-equip"
|
|
4728
|
+
}),
|
|
4729
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4730
|
+
{ x: 0, y: r + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4731
|
+
label
|
|
4732
|
+
)
|
|
4733
|
+
]);
|
|
4734
|
+
}
|
|
4735
|
+
case "pump_pd": {
|
|
4736
|
+
const r = 22;
|
|
4737
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4738
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-pid-equip" }),
|
|
4739
|
+
chunkLFZZ4NCP_cjs.circle({ cx: -8, cy: 0, r: 6, class: "lt-pid-tray-line", fill: "none" }),
|
|
4740
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 8, cy: 0, r: 6, class: "lt-pid-tray-line", fill: "none" }),
|
|
4741
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4742
|
+
{ x: 0, y: r + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4743
|
+
label
|
|
4744
|
+
)
|
|
4745
|
+
]);
|
|
4746
|
+
}
|
|
4747
|
+
case "compressor": {
|
|
4748
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4749
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4750
|
+
points: "-45,-20 45,-12 45,12 -45,20",
|
|
4751
|
+
class: "lt-pid-equip"
|
|
4752
|
+
}),
|
|
4753
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 36, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4754
|
+
]);
|
|
4755
|
+
}
|
|
4756
|
+
case "blower": {
|
|
4757
|
+
const r = 22;
|
|
4758
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4759
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-pid-equip" }),
|
|
4760
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4761
|
+
d: `M 0 0 L ${r * 0.8} ${-r * 0.5} M 0 0 L ${-r * 0.6} ${-r * 0.6} M 0 0 L 0 ${r * 0.8}`,
|
|
4762
|
+
class: "lt-pid-tray-line"
|
|
4763
|
+
}),
|
|
4764
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: r + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4765
|
+
]);
|
|
4766
|
+
}
|
|
4767
|
+
case "reactor_cstr": {
|
|
4768
|
+
const w = 90;
|
|
4769
|
+
const h = 110;
|
|
4770
|
+
const headH = 14;
|
|
4771
|
+
const top = -h / 2;
|
|
4772
|
+
const bot = h / 2;
|
|
4773
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4774
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4775
|
+
d: `M ${-w / 2} ${top + headH}
|
|
4776
|
+
A ${w / 2} ${headH} 0 0 1 ${w / 2} ${top + headH}
|
|
4777
|
+
L ${w / 2} ${bot - headH}
|
|
4778
|
+
A ${w / 2} ${headH} 0 0 1 ${-w / 2} ${bot - headH}
|
|
4779
|
+
Z`,
|
|
4780
|
+
class: "lt-pid-equip"
|
|
4781
|
+
}),
|
|
4782
|
+
// agitator shaft + paddle
|
|
4783
|
+
chunkLFZZ4NCP_cjs.line({ x1: 0, y1: top - 14, x2: 0, y2: 4, class: "lt-pid-tray-line" }),
|
|
4784
|
+
chunkLFZZ4NCP_cjs.rect({ x: -10, y: 4, width: 20, height: 4, class: "lt-pid-equip" }),
|
|
4785
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4786
|
+
{ x: 0, y: bot + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" },
|
|
4787
|
+
label
|
|
4788
|
+
)
|
|
4789
|
+
]);
|
|
4790
|
+
}
|
|
4791
|
+
case "reactor_pfr": {
|
|
4792
|
+
const w = 130;
|
|
4793
|
+
const h = 50;
|
|
4794
|
+
const headW = 12;
|
|
4795
|
+
const left = -w / 2;
|
|
4796
|
+
const right = w / 2;
|
|
4797
|
+
const dots = [];
|
|
4798
|
+
for (let xx = left + headW + 8; xx <= right - headW - 8; xx += 12) {
|
|
4799
|
+
for (let yy = -h / 2 + 12; yy <= h / 2 - 8; yy += 10) {
|
|
4800
|
+
dots.push(chunkLFZZ4NCP_cjs.circle({ cx: xx, cy: yy, r: 1.6, fill: STROKE_BLACK }));
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4803
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4804
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4805
|
+
d: `M ${left + headW} ${-h / 2}
|
|
4806
|
+
L ${right - headW} ${-h / 2}
|
|
4807
|
+
A ${headW} ${h / 2} 0 0 1 ${right - headW} ${h / 2}
|
|
4808
|
+
L ${left + headW} ${h / 2}
|
|
4809
|
+
A ${headW} ${h / 2} 0 0 1 ${left + headW} ${-h / 2}
|
|
4810
|
+
Z`,
|
|
4811
|
+
class: "lt-pid-equip"
|
|
4812
|
+
}),
|
|
4813
|
+
...dots,
|
|
4814
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4815
|
+
]);
|
|
4816
|
+
}
|
|
4817
|
+
case "filter": {
|
|
4818
|
+
const w = 70;
|
|
4819
|
+
const h = 70;
|
|
4820
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4821
|
+
chunkLFZZ4NCP_cjs.rect({ x: -w / 2, y: -h / 2, width: w, height: h, class: "lt-pid-equip" }),
|
|
4822
|
+
chunkLFZZ4NCP_cjs.line({ x1: -w / 2, y1: 0, x2: w / 2, y2: 0, class: "lt-pid-tray-line" }),
|
|
4823
|
+
chunkLFZZ4NCP_cjs.line({ x1: -w / 2 + 8, y1: -h / 2 + 8, x2: w / 2 - 8, y2: -8, class: "lt-pid-tray-line" }),
|
|
4824
|
+
chunkLFZZ4NCP_cjs.line({ x1: -w / 2 + 8, y1: 8, x2: w / 2 - 8, y2: h / 2 - 8, class: "lt-pid-tray-line" }),
|
|
4825
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4826
|
+
]);
|
|
4827
|
+
}
|
|
4828
|
+
case "cyclone": {
|
|
4829
|
+
const w = 70;
|
|
4830
|
+
const h = 100;
|
|
4831
|
+
const cyl = 30;
|
|
4832
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4833
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4834
|
+
d: `M ${-w / 2} ${-h / 2}
|
|
4835
|
+
L ${w / 2} ${-h / 2}
|
|
4836
|
+
L ${w / 2} ${-h / 2 + cyl}
|
|
4837
|
+
L 0 ${h / 2}
|
|
4838
|
+
L ${-w / 2} ${-h / 2 + cyl}
|
|
4839
|
+
Z`,
|
|
4840
|
+
class: "lt-pid-equip"
|
|
4841
|
+
}),
|
|
4842
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4843
|
+
]);
|
|
4844
|
+
}
|
|
4845
|
+
case "flare": {
|
|
4846
|
+
const w = 30;
|
|
4847
|
+
const h = 110;
|
|
4848
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4849
|
+
chunkLFZZ4NCP_cjs.rect({ x: -w / 2, y: -h / 2, width: w, height: h, class: "lt-pid-equip" }),
|
|
4850
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4851
|
+
points: `${ -8},${-h / 2 - 4} 0,${-h / 2 - 22} 8,${-h / 2 - 4}`,
|
|
4852
|
+
fill: "#ff7755",
|
|
4853
|
+
stroke: STROKE_BLACK
|
|
4854
|
+
}),
|
|
4855
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4856
|
+
]);
|
|
4857
|
+
}
|
|
4858
|
+
case "cooling_tower": {
|
|
4859
|
+
const w = 100;
|
|
4860
|
+
const h = 90;
|
|
4861
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4862
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4863
|
+
d: `M ${-w / 2} ${-h / 2}
|
|
4864
|
+
L ${w / 2} ${-h / 2}
|
|
4865
|
+
L ${w / 4} 0
|
|
4866
|
+
L ${w / 2} ${h / 2}
|
|
4867
|
+
L ${-w / 2} ${h / 2}
|
|
4868
|
+
L ${-w / 4} 0
|
|
4869
|
+
Z`,
|
|
4870
|
+
class: "lt-pid-equip"
|
|
4871
|
+
}),
|
|
4872
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: h / 2 + 14, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4873
|
+
]);
|
|
4874
|
+
}
|
|
4875
|
+
// ── Valves ──────────────────────────────────────────
|
|
4876
|
+
case "valve_gate":
|
|
4877
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4878
|
+
bowtie(),
|
|
4879
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 22, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4880
|
+
]);
|
|
4881
|
+
case "valve_ball":
|
|
4882
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4883
|
+
bowtie(),
|
|
4884
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r: 4, fill: STROKE_BLACK }),
|
|
4885
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 22, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4886
|
+
]);
|
|
4887
|
+
case "valve_globe":
|
|
4888
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4889
|
+
bowtie(),
|
|
4890
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: -5, r: 5, class: "lt-pid-valve-body", fill: FILL_WHITE }),
|
|
4891
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 22, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4892
|
+
]);
|
|
4893
|
+
case "valve_butterfly":
|
|
4894
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4895
|
+
bowtie(),
|
|
4896
|
+
chunkLFZZ4NCP_cjs.line({ x1: 0, y1: -10, x2: 0, y2: 10, class: "lt-pid-tray-line" }),
|
|
4897
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 22, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4898
|
+
]);
|
|
4899
|
+
case "valve_check":
|
|
4900
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4901
|
+
bowtie(),
|
|
4902
|
+
chunkLFZZ4NCP_cjs.path({ d: "M -10 -8 A 10 10 0 0 1 -10 8", class: "lt-pid-tray-line", fill: "none" }),
|
|
4903
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 22, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4904
|
+
]);
|
|
4905
|
+
case "valve_control":
|
|
4906
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4907
|
+
bowtie(),
|
|
4908
|
+
// actuator: diaphragm
|
|
4909
|
+
chunkLFZZ4NCP_cjs.line({ x1: 0, y1: -11, x2: 0, y2: -22, class: "lt-pid-tray-line" }),
|
|
4910
|
+
chunkLFZZ4NCP_cjs.path({ d: "M -14 -22 A 14 8 0 0 1 14 -22 L -14 -22 Z", class: "lt-pid-equip" }),
|
|
4911
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 24, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4912
|
+
]);
|
|
4913
|
+
case "valve_psv":
|
|
4914
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4915
|
+
bowtie(),
|
|
4916
|
+
// diagonal outlet (45°)
|
|
4917
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4918
|
+
x1: 18,
|
|
4919
|
+
y1: -11,
|
|
4920
|
+
x2: 26,
|
|
4921
|
+
y2: -22,
|
|
4922
|
+
class: "lt-pid-process"
|
|
4923
|
+
}),
|
|
4924
|
+
// spring stack
|
|
4925
|
+
chunkLFZZ4NCP_cjs.path({
|
|
4926
|
+
d: "M -6 -11 L -10 -16 L -2 -20 L -10 -24 L -2 -28",
|
|
4927
|
+
class: "lt-pid-tray-line",
|
|
4928
|
+
fill: "none"
|
|
4929
|
+
}),
|
|
4930
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 24, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4931
|
+
]);
|
|
4932
|
+
default:
|
|
4933
|
+
return chunkLFZZ4NCP_cjs.group({}, [
|
|
4934
|
+
chunkLFZZ4NCP_cjs.rect({ x: -30, y: -20, width: 60, height: 40, class: "lt-pid-equip" }),
|
|
4935
|
+
chunkLFZZ4NCP_cjs.text({ x: 0, y: 4, "text-anchor": "middle", class: "lt-pid-equip-tag" }, label)
|
|
4936
|
+
]);
|
|
4937
|
+
}
|
|
4938
|
+
}
|
|
4939
|
+
function renderInstrument(category, letterCode, loopNumber) {
|
|
4940
|
+
const r = 14;
|
|
4941
|
+
const isComputer = category.endsWith("computer");
|
|
4942
|
+
const isPlc = category.endsWith("plc");
|
|
4943
|
+
const isShared = category.endsWith("shared");
|
|
4944
|
+
const isControlRoom = category.startsWith("cr_");
|
|
4945
|
+
const isLocal = category.startsWith("local_");
|
|
4946
|
+
const parts = [];
|
|
4947
|
+
if (isComputer) {
|
|
4948
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-inst-body" }));
|
|
4949
|
+
parts.push(
|
|
4950
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4951
|
+
points: `0,${-r + 1} ${r - 1},0 0,${r - 1} ${ -13},0`,
|
|
4952
|
+
class: "lt-inst-body",
|
|
4953
|
+
fill: "none"
|
|
4954
|
+
})
|
|
4955
|
+
);
|
|
4956
|
+
} else if (isPlc) {
|
|
4957
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-inst-body" }));
|
|
4958
|
+
const side = r * Math.SQRT1_2 * 2 - 2;
|
|
4959
|
+
parts.push(
|
|
4960
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4961
|
+
x: -side / 2,
|
|
4962
|
+
y: -side / 2,
|
|
4963
|
+
width: side,
|
|
4964
|
+
height: side,
|
|
4965
|
+
class: "lt-inst-body",
|
|
4966
|
+
fill: "none"
|
|
4967
|
+
})
|
|
4968
|
+
);
|
|
4969
|
+
} else if (isShared) {
|
|
4970
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-inst-body" }));
|
|
4971
|
+
const hex = [];
|
|
4972
|
+
for (let i = 0; i < 6; i++) {
|
|
4973
|
+
const a = Math.PI / 3 * i - Math.PI / 2;
|
|
4974
|
+
hex.push(`${(r - 2) * Math.cos(a)},${(r - 2) * Math.sin(a)}`);
|
|
4975
|
+
}
|
|
4976
|
+
parts.push(
|
|
4977
|
+
chunkLFZZ4NCP_cjs.polygon({
|
|
4978
|
+
points: hex.join(" "),
|
|
4979
|
+
class: "lt-inst-body",
|
|
4980
|
+
fill: "none"
|
|
4981
|
+
})
|
|
4982
|
+
);
|
|
4983
|
+
} else {
|
|
4984
|
+
parts.push(chunkLFZZ4NCP_cjs.circle({ cx: 0, cy: 0, r, class: "lt-inst-body" }));
|
|
4985
|
+
}
|
|
4986
|
+
if (isControlRoom) {
|
|
4987
|
+
parts.push(chunkLFZZ4NCP_cjs.line({ x1: -r, y1: 0, x2: r, y2: 0, class: "lt-inst-cr-line" }));
|
|
4988
|
+
} else if (isLocal) {
|
|
4989
|
+
parts.push(chunkLFZZ4NCP_cjs.line({ x1: -r, y1: 0, x2: r, y2: 0, class: "lt-inst-local-line" }));
|
|
4990
|
+
}
|
|
4991
|
+
parts.push(
|
|
4992
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4993
|
+
{
|
|
4994
|
+
x: 0,
|
|
4995
|
+
y: -3,
|
|
4996
|
+
"text-anchor": "middle",
|
|
4997
|
+
class: "lt-inst-tag"
|
|
4998
|
+
},
|
|
4999
|
+
letterCode
|
|
5000
|
+
)
|
|
5001
|
+
);
|
|
5002
|
+
parts.push(
|
|
5003
|
+
chunkLFZZ4NCP_cjs.text(
|
|
5004
|
+
{
|
|
5005
|
+
x: 0,
|
|
5006
|
+
y: 9,
|
|
5007
|
+
"text-anchor": "middle",
|
|
5008
|
+
class: "lt-inst-tag"
|
|
5009
|
+
},
|
|
5010
|
+
loopNumber
|
|
5011
|
+
)
|
|
5012
|
+
);
|
|
5013
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-inst-symbol" }, parts);
|
|
5014
|
+
}
|
|
5015
|
+
|
|
5016
|
+
// src/diagrams/pid/layout.ts
|
|
5017
|
+
var PADDING = 30;
|
|
5018
|
+
var TITLE_AREA = 26;
|
|
5019
|
+
var EQUIP_GAP_X = 70;
|
|
5020
|
+
var INST_RADIUS = 14;
|
|
5021
|
+
var INST_OFFSET = 38;
|
|
5022
|
+
function defaultPort(direction, equip) {
|
|
5023
|
+
if (equip.equipType === "tank_atm" || equip.equipType === "tank_cone_roof") {
|
|
5024
|
+
return direction === "out" ? "bottom" : "top";
|
|
5025
|
+
}
|
|
5026
|
+
if (equip.equipType === "vessel_v" || equip.equipType === "column_tray" || equip.equipType === "column_packed") {
|
|
5027
|
+
return direction === "out" ? "bottom" : "top";
|
|
5028
|
+
}
|
|
5029
|
+
return direction === "out" ? "out" : "in";
|
|
5030
|
+
}
|
|
5031
|
+
function resolveSide(port) {
|
|
5032
|
+
if (port === "top" || port === "vapor_out" || port === "reflux") return "top";
|
|
5033
|
+
if (port === "bottom" || port === "liquid_out" || port === "bottom_return") return "bottom";
|
|
5034
|
+
if (port === "left" || port === "in" || port === "feed" || port === "tube_in" || port === "shell_in") return "left";
|
|
5035
|
+
return "right";
|
|
5036
|
+
}
|
|
5037
|
+
function getAnchor(layoutEq, port, fallback) {
|
|
5038
|
+
const ports = layoutEq.ports;
|
|
5039
|
+
let key = port;
|
|
5040
|
+
if (!key || !(key in ports)) {
|
|
5041
|
+
key = defaultPort(fallback, layoutEq.equip);
|
|
5042
|
+
}
|
|
5043
|
+
const p = ports[key] ?? ports.right ?? ports.out ?? ports.left ?? ports.in;
|
|
5044
|
+
if (!p) return { x: layoutEq.cx, y: layoutEq.cy, side: "right" };
|
|
5045
|
+
return { x: p.x, y: p.y, side: resolveSide(key ?? "right") };
|
|
5046
|
+
}
|
|
5047
|
+
function manhattanPath(fromX, fromY, fromSide, toX, toY, toSide) {
|
|
5048
|
+
const isHFrom = fromSide === "left" || fromSide === "right";
|
|
5049
|
+
const isHTo = toSide === "left" || toSide === "right";
|
|
5050
|
+
if (isHFrom && isHTo) {
|
|
5051
|
+
const midX = (fromX + toX) / 2;
|
|
5052
|
+
return {
|
|
5053
|
+
d: `M ${fromX} ${fromY} L ${midX} ${fromY} L ${midX} ${toY} L ${toX} ${toY}`,
|
|
5054
|
+
midX,
|
|
5055
|
+
midY: (fromY + toY) / 2
|
|
5056
|
+
};
|
|
5057
|
+
}
|
|
5058
|
+
if (!isHFrom && !isHTo) {
|
|
5059
|
+
const midY = (fromY + toY) / 2;
|
|
5060
|
+
return {
|
|
5061
|
+
d: `M ${fromX} ${fromY} L ${fromX} ${midY} L ${toX} ${midY} L ${toX} ${toY}`,
|
|
5062
|
+
midX: (fromX + toX) / 2,
|
|
5063
|
+
midY
|
|
5064
|
+
};
|
|
5065
|
+
}
|
|
5066
|
+
if (isHFrom) {
|
|
5067
|
+
return {
|
|
5068
|
+
d: `M ${fromX} ${fromY} L ${toX} ${fromY} L ${toX} ${toY}`,
|
|
5069
|
+
midX: toX,
|
|
5070
|
+
midY: (fromY + toY) / 2
|
|
5071
|
+
};
|
|
5072
|
+
}
|
|
5073
|
+
return {
|
|
5074
|
+
d: `M ${fromX} ${fromY} L ${fromX} ${toY} L ${toX} ${toY}`,
|
|
5075
|
+
midX: (fromX + toX) / 2,
|
|
5076
|
+
midY: toY
|
|
5077
|
+
};
|
|
5078
|
+
}
|
|
5079
|
+
function layoutPid(ast) {
|
|
5080
|
+
const equipment = [];
|
|
5081
|
+
const equipById = /* @__PURE__ */ new Map();
|
|
5082
|
+
const heights = ast.equipment.map((e) => GEOMETRY[e.equipType]?.height ?? 60);
|
|
5083
|
+
const maxH = Math.max(...heights, 0);
|
|
5084
|
+
const rowY = PADDING + TITLE_AREA + maxH / 2 + 30;
|
|
5085
|
+
let cursorX = PADDING + 40;
|
|
5086
|
+
for (const equip of ast.equipment) {
|
|
5087
|
+
const geo = GEOMETRY[equip.equipType] ?? { width: 60, height: 40, ports: {} };
|
|
5088
|
+
const cx = cursorX + geo.width / 2;
|
|
5089
|
+
const cy = rowY;
|
|
5090
|
+
const x = cx - geo.width / 2;
|
|
5091
|
+
const y = cy - geo.height / 2;
|
|
5092
|
+
const ports = {};
|
|
5093
|
+
for (const [name, p] of Object.entries(geo.ports)) {
|
|
5094
|
+
ports[name] = { x: cx + p.x, y: cy + p.y };
|
|
5095
|
+
}
|
|
5096
|
+
const layoutEq = {
|
|
5097
|
+
equip,
|
|
5098
|
+
x,
|
|
5099
|
+
y,
|
|
5100
|
+
width: geo.width,
|
|
5101
|
+
height: geo.height,
|
|
5102
|
+
cx,
|
|
5103
|
+
cy,
|
|
5104
|
+
ports
|
|
5105
|
+
};
|
|
5106
|
+
equipment.push(layoutEq);
|
|
5107
|
+
equipById.set(equip.id, layoutEq);
|
|
5108
|
+
cursorX += geo.width + EQUIP_GAP_X;
|
|
5109
|
+
}
|
|
5110
|
+
const instruments = [];
|
|
5111
|
+
const instById = /* @__PURE__ */ new Map();
|
|
5112
|
+
const crBandY = PADDING + TITLE_AREA + 40;
|
|
5113
|
+
let crSlot = 0;
|
|
5114
|
+
for (const inst of ast.instruments) {
|
|
5115
|
+
let cx = 0;
|
|
5116
|
+
let cy = 0;
|
|
5117
|
+
if (inst.category.startsWith("cr_")) {
|
|
5118
|
+
const tgt = inst.controls ?? inst.measures ?? "";
|
|
5119
|
+
const tgtEq = equipById.get(tgt);
|
|
5120
|
+
cx = tgtEq ? tgtEq.cx : PADDING + 80 + crSlot * (INST_RADIUS * 2 + 28);
|
|
5121
|
+
cy = crBandY;
|
|
5122
|
+
crSlot += 1;
|
|
5123
|
+
} else if (inst.category.startsWith("local_")) {
|
|
5124
|
+
cy = rowY + maxH / 2 + INST_OFFSET + INST_RADIUS;
|
|
5125
|
+
const tgt = inst.measures ?? inst.controls ?? "";
|
|
5126
|
+
const tgtEq = equipById.get(tgt);
|
|
5127
|
+
cx = tgtEq ? tgtEq.cx : PADDING + 80;
|
|
5128
|
+
} else {
|
|
5129
|
+
cy = rowY + maxH / 2 + INST_OFFSET;
|
|
5130
|
+
const tgt = inst.measures ?? inst.controls ?? "";
|
|
5131
|
+
const tgtEq = equipById.get(tgt);
|
|
5132
|
+
cx = tgtEq ? tgtEq.cx : PADDING + 80;
|
|
5133
|
+
}
|
|
5134
|
+
const lay = {
|
|
5135
|
+
inst,
|
|
5136
|
+
cx,
|
|
5137
|
+
cy,
|
|
5138
|
+
r: INST_RADIUS
|
|
5139
|
+
};
|
|
5140
|
+
instruments.push(lay);
|
|
5141
|
+
instById.set(inst.tag, lay);
|
|
5142
|
+
}
|
|
5143
|
+
const sameRow = (a, b) => Math.abs(a.cy - b.cy) < INST_RADIUS && Math.abs(a.cx - b.cx) < INST_RADIUS * 2 + 8;
|
|
5144
|
+
const sortedByX = [...instruments].sort((a, b) => a.cx - b.cx);
|
|
5145
|
+
for (let i = 1; i < sortedByX.length; i++) {
|
|
5146
|
+
const prev = sortedByX[i - 1];
|
|
5147
|
+
const cur = sortedByX[i];
|
|
5148
|
+
if (sameRow(prev, cur)) {
|
|
5149
|
+
cur.cx = prev.cx + INST_RADIUS * 2 + 14;
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
const lines = [];
|
|
5153
|
+
for (const ln of ast.lines) {
|
|
5154
|
+
const path2 = routeLine(ln, equipById, instById);
|
|
5155
|
+
if (path2) lines.push(path2);
|
|
5156
|
+
}
|
|
5157
|
+
const allX = [];
|
|
5158
|
+
const allY = [];
|
|
5159
|
+
for (const e of equipment) {
|
|
5160
|
+
const tagPad = Math.max(0, ((e.equip.tag ?? e.equip.id).length * 6.6 - e.width) / 2 + 4);
|
|
5161
|
+
allX.push(e.x - tagPad, e.x + e.width + tagPad);
|
|
5162
|
+
allY.push(e.y, e.y + e.height + 30);
|
|
5163
|
+
}
|
|
5164
|
+
for (const i of instruments) {
|
|
5165
|
+
allX.push(i.cx - i.r, i.cx + i.r);
|
|
5166
|
+
allY.push(i.cy - i.r, i.cy + i.r + 14);
|
|
5167
|
+
}
|
|
5168
|
+
if (allX.length === 0) {
|
|
5169
|
+
allX.push(0, 400);
|
|
5170
|
+
allY.push(0, 200);
|
|
5171
|
+
}
|
|
5172
|
+
const maxX = Math.max(...allX);
|
|
5173
|
+
const maxY = Math.max(...allY);
|
|
5174
|
+
return {
|
|
5175
|
+
width: Math.max(maxX + PADDING, 400),
|
|
5176
|
+
height: Math.max(maxY + PADDING, 200),
|
|
5177
|
+
equipment,
|
|
5178
|
+
instruments,
|
|
5179
|
+
lines,
|
|
5180
|
+
title: ast.title
|
|
5181
|
+
};
|
|
5182
|
+
}
|
|
5183
|
+
function routeLine(ln, equipById, instById) {
|
|
5184
|
+
const fromAnchor = resolveAnchor(ln.from.id, ln.from.port, "out", equipById, instById);
|
|
5185
|
+
const toAnchor = resolveAnchor(ln.to.id, ln.to.port, "in", equipById, instById);
|
|
5186
|
+
if (!fromAnchor || !toAnchor) return void 0;
|
|
5187
|
+
const { d, midX, midY } = manhattanPath(
|
|
5188
|
+
fromAnchor.x,
|
|
5189
|
+
fromAnchor.y,
|
|
5190
|
+
fromAnchor.side,
|
|
5191
|
+
toAnchor.x,
|
|
5192
|
+
toAnchor.y,
|
|
5193
|
+
toAnchor.side
|
|
5194
|
+
);
|
|
5195
|
+
return {
|
|
5196
|
+
line: ln,
|
|
5197
|
+
path: d,
|
|
5198
|
+
midX,
|
|
5199
|
+
midY
|
|
5200
|
+
};
|
|
5201
|
+
}
|
|
5202
|
+
function resolveAnchor(id, port, fallback, equipById, instById) {
|
|
5203
|
+
const eq = equipById.get(id);
|
|
5204
|
+
if (eq) return getAnchor(eq, port, fallback);
|
|
5205
|
+
const inst = instById.get(id);
|
|
5206
|
+
if (inst) {
|
|
5207
|
+
return {
|
|
5208
|
+
x: inst.cx,
|
|
5209
|
+
y: inst.cy,
|
|
5210
|
+
side: fallback === "out" ? "right" : "left"
|
|
5211
|
+
};
|
|
5212
|
+
}
|
|
5213
|
+
return void 0;
|
|
5214
|
+
}
|
|
5215
|
+
|
|
5216
|
+
// src/diagrams/pid/renderer.ts
|
|
5217
|
+
var STYLE2 = `
|
|
5218
|
+
.lt-pid-equip { fill: #ffffff; stroke: #1d1d1d; stroke-width: 1.6; }
|
|
5219
|
+
.lt-pid-equip-tag { font: 600 11px system-ui, sans-serif; fill: #1d1d1d; }
|
|
5220
|
+
.lt-pid-tray-line { stroke: #555; stroke-width: 1; fill: none; }
|
|
5221
|
+
|
|
5222
|
+
.lt-pid-process { stroke: #1d1d1d; stroke-width: 2.6; fill: none; }
|
|
5223
|
+
.lt-pid-process-min { stroke: #1d1d1d; stroke-width: 1.5; fill: none; }
|
|
5224
|
+
.lt-pid-pneumatic { stroke: #1d1d1d; stroke-width: 1.4; fill: none; }
|
|
5225
|
+
.lt-pid-electric { stroke: #1d1d1d; stroke-width: 1.4; fill: none; stroke-dasharray: 6 4; }
|
|
5226
|
+
.lt-pid-hydraulic { stroke: #1d1d1d; stroke-width: 1.4; fill: none; stroke-dasharray: 10 4; }
|
|
5227
|
+
.lt-pid-capillary { stroke: #1d1d1d; stroke-width: 1.4; fill: none; stroke-dasharray: 1 5; stroke-linecap: round; }
|
|
5228
|
+
.lt-pid-software { stroke: #6a6a6a; stroke-width: 1.3; fill: none; stroke-dasharray: 2 4; }
|
|
5229
|
+
.lt-pid-mechanical { stroke: #1d1d1d; stroke-width: 1.4; fill: none; stroke-dasharray: 3 2 1 2; }
|
|
5230
|
+
|
|
5231
|
+
.lt-pid-pneumatic-tick { stroke: #1d1d1d; stroke-width: 1.2; }
|
|
5232
|
+
|
|
5233
|
+
.lt-inst-body { fill: #ffffff; stroke: #1d1d1d; stroke-width: 1.4; }
|
|
5234
|
+
.lt-inst-tag { font: 600 9.5px system-ui, sans-serif; fill: #1d1d1d; }
|
|
5235
|
+
.lt-inst-cr-line { stroke: #1d1d1d; stroke-width: 1; }
|
|
5236
|
+
.lt-inst-local-line { stroke: #1d1d1d; stroke-width: 1; stroke-dasharray: 2 2; }
|
|
5237
|
+
.lt-pid-valve-body { fill: #ffffff; stroke: #1d1d1d; stroke-width: 1.4; }
|
|
5238
|
+
|
|
5239
|
+
.lt-pid-line-tag-bg { fill: #ffffff; stroke: #1d1d1d; stroke-width: 0.6; }
|
|
5240
|
+
.lt-pid-line-tag-text { font: 9px ui-monospace, monospace; fill: #1d1d1d; }
|
|
5241
|
+
|
|
5242
|
+
.lt-pid-title { font: 600 14px system-ui, sans-serif; fill: #1d1d1d; }
|
|
5243
|
+
`;
|
|
5244
|
+
var ARROW_ID = "lt-pid-arrow";
|
|
5245
|
+
function lineClass(t) {
|
|
5246
|
+
return `lt-pid-${t.replace("_", "-")}`;
|
|
5247
|
+
}
|
|
5248
|
+
function renderLine(l) {
|
|
5249
|
+
const cls = lineClass(l.line.lineType);
|
|
5250
|
+
const parts = [
|
|
5251
|
+
chunkLFZZ4NCP_cjs.path({
|
|
5252
|
+
d: l.path,
|
|
5253
|
+
class: cls,
|
|
5254
|
+
"data-line-id": l.line.id,
|
|
5255
|
+
"data-service": l.line.service ?? ""
|
|
5256
|
+
})
|
|
5257
|
+
];
|
|
5258
|
+
if (l.line.lineType === "pneumatic") {
|
|
5259
|
+
parts.push(...pneumaticTicks(l.path));
|
|
5260
|
+
}
|
|
5261
|
+
if (l.line.tag) {
|
|
5262
|
+
const w = Math.max(28, l.line.tag.length * 6);
|
|
5263
|
+
parts.push(
|
|
5264
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
5265
|
+
x: l.midX - w / 2,
|
|
5266
|
+
y: l.midY - 8,
|
|
5267
|
+
width: w,
|
|
5268
|
+
height: 14,
|
|
5269
|
+
rx: 2,
|
|
5270
|
+
ry: 2,
|
|
5271
|
+
class: "lt-pid-line-tag-bg"
|
|
5272
|
+
})
|
|
5273
|
+
);
|
|
5274
|
+
parts.push(
|
|
5275
|
+
chunkLFZZ4NCP_cjs.text(
|
|
5276
|
+
{
|
|
5277
|
+
x: l.midX,
|
|
5278
|
+
y: l.midY + 3,
|
|
5279
|
+
"text-anchor": "middle",
|
|
5280
|
+
class: "lt-pid-line-tag-text"
|
|
5281
|
+
},
|
|
5282
|
+
l.line.tag
|
|
5283
|
+
)
|
|
5284
|
+
);
|
|
5285
|
+
}
|
|
5286
|
+
return chunkLFZZ4NCP_cjs.group({ class: "lt-pid-line", "data-id": l.line.id }, parts);
|
|
5287
|
+
}
|
|
5288
|
+
function pneumaticTicks(d) {
|
|
5289
|
+
const tokens = d.match(/([MLC])\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/g) ?? [];
|
|
5290
|
+
const points = [];
|
|
5291
|
+
for (const t of tokens) {
|
|
5292
|
+
const m = t.match(/[MLC]\s+(-?\d+(?:\.\d+)?)\s+(-?\d+(?:\.\d+)?)/);
|
|
5293
|
+
if (!m) continue;
|
|
5294
|
+
points.push({ x: parseFloat(m[1]), y: parseFloat(m[2]) });
|
|
5295
|
+
}
|
|
5296
|
+
const ticks = [];
|
|
5297
|
+
for (let i = 1; i < points.length; i++) {
|
|
5298
|
+
const a = points[i - 1];
|
|
5299
|
+
const b = points[i];
|
|
5300
|
+
const dx = b.x - a.x;
|
|
5301
|
+
const dy = b.y - a.y;
|
|
5302
|
+
const len = Math.hypot(dx, dy);
|
|
5303
|
+
if (len < 12) continue;
|
|
5304
|
+
const ux = dx / len;
|
|
5305
|
+
const uy = dy / len;
|
|
5306
|
+
const px = -uy;
|
|
5307
|
+
const py = ux;
|
|
5308
|
+
for (let s = 18; s < len; s += 26) {
|
|
5309
|
+
const cx = a.x + ux * s;
|
|
5310
|
+
const cy = a.y + uy * s;
|
|
5311
|
+
ticks.push(
|
|
5312
|
+
chunkLFZZ4NCP_cjs.line({
|
|
5313
|
+
x1: cx + px * 4 - ux * 4,
|
|
5314
|
+
y1: cy + py * 4 - uy * 4,
|
|
5315
|
+
x2: cx - px * 4 + ux * 4,
|
|
5316
|
+
y2: cy - py * 4 + uy * 4,
|
|
5317
|
+
class: "lt-pid-pneumatic-tick"
|
|
5318
|
+
})
|
|
5319
|
+
);
|
|
5320
|
+
}
|
|
5321
|
+
}
|
|
5322
|
+
return ticks;
|
|
5323
|
+
}
|
|
5324
|
+
function renderPidAST(ast, _config) {
|
|
5325
|
+
const layout = layoutPid(ast);
|
|
5326
|
+
return renderLayout2(layout);
|
|
5327
|
+
}
|
|
5328
|
+
function renderLayout2(layout) {
|
|
5329
|
+
const equipNodes = layout.equipment.map((eq) => {
|
|
5330
|
+
const symbol = renderEquip(eq.equip.equipType, eq.equip.tag ?? eq.equip.id);
|
|
5331
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
5332
|
+
{
|
|
5333
|
+
class: "lt-pid-equip-wrap",
|
|
5334
|
+
"data-id": eq.equip.id,
|
|
5335
|
+
"data-type": eq.equip.equipType,
|
|
5336
|
+
transform: `translate(${eq.cx} ${eq.cy})`
|
|
5337
|
+
},
|
|
5338
|
+
[symbol]
|
|
5339
|
+
);
|
|
5340
|
+
});
|
|
5341
|
+
const instNodes = layout.instruments.map((i) => {
|
|
5342
|
+
const { letter, number } = parseTag(i.inst.tag);
|
|
5343
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
5344
|
+
{
|
|
5345
|
+
class: "lt-inst",
|
|
5346
|
+
"data-tag": i.inst.tag,
|
|
5347
|
+
"data-category": i.inst.category,
|
|
5348
|
+
transform: `translate(${i.cx} ${i.cy})`
|
|
5349
|
+
},
|
|
5350
|
+
[renderInstrument(i.inst.category, letter, number)]
|
|
5351
|
+
);
|
|
5352
|
+
});
|
|
5353
|
+
const autoSignals = [];
|
|
5354
|
+
for (const i of layout.instruments) {
|
|
5355
|
+
if (i.inst.measures) {
|
|
5356
|
+
const eq = layout.equipment.find((e) => e.equip.id === i.inst.measures);
|
|
5357
|
+
if (eq) {
|
|
5358
|
+
const ax = i.cx;
|
|
5359
|
+
const ay = i.cy;
|
|
5360
|
+
const bx = eq.cx;
|
|
5361
|
+
const by = eq.cy + eq.height / 2;
|
|
5362
|
+
autoSignals.push(
|
|
5363
|
+
chunkLFZZ4NCP_cjs.path({
|
|
5364
|
+
d: `M ${ax} ${ay} L ${ax} ${by + 8} L ${bx} ${by + 8} L ${bx} ${by}`,
|
|
5365
|
+
class: "lt-pid-electric"
|
|
5366
|
+
})
|
|
5367
|
+
);
|
|
5368
|
+
}
|
|
5369
|
+
}
|
|
5370
|
+
if (i.inst.controls) {
|
|
5371
|
+
const eq = layout.equipment.find((e) => e.equip.id === i.inst.controls);
|
|
5372
|
+
if (eq) {
|
|
5373
|
+
const ax = i.cx;
|
|
5374
|
+
const ay = i.cy + i.r;
|
|
5375
|
+
const bx = eq.cx;
|
|
5376
|
+
const by = eq.y;
|
|
5377
|
+
autoSignals.push(
|
|
5378
|
+
chunkLFZZ4NCP_cjs.path({
|
|
5379
|
+
d: `M ${ax} ${ay} L ${bx} ${ay} L ${bx} ${by}`,
|
|
5380
|
+
class: "lt-pid-pneumatic"
|
|
5381
|
+
})
|
|
5382
|
+
);
|
|
5383
|
+
}
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
const titleNode = layout.title ? chunkLFZZ4NCP_cjs.text({ x: 16, y: 22, class: "lt-pid-title" }, layout.title) : "";
|
|
5387
|
+
return chunkLFZZ4NCP_cjs.svgRoot(
|
|
5388
|
+
{
|
|
5389
|
+
width: layout.width,
|
|
5390
|
+
height: layout.height,
|
|
5391
|
+
viewBox: `0 0 ${layout.width} ${layout.height}`,
|
|
5392
|
+
class: "lt-pid",
|
|
5393
|
+
"data-diagram-type": "pid"
|
|
5394
|
+
},
|
|
5395
|
+
[
|
|
5396
|
+
chunkLFZZ4NCP_cjs.el("title", {}, chunkLFZZ4NCP_cjs.escapeXml(`P&ID${layout.title ? " \u2014 " + layout.title : ""}`)),
|
|
5397
|
+
chunkLFZZ4NCP_cjs.el("desc", {}, "ISA-5.1 / ISO 10628 P&ID rendered by Schematex"),
|
|
5398
|
+
chunkLFZZ4NCP_cjs.defs([
|
|
5399
|
+
chunkLFZZ4NCP_cjs.el(
|
|
5400
|
+
"marker",
|
|
5401
|
+
{
|
|
5402
|
+
id: ARROW_ID,
|
|
5403
|
+
markerWidth: 10,
|
|
5404
|
+
markerHeight: 10,
|
|
5405
|
+
refX: 9,
|
|
5406
|
+
refY: 3,
|
|
5407
|
+
orient: "auto",
|
|
5408
|
+
markerUnits: "strokeWidth"
|
|
5409
|
+
},
|
|
5410
|
+
[chunkLFZZ4NCP_cjs.polygon({ points: "0,0 10,3 0,6", fill: "#1d1d1d" })]
|
|
5411
|
+
),
|
|
5412
|
+
chunkLFZZ4NCP_cjs.el("style", {}, STYLE2)
|
|
5413
|
+
]),
|
|
5414
|
+
titleNode,
|
|
5415
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-pid-equipment" }, equipNodes),
|
|
5416
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-pid-lines" }, layout.lines.map(renderLine)),
|
|
5417
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-pid-signals" }, autoSignals),
|
|
5418
|
+
chunkLFZZ4NCP_cjs.group({ class: "lt-pid-instruments" }, instNodes)
|
|
5419
|
+
]
|
|
5420
|
+
);
|
|
5421
|
+
}
|
|
5422
|
+
function parseTag(tag) {
|
|
5423
|
+
const idx = tag.indexOf("-");
|
|
5424
|
+
if (idx < 0) return { letter: tag, number: "" };
|
|
5425
|
+
return { letter: tag.slice(0, idx), number: tag.slice(idx + 1) };
|
|
5426
|
+
}
|
|
5427
|
+
|
|
5428
|
+
// src/diagrams/pid/index.ts
|
|
5429
|
+
var pid = {
|
|
5430
|
+
type: "pid",
|
|
5431
|
+
detect(text2) {
|
|
5432
|
+
return /^\s*pid\b/i.test(text2);
|
|
5433
|
+
},
|
|
5434
|
+
parse: parsePid,
|
|
5435
|
+
render(text2, config) {
|
|
5436
|
+
const ast = parsePid(text2);
|
|
5437
|
+
return renderPidAST(ast);
|
|
5438
|
+
}
|
|
5439
|
+
};
|
|
5440
|
+
|
|
2631
5441
|
// src/diagrams/mindmap/inline.ts
|
|
2632
5442
|
var RE_TASK = /^\[( |x|X)\]\s+(.*)$/;
|
|
2633
5443
|
function tokenizeInline(raw) {
|
|
@@ -2903,7 +5713,7 @@ function parseMindmap(text2) {
|
|
|
2903
5713
|
}
|
|
2904
5714
|
|
|
2905
5715
|
// src/diagrams/mindmap/layout.ts
|
|
2906
|
-
var
|
|
5716
|
+
var PADDING2 = 40;
|
|
2907
5717
|
var SIBLING_GAP = 18;
|
|
2908
5718
|
var MAIN_GAP = 44;
|
|
2909
5719
|
var UNDERLINE_GAP = 4;
|
|
@@ -3050,13 +5860,13 @@ function normalize(nodes) {
|
|
|
3050
5860
|
minY = Math.min(minY, n.y - lh / 2);
|
|
3051
5861
|
maxY = Math.max(maxY, n.y + lh / 2);
|
|
3052
5862
|
}
|
|
3053
|
-
const dx =
|
|
3054
|
-
const dy =
|
|
5863
|
+
const dx = PADDING2 - minX;
|
|
5864
|
+
const dy = PADDING2 - minY;
|
|
3055
5865
|
for (const n of nodes) {
|
|
3056
5866
|
n.x += dx;
|
|
3057
5867
|
n.y += dy;
|
|
3058
5868
|
}
|
|
3059
|
-
return { width: maxX - minX +
|
|
5869
|
+
return { width: maxX - minX + PADDING2 * 2, height: maxY - minY + PADDING2 * 2 };
|
|
3060
5870
|
}
|
|
3061
5871
|
function underlineY(n) {
|
|
3062
5872
|
return n.y + n.labelHeight / 2 - UNDERLINE_GAP / 2;
|
|
@@ -3184,7 +5994,7 @@ function paletteColor(theme, branchIndex) {
|
|
|
3184
5994
|
if (branchIndex < 0) return theme.centralFill;
|
|
3185
5995
|
return theme.branchPalette[branchIndex % theme.branchPalette.length];
|
|
3186
5996
|
}
|
|
3187
|
-
function
|
|
5997
|
+
function renderLine2(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
3188
5998
|
const baselineY = cy + fontSize * 0.35;
|
|
3189
5999
|
const tspans = [];
|
|
3190
6000
|
const decorations = [];
|
|
@@ -3208,7 +6018,7 @@ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
|
3208
6018
|
}
|
|
3209
6019
|
case "code": {
|
|
3210
6020
|
const w = measureToken(tok, fontSize);
|
|
3211
|
-
decorations.push(
|
|
6021
|
+
decorations.push(chunkLFZZ4NCP_cjs.rect({
|
|
3212
6022
|
x: cursor,
|
|
3213
6023
|
y: cy - fontSize * 0.6,
|
|
3214
6024
|
width: w,
|
|
@@ -3230,7 +6040,7 @@ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
|
3230
6040
|
break;
|
|
3231
6041
|
}
|
|
3232
6042
|
case "link": {
|
|
3233
|
-
const aStart = `<a href="${
|
|
6043
|
+
const aStart = `<a href="${chunkLFZZ4NCP_cjs.escapeXml(tok.href)}" target="_blank" rel="noopener">`;
|
|
3234
6044
|
const innerStart = tspans.length;
|
|
3235
6045
|
for (const inner of tok.value) emit(inner, tok.href);
|
|
3236
6046
|
const innerTspans = tspans.splice(innerStart).join("");
|
|
@@ -3241,7 +6051,7 @@ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
|
3241
6051
|
const size = fontSize * 0.85;
|
|
3242
6052
|
const boxX = cursor;
|
|
3243
6053
|
const boxY = cy - size / 2;
|
|
3244
|
-
decorations.push(
|
|
6054
|
+
decorations.push(chunkLFZZ4NCP_cjs.rect({
|
|
3245
6055
|
x: boxX,
|
|
3246
6056
|
y: boxY,
|
|
3247
6057
|
width: size,
|
|
@@ -3254,7 +6064,7 @@ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
|
3254
6064
|
}));
|
|
3255
6065
|
if (tok.checked) {
|
|
3256
6066
|
const p = `M ${(boxX + size * 0.2).toFixed(1)} ${(boxY + size * 0.5).toFixed(1)} L ${(boxX + size * 0.42).toFixed(1)} ${(boxY + size * 0.72).toFixed(1)} L ${(boxX + size * 0.82).toFixed(1)} ${(boxY + size * 0.28).toFixed(1)}`;
|
|
3257
|
-
decorations.push(
|
|
6067
|
+
decorations.push(chunkLFZZ4NCP_cjs.path({
|
|
3258
6068
|
d: p,
|
|
3259
6069
|
fill: "none",
|
|
3260
6070
|
stroke: "#ffffff",
|
|
@@ -3269,7 +6079,7 @@ function renderLine(line2, leftX, cy, fontSize, fontFamily, fontWeight, theme) {
|
|
|
3269
6079
|
}
|
|
3270
6080
|
};
|
|
3271
6081
|
for (const tok of line2.tokens) emit(tok);
|
|
3272
|
-
const textElement =
|
|
6082
|
+
const textElement = chunkLFZZ4NCP_cjs.el("text", {
|
|
3273
6083
|
"font-family": fontFamily,
|
|
3274
6084
|
"font-size": fontSize,
|
|
3275
6085
|
"font-weight": fontWeight
|
|
@@ -3295,11 +6105,11 @@ function tspan(attrs, content) {
|
|
|
3295
6105
|
const pairs = [];
|
|
3296
6106
|
for (const [k, v] of Object.entries(attrs)) {
|
|
3297
6107
|
if (v === void 0) continue;
|
|
3298
|
-
pairs.push(`${k}="${typeof v === "number" ? String(v) :
|
|
6108
|
+
pairs.push(`${k}="${typeof v === "number" ? String(v) : chunkLFZZ4NCP_cjs.escapeXml(String(v))}"`);
|
|
3299
6109
|
}
|
|
3300
|
-
return `<tspan ${pairs.join(" ")}>${
|
|
6110
|
+
return `<tspan ${pairs.join(" ")}>${chunkLFZZ4NCP_cjs.escapeXml(content)}</tspan>`;
|
|
3301
6111
|
}
|
|
3302
|
-
function
|
|
6112
|
+
function renderNode2(n, color, theme, fontFamily) {
|
|
3303
6113
|
const isRoot = n.node.depth === 0;
|
|
3304
6114
|
const isMain = n.node.depth === 1;
|
|
3305
6115
|
const fs = n.fontSize;
|
|
@@ -3314,7 +6124,7 @@ function renderNode(n, color, theme, fontFamily) {
|
|
|
3314
6124
|
for (let i = 0; i < lineCount; i++) {
|
|
3315
6125
|
const line2 = n.lines[i];
|
|
3316
6126
|
const cy = topY + (i + 0.5) * lh;
|
|
3317
|
-
const r =
|
|
6127
|
+
const r = renderLine2(line2, textLeft, cy, fs, fontFamily, weight, theme);
|
|
3318
6128
|
decorations.push(...r.decorations);
|
|
3319
6129
|
children.push(r.textElement);
|
|
3320
6130
|
}
|
|
@@ -3322,7 +6132,7 @@ function renderNode(n, color, theme, fontFamily) {
|
|
|
3322
6132
|
const ux2 = n.x + n.labelWidth / 2;
|
|
3323
6133
|
const sw = underlineWidthFor(n.node.depth) * strokeScale(theme);
|
|
3324
6134
|
children.push(
|
|
3325
|
-
|
|
6135
|
+
chunkLFZZ4NCP_cjs.el("line", {
|
|
3326
6136
|
x1: ux1,
|
|
3327
6137
|
y1: underlineY2,
|
|
3328
6138
|
x2: ux2,
|
|
@@ -3333,7 +6143,7 @@ function renderNode(n, color, theme, fontFamily) {
|
|
|
3333
6143
|
})
|
|
3334
6144
|
);
|
|
3335
6145
|
const cls = isRoot ? "schematex-mindmap-central" : isMain ? "schematex-mindmap-main" : "schematex-mindmap-leaf";
|
|
3336
|
-
return
|
|
6146
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
3337
6147
|
{
|
|
3338
6148
|
class: cls,
|
|
3339
6149
|
"data-node-id": n.node.id,
|
|
@@ -3353,7 +6163,7 @@ function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -
|
|
|
3353
6163
|
if (!target) continue;
|
|
3354
6164
|
const color = paletteColor(theme, target.branchIndex);
|
|
3355
6165
|
edgeSvgs.push(
|
|
3356
|
-
|
|
6166
|
+
chunkLFZZ4NCP_cjs.path({
|
|
3357
6167
|
d: e.path,
|
|
3358
6168
|
fill: "none",
|
|
3359
6169
|
stroke: color,
|
|
@@ -3365,23 +6175,23 @@ function renderMindmapAST(ast, themeName = "default", fontFamily = "system-ui, -
|
|
|
3365
6175
|
const nodeSvgs = [];
|
|
3366
6176
|
for (const n of layout.nodes) {
|
|
3367
6177
|
const color = n.node.depth === 0 ? theme.centralFill : paletteColor(theme, n.branchIndex);
|
|
3368
|
-
nodeSvgs.push(
|
|
6178
|
+
nodeSvgs.push(renderNode2(n, color, theme, fontFamily));
|
|
3369
6179
|
}
|
|
3370
6180
|
const title2 = ast.title ?? tokensToPlainText(ast.root.tokens);
|
|
3371
|
-
return
|
|
6181
|
+
return chunkLFZZ4NCP_cjs.svgRoot(
|
|
3372
6182
|
{
|
|
3373
6183
|
viewBox: `0 0 ${layout.width.toFixed(1)} ${layout.height.toFixed(1)}`,
|
|
3374
6184
|
width: layout.width.toFixed(1),
|
|
3375
6185
|
height: layout.height.toFixed(1),
|
|
3376
6186
|
role: "graphics-document",
|
|
3377
|
-
"aria-label": `Mindmap: ${
|
|
6187
|
+
"aria-label": `Mindmap: ${chunkLFZZ4NCP_cjs.escapeXml(title2)}`
|
|
3378
6188
|
},
|
|
3379
6189
|
[
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
6190
|
+
chunkLFZZ4NCP_cjs.title(title2),
|
|
6191
|
+
chunkLFZZ4NCP_cjs.desc(`${layout.style} mindmap with ${layout.nodes.length} nodes`),
|
|
6192
|
+
chunkLFZZ4NCP_cjs.rect({ x: 0, y: 0, width: layout.width, height: layout.height, fill: theme.bg }),
|
|
6193
|
+
chunkLFZZ4NCP_cjs.group({ class: "schematex-mindmap-edges", "aria-hidden": "true" }, edgeSvgs),
|
|
6194
|
+
chunkLFZZ4NCP_cjs.group({ class: "schematex-mindmap-nodes" }, nodeSvgs)
|
|
3385
6195
|
]
|
|
3386
6196
|
);
|
|
3387
6197
|
}
|
|
@@ -3772,7 +6582,7 @@ function parseMatrix(text2) {
|
|
|
3772
6582
|
const lines = text2.split(/\r?\n/);
|
|
3773
6583
|
let templateName;
|
|
3774
6584
|
let inConfig = false;
|
|
3775
|
-
for (
|
|
6585
|
+
for (const raw of lines) {
|
|
3776
6586
|
let line2 = raw;
|
|
3777
6587
|
const hashIdx = findCommentStart(line2);
|
|
3778
6588
|
if (hashIdx >= 0) line2 = line2.slice(0, hashIdx);
|
|
@@ -4107,7 +6917,7 @@ var CSS = `
|
|
|
4107
6917
|
.sx-matrix-offchart { fill: #ea580c; }
|
|
4108
6918
|
`.trim();
|
|
4109
6919
|
function axisArrow() {
|
|
4110
|
-
return
|
|
6920
|
+
return chunkLFZZ4NCP_cjs.el(
|
|
4111
6921
|
"marker",
|
|
4112
6922
|
{
|
|
4113
6923
|
id: "sx-matrix-arrow",
|
|
@@ -4118,7 +6928,7 @@ function axisArrow() {
|
|
|
4118
6928
|
markerHeight: 8,
|
|
4119
6929
|
orient: "auto-start-reverse"
|
|
4120
6930
|
},
|
|
4121
|
-
[
|
|
6931
|
+
[chunkLFZZ4NCP_cjs.el("path", { d: "M0,0 L10,5 L0,10 z", fill: "#374151" })]
|
|
4122
6932
|
);
|
|
4123
6933
|
}
|
|
4124
6934
|
function bubbleFill(p, categories) {
|
|
@@ -4140,10 +6950,10 @@ function renderQuadrantBackground(ast, lay) {
|
|
|
4140
6950
|
{ x: plot.x0, y: plot.y0 + halfH, w: halfW, h: halfH, fill: QUADRANT_TINTS[2] },
|
|
4141
6951
|
{ x: plot.x0 + halfW, y: plot.y0 + halfH, w: halfW, h: halfH, fill: QUADRANT_TINTS[3] }
|
|
4142
6952
|
];
|
|
4143
|
-
return
|
|
6953
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
4144
6954
|
{ id: "sx-matrix-quad-bg" },
|
|
4145
6955
|
rects.map(
|
|
4146
|
-
(r) =>
|
|
6956
|
+
(r) => chunkLFZZ4NCP_cjs.rect({ x: r.x, y: r.y, width: r.w, height: r.h, fill: r.fill, "fill-opacity": 0.55 })
|
|
4147
6957
|
)
|
|
4148
6958
|
);
|
|
4149
6959
|
}
|
|
@@ -4157,15 +6967,15 @@ function renderGrid(ast, lay) {
|
|
|
4157
6967
|
for (let i = 1; i < cols; i++) {
|
|
4158
6968
|
const x = plot.x0 + plot.w * i / cols;
|
|
4159
6969
|
const cls = cols === 2 && i === 1 ? "sx-matrix-mid" : "sx-matrix-grid";
|
|
4160
|
-
lines.push(
|
|
6970
|
+
lines.push(chunkLFZZ4NCP_cjs.line({ x1: x, y1: plot.y0, x2: x, y2: plot.y0 + plot.h, class: cls }));
|
|
4161
6971
|
}
|
|
4162
6972
|
for (let j = 1; j < rows; j++) {
|
|
4163
6973
|
const y = plot.y0 + plot.h * j / rows;
|
|
4164
6974
|
const cls = rows === 2 && j === 1 ? "sx-matrix-mid" : "sx-matrix-grid";
|
|
4165
|
-
lines.push(
|
|
6975
|
+
lines.push(chunkLFZZ4NCP_cjs.line({ x1: plot.x0, y1: y, x2: plot.x0 + plot.w, y2: y, class: cls }));
|
|
4166
6976
|
}
|
|
4167
6977
|
lines.push(
|
|
4168
|
-
|
|
6978
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4169
6979
|
x: plot.x0,
|
|
4170
6980
|
y: plot.y0,
|
|
4171
6981
|
width: plot.w,
|
|
@@ -4174,7 +6984,7 @@ function renderGrid(ast, lay) {
|
|
|
4174
6984
|
fill: "none"
|
|
4175
6985
|
})
|
|
4176
6986
|
);
|
|
4177
|
-
return
|
|
6987
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-grid" }, lines);
|
|
4178
6988
|
}
|
|
4179
6989
|
function shouldShowAxis(ast) {
|
|
4180
6990
|
if (ast.config.showAxis === "on") return true;
|
|
@@ -4189,7 +6999,7 @@ function renderAxes(ast, lay) {
|
|
|
4189
6999
|
const xy = plot.y0 + plot.h + 14;
|
|
4190
7000
|
const yx = plot.x0 - 14;
|
|
4191
7001
|
els.push(
|
|
4192
|
-
|
|
7002
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4193
7003
|
x1: plot.x0,
|
|
4194
7004
|
y1: xy,
|
|
4195
7005
|
x2: plot.x0 + plot.w,
|
|
@@ -4200,7 +7010,7 @@ function renderAxes(ast, lay) {
|
|
|
4200
7010
|
})
|
|
4201
7011
|
);
|
|
4202
7012
|
els.push(
|
|
4203
|
-
|
|
7013
|
+
chunkLFZZ4NCP_cjs.line({
|
|
4204
7014
|
x1: yx,
|
|
4205
7015
|
y1: plot.y0 + plot.h,
|
|
4206
7016
|
x2: yx,
|
|
@@ -4212,7 +7022,7 @@ function renderAxes(ast, lay) {
|
|
|
4212
7022
|
);
|
|
4213
7023
|
if (ast.xAxis.low) {
|
|
4214
7024
|
els.push(
|
|
4215
|
-
|
|
7025
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4216
7026
|
{ x: plot.x0, y: xy + 20, class: "sx-matrix-axis-end", "text-anchor": "start" },
|
|
4217
7027
|
ast.xAxis.low
|
|
4218
7028
|
)
|
|
@@ -4220,7 +7030,7 @@ function renderAxes(ast, lay) {
|
|
|
4220
7030
|
}
|
|
4221
7031
|
if (ast.xAxis.high) {
|
|
4222
7032
|
els.push(
|
|
4223
|
-
|
|
7033
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4224
7034
|
{ x: plot.x0 + plot.w, y: xy + 20, class: "sx-matrix-axis-end", "text-anchor": "end" },
|
|
4225
7035
|
ast.xAxis.high
|
|
4226
7036
|
)
|
|
@@ -4228,7 +7038,7 @@ function renderAxes(ast, lay) {
|
|
|
4228
7038
|
}
|
|
4229
7039
|
if (ast.yAxis.low) {
|
|
4230
7040
|
els.push(
|
|
4231
|
-
|
|
7041
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4232
7042
|
{
|
|
4233
7043
|
x: yx - 24,
|
|
4234
7044
|
y: plot.y0 + plot.h,
|
|
@@ -4242,7 +7052,7 @@ function renderAxes(ast, lay) {
|
|
|
4242
7052
|
}
|
|
4243
7053
|
if (ast.yAxis.high) {
|
|
4244
7054
|
els.push(
|
|
4245
|
-
|
|
7055
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4246
7056
|
{
|
|
4247
7057
|
x: yx - 24,
|
|
4248
7058
|
y: plot.y0,
|
|
@@ -4254,7 +7064,7 @@ function renderAxes(ast, lay) {
|
|
|
4254
7064
|
)
|
|
4255
7065
|
);
|
|
4256
7066
|
}
|
|
4257
|
-
return
|
|
7067
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-axes" }, els);
|
|
4258
7068
|
}
|
|
4259
7069
|
function renderQuadAnnotations(ast, lay) {
|
|
4260
7070
|
if (!ast.config.quadrantAnnotations || ast.grid !== "2x2" || ast.annotations.length === 0) return "";
|
|
@@ -4279,14 +7089,14 @@ function renderQuadAnnotations(ast, lay) {
|
|
|
4279
7089
|
const descLines = a.description ? wrapLabel(a.description, 28) : [];
|
|
4280
7090
|
const labelY = growsUp && descLines.length > 0 ? pos.y - descLines.length * 12 : pos.y;
|
|
4281
7091
|
nodes.push(
|
|
4282
|
-
|
|
7092
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4283
7093
|
{ x: pos.x, y: labelY, class: "sx-matrix-quad-annot", "text-anchor": pos.anchor },
|
|
4284
7094
|
a.label
|
|
4285
7095
|
)
|
|
4286
7096
|
);
|
|
4287
7097
|
for (let i = 0; i < descLines.length; i++) {
|
|
4288
7098
|
nodes.push(
|
|
4289
|
-
|
|
7099
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4290
7100
|
{
|
|
4291
7101
|
x: pos.x,
|
|
4292
7102
|
y: labelY + 14 + i * 12,
|
|
@@ -4298,7 +7108,7 @@ function renderQuadAnnotations(ast, lay) {
|
|
|
4298
7108
|
);
|
|
4299
7109
|
}
|
|
4300
7110
|
}
|
|
4301
|
-
return
|
|
7111
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-quad-annot" }, nodes);
|
|
4302
7112
|
}
|
|
4303
7113
|
function wrapLabel(text2, maxChars) {
|
|
4304
7114
|
const words = text2.split(/\s+/);
|
|
@@ -4323,9 +7133,9 @@ function render3x3CellLabels(ast, lay) {
|
|
|
4323
7133
|
const nodes = ast.cellLabels.map((cl) => {
|
|
4324
7134
|
const cx = plot.x0 + cellW * (cl.col + 0.5);
|
|
4325
7135
|
const cy = plot.y0 + cellH * (ast.rows - 1 - cl.row + 0.5);
|
|
4326
|
-
return
|
|
7136
|
+
return chunkLFZZ4NCP_cjs.text({ x: cx, y: cy, class: "sx-matrix-cell-label" }, cl.label);
|
|
4327
7137
|
});
|
|
4328
|
-
return
|
|
7138
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-cell-labels" }, nodes);
|
|
4329
7139
|
}
|
|
4330
7140
|
function renderHeatmap(ast, lay) {
|
|
4331
7141
|
if (ast.mode !== "heatmap") return "";
|
|
@@ -4347,7 +7157,7 @@ function renderHeatmap(ast, lay) {
|
|
|
4347
7157
|
const x = plot.x0 + col * cellW;
|
|
4348
7158
|
const y = plot.y0 + (ast.rows - 1 - row) * cellH;
|
|
4349
7159
|
cells.push(
|
|
4350
|
-
|
|
7160
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4351
7161
|
x,
|
|
4352
7162
|
y,
|
|
4353
7163
|
width: cellW,
|
|
@@ -4365,7 +7175,7 @@ function renderHeatmap(ast, lay) {
|
|
|
4365
7175
|
if (!lbl) continue;
|
|
4366
7176
|
const y = plot.y0 + (ast.rows - 1 - row + 0.5) * cellH;
|
|
4367
7177
|
cells.push(
|
|
4368
|
-
|
|
7178
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4369
7179
|
{
|
|
4370
7180
|
x: plot.x0 - 8,
|
|
4371
7181
|
y,
|
|
@@ -4384,7 +7194,7 @@ function renderHeatmap(ast, lay) {
|
|
|
4384
7194
|
if (!lbl) continue;
|
|
4385
7195
|
const x = plot.x0 + (col + 0.5) * cellW;
|
|
4386
7196
|
cells.push(
|
|
4387
|
-
|
|
7197
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4388
7198
|
{
|
|
4389
7199
|
x,
|
|
4390
7200
|
y: plot.y0 + plot.h + 16,
|
|
@@ -4415,7 +7225,7 @@ function renderHeatmap(ast, lay) {
|
|
|
4415
7225
|
const startY = cy - (lines.length - 1) * lineH / 2;
|
|
4416
7226
|
for (let i = 0; i < lines.length; i++) {
|
|
4417
7227
|
cells.push(
|
|
4418
|
-
|
|
7228
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4419
7229
|
{
|
|
4420
7230
|
x: cx,
|
|
4421
7231
|
y: startY + i * lineH,
|
|
@@ -4427,7 +7237,7 @@ function renderHeatmap(ast, lay) {
|
|
|
4427
7237
|
);
|
|
4428
7238
|
}
|
|
4429
7239
|
}
|
|
4430
|
-
return
|
|
7240
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-heatmap" }, cells);
|
|
4431
7241
|
}
|
|
4432
7242
|
var DOT_COLORS = {
|
|
4433
7243
|
strong: "#16a34a",
|
|
@@ -4452,7 +7262,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4452
7262
|
for (let row = 0; row < ast.rows; row++) {
|
|
4453
7263
|
const y = plot.y0 + (ast.rows - 1 - row) * cellH;
|
|
4454
7264
|
nodes.push(
|
|
4455
|
-
|
|
7265
|
+
chunkLFZZ4NCP_cjs.rect({
|
|
4456
7266
|
x: plot.x0,
|
|
4457
7267
|
y,
|
|
4458
7268
|
width: gridW,
|
|
@@ -4463,11 +7273,11 @@ function renderCorrelation(ast, lay) {
|
|
|
4463
7273
|
}
|
|
4464
7274
|
for (let i = 0; i <= ast.cols; i++) {
|
|
4465
7275
|
const x = plot.x0 + i * cellW;
|
|
4466
|
-
nodes.push(
|
|
7276
|
+
nodes.push(chunkLFZZ4NCP_cjs.line({ x1: x, y1: plot.y0, x2: x, y2: plot.y0 + gridH, class: "sx-matrix-corr-grid" }));
|
|
4467
7277
|
}
|
|
4468
7278
|
for (let j = 0; j <= ast.rows; j++) {
|
|
4469
7279
|
const y = plot.y0 + j * cellH;
|
|
4470
|
-
nodes.push(
|
|
7280
|
+
nodes.push(chunkLFZZ4NCP_cjs.line({ x1: plot.x0, y1: y, x2: plot.x0 + gridW, y2: y, class: "sx-matrix-corr-grid" }));
|
|
4471
7281
|
}
|
|
4472
7282
|
const dotR = Math.max(4, Math.min(cellW, cellH) * 0.28);
|
|
4473
7283
|
const rowSums = new Array(ast.rows).fill(0);
|
|
@@ -4482,7 +7292,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4482
7292
|
const cx = plot.x0 + (c.col + 0.5) * cellW;
|
|
4483
7293
|
const cy = plot.y0 + (ast.rows - 1 - c.row + 0.5) * cellH;
|
|
4484
7294
|
nodes.push(
|
|
4485
|
-
|
|
7295
|
+
chunkLFZZ4NCP_cjs.circle({
|
|
4486
7296
|
cx,
|
|
4487
7297
|
cy,
|
|
4488
7298
|
r: dotR,
|
|
@@ -4501,7 +7311,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4501
7311
|
const startY = plot.y0 - 8 - (lines.length - 1) * 12;
|
|
4502
7312
|
for (let i = 0; i < lines.length; i++) {
|
|
4503
7313
|
nodes.push(
|
|
4504
|
-
|
|
7314
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4505
7315
|
{ x: cx, y: startY + i * 12, class: "sx-matrix-corr-header" },
|
|
4506
7316
|
lines[i]
|
|
4507
7317
|
)
|
|
@@ -4515,7 +7325,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4515
7325
|
if (!label) continue;
|
|
4516
7326
|
const y = plot.y0 + (ast.rows - 1 - row + 0.5) * cellH;
|
|
4517
7327
|
nodes.push(
|
|
4518
|
-
|
|
7328
|
+
chunkLFZZ4NCP_cjs.text({ x: plot.x0 - 8, y, class: "sx-matrix-corr-rowlabel" }, label)
|
|
4519
7329
|
);
|
|
4520
7330
|
}
|
|
4521
7331
|
}
|
|
@@ -4526,28 +7336,28 @@ function renderCorrelation(ast, lay) {
|
|
|
4526
7336
|
const bestCol = colSums.length > 0 ? Math.max(...colSums) : 0;
|
|
4527
7337
|
const scoreColX = plot.x0 + gridW + cellW * 0.5;
|
|
4528
7338
|
const rankColX = plot.x0 + gridW + cellW * 1.5;
|
|
4529
|
-
nodes.push(
|
|
4530
|
-
nodes.push(
|
|
7339
|
+
nodes.push(chunkLFZZ4NCP_cjs.text({ x: scoreColX, y: plot.y0 - 8, class: "sx-matrix-corr-header" }, "Score"));
|
|
7340
|
+
nodes.push(chunkLFZZ4NCP_cjs.text({ x: rankColX, y: plot.y0 - 8, class: "sx-matrix-corr-header" }, "Rank"));
|
|
4531
7341
|
for (let row = 0; row < ast.rows; row++) {
|
|
4532
7342
|
const y = plot.y0 + (ast.rows - 1 - row + 0.5) * cellH;
|
|
4533
7343
|
const sum = rowSums[row];
|
|
4534
7344
|
const rank = rowRanks[row];
|
|
4535
7345
|
const cls = sum === bestRow && sum > 0 ? "sx-matrix-corr-margin-best" : "sx-matrix-corr-margin";
|
|
4536
|
-
nodes.push(
|
|
7346
|
+
nodes.push(chunkLFZZ4NCP_cjs.text({ x: scoreColX, y, class: cls }, String(sum)));
|
|
4537
7347
|
nodes.push(
|
|
4538
|
-
|
|
7348
|
+
chunkLFZZ4NCP_cjs.text({ x: rankColX, y, class: rank === 1 ? "sx-matrix-corr-margin-best" : "sx-matrix-corr-margin" }, String(rank))
|
|
4539
7349
|
);
|
|
4540
7350
|
}
|
|
4541
7351
|
const scoreRowY = plot.y0 + gridH + cellH * 0.5;
|
|
4542
7352
|
const rankRowY = plot.y0 + gridH + cellH * 1.5;
|
|
4543
7353
|
nodes.push(
|
|
4544
|
-
|
|
7354
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4545
7355
|
{ x: plot.x0 - 8, y: scoreRowY, class: "sx-matrix-corr-rowlabel" },
|
|
4546
7356
|
"Score"
|
|
4547
7357
|
)
|
|
4548
7358
|
);
|
|
4549
7359
|
nodes.push(
|
|
4550
|
-
|
|
7360
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4551
7361
|
{ x: plot.x0 - 8, y: rankRowY, class: "sx-matrix-corr-rowlabel" },
|
|
4552
7362
|
"Rank"
|
|
4553
7363
|
)
|
|
@@ -4557,7 +7367,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4557
7367
|
const sum = colSums[col];
|
|
4558
7368
|
const rank = colRanks[col];
|
|
4559
7369
|
nodes.push(
|
|
4560
|
-
|
|
7370
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4561
7371
|
{
|
|
4562
7372
|
x: cx,
|
|
4563
7373
|
y: scoreRowY,
|
|
@@ -4567,7 +7377,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4567
7377
|
)
|
|
4568
7378
|
);
|
|
4569
7379
|
nodes.push(
|
|
4570
|
-
|
|
7380
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4571
7381
|
{
|
|
4572
7382
|
x: cx,
|
|
4573
7383
|
y: rankRowY,
|
|
@@ -4578,7 +7388,7 @@ function renderCorrelation(ast, lay) {
|
|
|
4578
7388
|
);
|
|
4579
7389
|
}
|
|
4580
7390
|
}
|
|
4581
|
-
return
|
|
7391
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-correlation" }, nodes);
|
|
4582
7392
|
}
|
|
4583
7393
|
function rankOf(vals) {
|
|
4584
7394
|
const sorted = [...vals].map((v, i) => ({ v, i })).sort((a, b) => b.v - a.v);
|
|
@@ -4606,12 +7416,12 @@ function renderCorrelationLegend(ast, lay) {
|
|
|
4606
7416
|
["weak", "Weak (1)"]
|
|
4607
7417
|
];
|
|
4608
7418
|
const rows = items.map(
|
|
4609
|
-
(it, i) =>
|
|
4610
|
-
|
|
4611
|
-
|
|
7419
|
+
(it, i) => chunkLFZZ4NCP_cjs.group({ transform: `translate(${xBase}, ${yBase + i * 18})` }, [
|
|
7420
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 6, cy: 6, r: 5, fill: DOT_COLORS[it[0]], stroke: DOT_COLORS[it[0]] }),
|
|
7421
|
+
chunkLFZZ4NCP_cjs.text({ x: 18, y: 10, class: "sx-matrix-legend-text" }, it[1])
|
|
4612
7422
|
])
|
|
4613
7423
|
);
|
|
4614
|
-
return
|
|
7424
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-corr-legend" }, rows);
|
|
4615
7425
|
}
|
|
4616
7426
|
function renderPoints(ast, lay) {
|
|
4617
7427
|
if (ast.mode !== "quadrant") return "";
|
|
@@ -4619,7 +7429,7 @@ function renderPoints(ast, lay) {
|
|
|
4619
7429
|
for (const p of lay.points) {
|
|
4620
7430
|
nodes.push(renderOnePoint(p, lay.categories));
|
|
4621
7431
|
}
|
|
4622
|
-
return
|
|
7432
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-points" }, nodes);
|
|
4623
7433
|
}
|
|
4624
7434
|
function renderOnePoint(pl, categories) {
|
|
4625
7435
|
const p = pl.point;
|
|
@@ -4630,7 +7440,7 @@ function renderOnePoint(pl, categories) {
|
|
|
4630
7440
|
const strokeWidth = p.highlight ? 2.2 : 1.5;
|
|
4631
7441
|
const fillOpacity = p.size !== void 0 ? 0.45 : 0.75;
|
|
4632
7442
|
if (shape === "circle") {
|
|
4633
|
-
shapeEl =
|
|
7443
|
+
shapeEl = chunkLFZZ4NCP_cjs.circle({
|
|
4634
7444
|
cx: pl.px,
|
|
4635
7445
|
cy: pl.py,
|
|
4636
7446
|
r: pl.r,
|
|
@@ -4641,7 +7451,7 @@ function renderOnePoint(pl, categories) {
|
|
|
4641
7451
|
class: "sx-matrix-bubble"
|
|
4642
7452
|
});
|
|
4643
7453
|
} else if (shape === "square") {
|
|
4644
|
-
shapeEl =
|
|
7454
|
+
shapeEl = chunkLFZZ4NCP_cjs.rect({
|
|
4645
7455
|
x: pl.px - pl.r,
|
|
4646
7456
|
y: pl.py - pl.r,
|
|
4647
7457
|
width: pl.r * 2,
|
|
@@ -4654,7 +7464,7 @@ function renderOnePoint(pl, categories) {
|
|
|
4654
7464
|
});
|
|
4655
7465
|
} else if (shape === "diamond") {
|
|
4656
7466
|
const r = pl.r;
|
|
4657
|
-
shapeEl =
|
|
7467
|
+
shapeEl = chunkLFZZ4NCP_cjs.polygon({
|
|
4658
7468
|
points: `${pl.px},${pl.py - r} ${pl.px + r},${pl.py} ${pl.px},${pl.py + r} ${pl.px - r},${pl.py}`,
|
|
4659
7469
|
fill: color,
|
|
4660
7470
|
"fill-opacity": fillOpacity,
|
|
@@ -4664,7 +7474,7 @@ function renderOnePoint(pl, categories) {
|
|
|
4664
7474
|
});
|
|
4665
7475
|
} else {
|
|
4666
7476
|
const r = pl.r;
|
|
4667
|
-
shapeEl =
|
|
7477
|
+
shapeEl = chunkLFZZ4NCP_cjs.polygon({
|
|
4668
7478
|
points: `${pl.px},${pl.py - r} ${pl.px + r},${pl.py + r * 0.8} ${pl.px - r},${pl.py + r * 0.8}`,
|
|
4669
7479
|
fill: color,
|
|
4670
7480
|
"fill-opacity": fillOpacity,
|
|
@@ -4673,14 +7483,14 @@ function renderOnePoint(pl, categories) {
|
|
|
4673
7483
|
class: "sx-matrix-bubble"
|
|
4674
7484
|
});
|
|
4675
7485
|
}
|
|
4676
|
-
const leader = pl.label.external ?
|
|
7486
|
+
const leader = pl.label.external ? chunkLFZZ4NCP_cjs.line({
|
|
4677
7487
|
x1: pl.px,
|
|
4678
7488
|
y1: pl.py,
|
|
4679
7489
|
x2: pl.label.lx,
|
|
4680
7490
|
y2: pl.label.ly,
|
|
4681
7491
|
class: "sx-matrix-leader"
|
|
4682
7492
|
}) : "";
|
|
4683
|
-
const label =
|
|
7493
|
+
const label = chunkLFZZ4NCP_cjs.text(
|
|
4684
7494
|
{ x: pl.label.lx, y: pl.label.ly, class: "sx-matrix-label" },
|
|
4685
7495
|
pl.label.text
|
|
4686
7496
|
);
|
|
@@ -4688,20 +7498,20 @@ function renderOnePoint(pl, categories) {
|
|
|
4688
7498
|
if (p.offChart) {
|
|
4689
7499
|
const bx = pl.px;
|
|
4690
7500
|
const by = pl.py;
|
|
4691
|
-
badge =
|
|
7501
|
+
badge = chunkLFZZ4NCP_cjs.text(
|
|
4692
7502
|
{ x: bx + pl.r + 4, y: by - pl.r - 2, class: "sx-matrix-offchart", "font-size": 14, "font-weight": 700 },
|
|
4693
7503
|
"\u2197"
|
|
4694
7504
|
);
|
|
4695
7505
|
}
|
|
4696
7506
|
const titleStr = p.note ? `${p.label} \xB7 (${p.origX ?? p.x}, ${p.origY ?? p.y}) \u2014 ${p.note}` : `${p.label} \xB7 (${(p.origX ?? p.x).toFixed(2)}, ${(p.origY ?? p.y).toFixed(2)})${p.size !== void 0 ? ` \xB7 size ${p.size}` : ""}`;
|
|
4697
|
-
return
|
|
7507
|
+
return chunkLFZZ4NCP_cjs.group(
|
|
4698
7508
|
{
|
|
4699
7509
|
class: "sx-matrix-point",
|
|
4700
7510
|
"data-point-id": p.id,
|
|
4701
7511
|
"data-label": p.label,
|
|
4702
7512
|
...p.category ? { "data-category": p.category } : {}
|
|
4703
7513
|
},
|
|
4704
|
-
[
|
|
7514
|
+
[chunkLFZZ4NCP_cjs.title(titleStr), shapeEl, leader, label, badge].filter((s) => s.length > 0)
|
|
4705
7515
|
);
|
|
4706
7516
|
}
|
|
4707
7517
|
function renderLegend2(ast, lay) {
|
|
@@ -4712,18 +7522,18 @@ function renderLegend2(ast, lay) {
|
|
|
4712
7522
|
const w = 210;
|
|
4713
7523
|
const h = 10;
|
|
4714
7524
|
const stops = HEAT_RAMP.map(
|
|
4715
|
-
(c, i) =>
|
|
7525
|
+
(c, i) => chunkLFZZ4NCP_cjs.el("stop", { offset: `${i / (HEAT_RAMP.length - 1) * 100}%`, "stop-color": c })
|
|
4716
7526
|
);
|
|
4717
|
-
const grad =
|
|
7527
|
+
const grad = chunkLFZZ4NCP_cjs.el(
|
|
4718
7528
|
"linearGradient",
|
|
4719
7529
|
{ id: "sx-matrix-heatgrad", x1: "0%", x2: "100%" },
|
|
4720
7530
|
stops
|
|
4721
7531
|
);
|
|
4722
|
-
return
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
7532
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-legend" }, [
|
|
7533
|
+
chunkLFZZ4NCP_cjs.el("defs", {}, [grad]),
|
|
7534
|
+
chunkLFZZ4NCP_cjs.rect({ x, y, width: w, height: h, fill: "url(#sx-matrix-heatgrad)", stroke: "#d1d5db" }),
|
|
7535
|
+
chunkLFZZ4NCP_cjs.text({ x, y: y - 4, class: "sx-matrix-legend-text", "text-anchor": "start" }, "Low"),
|
|
7536
|
+
chunkLFZZ4NCP_cjs.text(
|
|
4727
7537
|
{ x: x + w, y: y - 4, class: "sx-matrix-legend-text", "text-anchor": "end" },
|
|
4728
7538
|
"High"
|
|
4729
7539
|
)
|
|
@@ -4734,16 +7544,16 @@ function renderLegend2(ast, lay) {
|
|
|
4734
7544
|
const yBase = lay.plot.y0 + 8;
|
|
4735
7545
|
const rows = lay.categories.map((cat, i) => {
|
|
4736
7546
|
const color = CATEGORY_COLORS[i % CATEGORY_COLORS.length];
|
|
4737
|
-
return
|
|
4738
|
-
|
|
4739
|
-
|
|
7547
|
+
return chunkLFZZ4NCP_cjs.group({ transform: `translate(${xBase}, ${yBase + i * 18})` }, [
|
|
7548
|
+
chunkLFZZ4NCP_cjs.circle({ cx: 6, cy: 6, r: 5, fill: color, "fill-opacity": 0.7, stroke: color }),
|
|
7549
|
+
chunkLFZZ4NCP_cjs.text({ x: 18, y: 10, class: "sx-matrix-legend-text" }, cat)
|
|
4740
7550
|
]);
|
|
4741
7551
|
});
|
|
4742
|
-
return
|
|
7552
|
+
return chunkLFZZ4NCP_cjs.group({ id: "sx-matrix-legend" }, rows);
|
|
4743
7553
|
}
|
|
4744
7554
|
function renderTitle(ast, lay) {
|
|
4745
7555
|
if (!ast.title) return "";
|
|
4746
|
-
return
|
|
7556
|
+
return chunkLFZZ4NCP_cjs.text(
|
|
4747
7557
|
{ x: lay.canvasWidth / 2, y: 28, class: "sx-matrix-title", "text-anchor": "middle" },
|
|
4748
7558
|
ast.title
|
|
4749
7559
|
);
|
|
@@ -4766,7 +7576,7 @@ function renderMatrixAST(ast) {
|
|
|
4766
7576
|
renderLegend2(ast, lay),
|
|
4767
7577
|
renderCorrelationLegend(ast, lay)
|
|
4768
7578
|
].filter((s) => s.length > 0);
|
|
4769
|
-
return
|
|
7579
|
+
return chunkLFZZ4NCP_cjs.svgRoot(
|
|
4770
7580
|
{
|
|
4771
7581
|
class: "sx-matrix",
|
|
4772
7582
|
"data-diagram-type": "matrix",
|
|
@@ -4777,11 +7587,11 @@ function renderMatrixAST(ast) {
|
|
|
4777
7587
|
role: "graphics-document"
|
|
4778
7588
|
},
|
|
4779
7589
|
[
|
|
4780
|
-
|
|
4781
|
-
|
|
7590
|
+
chunkLFZZ4NCP_cjs.title(ast.title ? `Matrix \u2014 ${chunkLFZZ4NCP_cjs.escapeXml(ast.title)}` : "Matrix diagram"),
|
|
7591
|
+
chunkLFZZ4NCP_cjs.desc(
|
|
4782
7592
|
`Matrix diagram${ast.template ? ` (${ast.template} template)` : ""}, ${ast.mode} mode, ${ast.points.length} point(s)`
|
|
4783
7593
|
),
|
|
4784
|
-
|
|
7594
|
+
chunkLFZZ4NCP_cjs.defs([chunkLFZZ4NCP_cjs.el("style", {}, CSS), axisArrow()]),
|
|
4785
7595
|
...body
|
|
4786
7596
|
]
|
|
4787
7597
|
);
|
|
@@ -4806,26 +7616,28 @@ var matrix = {
|
|
|
4806
7616
|
|
|
4807
7617
|
// src/core/api.ts
|
|
4808
7618
|
var plugins = [
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
7619
|
+
chunkBUN3CRMP_cjs.genogram,
|
|
7620
|
+
chunkUK7JF5QB_cjs.ecomap,
|
|
7621
|
+
chunkKUXOHLGC_cjs.pedigree,
|
|
7622
|
+
chunkOK5RYX55_cjs.phylo,
|
|
7623
|
+
chunkC3IVD7DI_cjs.sociogram,
|
|
7624
|
+
chunkK5QG53GT_cjs.timing,
|
|
7625
|
+
chunk7MVDN5UC_cjs.logic,
|
|
7626
|
+
chunkXUEROLSB_cjs.circuit,
|
|
7627
|
+
chunk2UJAVPA4_cjs.blockdiagram,
|
|
7628
|
+
chunkMKKFIPKU_cjs.ladder,
|
|
7629
|
+
chunkEYHD7LV3_cjs.sld,
|
|
7630
|
+
chunkXI6JOG76_cjs.entity,
|
|
7631
|
+
chunk3YXXZ4LT_cjs.fishbone,
|
|
7632
|
+
chunkW7GIQTJV_cjs.venn,
|
|
7633
|
+
chunkGYTWJ6VB_cjs.flowchart,
|
|
4824
7634
|
mindmap,
|
|
4825
7635
|
matrix,
|
|
4826
|
-
|
|
7636
|
+
chunkL2KUGWFR_cjs.orgchart,
|
|
4827
7637
|
decisiontree,
|
|
4828
|
-
timeline
|
|
7638
|
+
timeline,
|
|
7639
|
+
state,
|
|
7640
|
+
pid
|
|
4829
7641
|
];
|
|
4830
7642
|
function detectPlugin(text2, config) {
|
|
4831
7643
|
if (config?.type) {
|
|
@@ -4859,7 +7671,9 @@ function render(text2, config) {
|
|
|
4859
7671
|
|
|
4860
7672
|
exports.decisiontree = decisiontree;
|
|
4861
7673
|
exports.parse = parse;
|
|
7674
|
+
exports.pid = pid;
|
|
4862
7675
|
exports.render = render;
|
|
7676
|
+
exports.state = state;
|
|
4863
7677
|
exports.timeline = timeline;
|
|
4864
|
-
//# sourceMappingURL=chunk-
|
|
4865
|
-
//# sourceMappingURL=chunk-
|
|
7678
|
+
//# sourceMappingURL=chunk-YTEEZV6J.cjs.map
|
|
7679
|
+
//# sourceMappingURL=chunk-YTEEZV6J.cjs.map
|