@diagrammo/dgmo 0.46.0 → 0.48.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 (534) hide show
  1. package/dist/advanced.d.ts +3 -855
  2. package/dist/advanced.js +541 -70107
  3. package/dist/analyzer-UYKBXAKR.js +15 -0
  4. package/dist/auto.js +1 -1
  5. package/dist/auto.mjs +1 -1
  6. package/dist/block.js +83 -69417
  7. package/dist/calculator-LDYQCDDY.js +11 -0
  8. package/dist/charts-d3-QOZHKTCT.js +25 -0
  9. package/dist/chunk-2DXMZRWJ.js +800 -0
  10. package/dist/chunk-2LACINWN.js +786 -0
  11. package/dist/chunk-33LCUH4H.js +893 -0
  12. package/dist/chunk-3CIOJ5YJ.js +35 -0
  13. package/dist/chunk-3HDBAXF5.js +86 -0
  14. package/dist/chunk-3JLKYGBQ.js +290 -0
  15. package/dist/chunk-3MQQNXPD.js +415 -0
  16. package/dist/chunk-3R5POCTZ.js +967 -0
  17. package/dist/chunk-3SMGIJDD.js +112 -0
  18. package/dist/chunk-44CM72SQ.js +409 -0
  19. package/dist/chunk-4GRI7MEB.js +1604 -0
  20. package/dist/chunk-4OHACBGX.js +606 -0
  21. package/dist/chunk-5DH3KYFH.js +21 -0
  22. package/dist/chunk-5MLYVTYM.js +76 -0
  23. package/dist/chunk-5QXL4NYS.js +553 -0
  24. package/dist/chunk-5WRI5ZAA.js +31 -0
  25. package/dist/chunk-6EK55ART.js +117 -0
  26. package/dist/chunk-6FZYCKXB.js +2065 -0
  27. package/dist/chunk-6HO5ZTXK.js +277 -0
  28. package/dist/chunk-6KFWC4CO.js +7 -0
  29. package/dist/chunk-6MTWIQVO.js +121 -0
  30. package/dist/chunk-6NYWYNBI.js +329 -0
  31. package/dist/chunk-6SM5NJQH.js +620 -0
  32. package/dist/chunk-725LDASD.js +422 -0
  33. package/dist/chunk-76OWZ3BA.js +130 -0
  34. package/{src/block/parser.ts → dist/chunk-7JEGTRLD.js} +100 -189
  35. package/dist/chunk-A44USUV7.js +923 -0
  36. package/dist/chunk-A4GOY3PE.js +25 -0
  37. package/dist/chunk-A4VFQH5G.js +251 -0
  38. package/dist/chunk-AELOBFW5.js +375 -0
  39. package/dist/chunk-AN2MOO5T.js +522 -0
  40. package/dist/chunk-BMR4CIEO.js +41 -0
  41. package/dist/chunk-BS7SV7C3.js +51 -0
  42. package/dist/chunk-BUPDIHML.js +613 -0
  43. package/dist/chunk-BUVJFRPY.js +887 -0
  44. package/dist/chunk-C3Z4DX3V.js +112 -0
  45. package/dist/chunk-CI2G3OEB.js +1818 -0
  46. package/dist/chunk-CKNVO24D.js +54 -0
  47. package/dist/chunk-CUVHQHZ7.js +391 -0
  48. package/dist/chunk-CXK4DZH3.js +114 -0
  49. package/dist/{editor.cjs → chunk-DKEPS5LH.js} +14 -225
  50. package/dist/chunk-DU7W62N5.js +487 -0
  51. package/dist/chunk-DZAQBW35.js +751 -0
  52. package/dist/chunk-EB6FPQUP.js +316 -0
  53. package/dist/chunk-EMS2SK26.js +376 -0
  54. package/dist/chunk-ERLBPDGU.js +510 -0
  55. package/dist/chunk-EVCVDTXE.js +732 -0
  56. package/dist/chunk-FCIIHT24.js +384 -0
  57. package/dist/chunk-FFUN5D66.js +97 -0
  58. package/dist/chunk-FITOLXSX.js +714 -0
  59. package/dist/chunk-FMDSF3OV.js +68 -0
  60. package/dist/chunk-FNB3PNGF.js +410 -0
  61. package/dist/chunk-G2H74XJZ.js +2104 -0
  62. package/dist/chunk-GMR5MFHJ.js +339 -0
  63. package/dist/chunk-H6PI3KJT.js +305 -0
  64. package/dist/chunk-I46X5VUA.js +59 -0
  65. package/dist/chunk-I5IGB56C.js +255 -0
  66. package/dist/chunk-IH6ZMVQ5.js +3950 -0
  67. package/dist/chunk-IJZFN3HM.js +463 -0
  68. package/dist/chunk-IPWPWM6R.js +3079 -0
  69. package/dist/chunk-IYULMRBE.js +23 -0
  70. package/dist/chunk-IZMRON6C.js +167 -0
  71. package/dist/chunk-J5FIXQRT.js +813 -0
  72. package/dist/chunk-JED6ZDEE.js +73 -0
  73. package/dist/chunk-JEUJOX5X.js +136 -0
  74. package/dist/chunk-JM4LEPY3.js +436 -0
  75. package/dist/chunk-L3UHP6TD.js +101 -0
  76. package/dist/chunk-L66GEFB6.js +524 -0
  77. package/dist/chunk-LIOHW36Z.js +469 -0
  78. package/dist/chunk-LP7EC4MI.js +16 -0
  79. package/dist/chunk-MITI6NOL.js +548 -0
  80. package/dist/chunk-MO5YHHMQ.js +168 -0
  81. package/dist/chunk-MZSBFAPJ.js +885 -0
  82. package/dist/chunk-NNAAJVBU.js +9 -0
  83. package/dist/chunk-NOTA6TEI.js +47 -0
  84. package/dist/chunk-NURGB5Z4.js +335 -0
  85. package/dist/chunk-NX4EQS3U.js +1062 -0
  86. package/dist/chunk-NXMESY4J.js +1 -0
  87. package/dist/chunk-OJR3MQYV.js +1458 -0
  88. package/dist/chunk-OURHMODR.js +454 -0
  89. package/dist/chunk-P235SVAH.js +1057 -0
  90. package/dist/chunk-P4RH4OSP.js +1038 -0
  91. package/dist/chunk-P6T66CCZ.js +226 -0
  92. package/dist/chunk-PBAHEPLQ.js +223 -0
  93. package/dist/chunk-PBHE5UG6.js +1530 -0
  94. package/dist/chunk-PDKUANDZ.js +35 -0
  95. package/dist/chunk-PWIHZ6NJ.js +296 -0
  96. package/{src/c4/layout.ts → dist/chunk-QEBUY5NY.js} +384 -1140
  97. package/dist/chunk-QLCCJEJI.js +253 -0
  98. package/dist/chunk-QOOUC2J5.js +52 -0
  99. package/dist/chunk-QYTPPDAO.js +402 -0
  100. package/dist/chunk-R3XI2VC7.js +801 -0
  101. package/dist/chunk-RCERWOJR.js +154 -0
  102. package/dist/chunk-RJE5JTVK.js +362 -0
  103. package/dist/chunk-RTLBSQ3G.js +1155 -0
  104. package/dist/chunk-RUNNI6VE.js +448 -0
  105. package/dist/chunk-RVMRZAPB.js +354 -0
  106. package/dist/chunk-RYEGFMUO.js +955 -0
  107. package/dist/chunk-RZCF2VVM.js +528 -0
  108. package/dist/chunk-SML67VPV.js +1025 -0
  109. package/dist/chunk-SQ7IY53Q.js +44 -0
  110. package/dist/chunk-SQAG3UXH.js +161 -0
  111. package/dist/chunk-SRTU6HMQ.js +1851 -0
  112. package/dist/chunk-T2OE3YQB.js +550 -0
  113. package/dist/chunk-T3UBLACL.js +299 -0
  114. package/dist/chunk-TLVIHFRO.js +296 -0
  115. package/dist/chunk-TYS6CSS5.js +52 -0
  116. package/dist/chunk-U6EQI3U6.js +130 -0
  117. package/dist/chunk-UJ4FJLBF.js +86 -0
  118. package/dist/chunk-ULOEATBZ.js +347 -0
  119. package/dist/chunk-UNCCZ3NU.js +127 -0
  120. package/dist/chunk-USZW2HHU.js +197 -0
  121. package/dist/chunk-UWN33VNX.js +1610 -0
  122. package/dist/chunk-UZ7EZW3B.js +40 -0
  123. package/dist/chunk-VOKGH627.js +37 -0
  124. package/dist/chunk-WBRZJOEC.js +204 -0
  125. package/dist/chunk-WCSOJFU3.js +380 -0
  126. package/dist/chunk-WCT3NYCV.js +160 -0
  127. package/dist/chunk-WVAJFAIA.js +529 -0
  128. package/dist/chunk-X5LCYCL5.js +394 -0
  129. package/dist/chunk-XAKEUMEJ.js +1256 -0
  130. package/dist/chunk-Y2ZE3MSG.js +590 -0
  131. package/dist/chunk-Y3J7VR52.js +646 -0
  132. package/dist/chunk-Y5QGVTVC.js +33 -0
  133. package/dist/chunk-YAA6IID3.js +548 -0
  134. package/dist/chunk-YGJTDXVR.js +692 -0
  135. package/{src/utils/time-ticks.ts → dist/chunk-YRYKTYMQ.js} +45 -112
  136. package/dist/chunk-YYVTBZZC.js +61 -0
  137. package/dist/chunk-Z5CGSFJB.js +647 -0
  138. package/{src/gantt/calculator.ts → dist/chunk-Z72XRXD4.js} +236 -428
  139. package/dist/chunk-ZGR7ULFJ.js +978 -0
  140. package/dist/chunk-ZJEL4H2R.js +851 -0
  141. package/dist/chunk-ZO27FGJS.js +554 -0
  142. package/dist/collapse-CLPJD2RL.js +11 -0
  143. package/dist/collapse-SLINJQW6.js +9 -0
  144. package/dist/collapse-ZWUFFCK2.js +9 -0
  145. package/dist/compute-G55RG53N.js +8 -0
  146. package/dist/dgmo-router-DZCIDUO5.js +73 -0
  147. package/dist/dimensions-J3FHIMJ6.js +22 -0
  148. package/dist/element.js +1 -1
  149. package/dist/element.mjs +1 -1
  150. package/dist/flowchart-parser-ZNSKIBVR.js +21 -0
  151. package/dist/flowchart-renderer-ZAEOL4DX.js +35 -0
  152. package/dist/index.d.ts +3 -469
  153. package/dist/index.js +137 -69685
  154. package/dist/layout-46N4JJYK.js +17 -0
  155. package/dist/layout-5RA6QWR6.js +26 -0
  156. package/dist/layout-5T6RH5M6.js +14 -0
  157. package/dist/layout-7QXCNOVS.js +13 -0
  158. package/dist/layout-EE6GE46Y.js +17 -0
  159. package/dist/layout-G23F7LDH.js +9 -0
  160. package/dist/layout-HRBZPFCN.js +23 -0
  161. package/dist/layout-HWDSRX5E.js +20 -0
  162. package/dist/layout-HYZPWAK5.js +18 -0
  163. package/dist/layout-N76NR4ZO.js +19 -0
  164. package/dist/layout-OB3RI63S.js +14 -0
  165. package/dist/layout-S2QBYSK2.js +15 -0
  166. package/dist/layout-UM5F4DJB.js +15 -0
  167. package/dist/layout-search-OYV77HHS.js +1655 -0
  168. package/dist/load-data-EHDDZ5ZS.js +8 -0
  169. package/dist/palettes-PRJ2RI6D.js +56 -0
  170. package/dist/parser-2MFP2H2E.js +11 -0
  171. package/dist/parser-3STE62GB.js +21 -0
  172. package/dist/parser-4FL2CMDG.js +18 -0
  173. package/dist/parser-4OGOBJJ4.js +13 -0
  174. package/dist/parser-6BTRLKRZ.js +15 -0
  175. package/dist/parser-AQETEVRW.js +21 -0
  176. package/dist/parser-CFZD5IBL.js +12 -0
  177. package/dist/parser-FUSKFGZN.js +16 -0
  178. package/dist/parser-I6KXEYFK.js +13 -0
  179. package/dist/parser-IXSZZQHY.js +18 -0
  180. package/dist/parser-JAL2HD4I.js +13 -0
  181. package/dist/parser-KNSQSKQO.js +20 -0
  182. package/dist/parser-N5O4IHUN.js +13 -0
  183. package/dist/parser-NGU3ETO6.js +16 -0
  184. package/dist/parser-NRAI6O25.js +19 -0
  185. package/dist/parser-O5J4VBII.js +11 -0
  186. package/dist/parser-OV7NOBW6.js +21 -0
  187. package/dist/parser-PQ3POX45.js +23 -0
  188. package/dist/parser-TFZFBVWN.js +11 -0
  189. package/dist/parser-TRTHDFPP.js +18 -0
  190. package/dist/parser-VQP2UJ6W.js +11 -0
  191. package/dist/parser-XDVELHRK.js +13 -0
  192. package/dist/parser-XKRP7QKP.js +11 -0
  193. package/dist/parser-Y6WTBU76.js +14 -0
  194. package/dist/parser-ZSDPZYQP.js +12 -0
  195. package/dist/renderer-2XQQQ6QR.js +28 -0
  196. package/dist/renderer-5NDVNDAZ.js +26 -0
  197. package/dist/renderer-6EEZHMH4.js +26 -0
  198. package/dist/renderer-6W5462RB.js +43 -0
  199. package/dist/renderer-7MVLWWQD.js +22 -0
  200. package/dist/renderer-AWWAF6XD.js +33 -0
  201. package/dist/renderer-BYCNMBF7.js +34 -0
  202. package/dist/renderer-CLJHQPBJ.js +29 -0
  203. package/dist/renderer-GHPZMFU2.js +15 -0
  204. package/dist/renderer-JGBKUCZD.js +16 -0
  205. package/dist/renderer-KQB7UGDS.js +19 -0
  206. package/dist/renderer-PGX2TKVS.js +24 -0
  207. package/dist/renderer-QIWVHWZO.js +15 -0
  208. package/dist/renderer-RPOA5YPZ.js +35 -0
  209. package/dist/renderer-SMIBCRVB.js +24 -0
  210. package/dist/renderer-T7YKC5VP.js +28 -0
  211. package/dist/renderer-TOCOVLHS.js +37 -0
  212. package/dist/renderer-UWA5XS74.js +39 -0
  213. package/dist/renderer-VACVQYML.js +25 -0
  214. package/dist/renderer-W4M6QLIJ.js +37 -0
  215. package/dist/renderer-WZRREQ2P.js +23 -0
  216. package/dist/renderer-YY2OSF6E.js +27 -0
  217. package/dist/renderer-Z7I3W2PP.js +24 -0
  218. package/dist/renderer-ZGNTUWC4.js +22 -0
  219. package/dist/renderer-ZTR3DER3.js +19 -0
  220. package/dist/renderer-radial-C32GPJQ7.js +21 -0
  221. package/dist/resolver-NOAA7ID7.js +13 -0
  222. package/dist/state-collapse-HCGD6IVJ.js +8 -0
  223. package/dist/state-parser-Z2V23ATR.js +18 -0
  224. package/dist/state-renderer-RFYHSP4K.js +34 -0
  225. package/dist/themes-1-CuKpeH.d.ts +908 -0
  226. package/package.json +19 -70
  227. package/dist/advanced.cjs +0 -71648
  228. package/dist/advanced.d.cts +0 -6571
  229. package/dist/auto.cjs +0 -70648
  230. package/dist/auto.d.cts +0 -54
  231. package/dist/block.cjs +0 -70208
  232. package/dist/block.d.cts +0 -115
  233. package/dist/editor.d.cts +0 -26
  234. package/dist/element.cjs +0 -70530
  235. package/dist/element.d.cts +0 -62
  236. package/dist/highlight.cjs +0 -852
  237. package/dist/highlight.d.cts +0 -49
  238. package/dist/index.cjs +0 -70491
  239. package/dist/index.d.cts +0 -626
  240. package/dist/pert.cjs +0 -325
  241. package/dist/pert.d.cts +0 -559
  242. package/src/advanced.ts +0 -873
  243. package/src/arc/parser.ts +0 -15
  244. package/src/arc/renderer.ts +0 -633
  245. package/src/auto/index.ts +0 -621
  246. package/src/auto/shared.ts +0 -370
  247. package/src/auto/styles.ts +0 -73
  248. package/src/block/layout.ts +0 -198
  249. package/src/block/renderer.ts +0 -484
  250. package/src/block/types.ts +0 -67
  251. package/src/boxes-and-lines/collapse.ts +0 -96
  252. package/src/boxes-and-lines/focus.ts +0 -257
  253. package/src/boxes-and-lines/label-placement.ts +0 -339
  254. package/src/boxes-and-lines/layout-grouped.ts +0 -912
  255. package/src/boxes-and-lines/layout-layered.ts +0 -722
  256. package/src/boxes-and-lines/layout-search.ts +0 -1678
  257. package/src/boxes-and-lines/layout.ts +0 -398
  258. package/src/boxes-and-lines/parser.ts +0 -1181
  259. package/src/boxes-and-lines/renderer.ts +0 -1465
  260. package/src/boxes-and-lines/types.ts +0 -66
  261. package/src/c4/parser.ts +0 -1158
  262. package/src/c4/renderer.ts +0 -2008
  263. package/src/c4/types.ts +0 -89
  264. package/src/chart-type-registry.ts +0 -529
  265. package/src/chart-types.ts +0 -225
  266. package/src/chart.ts +0 -685
  267. package/src/charts-d3/bar.ts +0 -338
  268. package/src/charts-d3/chord.ts +0 -140
  269. package/src/charts-d3/function.ts +0 -147
  270. package/src/charts-d3/funnel.ts +0 -104
  271. package/src/charts-d3/heatmap.ts +0 -145
  272. package/src/charts-d3/index.ts +0 -337
  273. package/src/charts-d3/interactions.ts +0 -477
  274. package/src/charts-d3/line.ts +0 -344
  275. package/src/charts-d3/mount.ts +0 -151
  276. package/src/charts-d3/pie.ts +0 -117
  277. package/src/charts-d3/polar.ts +0 -89
  278. package/src/charts-d3/radar.ts +0 -0
  279. package/src/charts-d3/sankey.ts +0 -0
  280. package/src/charts-d3/scatter.ts +0 -185
  281. package/src/charts-d3/shared.ts +0 -208
  282. package/src/class/layout.ts +0 -326
  283. package/src/class/parser.ts +0 -635
  284. package/src/class/renderer.ts +0 -793
  285. package/src/class/types.ts +0 -58
  286. package/src/cli-banner.ts +0 -106
  287. package/src/cli.ts +0 -1080
  288. package/src/colors-diagnostics.ts +0 -35
  289. package/src/colors.ts +0 -379
  290. package/src/completion-types.ts +0 -27
  291. package/src/completion.ts +0 -2668
  292. package/src/cycle/layout.ts +0 -1026
  293. package/src/cycle/parser.ts +0 -387
  294. package/src/cycle/renderer.ts +0 -653
  295. package/src/cycle/types.ts +0 -101
  296. package/src/d3.ts +0 -1434
  297. package/src/data-chart-parser.ts +0 -1007
  298. package/src/dgmo-router.ts +0 -296
  299. package/src/diagnostics-registry.ts +0 -108
  300. package/src/diagnostics.ts +0 -0
  301. package/src/dimensions.ts +0 -20
  302. package/src/directives-registry.ts +0 -396
  303. package/src/editor/dgmo.grammar +0 -76
  304. package/src/editor/dgmo.grammar.d.ts +0 -2
  305. package/src/editor/dgmo.grammar.js +0 -18
  306. package/src/editor/dgmo.grammar.terms.d.ts +0 -5
  307. package/src/editor/dgmo.grammar.terms.js +0 -35
  308. package/src/editor/highlight-api.ts +0 -596
  309. package/src/editor/highlight.ts +0 -36
  310. package/src/editor/index.ts +0 -27
  311. package/src/editor/keywords.ts +0 -128
  312. package/src/editor/tokens.ts +0 -30
  313. package/src/element/index.ts +0 -432
  314. package/src/embed/css.ts +0 -312
  315. package/src/embed/escape.ts +0 -15
  316. package/src/embed/index.ts +0 -280
  317. package/src/er/classify.ts +0 -228
  318. package/src/er/layout.ts +0 -530
  319. package/src/er/parser.ts +0 -750
  320. package/src/er/renderer.ts +0 -725
  321. package/src/er/types.ts +0 -52
  322. package/src/error-card.ts +0 -269
  323. package/src/event-line/diagnostics.ts +0 -117
  324. package/src/event-line/parser.ts +0 -643
  325. package/src/event-line/renderer.ts +0 -1742
  326. package/src/event-line/types.ts +0 -74
  327. package/src/fonts.ts +0 -3
  328. package/src/gantt/parser.ts +0 -1641
  329. package/src/gantt/renderer.ts +0 -3787
  330. package/src/gantt/resolver.ts +0 -172
  331. package/src/gantt/types.ts +0 -206
  332. package/src/graph/diagnostics.ts +0 -64
  333. package/src/graph/edge-spline.ts +0 -29
  334. package/src/graph/flowchart-parser.ts +0 -759
  335. package/src/graph/flowchart-renderer.ts +0 -817
  336. package/src/graph/layout.ts +0 -472
  337. package/src/graph/notes.ts +0 -21
  338. package/src/graph/state-collapse.ts +0 -78
  339. package/src/graph/state-parser.ts +0 -574
  340. package/src/graph/state-renderer.ts +0 -653
  341. package/src/graph/types.ts +0 -65
  342. package/src/index.ts +0 -261
  343. package/src/infra/compute.ts +0 -1385
  344. package/src/infra/layout.ts +0 -888
  345. package/src/infra/parser.ts +0 -1234
  346. package/src/infra/renderer.ts +0 -2534
  347. package/src/infra/roles.ts +0 -75
  348. package/src/infra/types.ts +0 -216
  349. package/src/infra/validation.ts +0 -201
  350. package/src/journey-map/layout.ts +0 -490
  351. package/src/journey-map/parser.ts +0 -557
  352. package/src/journey-map/renderer.ts +0 -1580
  353. package/src/journey-map/types.ts +0 -47
  354. package/src/kanban/mutations.ts +0 -175
  355. package/src/kanban/parser.ts +0 -509
  356. package/src/kanban/renderer.ts +0 -1449
  357. package/src/kanban/types.ts +0 -39
  358. package/src/label-layout.ts +0 -368
  359. package/src/map/colorize.ts +0 -54
  360. package/src/map/completion.ts +0 -316
  361. package/src/map/context-labels.ts +0 -609
  362. package/src/map/data/PROVENANCE.json +0 -1
  363. package/src/map/data/README.md +0 -40
  364. package/src/map/data/airport-collisions.json +0 -1
  365. package/src/map/data/airports.json +0 -1
  366. package/src/map/data/gazetteer.json +0 -1
  367. package/src/map/data/lakes.json +0 -1
  368. package/src/map/data/mountain-ranges.json +0 -1
  369. package/src/map/data/na-lakes.json +0 -1
  370. package/src/map/data/na-land.json +0 -1
  371. package/src/map/data/region-names.json +0 -1
  372. package/src/map/data/rivers.json +0 -1
  373. package/src/map/data/types.ts +0 -121
  374. package/src/map/data/us-states.json +0 -1
  375. package/src/map/data/water-bodies.json +0 -1
  376. package/src/map/data/world-coarse.json +0 -1
  377. package/src/map/data/world-detail.json +0 -1
  378. package/src/map/diagnostics.ts +0 -134
  379. package/src/map/dimensions.ts +0 -150
  380. package/src/map/geo-query.ts +0 -295
  381. package/src/map/geo.ts +0 -438
  382. package/src/map/invert.ts +0 -111
  383. package/src/map/layout.ts +0 -5069
  384. package/src/map/legend-band.ts +0 -127
  385. package/src/map/load-data.ts +0 -186
  386. package/src/map/parser.ts +0 -783
  387. package/src/map/renderer.ts +0 -1445
  388. package/src/map/resolved-types.ts +0 -160
  389. package/src/map/resolver.ts +0 -1146
  390. package/src/map/types.ts +0 -194
  391. package/src/mindmap/collapse.ts +0 -67
  392. package/src/mindmap/layout.ts +0 -649
  393. package/src/mindmap/parser.ts +0 -430
  394. package/src/mindmap/renderer.ts +0 -637
  395. package/src/mindmap/text-wrap.ts +0 -218
  396. package/src/mindmap/types.ts +0 -56
  397. package/src/org/collapse.ts +0 -151
  398. package/src/org/layout.ts +0 -1262
  399. package/src/org/parser.ts +0 -519
  400. package/src/org/renderer.ts +0 -866
  401. package/src/org/resolver.ts +0 -636
  402. package/src/palettes/atlas.ts +0 -77
  403. package/src/palettes/blueprint.ts +0 -73
  404. package/src/palettes/catppuccin.ts +0 -84
  405. package/src/palettes/color-utils.ts +0 -443
  406. package/src/palettes/index.ts +0 -67
  407. package/src/palettes/nord.ts +0 -67
  408. package/src/palettes/registry.ts +0 -114
  409. package/src/palettes/slate.ts +0 -73
  410. package/src/palettes/tidewater.ts +0 -73
  411. package/src/palettes/tokyo-night.ts +0 -86
  412. package/src/palettes/types.ts +0 -88
  413. package/src/pert/analyzer.ts +0 -1183
  414. package/src/pert/diagnostics.ts +0 -110
  415. package/src/pert/index.ts +0 -43
  416. package/src/pert/internal.ts +0 -252
  417. package/src/pert/layout.ts +0 -971
  418. package/src/pert/monte-carlo.ts +0 -446
  419. package/src/pert/parser.ts +0 -1606
  420. package/src/pert/renderer.ts +0 -4009
  421. package/src/pert/share-normalize.ts +0 -62
  422. package/src/pert/types.ts +0 -604
  423. package/src/pyramid/parser.ts +0 -185
  424. package/src/pyramid/renderer.ts +0 -768
  425. package/src/pyramid/types.ts +0 -28
  426. package/src/quadrant/parser.ts +0 -18
  427. package/src/quadrant/renderer.ts +0 -638
  428. package/src/raci/diagnostics.ts +0 -213
  429. package/src/raci/index.ts +0 -23
  430. package/src/raci/mutations.ts +0 -321
  431. package/src/raci/parser.ts +0 -699
  432. package/src/raci/renderer.ts +0 -1627
  433. package/src/raci/types.ts +0 -82
  434. package/src/raci/variants.ts +0 -320
  435. package/src/render.ts +0 -268
  436. package/src/ring/parser.ts +0 -212
  437. package/src/ring/renderer.ts +0 -490
  438. package/src/ring/types.ts +0 -27
  439. package/src/sequence/collapse.ts +0 -174
  440. package/src/sequence/parser.ts +0 -1596
  441. package/src/sequence/participant-inference.ts +0 -152
  442. package/src/sequence/renderer.ts +0 -3168
  443. package/src/sequence/tag-resolution.ts +0 -164
  444. package/src/sharing.ts +0 -211
  445. package/src/sitemap/collapse.ts +0 -100
  446. package/src/sitemap/layout.ts +0 -925
  447. package/src/sitemap/parser.ts +0 -755
  448. package/src/sitemap/renderer.ts +0 -828
  449. package/src/sitemap/types.ts +0 -42
  450. package/src/slope/parser.ts +0 -18
  451. package/src/slope/renderer.ts +0 -378
  452. package/src/swimlane/diagnostics.ts +0 -94
  453. package/src/swimlane/layout.ts +0 -597
  454. package/src/swimlane/parser.ts +0 -613
  455. package/src/swimlane/renderer.ts +0 -681
  456. package/src/swimlane/types.ts +0 -151
  457. package/src/tech-radar/interactive.ts +0 -1129
  458. package/src/tech-radar/layout.ts +0 -197
  459. package/src/tech-radar/parser.ts +0 -436
  460. package/src/tech-radar/renderer.ts +0 -1239
  461. package/src/tech-radar/shared.ts +0 -151
  462. package/src/tech-radar/types.ts +0 -86
  463. package/src/themes.ts +0 -22
  464. package/src/timeline/parser.ts +0 -472
  465. package/src/timeline/renderer.ts +0 -3024
  466. package/src/timeline/types.ts +0 -33
  467. package/src/timeline/viz-parser.ts +0 -21
  468. package/src/treemap/diagnostics.ts +0 -62
  469. package/src/treemap/layout-radial.ts +0 -233
  470. package/src/treemap/layout.ts +0 -189
  471. package/src/treemap/parser.ts +0 -463
  472. package/src/treemap/renderer-radial.ts +0 -438
  473. package/src/treemap/renderer.ts +0 -572
  474. package/src/treemap/treemap-shared.ts +0 -309
  475. package/src/treemap/types.ts +0 -60
  476. package/src/utils/arrow-markers.ts +0 -51
  477. package/src/utils/arrows-diagnostics.ts +0 -62
  478. package/src/utils/arrows.ts +0 -227
  479. package/src/utils/brand.ts +0 -61
  480. package/src/utils/card.ts +0 -183
  481. package/src/utils/collapse-engine/tree-edges.ts +0 -115
  482. package/src/utils/collapse-engine/tree.ts +0 -117
  483. package/src/utils/d3-helpers.ts +0 -219
  484. package/src/utils/d3-types.ts +0 -9
  485. package/src/utils/description-helpers.ts +0 -38
  486. package/src/utils/duration.ts +0 -312
  487. package/src/utils/export-container.ts +0 -41
  488. package/src/utils/expr-eval.ts +0 -27
  489. package/src/utils/fit-canvas.ts +0 -64
  490. package/src/utils/hover-styles.ts +0 -673
  491. package/src/utils/inline-markdown.ts +0 -96
  492. package/src/utils/legend-constants.ts +0 -48
  493. package/src/utils/legend-d3.ts +0 -618
  494. package/src/utils/legend-integration.ts +0 -107
  495. package/src/utils/legend-layout.ts +0 -776
  496. package/src/utils/legend-svg.ts +0 -214
  497. package/src/utils/legend-types.ts +0 -272
  498. package/src/utils/name-normalize.ts +0 -163
  499. package/src/utils/note-box/constants.ts +0 -25
  500. package/src/utils/note-box/index.ts +0 -11
  501. package/src/utils/note-box/metrics.ts +0 -90
  502. package/src/utils/note-box/svg.ts +0 -331
  503. package/src/utils/notes/bounds.ts +0 -30
  504. package/src/utils/notes/build.ts +0 -131
  505. package/src/utils/notes/index.ts +0 -18
  506. package/src/utils/notes/model.ts +0 -19
  507. package/src/utils/notes/parse.ts +0 -131
  508. package/src/utils/notes/place.ts +0 -177
  509. package/src/utils/notes/resolve.ts +0 -88
  510. package/src/utils/number-format.ts +0 -36
  511. package/src/utils/parsing.ts +0 -953
  512. package/src/utils/reserved-key-registry.ts +0 -239
  513. package/src/utils/safe-href.ts +0 -38
  514. package/src/utils/scaling.ts +0 -97
  515. package/src/utils/svg-embed.ts +0 -251
  516. package/src/utils/tag-groups.ts +0 -607
  517. package/src/utils/text-measure.ts +0 -122
  518. package/src/utils/title-constants.ts +0 -24
  519. package/src/utils/visual-conventions.ts +0 -61
  520. package/src/utils/wrapped-desc.ts +0 -87
  521. package/src/venn/parser.ts +0 -18
  522. package/src/venn/renderer.ts +0 -1047
  523. package/src/version-control/diagnostics.ts +0 -67
  524. package/src/version-control/parser.ts +0 -544
  525. package/src/version-control/renderer.ts +0 -724
  526. package/src/version-control/types.ts +0 -100
  527. package/src/visualizations/parse.ts +0 -1560
  528. package/src/visualizations/types.ts +0 -262
  529. package/src/wireframe/layout.ts +0 -479
  530. package/src/wireframe/parser.ts +0 -1114
  531. package/src/wireframe/renderer.ts +0 -1318
  532. package/src/wireframe/types.ts +0 -110
  533. package/src/wordcloud/parser.ts +0 -18
  534. package/src/wordcloud/renderer.ts +0 -357
package/src/org/layout.ts DELETED
@@ -1,1262 +0,0 @@
1
- // ============================================================
2
- // Org Chart Tree Layout Engine (d3-hierarchy)
3
- // ============================================================
4
-
5
- import { tagAttrKey } from '../utils/tag-groups';
6
- import { hierarchy, tree } from 'd3-hierarchy';
7
- import type { ParsedOrg, OrgNode } from './parser';
8
- import type { Writable } from '../utils/brand';
9
- import type { TagGroup } from '../utils/tag-groups';
10
- import { resolveTagColor, injectDefaultTagMetadata } from '../utils/tag-groups';
11
- import {
12
- LEGEND_PILL_FONT_SIZE,
13
- LEGEND_ENTRY_FONT_SIZE,
14
- LEGEND_HEIGHT,
15
- LEGEND_PILL_PAD,
16
- LEGEND_CAPSULE_PAD,
17
- LEGEND_DOT_R,
18
- LEGEND_ENTRY_DOT_GAP,
19
- LEGEND_ENTRY_TRAIL,
20
- LEGEND_GROUP_GAP,
21
- LEGEND_EYE_SIZE,
22
- LEGEND_EYE_GAP,
23
- measureLegendText,
24
- } from '../utils/legend-constants';
25
- import { measureText } from '../utils/text-measure';
26
-
27
- // ============================================================
28
- // Types
29
- // ============================================================
30
-
31
- export interface OrgLayoutNode {
32
- readonly id: string;
33
- readonly label: string;
34
- readonly metadata: Readonly<Record<string, string>>;
35
- /** Original (unfiltered) metadata — used for tag-based hover dimming even when the group is hidden */
36
- readonly tagMetadata: Readonly<Record<string, string>>;
37
- readonly isContainer: boolean;
38
- readonly lineNumber: number;
39
- readonly color?: string;
40
- readonly x: number;
41
- readonly y: number;
42
- readonly width: number;
43
- readonly height: number;
44
- /** Count of hidden descendants when this node is collapsed */
45
- readonly hiddenCount?: number;
46
- /** True if node has children (expanded or collapsed) — drives toggle UI */
47
- readonly hasChildren?: boolean;
48
- }
49
-
50
- export interface OrgLayoutEdge {
51
- readonly sourceId: string;
52
- readonly targetId: string;
53
- readonly points: ReadonlyArray<{ readonly x: number; readonly y: number }>;
54
- }
55
-
56
- export interface OrgContainerBounds {
57
- readonly nodeId: string;
58
- readonly label: string;
59
- readonly lineNumber: number;
60
- readonly color?: string;
61
- readonly metadata: Readonly<Record<string, string>>;
62
- /** Original (unfiltered) metadata — used for tag-based hover dimming even when the group is hidden */
63
- readonly tagMetadata: Readonly<Record<string, string>>;
64
- readonly x: number;
65
- readonly y: number;
66
- readonly width: number;
67
- readonly height: number;
68
- readonly labelHeight: number;
69
- /** Count of hidden descendants when this container is collapsed */
70
- readonly hiddenCount?: number;
71
- /** True if container has children (expanded or collapsed) — drives toggle UI */
72
- readonly hasChildren?: boolean;
73
- }
74
-
75
- export interface OrgLegendEntry {
76
- readonly value: string;
77
- readonly color: string;
78
- }
79
-
80
- export interface OrgLegendGroup {
81
- readonly name: string;
82
- readonly alias?: string;
83
- readonly entries: readonly OrgLegendEntry[];
84
- readonly x: number;
85
- readonly y: number;
86
- readonly width: number;
87
- readonly height: number;
88
- readonly minifiedWidth: number;
89
- readonly minifiedHeight: number;
90
- }
91
-
92
- export interface OrgLayoutResult {
93
- readonly nodes: readonly OrgLayoutNode[];
94
- readonly edges: readonly OrgLayoutEdge[];
95
- readonly containers: readonly OrgContainerBounds[];
96
- readonly legend: readonly OrgLegendGroup[];
97
- readonly width: number;
98
- readonly height: number;
99
- }
100
-
101
- // ============================================================
102
- // Constants
103
- // ============================================================
104
-
105
- // Card text font sizes — MUST match the renderer (LABEL_FONT_SIZE / META_FONT_SIZE)
106
- // so node sizing measures text at the exact size it is drawn.
107
- const LABEL_FONT_SIZE = 13;
108
- const META_FONT_SIZE = 11;
109
- const META_LINE_HEIGHT = 16;
110
- const HEADER_HEIGHT = 28;
111
- const SEPARATOR_GAP = 6;
112
- const CARD_H_PAD = 20;
113
- const CARD_V_PAD = 10;
114
- const MIN_CARD_WIDTH = 140;
115
- const H_GAP = 30;
116
- const V_GAP = 50;
117
- const MARGIN = 40;
118
- const CONTAINER_PAD_X = 24;
119
- const CONTAINER_PAD_BOTTOM = 24;
120
- const CONTAINER_LABEL_HEIGHT = 28;
121
- const CONTAINER_META_LINE_HEIGHT = 16;
122
- const STACK_V_GAP = 20;
123
-
124
- // Legend (kanban-style pills)
125
-
126
- // ============================================================
127
- // Helpers
128
- // ============================================================
129
-
130
- /** Count all non-container descendants recursively, including hidden (collapsed) ones. */
131
- function countDescendantNodes(
132
- node: OrgNode,
133
- hiddenCounts?: Map<string, number>
134
- ): number {
135
- let count = 0;
136
- for (const child of node.children) {
137
- count +=
138
- (child.isContainer ? 0 : 1) + countDescendantNodes(child, hiddenCounts);
139
- const hc = hiddenCounts?.get(child.id);
140
- if (hc) count += hc;
141
- }
142
- return count;
143
- }
144
-
145
- // ============================================================
146
- // Card Sizing
147
- // ============================================================
148
-
149
- function filterMetadata(
150
- metadata: Record<string, string>,
151
- hiddenAttributes?: Set<string>
152
- ): Record<string, string> {
153
- if (!hiddenAttributes || hiddenAttributes.size === 0) return metadata;
154
- const filtered: Record<string, string> = {};
155
- for (const [key, value] of Object.entries(metadata)) {
156
- if (!hiddenAttributes.has(key)) {
157
- filtered[key] = value;
158
- }
159
- }
160
- return filtered;
161
- }
162
-
163
- function computeCardWidth(label: string, meta: Record<string, string>): number {
164
- // Label is drawn bold at LABEL_FONT_SIZE; meta rows at META_FONT_SIZE.
165
- let maxTextWidth = measureText(label, LABEL_FONT_SIZE);
166
-
167
- for (const [key, value] of Object.entries(meta)) {
168
- const lineWidth = measureText(`${key}: ${value}`, META_FONT_SIZE);
169
- if (lineWidth > maxTextWidth) maxTextWidth = lineWidth;
170
- }
171
-
172
- return Math.max(MIN_CARD_WIDTH, Math.ceil(maxTextWidth) + CARD_H_PAD * 2);
173
- }
174
-
175
- function computeCardHeight(meta: Record<string, string>): number {
176
- const metaCount = Object.keys(meta).length;
177
- if (metaCount === 0) return HEADER_HEIGHT + CARD_V_PAD;
178
- return (
179
- HEADER_HEIGHT + SEPARATOR_GAP + metaCount * META_LINE_HEIGHT + CARD_V_PAD
180
- );
181
- }
182
-
183
- // ============================================================
184
- // Tag Group Color Resolution
185
- // ============================================================
186
-
187
- function resolveNodeColor(
188
- node: OrgNode,
189
- tagGroups: readonly TagGroup[],
190
- activeGroupName: string | null
191
- ): string | undefined {
192
- // Explicit inline (color) always wins — handled before tag resolution
193
- if (node.color) return node.color;
194
- return resolveTagColor(
195
- node.metadata,
196
- [...tagGroups],
197
- activeGroupName,
198
- node.isContainer
199
- );
200
- }
201
-
202
- // ============================================================
203
- // Hierarchy Helpers
204
- // ============================================================
205
-
206
- interface TreeNode {
207
- orgNode: OrgNode;
208
- children: TreeNode[];
209
- width: number;
210
- height: number;
211
- }
212
-
213
- function buildTreeNodes(
214
- nodes: readonly OrgNode[],
215
- hiddenCounts?: Map<string, number>,
216
- hiddenAttributes?: Set<string>,
217
- subNodeLabel?: string,
218
- showSubNodeCount?: boolean
219
- ): TreeNode[] {
220
- return nodes.map((orgNode) => {
221
- const meta = filterMetadata(orgNode.metadata, hiddenAttributes);
222
- const hc = hiddenCounts?.get(orgNode.id);
223
- if (!orgNode.isContainer && showSubNodeCount && !(hc != null && hc > 0)) {
224
- const count = countDescendantNodes(orgNode, hiddenCounts);
225
- if (count > 0) {
226
- meta[subNodeLabel ?? 'Sub-node Count'] = String(count);
227
- }
228
- }
229
- return {
230
- orgNode,
231
- children: buildTreeNodes(
232
- orgNode.children,
233
- hiddenCounts,
234
- hiddenAttributes,
235
- subNodeLabel,
236
- showSubNodeCount
237
- ),
238
- width: computeCardWidth(orgNode.label, meta),
239
- height: computeCardHeight(meta),
240
- };
241
- });
242
- }
243
-
244
- /**
245
- * Count total descendants (children + grandchildren + ...) of a TreeNode.
246
- */
247
- function countDescendants(node: TreeNode): number {
248
- let count = 0;
249
- for (const child of node.children) {
250
- count += 1 + countDescendants(child);
251
- }
252
- return count;
253
- }
254
-
255
- /**
256
- * Recursively reorder children so subtrees with the most descendants
257
- * occupy center positions. Produces a balanced, symmetrical layout.
258
- * Skips nodes with ≤2 children (no meaningful center to target).
259
- */
260
- function centerHeavyChildren(node: TreeNode): void {
261
- for (const child of node.children) {
262
- centerHeavyChildren(child);
263
- }
264
- if (node.children.length <= 2) return;
265
-
266
- const weighted = node.children
267
- .map((child) => ({ child, weight: countDescendants(child) }))
268
- .sort((a, b) => b.weight - a.weight);
269
-
270
- const result: TreeNode[] = new Array(weighted.length);
271
- const mid = Math.floor((weighted.length - 1) / 2);
272
- let left = mid;
273
- let right = mid;
274
-
275
- for (let i = 0; i < weighted.length; i++) {
276
- // In-bounds by loop guard.
277
- const w = weighted[i]!;
278
- if (i === 0) {
279
- result[mid] = w.child;
280
- } else if (i % 2 === 1) {
281
- right++;
282
- result[right] = w.child;
283
- } else {
284
- left--;
285
- result[left] = w.child;
286
- }
287
- }
288
-
289
- node.children = result;
290
- }
291
-
292
- // ============================================================
293
- // Layout
294
- // ============================================================
295
-
296
- function computeLegendGroups(
297
- tagGroups: readonly TagGroup[],
298
- showEyeIcons: boolean,
299
- usedValuesByGroup?: Map<string, Set<string>>
300
- ): Writable<OrgLegendGroup>[] {
301
- const groups: Writable<OrgLegendGroup>[] = [];
302
-
303
- for (const group of tagGroups) {
304
- if (group.entries.length === 0) continue;
305
-
306
- // Filter entries to only values actually used by nodes (if provided)
307
- const usedValues = usedValuesByGroup?.get(tagAttrKey(group.name));
308
- const visibleEntries = usedValues
309
- ? group.entries.filter((e) => usedValues.has(e.value.toLowerCase()))
310
- : group.entries;
311
- if (visibleEntries.length === 0) continue;
312
-
313
- // Pill label shows just the group name (alias is for DSL shorthand only)
314
- const pillWidth =
315
- measureLegendText(group.name, LEGEND_PILL_FONT_SIZE) + LEGEND_PILL_PAD;
316
- const minPillWidth = pillWidth;
317
-
318
- // Capsule: pad + pill + gap + entries + pad
319
- let entriesWidth = 0;
320
- for (const entry of visibleEntries) {
321
- entriesWidth +=
322
- LEGEND_DOT_R * 2 +
323
- LEGEND_ENTRY_DOT_GAP +
324
- measureLegendText(entry.value, LEGEND_ENTRY_FONT_SIZE) +
325
- LEGEND_ENTRY_TRAIL;
326
- }
327
- const eyeSpace = showEyeIcons ? LEGEND_EYE_SIZE + LEGEND_EYE_GAP : 0;
328
- const capsuleWidth =
329
- LEGEND_CAPSULE_PAD * 2 + pillWidth + 4 + eyeSpace + entriesWidth;
330
-
331
- groups.push({
332
- name: group.name,
333
- ...(group.alias !== undefined && { alias: group.alias }),
334
- entries: visibleEntries.map((e) => ({
335
- value: e.value,
336
- color: e.color,
337
- })),
338
- x: 0,
339
- y: 0,
340
- width: capsuleWidth,
341
- height: LEGEND_HEIGHT,
342
- minifiedWidth: minPillWidth,
343
- minifiedHeight: LEGEND_HEIGHT,
344
- });
345
- }
346
-
347
- return groups;
348
- }
349
-
350
- /**
351
- * Inject default tag group values into non-container node metadata.
352
- * Delegates to shared `injectDefaultTagMetadata` with org-specific skip logic.
353
- */
354
- function injectDefaultMetadata(
355
- roots: readonly OrgNode[],
356
- tagGroups: readonly TagGroup[]
357
- ): void {
358
- // Flatten all nodes (recursive) for the shared utility
359
- const allNodes: OrgNode[] = [];
360
- const collect = (node: OrgNode) => {
361
- allNodes.push(node);
362
- for (const child of node.children) collect(child);
363
- };
364
- for (const root of roots) collect(root);
365
-
366
- injectDefaultTagMetadata(
367
- allNodes,
368
- tagGroups,
369
- (entity) => (entity as OrgNode).isContainer
370
- );
371
- }
372
-
373
- export function layoutOrg(
374
- parsed: ParsedOrg,
375
- hiddenCounts?: Map<string, number>,
376
- activeTagGroup?: string | null,
377
- hiddenAttributes?: Set<string>,
378
- expandAllLegend?: boolean
379
- ): OrgLayoutResult {
380
- if (parsed.roots.length === 0) {
381
- // Legend-only: compute and position legend groups even without nodes
382
- const showEyeIcons = hiddenAttributes !== undefined;
383
- const legendGroups = computeLegendGroups(parsed.tagGroups, showEyeIcons);
384
- if (legendGroups.length === 0) {
385
- return {
386
- nodes: [],
387
- edges: [],
388
- containers: [],
389
- legend: [],
390
- width: 0,
391
- height: 0,
392
- };
393
- }
394
-
395
- // Legend-only mode: stack groups vertically, all expanded
396
- let cy = MARGIN;
397
- let maxWidth = 0;
398
- for (const g of legendGroups) {
399
- g.x = MARGIN;
400
- g.y = cy;
401
- cy += LEGEND_HEIGHT + LEGEND_GROUP_GAP;
402
- if (g.width > maxWidth) maxWidth = g.width;
403
- }
404
- return {
405
- nodes: [],
406
- edges: [],
407
- containers: [],
408
- legend: legendGroups,
409
- width: maxWidth + MARGIN * 2,
410
- height: cy - LEGEND_GROUP_GAP + MARGIN,
411
- };
412
- }
413
-
414
- // Inject default tag group values into node metadata for display.
415
- // Must happen before buildTreeNodes so card sizing accounts for extra rows.
416
- injectDefaultMetadata(parsed.roots, parsed.tagGroups);
417
-
418
- // Build tree structure
419
- const subNodeLabel = parsed.options['sub-node-label'] ?? undefined;
420
- const showSubNodeCount = ['yes', 'on'].includes(
421
- parsed.options['show-sub-node-count']?.toLowerCase() ?? ''
422
- );
423
- const treeNodes = buildTreeNodes(
424
- parsed.roots,
425
- hiddenCounts,
426
- hiddenAttributes,
427
- subNodeLabel,
428
- showSubNodeCount
429
- );
430
-
431
- // Single root or virtual root for multiple roots
432
- let root: TreeNode;
433
- if (treeNodes.length === 1) {
434
- // In-bounds by length === 1 guard.
435
- root = treeNodes[0]!;
436
- } else {
437
- root = {
438
- orgNode: {
439
- id: '__virtual_root__',
440
- label: '',
441
- metadata: {},
442
- children: parsed.roots,
443
- parentId: null,
444
- isContainer: false,
445
- lineNumber: 0,
446
- },
447
- children: treeNodes,
448
- width: 0,
449
- height: 0,
450
- };
451
- }
452
-
453
- // Pre-compute max card dimensions for node separation
454
- let maxWidth = 0;
455
- let maxHeight = 0;
456
- const allTreeNodes: TreeNode[] = [];
457
- const collectNodes = (tn: TreeNode) => {
458
- if (tn.orgNode.id !== '__virtual_root__') {
459
- allTreeNodes.push(tn);
460
- if (tn.width > maxWidth) maxWidth = tn.width;
461
- if (tn.height > maxHeight) maxHeight = tn.height;
462
- }
463
- for (const child of tn.children) collectNodes(child);
464
- };
465
- collectNodes(root);
466
-
467
- // Standardize all cards to the widest width for uniform appearance
468
- for (const tn of allTreeNodes) {
469
- tn.width = maxWidth;
470
- }
471
-
472
- // Collapse leaf containers: when a container's children are ALL leaves
473
- // (no grandchildren), replace them with a single virtual stack node so
474
- // the d3 tree allocates a narrow column instead of a wide row.
475
- const leafStacks = new Map<
476
- string,
477
- { children: TreeNode[]; placeholderId: string }
478
- >();
479
-
480
- const collapseLeafContainers = (tn: TreeNode): void => {
481
- for (const child of tn.children) collapseLeafContainers(child);
482
-
483
- if (
484
- tn.orgNode.isContainer &&
485
- tn.children.length > 0 &&
486
- tn.children.every((c) => c.children.length === 0)
487
- ) {
488
- const placeholderId = `__stack_${tn.orgNode.id}`;
489
- leafStacks.set(tn.orgNode.id, {
490
- children: [...tn.children],
491
- placeholderId,
492
- });
493
-
494
- const maxW = Math.max(...tn.children.map((c) => c.width));
495
- // Standardize all children to the widest card width
496
- for (const child of tn.children) {
497
- child.width = maxW;
498
- }
499
- const totalH =
500
- tn.children.reduce((s, c) => s + c.height, 0) +
501
- (tn.children.length - 1) * STACK_V_GAP;
502
-
503
- tn.children = [
504
- {
505
- orgNode: {
506
- id: placeholderId,
507
- label: '',
508
- metadata: {},
509
- children: [],
510
- parentId: tn.orgNode.id,
511
- isContainer: false,
512
- lineNumber: 0,
513
- },
514
- children: [],
515
- width: maxW,
516
- height: totalH,
517
- },
518
- ];
519
- }
520
- };
521
- collapseLeafContainers(root);
522
-
523
- // Reorder children: heaviest subtrees in center positions
524
- centerHeavyChildren(root);
525
-
526
- // Build d3 hierarchy
527
- const h = hierarchy<TreeNode>(root, (d) => d.children);
528
-
529
- // Run Reingold-Tilford tree layout with nodeSize
530
- // x = horizontal spread, y = vertical (depth)
531
- const treeLayout = tree<TreeNode>().nodeSize([
532
- maxWidth + H_GAP,
533
- maxHeight + V_GAP,
534
- ]);
535
- treeLayout(h);
536
-
537
- // Post-layout: compact vertical spacing per depth level.
538
- // D3 tree uses uniform nodeSize (maxHeight + V_GAP) for every level, which
539
- // creates disproportionate gaps when short nodes (no metadata) are placed at
540
- // the same level-spacing as tall nodes (multiple metadata rows). Recompute
541
- // Y positions so each level's gap is based on the actual max height at that
542
- // level rather than the global max.
543
- {
544
- const descendants = h
545
- .descendants()
546
- .filter((d) => d.data.orgNode.id !== '__virtual_root__');
547
-
548
- // Collect max actual card height per depth level.
549
- // Exclude __stack_ placeholders — their aggregate height (multiple
550
- // stacked cards) would inflate the level max and push sibling
551
- // subtrees' deeper children far below where they need to be.
552
- const levelMaxHeight = new Map<number, number>();
553
- for (const d of descendants) {
554
- if (d.data.orgNode.id.startsWith('__stack_')) continue;
555
- const cur = levelMaxHeight.get(d.depth) ?? 0;
556
- if (d.data.height > cur) levelMaxHeight.set(d.depth, d.data.height);
557
- }
558
-
559
- // Compute compacted Y position for each depth level
560
- const maxDepth = Math.max(...levelMaxHeight.keys(), 0);
561
- const compactedY = new Map<number, number>();
562
- // Virtual root (depth 0 in hierarchy) stays at y=0
563
- // First real level starts at depth 1 for multi-root or depth 0 for single root.
564
- // We compute based on the d3 hierarchy's depth numbering.
565
- const rootDepth = treeNodes.length === 1 ? 0 : 1;
566
- compactedY.set(rootDepth, 0);
567
- for (let d = rootDepth + 1; d <= maxDepth; d++) {
568
- const parentH = levelMaxHeight.get(d - 1) ?? maxHeight;
569
- const prevY = compactedY.get(d - 1) ?? 0;
570
- compactedY.set(d, prevY + parentH + V_GAP);
571
- }
572
-
573
- // Shift each node from uniform Y to compacted Y (top-aligned).
574
- // Siblings share the same Y so connecting edges align cleanly.
575
- for (const d of h.descendants()) {
576
- if (d.data.orgNode.id === '__virtual_root__') continue;
577
- d.y = compactedY.get(d.depth) ?? d.y!;
578
- }
579
- }
580
-
581
- // Post-layout: tighten vertical spacing inside containers.
582
- // Container-with-children nodes render as background boxes (not cards),
583
- // so their children can sit closer to the container header.
584
- for (const d of h.descendants()) {
585
- if (d.data.orgNode.id === '__virtual_root__') continue;
586
- if (!d.data.orgNode.isContainer) continue;
587
- if (!d.children || d.children.length === 0) continue;
588
-
589
- // Actual gap between this container and its direct children — in-bounds by length > 0 guard above.
590
- const childY = d.children[0]!.y!;
591
- const actualLevelGap = childY - d.y!;
592
-
593
- const metaCount = Object.keys(d.data.orgNode.metadata).length;
594
- const headerHeight =
595
- CONTAINER_LABEL_HEIGHT + metaCount * CONTAINER_META_LINE_HEIGHT;
596
- const desiredGap = headerHeight + 15;
597
- const shiftUp = actualLevelGap - desiredGap;
598
- if (shiftUp <= 0) continue;
599
-
600
- // Shift all descendants upward
601
- const shift = (node: typeof d) => {
602
- if (node.children) {
603
- for (const child of node.children) {
604
- child.y! -= shiftUp;
605
- shift(child);
606
- }
607
- }
608
- };
609
- shift(d);
610
- }
611
-
612
- // Post-layout: tighten gap between non-container parents and their
613
- // container children. Containers render as header boxes (not full cards),
614
- // so the standard inter-level gap is visually excessive.
615
- for (const d of h.descendants()) {
616
- if (d.data.orgNode.id === '__virtual_root__') continue;
617
- if (d.data.orgNode.isContainer) continue; // only non-container parents
618
- if (!d.children || d.children.length === 0) continue;
619
-
620
- // Only apply when ALL direct children are containers — mixed children
621
- // need standard spacing so siblings stay aligned.
622
- if (!d.children.every((c) => c.data.orgNode.isContainer)) continue;
623
-
624
- const parentBottomY = d.y! + d.data.height;
625
- const firstChildY = Math.min(...d.children.map((c) => c.y!));
626
- const currentGap = firstChildY - parentBottomY;
627
- const desiredGap = V_GAP * 0.6;
628
- const shiftUp = currentGap - desiredGap;
629
- if (shiftUp <= 0) continue;
630
-
631
- // Shift all container children and their descendants up
632
- const shiftDown = (node: typeof d) => {
633
- node.y! -= shiftUp;
634
- if (node.children) {
635
- for (const child of node.children) {
636
- shiftDown(child);
637
- }
638
- }
639
- };
640
- for (const child of d.children) {
641
- shiftDown(child);
642
- }
643
- }
644
-
645
- // Post-layout: compact sibling spacing based on actual subtree widths.
646
- // D3 uses uniform nodeSize so narrow stacks get the same gap as wide
647
- // subtrees. Process bottom-up so inner subtrees are compact first.
648
- {
649
- type HNode = typeof h;
650
- const subtreeExtent = (node: HNode): { minX: number; maxX: number } => {
651
- // Start with this node's own card/header bounds
652
- let min = node.x! - node.data.width / 2;
653
- let max = node.x! + node.data.width / 2;
654
-
655
- // Include children's subtree extents
656
- if (node.children) {
657
- for (const child of node.children) {
658
- const childExt = subtreeExtent(child);
659
- if (childExt.minX < min) min = childExt.minX;
660
- if (childExt.maxX > max) max = childExt.maxX;
661
- }
662
- }
663
-
664
- // Container boxes wrap their content with padding — mirror the
665
- // actual bounding-box computation so compaction sees the true width.
666
- if (node.data.orgNode.isContainer) {
667
- min -= CONTAINER_PAD_X;
668
- max += CONTAINER_PAD_X;
669
- }
670
-
671
- return { minX: min, maxX: max };
672
- };
673
-
674
- const shiftX = (node: HNode, dx: number) => {
675
- node.x! += dx;
676
- if (node.children) node.children.forEach((c) => shiftX(c, dx));
677
- };
678
-
679
- const internalNodes = h
680
- .descendants()
681
- .filter((d) => d.children && d.children.length >= 2)
682
- .sort((a, b) => b.depth - a.depth);
683
-
684
- for (const parent of internalNodes) {
685
- const children = parent.children!;
686
-
687
- const extents = children.map((child) => {
688
- const ext = subtreeExtent(child);
689
- return {
690
- relLeft: ext.minX - child.x!,
691
- relRight: ext.maxX - child.x!,
692
- };
693
- });
694
-
695
- // children filtered to length >= 2 above, so first and last are in-bounds.
696
- const currentCenter =
697
- (children[0]!.x! + children[children.length - 1]!.x!) / 2;
698
-
699
- const positions: number[] = [0];
700
- for (let i = 1; i < children.length; i++) {
701
- // In-bounds: i >= 1 so i-1 >= 0, and extents is parallel to children.
702
- const prevRight = positions[i - 1]! + extents[i - 1]!.relRight;
703
- positions[i] = prevRight + H_GAP - extents[i]!.relLeft;
704
- }
705
-
706
- // positions has at least one element (initialized with [0]).
707
- const newCenter = (positions[0]! + positions[positions.length - 1]!) / 2;
708
- const centerShift = currentCenter - newCenter;
709
-
710
- for (let i = 0; i < children.length; i++) {
711
- // In-bounds by loop guard.
712
- const newX = positions[i]! + centerShift;
713
- const dx = newX - children[i]!.x!;
714
- if (Math.abs(dx) > 0.001) {
715
- shiftX(children[i]!, dx);
716
- }
717
- }
718
- }
719
- }
720
-
721
- // Post-layout: center each parent exactly over its direct children.
722
- // d3-hierarchy centers over the subtree centroid, which drifts when
723
- // grandchildren have asymmetric widths. Process bottom-up so parents
724
- // see already-adjusted child positions.
725
- {
726
- const parentNodes = h
727
- .descendants()
728
- .filter(
729
- (d) =>
730
- d.children &&
731
- d.children.length >= 1 &&
732
- d.data.orgNode.id !== '__virtual_root__'
733
- )
734
- .sort((a, b) => b.depth - a.depth);
735
-
736
- for (const parent of parentNodes) {
737
- const childXs = parent.children!.map((c) => c.x!);
738
- const desiredX = (Math.min(...childXs) + Math.max(...childXs)) / 2;
739
- parent.x = desiredX;
740
- }
741
- }
742
-
743
- // Collect positioned nodes and edges
744
- const layoutNodes: Writable<OrgLayoutNode>[] = [];
745
- const layoutEdges: Writable<OrgLayoutEdge>[] = [];
746
-
747
- // Find bounding box and build outputs
748
- let minX = Infinity;
749
- let maxX = -Infinity;
750
- let minY = Infinity;
751
- let maxY = -Infinity;
752
-
753
- // Expand leaf container stacks: compute individual child positions
754
- // in d3 coordinate space (before offset) so bounding box is correct
755
- interface ExpandedChild {
756
- orgNode: OrgNode;
757
- width: number;
758
- height: number;
759
- cx: number;
760
- cy: number;
761
- }
762
- const expandedChildren: ExpandedChild[] = [];
763
-
764
- for (const d of h.descendants()) {
765
- if (d.data.orgNode.id === '__virtual_root__') continue;
766
- if (!d.data.orgNode.id.startsWith('__stack_')) continue;
767
-
768
- const containerId = d.data.orgNode.id.replace('__stack_', '');
769
- const stack = leafStacks.get(containerId);
770
- if (!stack) continue;
771
-
772
- let currentY = d.y!;
773
- for (const child of stack.children) {
774
- expandedChildren.push({
775
- orgNode: child.orgNode,
776
- width: child.width,
777
- height: child.height,
778
- cx: d.x!,
779
- cy: currentY,
780
- });
781
- currentY += child.height + STACK_V_GAP;
782
- }
783
- }
784
-
785
- for (const d of h.descendants()) {
786
- if (d.data.orgNode.id === '__virtual_root__') continue;
787
- if (d.data.orgNode.id.startsWith('__stack_')) continue;
788
-
789
- const w = d.data.width;
790
- const ht = d.data.height;
791
- const cx = d.x!;
792
- const cy = d.y!;
793
-
794
- if (cx - w / 2 < minX) minX = cx - w / 2;
795
- if (cx + w / 2 > maxX) maxX = cx + w / 2;
796
- if (cy < minY) minY = cy;
797
- if (cy + ht > maxY) maxY = cy + ht;
798
- }
799
-
800
- for (const ec of expandedChildren) {
801
- if (ec.cx - ec.width / 2 < minX) minX = ec.cx - ec.width / 2;
802
- if (ec.cx + ec.width / 2 > maxX) maxX = ec.cx + ec.width / 2;
803
- if (ec.cy < minY) minY = ec.cy;
804
- if (ec.cy + ec.height > maxY) maxY = ec.cy + ec.height;
805
- }
806
-
807
- // Translate so all coordinates are positive, starting at MARGIN
808
- const offsetX = -minX + MARGIN;
809
- const offsetY = -minY + MARGIN;
810
-
811
- // Add expanded stack children as layout nodes
812
- const subNodeKey = subNodeLabel ?? 'Sub-node Count';
813
- for (const ec of expandedChildren) {
814
- const hc = hiddenCounts?.get(ec.orgNode.id);
815
- const meta = filterMetadata(ec.orgNode.metadata, hiddenAttributes);
816
- if (
817
- !ec.orgNode.isContainer &&
818
- showSubNodeCount &&
819
- !(hc != null && hc > 0)
820
- ) {
821
- const count = countDescendantNodes(ec.orgNode, hiddenCounts);
822
- if (count > 0) meta[subNodeKey] = String(count);
823
- }
824
- const ecColor = resolveNodeColor(
825
- ec.orgNode,
826
- parsed.tagGroups,
827
- activeTagGroup ?? null
828
- );
829
- const ecHasChildren =
830
- ec.orgNode.children.length > 0 || (hc != null && hc > 0) || undefined;
831
- layoutNodes.push({
832
- id: ec.orgNode.id,
833
- label: ec.orgNode.label,
834
- metadata: meta,
835
- tagMetadata: { ...ec.orgNode.metadata },
836
- isContainer: ec.orgNode.isContainer,
837
- lineNumber: ec.orgNode.lineNumber,
838
- ...(ecColor !== undefined && { color: ecColor }),
839
- x: ec.cx + offsetX,
840
- y: ec.cy + offsetY,
841
- width: ec.width,
842
- height: ec.height,
843
- ...(hc !== undefined && { hiddenCount: hc }),
844
- ...(ecHasChildren !== undefined && { hasChildren: ecHasChildren }),
845
- });
846
- }
847
-
848
- // Map parent ID → { parentX, parentBottomY, children[] } for bus-style edges
849
- const busGroups = new Map<
850
- string,
851
- {
852
- parentX: number;
853
- parentBottomY: number;
854
- children: { id: string; x: number; topY: number }[];
855
- }
856
- >();
857
-
858
- for (const d of h.descendants()) {
859
- if (d.data.orgNode.id === '__virtual_root__') continue;
860
- if (d.data.orgNode.id.startsWith('__stack_')) continue;
861
-
862
- const orgNode = d.data.orgNode;
863
- const w = d.data.width;
864
- const ht = d.data.height;
865
- const x = d.x! + offsetX;
866
- const y = d.y! + offsetY;
867
-
868
- const hc = hiddenCounts?.get(orgNode.id);
869
- const nodeMeta = filterMetadata(orgNode.metadata, hiddenAttributes);
870
- if (!orgNode.isContainer && showSubNodeCount && !(hc != null && hc > 0)) {
871
- const count = countDescendantNodes(orgNode, hiddenCounts);
872
- if (count > 0) nodeMeta[subNodeKey] = String(count);
873
- }
874
- const nodeColor = resolveNodeColor(
875
- orgNode,
876
- parsed.tagGroups,
877
- activeTagGroup ?? null
878
- );
879
- const nodeHasChildren =
880
- (d.children != null && d.children.length > 0) ||
881
- (hc != null && hc > 0) ||
882
- undefined;
883
- layoutNodes.push({
884
- id: orgNode.id,
885
- label: orgNode.label,
886
- metadata: nodeMeta,
887
- tagMetadata: { ...orgNode.metadata },
888
- isContainer: orgNode.isContainer,
889
- lineNumber: orgNode.lineNumber,
890
- ...(nodeColor !== undefined && { color: nodeColor }),
891
- x,
892
- y,
893
- width: w,
894
- height: ht,
895
- ...(hc !== undefined && { hiddenCount: hc }),
896
- ...(nodeHasChildren !== undefined && { hasChildren: nodeHasChildren }),
897
- });
898
-
899
- // Collect children per parent for bus-style edge generation
900
- const parentIsContainerBox =
901
- d.parent?.data.orgNode.isContainer &&
902
- d.parent.children &&
903
- d.parent.children.length > 0;
904
- if (
905
- d.parent &&
906
- d.parent.data.orgNode.id !== '__virtual_root__' &&
907
- !parentIsContainerBox
908
- ) {
909
- const parentId = d.parent.data.orgNode.id;
910
- if (!busGroups.has(parentId)) {
911
- const px = d.parent.x! + offsetX;
912
- const py = d.parent.y! + offsetY;
913
- const parentH = d.parent.data.height;
914
- busGroups.set(parentId, {
915
- parentX: px,
916
- parentBottomY: py + parentH,
917
- children: [],
918
- });
919
- }
920
- busGroups.get(parentId)!.children.push({
921
- id: orgNode.id,
922
- x,
923
- topY: y,
924
- });
925
- }
926
- }
927
-
928
- // Generate non-overlapping edges using bus pattern
929
- for (const [parentId, group] of busGroups) {
930
- const { parentX, parentBottomY, children } = group;
931
-
932
- if (children.length === 1) {
933
- // Single child: simple elbow (no overlap possible) — in-bounds by length === 1.
934
- const child = children[0]!;
935
- const midY = (parentBottomY + child.topY) / 2;
936
- layoutEdges.push({
937
- sourceId: parentId,
938
- targetId: child.id,
939
- points: [
940
- { x: parentX, y: parentBottomY },
941
- { x: parentX, y: midY },
942
- { x: child.x, y: midY },
943
- { x: child.x, y: child.topY },
944
- ],
945
- });
946
- } else {
947
- // Bus pattern: trunk + horizontal bar + per-child drops — length >= 2 here.
948
- const midY = (parentBottomY + children[0]!.topY) / 2;
949
- const childXs = children.map((c) => c.x);
950
- const leftX = Math.min(...childXs);
951
- const rightX = Math.max(...childXs);
952
-
953
- // Trunk: parent bottom → midY
954
- layoutEdges.push({
955
- sourceId: parentId,
956
- targetId: parentId,
957
- points: [
958
- { x: parentX, y: parentBottomY },
959
- { x: parentX, y: midY },
960
- ],
961
- });
962
-
963
- // Horizontal bus: leftmost child → rightmost child at midY
964
- layoutEdges.push({
965
- sourceId: parentId,
966
- targetId: parentId,
967
- points: [
968
- { x: leftX, y: midY },
969
- { x: rightX, y: midY },
970
- ],
971
- });
972
-
973
- // Drops: midY → child top for each child
974
- for (const child of children) {
975
- layoutEdges.push({
976
- sourceId: parentId,
977
- targetId: child.id,
978
- points: [
979
- { x: child.x, y: midY },
980
- { x: child.x, y: child.topY },
981
- ],
982
- });
983
- }
984
- }
985
- }
986
-
987
- // Compute container bounds from d3 hierarchy (bottom-up so inner
988
- // container boxes are available when computing outer containers)
989
- const allContainerNodes = h
990
- .descendants()
991
- .filter(
992
- (d) =>
993
- d.data.orgNode.id !== '__virtual_root__' && d.data.orgNode.isContainer
994
- );
995
-
996
- // Map from node ID to computed visual bounds (offset-space)
997
- const containerBoundsMap = new Map<
998
- string,
999
- { minX: number; maxX: number; minY: number; maxY: number }
1000
- >();
1001
-
1002
- const containers: Writable<OrgContainerBounds>[] = [];
1003
-
1004
- // First pass: childless containers — simple boxes at their own position.
1005
- // Must be computed before parent containers so their bounds are available.
1006
- const EMPTY_CONTAINER_MIN_HEIGHT = 60;
1007
- for (const d of allContainerNodes) {
1008
- if (d.children && d.children.length > 0) continue;
1009
-
1010
- const cx = d.x! + offsetX;
1011
- const cy = d.y! + offsetY;
1012
- const metaCount = Object.keys(d.data.orgNode.metadata).length;
1013
- const labelHeight =
1014
- CONTAINER_LABEL_HEIGHT + metaCount * CONTAINER_META_LINE_HEIGHT;
1015
- const boxWidth = d.data.width;
1016
- const boxHeight = Math.max(
1017
- labelHeight + CONTAINER_PAD_BOTTOM,
1018
- EMPTY_CONTAINER_MIN_HEIGHT
1019
- );
1020
- const boxX = cx - boxWidth / 2;
1021
- const boxY = cy;
1022
-
1023
- containerBoundsMap.set(d.data.orgNode.id, {
1024
- minX: boxX,
1025
- maxX: boxX + boxWidth,
1026
- minY: boxY,
1027
- maxY: boxY + boxHeight,
1028
- });
1029
-
1030
- const chc = hiddenCounts?.get(d.data.orgNode.id);
1031
- const cMeta = filterMetadata(d.data.orgNode.metadata, hiddenAttributes);
1032
- const cColor = resolveNodeColor(
1033
- d.data.orgNode,
1034
- parsed.tagGroups,
1035
- activeTagGroup ?? null
1036
- );
1037
- const cHasChildren = (chc != null && chc > 0) || undefined;
1038
- containers.push({
1039
- nodeId: d.data.orgNode.id,
1040
- label: d.data.orgNode.label,
1041
- lineNumber: d.data.orgNode.lineNumber,
1042
- ...(cColor !== undefined && { color: cColor }),
1043
- metadata: cMeta,
1044
- tagMetadata: { ...d.data.orgNode.metadata },
1045
- x: boxX,
1046
- y: boxY,
1047
- width: boxWidth,
1048
- height: boxHeight,
1049
- labelHeight,
1050
- ...(chc !== undefined && { hiddenCount: chc }),
1051
- ...(cHasChildren !== undefined && { hasChildren: cHasChildren }),
1052
- });
1053
- }
1054
-
1055
- // Second pass: containers with children, deepest first
1056
- const containerCandidates = allContainerNodes.filter(
1057
- (d) => d.children && d.children.length > 0
1058
- );
1059
- containerCandidates.sort((a, b) => b.depth - a.depth);
1060
-
1061
- for (const d of containerCandidates) {
1062
- // Collect all descendants (not just direct children)
1063
- const allDesc: (typeof d)[] = [];
1064
- const collectDesc = (node: typeof d) => {
1065
- if (node.children) {
1066
- for (const child of node.children) {
1067
- allDesc.push(child);
1068
- collectDesc(child);
1069
- }
1070
- }
1071
- };
1072
- collectDesc(d);
1073
-
1074
- if (allDesc.length === 0) continue;
1075
-
1076
- // Compute bounding box from all descendants, using inner container
1077
- // bounds when available (so nested boxes don't overlap)
1078
- let descMinX = Infinity;
1079
- let descMaxX = -Infinity;
1080
- let descMaxY = -Infinity;
1081
-
1082
- for (const desc of allDesc) {
1083
- const innerBounds = containerBoundsMap.get(desc.data.orgNode.id);
1084
- if (innerBounds) {
1085
- // Use the inner container's expanded box
1086
- if (innerBounds.minX < descMinX) descMinX = innerBounds.minX;
1087
- if (innerBounds.maxX > descMaxX) descMaxX = innerBounds.maxX;
1088
- if (innerBounds.maxY > descMaxY) descMaxY = innerBounds.maxY;
1089
- } else if (desc.data.orgNode.id.startsWith('__stack_')) {
1090
- // Use expanded children positions for stack placeholders
1091
- const cid = desc.data.orgNode.id.replace('__stack_', '');
1092
- const stack = leafStacks.get(cid);
1093
- if (stack) {
1094
- for (const ec of expandedChildren) {
1095
- if (ec.orgNode.parentId !== cid) continue;
1096
- const ex = ec.cx + offsetX;
1097
- const ey = ec.cy + offsetY;
1098
- if (ex - ec.width / 2 < descMinX) descMinX = ex - ec.width / 2;
1099
- if (ex + ec.width / 2 > descMaxX) descMaxX = ex + ec.width / 2;
1100
- if (ey + ec.height > descMaxY) descMaxY = ey + ec.height;
1101
- }
1102
- }
1103
- } else {
1104
- // Use card dimensions
1105
- const dw = desc.data.width;
1106
- const dh = desc.data.height;
1107
- const dx = desc.x! + offsetX;
1108
- const dy = desc.y! + offsetY;
1109
-
1110
- if (dx - dw / 2 < descMinX) descMinX = dx - dw / 2;
1111
- if (dx + dw / 2 > descMaxX) descMaxX = dx + dw / 2;
1112
- if (dy + dh > descMaxY) descMaxY = dy + dh;
1113
- }
1114
- }
1115
-
1116
- const containerX = d.x! + offsetX;
1117
- const containerY = d.y! + offsetY;
1118
- const metaCount = Object.keys(d.data.orgNode.metadata).length;
1119
- const labelHeight =
1120
- CONTAINER_LABEL_HEIGHT + metaCount * CONTAINER_META_LINE_HEIGHT;
1121
-
1122
- // Box top = container's own y, extends to cover all children
1123
- const boxY = containerY;
1124
- const boxHeight = descMaxY - containerY + CONTAINER_PAD_BOTTOM;
1125
-
1126
- // Tight-fit box around content with padding
1127
- const boxX = descMinX - CONTAINER_PAD_X;
1128
- const contentWidth = descMaxX - descMinX + CONTAINER_PAD_X * 2;
1129
- const finalBoxWidth = Math.max(contentWidth, d.data.width);
1130
- // Center the box if the label is wider than the content
1131
- const centeredBoxX =
1132
- finalBoxWidth > contentWidth ? containerX - finalBoxWidth / 2 : boxX;
1133
-
1134
- // Store bounds for parent containers to reference
1135
- containerBoundsMap.set(d.data.orgNode.id, {
1136
- minX: centeredBoxX,
1137
- maxX: centeredBoxX + finalBoxWidth,
1138
- minY: boxY,
1139
- maxY: boxY + boxHeight,
1140
- });
1141
-
1142
- const chc2 = hiddenCounts?.get(d.data.orgNode.id);
1143
- const cMeta2 = filterMetadata(d.data.orgNode.metadata, hiddenAttributes);
1144
- const c2Color = resolveNodeColor(
1145
- d.data.orgNode,
1146
- parsed.tagGroups,
1147
- activeTagGroup ?? null
1148
- );
1149
- containers.push({
1150
- nodeId: d.data.orgNode.id,
1151
- label: d.data.orgNode.label,
1152
- lineNumber: d.data.orgNode.lineNumber,
1153
- ...(c2Color !== undefined && { color: c2Color }),
1154
- metadata: cMeta2,
1155
- tagMetadata: { ...d.data.orgNode.metadata },
1156
- x: centeredBoxX,
1157
- y: boxY,
1158
- width: finalBoxWidth,
1159
- height: boxHeight,
1160
- labelHeight,
1161
- ...(chc2 !== undefined && { hiddenCount: chc2 }),
1162
- hasChildren: true,
1163
- });
1164
- }
1165
-
1166
- // Reverse so outer containers render first (behind inner containers)
1167
- containers.reverse();
1168
-
1169
- // Bounding box — expand for container backgrounds that may extend beyond nodes
1170
- // Convert container coords (offset space) back to pre-offset space for comparison
1171
- let finalMinX = minX;
1172
- let finalMaxX = maxX;
1173
- let finalMaxY = maxY;
1174
- for (const c of containers) {
1175
- const cLeft = c.x - offsetX;
1176
- const cRight = cLeft + c.width;
1177
- const cBottom = c.y - offsetY + c.height;
1178
- if (cLeft < finalMinX) finalMinX = cLeft;
1179
- if (cRight > finalMaxX) finalMaxX = cRight;
1180
- if (cBottom > finalMaxY) finalMaxY = cBottom;
1181
- }
1182
-
1183
- const totalWidth = finalMaxX - finalMinX + MARGIN * 2;
1184
- const totalHeight = finalMaxY - minY + MARGIN * 2;
1185
-
1186
- // Collect which tag group values are actually used by nodes
1187
- const usedValuesByGroup = new Map<string, Set<string>>();
1188
- for (const group of parsed.tagGroups) {
1189
- const key = tagAttrKey(group.name);
1190
- const used = new Set<string>();
1191
- const walk = (node: OrgNode) => {
1192
- if (!node.isContainer && node.metadata[key]) {
1193
- used.add(node.metadata[key].toLowerCase());
1194
- }
1195
- for (const child of node.children) walk(child);
1196
- };
1197
- for (const root of parsed.roots) walk(root);
1198
- usedValuesByGroup.set(key, used);
1199
- }
1200
-
1201
- // Compute legend for tag groups
1202
- const showEyeIcons = hiddenAttributes !== undefined;
1203
- const legendGroups = computeLegendGroups(
1204
- parsed.tagGroups,
1205
- showEyeIcons,
1206
- usedValuesByGroup
1207
- );
1208
- let finalWidth = totalWidth;
1209
- let finalHeight = totalHeight;
1210
-
1211
- // When a tag group is active, only that group is laid out (full size).
1212
- // When none is active, all groups are laid out minified — unless
1213
- // expandAllLegend is set (export mode), which shows all groups expanded.
1214
- const visibleGroups =
1215
- activeTagGroup != null
1216
- ? legendGroups.filter(
1217
- (g) => g.name.toLowerCase() === activeTagGroup.toLowerCase()
1218
- )
1219
- : legendGroups;
1220
- const allExpanded = expandAllLegend && activeTagGroup == null;
1221
- const effectiveW = (g: OrgLegendGroup) =>
1222
- activeTagGroup != null || allExpanded ? g.width : g.minifiedWidth;
1223
-
1224
- if (visibleGroups.length > 0) {
1225
- // Top: horizontal row above chart content, left-aligned
1226
- const legendShift = LEGEND_HEIGHT + LEGEND_GROUP_GAP;
1227
-
1228
- // Push all chart content down
1229
- for (const n of layoutNodes) n.y += legendShift;
1230
- for (const c of containers) c.y += legendShift;
1231
- for (const e of layoutEdges) {
1232
- for (const p of e.points as Writable<(typeof e.points)[number]>[])
1233
- p.y += legendShift;
1234
- }
1235
-
1236
- const totalGroupsWidth =
1237
- visibleGroups.reduce((s, g) => s + effectiveW(g), 0) +
1238
- (visibleGroups.length - 1) * LEGEND_GROUP_GAP;
1239
-
1240
- let cx = MARGIN;
1241
- for (const g of visibleGroups) {
1242
- g.x = cx;
1243
- g.y = MARGIN;
1244
- cx += effectiveW(g) + LEGEND_GROUP_GAP;
1245
- }
1246
-
1247
- finalHeight += legendShift;
1248
- const neededWidth = totalGroupsWidth + MARGIN * 2;
1249
- if (neededWidth > finalWidth) {
1250
- finalWidth = neededWidth;
1251
- }
1252
- }
1253
-
1254
- return {
1255
- nodes: layoutNodes,
1256
- edges: layoutEdges,
1257
- containers,
1258
- legend: legendGroups,
1259
- width: finalWidth,
1260
- height: finalHeight,
1261
- };
1262
- }