@diagrammo/dgmo 0.74.0 → 0.76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/dist/advanced.d.ts +51 -50
  2. package/dist/advanced.js +211 -49
  3. package/dist/{analyzer-FHRJUIMW.js → analyzer-QTDQEMS5.js} +4 -6
  4. package/dist/block.css +20 -3
  5. package/dist/block.d.ts +10 -2
  6. package/dist/block.js +34 -17
  7. package/dist/chart-meta.js +6 -6
  8. package/dist/{charts-d3-LWHTOVX7.js → charts-d3-SQEVMIAM.js} +5 -5
  9. package/dist/{chunk-TC63QU4M.js → chunk-32MOGTKT.js} +31 -196
  10. package/dist/{chunk-LYLRNAX2.js → chunk-3EGIU5WY.js} +2 -2
  11. package/dist/{chunk-CMQJP5L4.js → chunk-3LJNQ6LR.js} +4 -4
  12. package/dist/{chunk-GJQQCI63.js → chunk-3SQJZMPO.js} +1 -127
  13. package/dist/{chunk-2NRIGEHZ.js → chunk-46KVXDUJ.js} +10 -3
  14. package/dist/{chunk-YXY6V2YN.js → chunk-4CRLM3IT.js} +56 -52
  15. package/dist/{chunk-BBH5IAAR.js → chunk-76IBFEYW.js} +3 -3
  16. package/dist/{chunk-YJ5G2WRU.js → chunk-7EZ5AKBK.js} +3 -3
  17. package/dist/{chunk-5NAOTRLN.js → chunk-7G4XMHDB.js} +3 -3
  18. package/dist/chunk-7IATMZSA.js +72 -0
  19. package/dist/{chunk-LSHMDQZQ.js → chunk-AFR6GWXD.js} +3 -3
  20. package/dist/{chunk-T6BO4VO6.js → chunk-AYM472K3.js} +2 -2
  21. package/dist/{chunk-YSMI6TNZ.js → chunk-BCB24FG7.js} +2 -2
  22. package/dist/{chunk-6DYZ2JM6.js → chunk-BZQCAZZZ.js} +203 -29
  23. package/dist/{chunk-KR432TCU.js → chunk-C576CU77.js} +4 -4
  24. package/dist/{chunk-5KE6KHY6.js → chunk-CAPR5DET.js} +2 -2
  25. package/dist/{chunk-GQJ35I2I.js → chunk-CLQJAGWL.js} +7 -5
  26. package/dist/{chunk-NW3VXCXR.js → chunk-COCMMQXW.js} +2 -2
  27. package/dist/{chunk-A4GOY3PE.js → chunk-DEW62ON3.js} +1 -3
  28. package/dist/{chunk-SXZS56YM.js → chunk-EGXJWRO6.js} +3 -3
  29. package/dist/{chunk-RT7ACF77.js → chunk-EGY3TS62.js} +6 -6
  30. package/dist/{chunk-TDHD3HNO.js → chunk-F4X5NVKY.js} +37 -16
  31. package/dist/{chunk-RQ6SEQOT.js → chunk-FMZEU7MF.js} +65 -24
  32. package/dist/{chunk-R5JPMW2F.js → chunk-FTTB64OJ.js} +5 -5
  33. package/dist/{chunk-PHRBLJ3K.js → chunk-GEURKGZS.js} +2 -2
  34. package/dist/{chunk-ALDU62VN.js → chunk-GFXFRKUG.js} +4 -4
  35. package/dist/{chunk-L2EA5YLO.js → chunk-HGFKDSKZ.js} +3 -3
  36. package/dist/{chunk-JSYAH7KR.js → chunk-HOIAQ3P2.js} +2 -2
  37. package/dist/{chunk-FGXBIOVK.js → chunk-IFC3JXCT.js} +2 -2
  38. package/dist/{chunk-EV6BZMBZ.js → chunk-IHUOYDLN.js} +3 -3
  39. package/dist/{chunk-474D3IUN.js → chunk-JL7BDLC6.js} +4 -4
  40. package/dist/{chunk-WWQ6TUVK.js → chunk-JLJ7SP4X.js} +3 -3
  41. package/dist/{chunk-ULEWCCBN.js → chunk-JQ575OAK.js} +2 -2
  42. package/dist/{chunk-SUA56ZSB.js → chunk-LTTZX6RD.js} +6 -2
  43. package/dist/{chunk-YJMWEZOB.js → chunk-MG3DE3VO.js} +2 -2
  44. package/dist/{chunk-GE5RO4BS.js → chunk-N6MZSBOL.js} +5 -1
  45. package/dist/{chunk-DU3OIBQE.js → chunk-NWNSXHA5.js} +6 -2
  46. package/dist/{chunk-57Z2WXJ2.js → chunk-OBYZU23V.js} +5 -5
  47. package/dist/{chunk-2MJSSDK5.js → chunk-OUJG73YJ.js} +2 -2
  48. package/dist/{chunk-XCAEHWQB.js → chunk-PAW4RMH3.js} +2 -2
  49. package/dist/{chunk-CDFIZHVD.js → chunk-QI4Q5ZZH.js} +3 -3
  50. package/dist/{chunk-ALBVWTU4.js → chunk-TF76LCZS.js} +35 -51
  51. package/dist/{chunk-FL5IKZQA.js → chunk-U5B3TUEW.js} +2 -2
  52. package/dist/{chunk-TTCXHFFB.js → chunk-U7AO6FRL.js} +2 -2
  53. package/dist/{chunk-RN3PAL4E.js → chunk-UBW53CNS.js} +2 -2
  54. package/dist/{chunk-MDEG62W7.js → chunk-UTTRJ6KN.js} +3 -3
  55. package/dist/{chunk-Q6LP67RP.js → chunk-UWYZIGCB.js} +2 -2
  56. package/dist/{chunk-XJLNQEQS.js → chunk-XHROEQ23.js} +3 -3
  57. package/dist/{chunk-EPH4UMUE.js → chunk-YVDBBWEP.js} +2 -2
  58. package/dist/{dgmo-router-KYNLRE7S.js → dgmo-router-A3LIHT6H.js} +7 -7
  59. package/dist/{dimensions-Q5SFPATB.js → dimensions-7NYBSZRJ.js} +4 -4
  60. package/dist/{flowchart-parser-LY5GGQL2.js → flowchart-parser-NVBP3C5D.js} +2 -2
  61. package/dist/{flowchart-renderer-TTUSBBQI.js → flowchart-renderer-QYGQ64BM.js} +6 -6
  62. package/dist/index.js +13 -13
  63. package/dist/{layout-UJ62RQQ3.js → layout-2OJ25STS.js} +2 -2
  64. package/dist/{layout-DAYQ46PS.js → layout-LAS67TK3.js} +3 -3
  65. package/dist/{parser-LUOINP6H.js → parser-QYAIFXLP.js} +3 -3
  66. package/dist/{parser-L7RXUKYN.js → parser-WVE6SKB7.js} +2 -2
  67. package/dist/{parser-JYIZEKAS.js → parser-ZYAFHXKQ.js} +2 -2
  68. package/dist/pert.d.ts +4 -33
  69. package/dist/{renderer-AA5CC4VJ.js → renderer-4EWGZLJ6.js} +3 -3
  70. package/dist/{renderer-6SSIELBC.js → renderer-4PNVGHVA.js} +3 -3
  71. package/dist/{renderer-U6PK5ZKD.js → renderer-5W3HWIUL.js} +3 -3
  72. package/dist/{renderer-TI7QABY7.js → renderer-CGOPX4HW.js} +4 -4
  73. package/dist/{renderer-6IGQEVTE.js → renderer-CO5O5VR5.js} +3 -3
  74. package/dist/{renderer-QLZVE45Z.js → renderer-D7N7PPB7.js} +3 -3
  75. package/dist/{renderer-6HRDO635.js → renderer-DKW273R7.js} +4 -4
  76. package/dist/{renderer-227JWWHX.js → renderer-E6NHTVN6.js} +5 -5
  77. package/dist/{renderer-IPNSOM5J.js → renderer-F24V3RD3.js} +4 -4
  78. package/dist/{renderer-N2X3WYBY.js → renderer-F6WSR7UM.js} +5 -5
  79. package/dist/{renderer-55JP6AO4.js → renderer-FGGDZZFQ.js} +3 -3
  80. package/dist/{renderer-E5BYZTVH.js → renderer-FUJNSC5X.js} +3 -3
  81. package/dist/{renderer-YQI5U6KJ.js → renderer-GF6S5ZX6.js} +3 -3
  82. package/dist/{renderer-UXZEYV2X.js → renderer-GJDVPXI3.js} +4 -4
  83. package/dist/{renderer-UYYBJ7OB.js → renderer-IH45QV6Z.js} +9 -9
  84. package/dist/{renderer-NECP7G4X.js → renderer-JMJ7Q5OC.js} +4 -4
  85. package/dist/{renderer-YM7PLDBF.js → renderer-KMOGGMM7.js} +5 -5
  86. package/dist/{renderer-P55KPBIX.js → renderer-LBNVKVO3.js} +4 -4
  87. package/dist/{renderer-46QQH33X.js → renderer-LE3ZKHNS.js} +4 -4
  88. package/dist/{renderer-4K6KR3U3.js → renderer-MUW4G2N6.js} +6 -6
  89. package/dist/{renderer-2WW35ZIW.js → renderer-PIEPRK6M.js} +4 -4
  90. package/dist/{renderer-EJXFEA5C.js → renderer-PKRKLOYR.js} +4 -4
  91. package/dist/{renderer-W7RKBG6C.js → renderer-PR3KLNST.js} +4 -4
  92. package/dist/{renderer-SCIHPARI.js → renderer-QAMOXOZ2.js} +3 -3
  93. package/dist/{renderer-3LD3ANCP.js → renderer-RUHC6D3B.js} +4 -4
  94. package/dist/{renderer-OWBIWBMK.js → renderer-UUP6OX6F.js} +3 -3
  95. package/dist/{renderer-UUPNOGO5.js → renderer-UYZSP7MF.js} +4 -4
  96. package/dist/{renderer-CF5TYQT4.js → renderer-ZAJ5353N.js} +3 -3
  97. package/dist/{state-renderer-OPP6YOJI.js → state-renderer-UIE3AQM6.js} +6 -6
  98. package/docs/language-reference.md +6 -6
  99. package/package.json +3 -3
  100. package/dist/chunk-PDKUANDZ.js +0 -35
@@ -25,14 +25,14 @@ import {
25
25
  } from "./chunk-24YPR5EH.js";
26
26
  import {
27
27
  layoutInlineHeader
28
- } from "./chunk-YJMWEZOB.js";
28
+ } from "./chunk-MG3DE3VO.js";
29
29
  import {
30
30
  serializeSvg
31
31
  } from "./chunk-RU2HHHYA.js";
32
32
  import {
33
33
  TITLE_FONT_SIZE,
34
34
  TITLE_FONT_WEIGHT
35
- } from "./chunk-A4GOY3PE.js";
35
+ } from "./chunk-DEW62ON3.js";
36
36
  import {
37
37
  renderIntegratedLegend
38
38
  } from "./chunk-QT5UMFPE.js";
@@ -500,4 +500,4 @@ export {
500
500
  renderSitemap,
501
501
  renderSitemapForExport
502
502
  };
503
- //# sourceMappingURL=chunk-5NAOTRLN.js.map
503
+ //# sourceMappingURL=chunk-7G4XMHDB.js.map
@@ -0,0 +1,72 @@
1
+ // src/utils/fit-canvas.ts
2
+ function fitDiagramToCanvas(p) {
3
+ const scaleX = (p.width - p.padding * 2) / p.diagramW;
4
+ let scale;
5
+ let canvasHeight;
6
+ if (p.exportMode) {
7
+ scale = Math.min(p.maxScale, scaleX);
8
+ canvasHeight = p.titleHeight + p.diagramH * scale + p.padding * 2;
9
+ } else {
10
+ const availH = p.height - p.titleHeight;
11
+ const scaleY = (availH - p.padding * 2) / p.diagramH;
12
+ scale = Math.min(p.maxScale, scaleX, scaleY);
13
+ canvasHeight = p.height;
14
+ }
15
+ const scaledW = p.diagramW * scale;
16
+ return {
17
+ scale,
18
+ offsetX: (p.width - scaledW) / 2,
19
+ offsetY: p.titleHeight + p.padding,
20
+ canvasHeight
21
+ };
22
+ }
23
+
24
+ // src/graph/edge-spline.ts
25
+ import * as d3Shape from "d3-shape";
26
+ var lineGenerator = d3Shape.line().x((d) => d.x).y((d) => d.y).curve(d3Shape.curveBasis);
27
+ function edgeSplinePath(points) {
28
+ return lineGenerator(points);
29
+ }
30
+ function selfLoopArcPath(points) {
31
+ if (points.length < 3) return null;
32
+ const p0 = points[0];
33
+ const p3 = points[points.length - 1];
34
+ const chordX = p3.x - p0.x;
35
+ const chordY = p3.y - p0.y;
36
+ const chordLen = Math.hypot(chordX, chordY);
37
+ if (chordLen === 0) return null;
38
+ let apex = points[Math.floor(points.length / 2)];
39
+ let farthest = -1;
40
+ for (let i = 1; i < points.length - 1; i++) {
41
+ const pt = points[i];
42
+ const away = Math.abs((pt.x - p0.x) * chordY - (pt.y - p0.y) * chordX) / chordLen;
43
+ if (away > farthest) {
44
+ farthest = away;
45
+ apex = pt;
46
+ }
47
+ }
48
+ let ux = apex.x - (p0.x + p3.x) / 2;
49
+ let uy = apex.y - (p0.y + p3.y) / 2;
50
+ const uLen = Math.hypot(ux, uy);
51
+ if (uLen === 0) return null;
52
+ ux /= uLen;
53
+ uy /= uLen;
54
+ const a1 = points[1];
55
+ const a2 = points[points.length - 2];
56
+ const needX = (8 * apex.x - p0.x - p3.x) / 3;
57
+ const needY = (8 * apex.y - p0.y - p3.y) / 3;
58
+ const t = Math.abs(ux) >= Math.abs(uy) ? (needX - (a1.x + a2.x)) / (2 * ux) : (needY - (a1.y + a2.y)) / (2 * uy);
59
+ if (!Number.isFinite(t)) return null;
60
+ const c1x = a1.x + ux * t;
61
+ const c1y = a1.y + uy * t;
62
+ const c2x = a2.x + ux * t;
63
+ const c2y = a2.y + uy * t;
64
+ return `M${p0.x},${p0.y}C${c1x},${c1y},${c2x},${c2y},${p3.x},${p3.y}`;
65
+ }
66
+
67
+ export {
68
+ fitDiagramToCanvas,
69
+ edgeSplinePath,
70
+ selfLoopArcPath
71
+ };
72
+ //# sourceMappingURL=chunk-7IATMZSA.js.map
@@ -8,12 +8,12 @@ import {
8
8
  import {
9
9
  INLINE_HEADER_PAD,
10
10
  layoutInlineHeader
11
- } from "./chunk-YJMWEZOB.js";
11
+ } from "./chunk-MG3DE3VO.js";
12
12
  import {
13
13
  TITLE_FONT_SIZE,
14
14
  TITLE_FONT_WEIGHT,
15
15
  TITLE_Y
16
- } from "./chunk-A4GOY3PE.js";
16
+ } from "./chunk-DEW62ON3.js";
17
17
  import {
18
18
  renderIntegratedLegend
19
19
  } from "./chunk-QT5UMFPE.js";
@@ -2152,4 +2152,4 @@ export {
2152
2152
  renderGantt,
2153
2153
  buildTagLaneRowList
2154
2154
  };
2155
- //# sourceMappingURL=chunk-LSHMDQZQ.js.map
2155
+ //# sourceMappingURL=chunk-AFR6GWXD.js.map
@@ -21,7 +21,7 @@ import {
21
21
  import {
22
22
  TITLE_FONT_SIZE,
23
23
  TITLE_FONT_WEIGHT
24
- } from "./chunk-A4GOY3PE.js";
24
+ } from "./chunk-DEW62ON3.js";
25
25
  import {
26
26
  renderIntegratedLegend
27
27
  } from "./chunk-QT5UMFPE.js";
@@ -1039,4 +1039,4 @@ export {
1039
1039
  renderC4Deployment,
1040
1040
  renderC4DeploymentForExport
1041
1041
  };
1042
- //# sourceMappingURL=chunk-T6BO4VO6.js.map
1042
+ //# sourceMappingURL=chunk-AYM472K3.js.map
@@ -11,7 +11,7 @@ import {
11
11
  TITLE_FONT_SIZE,
12
12
  TITLE_FONT_WEIGHT,
13
13
  TITLE_Y
14
- } from "./chunk-A4GOY3PE.js";
14
+ } from "./chunk-DEW62ON3.js";
15
15
  import {
16
16
  renderIntegratedLegend
17
17
  } from "./chunk-QT5UMFPE.js";
@@ -985,4 +985,4 @@ export {
985
985
  renderCycle,
986
986
  renderCycleForExport
987
987
  };
988
- //# sourceMappingURL=chunk-YSMI6TNZ.js.map
988
+ //# sourceMappingURL=chunk-BCB24FG7.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SKETCH_DIAGNOSTIC_CODES
3
- } from "./chunk-RT7ACF77.js";
3
+ } from "./chunk-EGY3TS62.js";
4
4
  import {
5
5
  makeDgmoError
6
6
  } from "./chunk-5SI6T5A5.js";
@@ -94,15 +94,85 @@ function resolveAutoFlags(f = {}) {
94
94
  function unitRect(c, r) {
95
95
  return { c, r, w: SKETCH_SEP, h: SKETCH_SEP };
96
96
  }
97
+ var childBoxAt = /* @__PURE__ */ new Map();
98
+ function nearestFreeRect(base, occupied) {
99
+ if (!occupied.hits(base)) return { c: base.c, r: base.r };
100
+ for (let d = 1; d <= 200; d++) {
101
+ const candidates = [];
102
+ for (let dc = -d; dc <= d; dc++) {
103
+ const dr = d - Math.abs(dc);
104
+ candidates.push({ c: base.c + dc, r: base.r + dr });
105
+ if (dr !== 0) candidates.push({ c: base.c + dc, r: base.r - dr });
106
+ }
107
+ candidates.sort((a, b) => {
108
+ const costA = (a.r < base.r ? 2 : 0) + (a.c < base.c ? 1 : 0);
109
+ const costB = (b.r < base.r ? 2 : 0) + (b.c < base.c ? 1 : 0);
110
+ return costA - costB || a.r - b.r || a.c - b.c;
111
+ });
112
+ for (const cand of candidates) {
113
+ if (!occupied.hits({ ...base, c: cand.c, r: cand.r })) return cand;
114
+ }
115
+ }
116
+ return { c: base.c, r: base.r };
117
+ }
97
118
  function rectsOverlap(a, b) {
98
119
  return a.c < b.c + b.w && b.c < a.c + a.w && a.r < b.r + b.h && b.r < a.r + a.h;
99
120
  }
100
- function collidesAny(rect, occupied) {
101
- for (const o of occupied) if (rectsOverlap(rect, o)) return true;
102
- return false;
121
+ var CELL = SKETCH_SEP;
122
+ var OVERSIZED_CELLS = 64;
123
+ function cellRange(rect) {
124
+ return [
125
+ Math.floor(rect.c / CELL),
126
+ Math.floor(rect.r / CELL),
127
+ Math.floor((rect.c + rect.w) / CELL),
128
+ Math.floor((rect.r + rect.h) / CELL)
129
+ ];
130
+ }
131
+ function cellSpan(range) {
132
+ return (range[2] - range[0] + 1) * (range[3] - range[1] + 1);
103
133
  }
134
+ var Occupancy = class {
135
+ grid = /* @__PURE__ */ new Map();
136
+ oversized = [];
137
+ /** Every rect, in insertion order — the extent and flow-origin maths want it. */
138
+ rects = [];
139
+ add(rect) {
140
+ this.rects.push(rect);
141
+ const range = cellRange(rect);
142
+ if (cellSpan(range) > OVERSIZED_CELLS) {
143
+ this.oversized.push(rect);
144
+ return;
145
+ }
146
+ const [c0, r0, c1, r1] = range;
147
+ for (let c = c0; c <= c1; c++) {
148
+ for (let r = r0; r <= r1; r++) {
149
+ const key = `${c},${r}`;
150
+ const bucket = this.grid.get(key);
151
+ if (bucket) bucket.push(rect);
152
+ else this.grid.set(key, [rect]);
153
+ }
154
+ }
155
+ }
156
+ hits(rect) {
157
+ for (const o of this.oversized) if (rectsOverlap(rect, o)) return true;
158
+ const range = cellRange(rect);
159
+ if (cellSpan(range) > OVERSIZED_CELLS) {
160
+ for (const o of this.rects) if (rectsOverlap(rect, o)) return true;
161
+ return false;
162
+ }
163
+ const [c0, r0, c1, r1] = range;
164
+ for (let c = c0; c <= c1; c++) {
165
+ for (let r = r0; r <= r1; r++) {
166
+ const bucket = this.grid.get(`${c},${r}`);
167
+ if (!bucket) continue;
168
+ for (const o of bucket) if (rectsOverlap(rect, o)) return true;
169
+ }
170
+ }
171
+ return false;
172
+ }
173
+ };
104
174
  function nearestFree(base, occupied) {
105
- if (!collidesAny(base, occupied)) return { c: base.c, r: base.r };
175
+ if (!occupied.hits(base)) return { c: base.c, r: base.r };
106
176
  for (let d = 1; d <= 200; d++) {
107
177
  const candidates = [];
108
178
  for (let dc = -d; dc <= d; dc++) {
@@ -116,17 +186,28 @@ function nearestFree(base, occupied) {
116
186
  return costA - costB || a.r - b.r || a.c - b.c;
117
187
  });
118
188
  for (const cand of candidates) {
119
- if (!collidesAny({ ...base, c: cand.c, r: cand.r }, occupied)) {
189
+ if (!occupied.hits({ ...base, c: cand.c, r: cand.r })) {
120
190
  return cand;
121
191
  }
122
192
  }
123
193
  }
124
194
  return { c: base.c, r: base.r };
125
195
  }
126
- function layoutChildren(box, nodesById, warn, flags) {
127
- const occupied = [];
196
+ function layoutChildren(box, nodesById, warn, flags, childBoxRects = /* @__PURE__ */ new Map()) {
197
+ const occupied = new Occupancy();
128
198
  const children = [];
199
+ const localBoxes = [];
129
200
  const pending = [];
201
+ for (const boxId of box.childBoxes) {
202
+ const rect = childBoxRects.get(boxId);
203
+ if (!rect) continue;
204
+ const at = childBoxAt.get(boxId) ?? null;
205
+ const base = at ?? { c: 0, r: 0 };
206
+ const want = { ...rect, c: base.c, r: base.r };
207
+ const spot = flags.resolveOverlap ? nearestFreeRect(want, occupied) : { c: want.c, r: want.r };
208
+ occupied.add({ ...rect, c: spot.c, r: spot.r });
209
+ localBoxes.push({ boxId, c: spot.c, r: spot.r, rect });
210
+ }
130
211
  for (const id of box.children) {
131
212
  const node = nodesById.get(id);
132
213
  if (!node) continue;
@@ -139,25 +220,25 @@ function layoutChildren(box, nodesById, warn, flags) {
139
220
  if (spot.c !== node.at.c || spot.r !== node.at.r) {
140
221
  warn(node.lineNumber, node.label);
141
222
  }
142
- occupied.push(unitRect(spot.c, spot.r));
223
+ occupied.add(unitRect(spot.c, spot.r));
143
224
  children.push({ node, c: spot.c, r: spot.r });
144
225
  }
145
226
  if (!flags.flowPlaceUnpositioned) {
146
227
  for (const node of pending) children.push({ node, c: 0, r: 0 });
147
228
  pending.length = 0;
148
229
  }
149
- let flowRow = occupied.length > 0 ? Math.max(...occupied.map((o) => o.r)) + SKETCH_SEP : 0;
230
+ let flowRow = occupied.rects.length > 0 ? Math.max(...occupied.rects.map((o) => o.r)) + SKETCH_SEP : 0;
150
231
  let flowCol = 0;
151
232
  const wrapAt = Math.max(
152
233
  SKETCH_SEP * 3,
153
- occupied.length > 0 ? Math.max(...occupied.map((o) => o.c)) + SKETCH_SEP : SKETCH_SEP * 3
234
+ occupied.rects.length > 0 ? Math.max(...occupied.rects.map((o) => o.c)) + SKETCH_SEP : SKETCH_SEP * 3
154
235
  );
155
236
  for (const node of pending) {
156
237
  let placed = false;
157
238
  while (!placed) {
158
239
  const rect = unitRect(flowCol, flowRow);
159
- if (!collidesAny(rect, occupied)) {
160
- occupied.push(rect);
240
+ if (!occupied.hits(rect)) {
241
+ occupied.add(rect);
161
242
  children.push({ node, c: flowCol, r: flowRow });
162
243
  placed = true;
163
244
  }
@@ -169,16 +250,16 @@ function layoutChildren(box, nodesById, warn, flags) {
169
250
  }
170
251
  }
171
252
  let extent;
172
- if (occupied.length === 0) {
253
+ if (occupied.rects.length === 0) {
173
254
  extent = { c: 0, r: 0, w: SKETCH_SEP, h: SKETCH_SEP };
174
255
  } else {
175
- const cMin = Math.min(...occupied.map((o) => o.c));
176
- const rMin = Math.min(...occupied.map((o) => o.r));
177
- const cMax = Math.max(...occupied.map((o) => o.c + o.w));
178
- const rMax = Math.max(...occupied.map((o) => o.r + o.h));
256
+ const cMin = Math.min(...occupied.rects.map((o) => o.c));
257
+ const rMin = Math.min(...occupied.rects.map((o) => o.r));
258
+ const cMax = Math.max(...occupied.rects.map((o) => o.c + o.w));
259
+ const rMax = Math.max(...occupied.rects.map((o) => o.r + o.h));
179
260
  extent = { c: cMin, r: rMin, w: cMax - cMin, h: rMax - rMin };
180
261
  }
181
- return { children, extent };
262
+ return { children, boxes: localBoxes, extent };
182
263
  }
183
264
  function layoutSketch(parsed, options = {}) {
184
265
  const diagnostics = [];
@@ -200,11 +281,41 @@ function layoutSketch(parsed, options = {}) {
200
281
  const bandHs = SKETCH_GEOMETRY.bandPx / SKETCH_HALF_SLOT_Y;
201
282
  const boxLocal = /* @__PURE__ */ new Map();
202
283
  const inExpandedBox = /* @__PURE__ */ new Set();
284
+ const boxById = new Map(collapsed.boxes.map((b) => [b.id, b]));
285
+ const nestedBoxIds = new Set(
286
+ collapsed.boxes.filter((b) => b.parentBoxId !== null).map((b) => b.id)
287
+ );
288
+ childBoxAt.clear();
203
289
  for (const box of collapsed.boxes) {
290
+ if (!nestedBoxIds.has(box.id)) continue;
291
+ childBoxAt.set(box.id, box.at);
204
292
  const local = layoutChildren(box, nodesById, overlapWarn, flags);
205
293
  boxLocal.set(box.id, local);
206
294
  for (const child of local.children) inExpandedBox.add(child.node.id);
207
295
  }
296
+ const childBoxRects = /* @__PURE__ */ new Map();
297
+ for (const box of collapsed.boxes) {
298
+ if (!nestedBoxIds.has(box.id)) continue;
299
+ const local = boxLocal.get(box.id);
300
+ childBoxRects.set(box.id, {
301
+ c: 0,
302
+ r: 0,
303
+ w: local.extent.w + 2 * padHsX,
304
+ h: local.extent.h + bandHs + padHsY
305
+ });
306
+ }
307
+ for (const box of collapsed.boxes) {
308
+ if (nestedBoxIds.has(box.id)) continue;
309
+ const local = layoutChildren(
310
+ box,
311
+ nodesById,
312
+ overlapWarn,
313
+ flags,
314
+ childBoxRects
315
+ );
316
+ boxLocal.set(box.id, local);
317
+ for (const child of local.children) inExpandedBox.add(child.node.id);
318
+ }
208
319
  const allNodesById = new Map(parsed.nodes.map((n) => [n.id, n]));
209
320
  const noWarn = () => {
210
321
  };
@@ -242,6 +353,7 @@ function layoutSketch(parsed, options = {}) {
242
353
  rootUnits.push({ kind: "virtual", box });
243
354
  }
244
355
  for (const box of collapsed.boxes) {
356
+ if (nestedBoxIds.has(box.id)) continue;
245
357
  rootUnits.push({ kind: "box", box });
246
358
  }
247
359
  const lineOf = (u) => u.kind === "shape" ? u.node.lineNumber : u.box.lineNumber;
@@ -274,7 +386,7 @@ function layoutSketch(parsed, options = {}) {
274
386
  }
275
387
  return unitRect(c, r);
276
388
  };
277
- const occupied = [];
389
+ const occupied = new Occupancy();
278
390
  const placedAt = /* @__PURE__ */ new Map();
279
391
  const pending = [];
280
392
  for (const unit of rootUnits) {
@@ -285,7 +397,7 @@ function layoutSketch(parsed, options = {}) {
285
397
  }
286
398
  const base = rectFor(unit, at.c, at.r);
287
399
  let spot = { c: at.c, r: at.r };
288
- if (flags.resolveOverlap && unit.kind === "shape" && collidesAny(base, occupied)) {
400
+ if (flags.resolveOverlap && unit.kind === "shape" && occupied.hits(base)) {
289
401
  const freed = nearestFree(base, occupied);
290
402
  spot = {
291
403
  c: at.c + (freed.c - base.c),
@@ -293,28 +405,28 @@ function layoutSketch(parsed, options = {}) {
293
405
  };
294
406
  overlapWarn(unit.node.lineNumber, unit.node.label);
295
407
  }
296
- occupied.push(rectFor(unit, spot.c, spot.r));
408
+ occupied.add(rectFor(unit, spot.c, spot.r));
297
409
  placedAt.set(unit, spot);
298
410
  }
299
411
  if (!flags.flowPlaceUnpositioned) {
300
412
  for (const unit of pending) {
301
- occupied.push(rectFor(unit, 0, 0));
413
+ occupied.add(rectFor(unit, 0, 0));
302
414
  placedAt.set(unit, { c: 0, r: 0 });
303
415
  }
304
416
  pending.length = 0;
305
417
  }
306
- let flowRow = occupied.length > 0 ? Math.ceil(Math.max(...occupied.map((o) => o.r + o.h))) : 0;
418
+ let flowRow = occupied.rects.length > 0 ? Math.ceil(Math.max(...occupied.rects.map((o) => o.r + o.h))) : 0;
307
419
  let flowCol = 0;
308
420
  const wrapAt = Math.max(
309
421
  SKETCH_SEP * 4,
310
- occupied.length > 0 ? Math.ceil(Math.max(...occupied.map((o) => o.c + o.w))) : SKETCH_SEP * 4
422
+ occupied.rects.length > 0 ? Math.ceil(Math.max(...occupied.rects.map((o) => o.c + o.w))) : SKETCH_SEP * 4
311
423
  );
312
424
  for (const unit of pending) {
313
425
  let placed = false;
314
426
  while (!placed) {
315
427
  const rect = rectFor(unit, flowCol, flowRow);
316
- if (!collidesAny(rect, occupied)) {
317
- occupied.push(rect);
428
+ if (!occupied.hits(rect)) {
429
+ occupied.add(rect);
318
430
  placedAt.set(unit, { c: flowCol, r: flowRow });
319
431
  placed = true;
320
432
  }
@@ -409,6 +521,64 @@ function layoutSketch(parsed, options = {}) {
409
521
  maxX = origin.x + SKETCH_FOOT_W;
410
522
  maxY = minY;
411
523
  }
524
+ for (const inner of local.boxes) {
525
+ const innerBox = boxById.get(inner.boxId);
526
+ const innerLocal = boxLocal.get(inner.boxId);
527
+ if (!innerBox || !innerLocal) continue;
528
+ const innerRectOrigin = toPx(spot.c + inner.c, spot.r + inner.r);
529
+ const innerContentX = innerRectOrigin.x + SKETCH_GEOMETRY.boxPadPx - innerLocal.extent.c * SKETCH_HALF_SLOT_X;
530
+ const innerContentY = innerRectOrigin.y + SKETCH_GEOMETRY.bandPx - innerLocal.extent.r * SKETCH_HALF_SLOT_Y;
531
+ let iMinX = Infinity;
532
+ let iMinY = Infinity;
533
+ let iMaxX = -Infinity;
534
+ let iMaxY = -Infinity;
535
+ for (const gc of innerLocal.children) {
536
+ const gx = innerContentX + gc.c * SKETCH_HALF_SLOT_X;
537
+ const gy = innerContentY + gc.r * SKETCH_HALF_SLOT_Y;
538
+ nodes.push({
539
+ id: gc.node.id,
540
+ label: gc.node.label,
541
+ shape: gc.node.shape,
542
+ metadata: gc.node.metadata,
543
+ ...gc.node.description && { description: gc.node.description },
544
+ boxLabel: innerBox.label,
545
+ lineNumber: gc.node.lineNumber,
546
+ slot: { c: spot.c + inner.c, r: spot.r + inner.r },
547
+ x: gx,
548
+ y: gy,
549
+ w: SKETCH_FOOT_W,
550
+ h: SKETCH_FOOT_H
551
+ });
552
+ iMinX = Math.min(iMinX, gx);
553
+ iMinY = Math.min(iMinY, gy);
554
+ iMaxX = Math.max(iMaxX, gx + SKETCH_FOOT_W);
555
+ iMaxY = Math.max(iMaxY, gy + SKETCH_FOOT_H);
556
+ }
557
+ if (iMinX === Infinity) {
558
+ iMinX = innerContentX;
559
+ iMinY = innerContentY + SKETCH_GEOMETRY.bandPx;
560
+ iMaxX = innerContentX + SKETCH_FOOT_W;
561
+ iMaxY = iMinY;
562
+ }
563
+ const iFrame = {
564
+ x: iMinX - SKETCH_GEOMETRY.boxPadPx,
565
+ y: iMinY - SKETCH_GEOMETRY.bandPx,
566
+ w: iMaxX - iMinX + 2 * SKETCH_GEOMETRY.boxPadPx,
567
+ h: iMaxY - iMinY + SKETCH_GEOMETRY.bandPx + SKETCH_GEOMETRY.boxPadPx
568
+ };
569
+ boxes.push({
570
+ id: innerBox.id,
571
+ label: innerBox.label,
572
+ metadata: innerBox.metadata,
573
+ lineNumber: innerBox.lineNumber,
574
+ ...iFrame,
575
+ bandH: SKETCH_GEOMETRY.bandPx
576
+ });
577
+ minX = Math.min(minX, iFrame.x);
578
+ minY = Math.min(minY, iFrame.y);
579
+ maxX = Math.max(maxX, iFrame.x + iFrame.w);
580
+ maxY = Math.max(maxY, iFrame.y + iFrame.h);
581
+ }
412
582
  boxes.push({
413
583
  id: unit.box.id,
414
584
  label: unit.box.label,
@@ -507,9 +677,13 @@ function layoutSketch(parsed, options = {}) {
507
677
  width = Math.max(width, b.x + b.w);
508
678
  height = Math.max(height, b.y + b.h);
509
679
  }
680
+ const orderedBoxes = [
681
+ ...boxes.filter((b) => !nestedBoxIds.has(b.id)),
682
+ ...boxes.filter((b) => nestedBoxIds.has(b.id))
683
+ ];
510
684
  return {
511
685
  nodes,
512
- boxes,
686
+ boxes: orderedBoxes,
513
687
  edges: collapsed.edges,
514
688
  width,
515
689
  height,
@@ -532,4 +706,4 @@ export {
532
706
  SKETCH_AUTO_LAYOUT_DEFAULTS,
533
707
  layoutSketch
534
708
  };
535
- //# sourceMappingURL=chunk-6DYZ2JM6.js.map
709
+ //# sourceMappingURL=chunk-BZQCAZZZ.js.map
@@ -21,12 +21,12 @@ import {
21
21
  } from "./chunk-24YPR5EH.js";
22
22
  import {
23
23
  layoutInlineHeader
24
- } from "./chunk-YJMWEZOB.js";
24
+ } from "./chunk-MG3DE3VO.js";
25
25
  import {
26
26
  TITLE_FONT_SIZE,
27
27
  TITLE_FONT_WEIGHT,
28
28
  TITLE_Y
29
- } from "./chunk-A4GOY3PE.js";
29
+ } from "./chunk-DEW62ON3.js";
30
30
  import {
31
31
  renderIntegratedLegend
32
32
  } from "./chunk-QT5UMFPE.js";
@@ -44,7 +44,7 @@ import {
44
44
  } from "./chunk-MTGGOCND.js";
45
45
  import {
46
46
  parseClassDiagram
47
- } from "./chunk-SUA56ZSB.js";
47
+ } from "./chunk-LTTZX6RD.js";
48
48
  import {
49
49
  fillModeFromOptions,
50
50
  legendInlineRequested,
@@ -448,4 +448,4 @@ export {
448
448
  renderClassDiagram,
449
449
  renderClassDiagramForExport
450
450
  };
451
- //# sourceMappingURL=chunk-KR432TCU.js.map
451
+ //# sourceMappingURL=chunk-C576CU77.js.map
@@ -5,7 +5,7 @@ import {
5
5
  TITLE_FONT_SIZE,
6
6
  TITLE_FONT_WEIGHT,
7
7
  TITLE_Y
8
- } from "./chunk-A4GOY3PE.js";
8
+ } from "./chunk-DEW62ON3.js";
9
9
  import {
10
10
  FONT_FAMILY
11
11
  } from "./chunk-UTCPNJND.js";
@@ -401,4 +401,4 @@ function drawCenteredLabel(g, label, cx, cy, fill, fontSize, tight = false, halo
401
401
  export {
402
402
  renderSwimlaneForExport
403
403
  };
404
- //# sourceMappingURL=chunk-5KE6KHY6.js.map
404
+ //# sourceMappingURL=chunk-CAPR5DET.js.map
@@ -12,12 +12,12 @@ import {
12
12
  } from "./chunk-24YPR5EH.js";
13
13
  import {
14
14
  layoutInlineHeader
15
- } from "./chunk-YJMWEZOB.js";
15
+ } from "./chunk-MG3DE3VO.js";
16
16
  import {
17
17
  TITLE_FONT_SIZE,
18
18
  TITLE_FONT_WEIGHT,
19
19
  TITLE_Y
20
- } from "./chunk-A4GOY3PE.js";
20
+ } from "./chunk-DEW62ON3.js";
21
21
  import {
22
22
  renderIntegratedLegend
23
23
  } from "./chunk-QT5UMFPE.js";
@@ -1490,7 +1490,8 @@ function renderSequenceDiagram(container, parsed, palette, isDark, _onNavigateTo
1490
1490
  sBoxW,
1491
1491
  sBoxH,
1492
1492
  sLabelTextWidth,
1493
- sLabelFontSize
1493
+ sLabelFontSize,
1494
+ isCollapsedGroup
1494
1495
  );
1495
1496
  if (isCollapsedGroup) {
1496
1497
  const meta = collapsedGroupMeta.get(participant.id);
@@ -2004,11 +2005,12 @@ function buildNoteMessageMap(elements) {
2004
2005
  walk(elements);
2005
2006
  return map;
2006
2007
  }
2007
- function renderParticipant(svg, participant, cx, cy, palette, isDark, color, tagAttr, fillMode, boxW = W, boxH = H, labelTextW = labelTextWidth(W), labelFontSize = LABEL_FONT_SIZE) {
2008
+ function renderParticipant(svg, participant, cx, cy, palette, isDark, color, tagAttr, fillMode, boxW = W, boxH = H, labelTextW = labelTextWidth(W), labelFontSize = LABEL_FONT_SIZE, overlaid = false) {
2008
2009
  const g = svg.append("g").attr("transform", `translate(${cx}, ${cy})`).attr("class", "participant").attr("data-participant-id", participant.id);
2009
2010
  if (tagAttr) {
2010
2011
  g.attr(`data-tag-${tagAttr.key}`, tagAttr.value);
2011
2012
  }
2013
+ if (overlaid) return;
2012
2014
  switch (participant.type) {
2013
2015
  case "actor":
2014
2016
  renderActorParticipant(g, palette, color, boxH);
@@ -2072,4 +2074,4 @@ export {
2072
2074
  renderSequenceDiagram,
2073
2075
  buildNoteMessageMap
2074
2076
  };
2075
- //# sourceMappingURL=chunk-GQJ35I2I.js.map
2077
+ //# sourceMappingURL=chunk-CLQJAGWL.js.map
@@ -8,7 +8,7 @@ import {
8
8
  TITLE_FONT_SIZE,
9
9
  TITLE_FONT_WEIGHT,
10
10
  TITLE_Y
11
- } from "./chunk-A4GOY3PE.js";
11
+ } from "./chunk-DEW62ON3.js";
12
12
  import {
13
13
  FONT_FAMILY
14
14
  } from "./chunk-UTCPNJND.js";
@@ -859,4 +859,4 @@ export {
859
859
  renderRaci,
860
860
  renderRaciForExport
861
861
  };
862
- //# sourceMappingURL=chunk-NW3VXCXR.js.map
862
+ //# sourceMappingURL=chunk-COCMMQXW.js.map
@@ -4,7 +4,6 @@ var TITLE_FONT_WEIGHT = "700";
4
4
  var TITLE_Y = 30;
5
5
  var TITLE_OFFSET = 40;
6
6
  var CAPTION_FONT_SIZE = 13;
7
- var CAPTION_FONT_WEIGHT = "400";
8
7
  var CAPTION_LINE_HEIGHT = 18;
9
8
  var CAPTION_TOP_GAP = 12;
10
9
  var CAPTION_BOX_PADDING_X = 16;
@@ -16,10 +15,9 @@ export {
16
15
  TITLE_Y,
17
16
  TITLE_OFFSET,
18
17
  CAPTION_FONT_SIZE,
19
- CAPTION_FONT_WEIGHT,
20
18
  CAPTION_LINE_HEIGHT,
21
19
  CAPTION_TOP_GAP,
22
20
  CAPTION_BOX_PADDING_X,
23
21
  CAPTION_BOX_PADDING_Y
24
22
  };
25
- //# sourceMappingURL=chunk-A4GOY3PE.js.map
23
+ //# sourceMappingURL=chunk-DEW62ON3.js.map
@@ -6,12 +6,12 @@ import {
6
6
  mapLegendConfig,
7
7
  mapLegendGroups,
8
8
  parsePathRings
9
- } from "./chunk-RQ6SEQOT.js";
9
+ } from "./chunk-FMZEU7MF.js";
10
10
  import {
11
11
  TITLE_FONT_SIZE,
12
12
  TITLE_FONT_WEIGHT,
13
13
  TITLE_Y
14
- } from "./chunk-A4GOY3PE.js";
14
+ } from "./chunk-DEW62ON3.js";
15
15
  import {
16
16
  renderIntegratedLegend
17
17
  } from "./chunk-QT5UMFPE.js";
@@ -781,4 +781,4 @@ export {
781
781
  renderMap,
782
782
  renderMapForExport
783
783
  };
784
- //# sourceMappingURL=chunk-SXZS56YM.js.map
784
+ //# sourceMappingURL=chunk-EGXJWRO6.js.map