@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
@@ -0,0 +1,1818 @@
1
+ import {
2
+ computeNodeSizing,
3
+ layoutPert
4
+ } from "./chunk-4OHACBGX.js";
5
+ import {
6
+ analyzePert
7
+ } from "./chunk-NX4EQS3U.js";
8
+ import {
9
+ COLLAPSE_BAR_HEIGHT,
10
+ CONTAINER_HEADER_HEIGHT,
11
+ CONTAINER_LABEL_FONT_SIZE,
12
+ CONTAINER_RADIUS,
13
+ EDGE_STROKE_WIDTH,
14
+ NODE_STROKE_WIDTH
15
+ } from "./chunk-3CIOJ5YJ.js";
16
+ import {
17
+ renderIntegratedLegend
18
+ } from "./chunk-PWIHZ6NJ.js";
19
+ import {
20
+ ScaleContext
21
+ } from "./chunk-YYVTBZZC.js";
22
+ import {
23
+ CAPTION_BOX_PADDING_X,
24
+ CAPTION_BOX_PADDING_Y,
25
+ CAPTION_FONT_SIZE,
26
+ CAPTION_FONT_WEIGHT,
27
+ CAPTION_LINE_HEIGHT,
28
+ CAPTION_TOP_GAP,
29
+ TITLE_FONT_SIZE,
30
+ TITLE_FONT_WEIGHT,
31
+ TITLE_Y
32
+ } from "./chunk-A4GOY3PE.js";
33
+ import {
34
+ FONT_FAMILY
35
+ } from "./chunk-6KFWC4CO.js";
36
+ import {
37
+ LEGEND_HEIGHT
38
+ } from "./chunk-QOOUC2J5.js";
39
+ import {
40
+ measureText,
41
+ truncateText,
42
+ wrapTextToWidth
43
+ } from "./chunk-WCT3NYCV.js";
44
+ import {
45
+ parsePert
46
+ } from "./chunk-RTLBSQ3G.js";
47
+ import {
48
+ addCalendarDays,
49
+ formatDuration,
50
+ formatScheduleValue,
51
+ formatSlackValue,
52
+ formatSprintCell
53
+ } from "./chunk-L3UHP6TD.js";
54
+ import {
55
+ contrastText,
56
+ mix,
57
+ shapeFill,
58
+ themeBaseBg
59
+ } from "./chunk-P6T66CCZ.js";
60
+ import {
61
+ resolveActiveTagGroup,
62
+ resolveTagColor
63
+ } from "./chunk-QLCCJEJI.js";
64
+
65
+ // src/pert/renderer.ts
66
+ import * as d3Selection from "d3-selection";
67
+ import * as d3Shape from "d3-shape";
68
+ var DIAGRAM_PADDING = 20;
69
+ var NODE_FONT_SIZE = 13;
70
+ var NODE_CELL_FONT_SIZE = 11;
71
+ var NODE_RADIUS = 6;
72
+ function analysisBlockChrome(palette, isDark) {
73
+ const surfaceBg = themeBaseBg(palette, isDark);
74
+ return {
75
+ fill: mix(palette.surface, palette.bg, 40),
76
+ stroke: mix(palette.textMuted, surfaceBg, 35)
77
+ };
78
+ }
79
+ var NODE_TOP_ROW_HEIGHT = 26;
80
+ var NODE_BOTTOM_ROW_HEIGHT = 26;
81
+ var ARROWHEAD_W = 10;
82
+ var ARROWHEAD_H = 7;
83
+ var DURATION_FADE_OPACITY = 0.55;
84
+ var PIN_ICON_W = 13;
85
+ var PIN_ICON_H = 13;
86
+ var LEGEND_PILL_HEIGHT = LEGEND_HEIGHT;
87
+ var LEGEND_TOP_GAP = 12;
88
+ var LEGEND_BOTTOM_GAP = 12;
89
+ var FIELD_LEGEND_HEADER_BAND_HEIGHT = 26;
90
+ var FIELD_LEGEND_CELL_VPAD = 14;
91
+ function fieldLegendRowHeight(maxDescLines) {
92
+ return FIELD_LEGEND_CELL_VPAD * 2 + FIELD_LEGEND_LABEL_FONT_SIZE + FIELD_LEGEND_LABEL_DESC_GAP + maxDescLines * FIELD_LEGEND_DESC_LINE_HEIGHT;
93
+ }
94
+ function fieldLegendDescWidth(colW) {
95
+ return colW - 8;
96
+ }
97
+ function fieldLegendHeightFor(width) {
98
+ const colW = width / 3;
99
+ const wrapW = fieldLegendDescWidth(colW);
100
+ let maxLines = 1;
101
+ for (const cell of FIELD_LEGEND_CELLS) {
102
+ const n = wrapTextToWidth(
103
+ cell.desc,
104
+ FIELD_LEGEND_DESC_FONT_SIZE,
105
+ wrapW
106
+ ).length;
107
+ if (n > maxLines) maxLines = n;
108
+ }
109
+ return FIELD_LEGEND_HEADER_BAND_HEIGHT + fieldLegendRowHeight(maxLines) * 2 + CAPTION_BOX_PADDING_Y;
110
+ }
111
+ var FIELD_LEGEND_LABEL_FONT_SIZE = 13;
112
+ var FIELD_LEGEND_DESC_FONT_SIZE = 13;
113
+ var FIELD_LEGEND_DESC_LINE_HEIGHT = 17;
114
+ var FIELD_LEGEND_LABEL_DESC_GAP = 4;
115
+ var FIELD_LEGEND_CELLS = [
116
+ {
117
+ label: "Early Start",
118
+ desc: "earliest this activity can begin once predecessors finish"
119
+ },
120
+ {
121
+ label: "Duration",
122
+ desc: "expected time needed to complete the work"
123
+ },
124
+ {
125
+ label: "Early Finish",
126
+ desc: "earliest this activity can be fully completed"
127
+ },
128
+ {
129
+ label: "Late Start",
130
+ desc: "latest this activity can begin without delaying the project"
131
+ },
132
+ {
133
+ label: "Slack",
134
+ desc: "extra time before this activity's delay pushes the deadline"
135
+ },
136
+ {
137
+ label: "Late Finish",
138
+ desc: "latest this activity can finish without delaying the project"
139
+ }
140
+ ];
141
+ var lineGenerator = d3Shape.line().x((d) => d.x).y((d) => d.y).curve(d3Shape.curveBasis);
142
+ function criticalityBand(c) {
143
+ if (c === null) return null;
144
+ if (c >= 0.8) return "red";
145
+ if (c >= 0.5) return "orange";
146
+ if (c >= 0.25) return "yellow";
147
+ if (c >= 0.1) return "green";
148
+ if (c >= 0.02) return "blue";
149
+ return null;
150
+ }
151
+ function bandColor(band, palette, fallback) {
152
+ return band === null ? fallback : palette.colors[band];
153
+ }
154
+ function bandArrow(band) {
155
+ return band === null ? "pert-arrow" : `pert-arrow-${band}`;
156
+ }
157
+ function renderPert(container, resolved, layout, palette, isDark, options = {}) {
158
+ d3Selection.select(container).selectAll(":not([data-d3-tooltip])").remove();
159
+ const effectiveTitle = options.title;
160
+ const effectiveSubtitle = options.subtitle ?? null;
161
+ const titleHeight = effectiveTitle ? 80 : effectiveSubtitle ? 50 : 0;
162
+ const anchorAnnotation = anchorAnnotationText(resolved);
163
+ const collapsedSet = new Set(options.collapsedGroupIds ?? []);
164
+ const captionRows = resolved.error !== null ? null : resolved.summaryRows;
165
+ const captionBullets = captionRows !== null && captionRows.length > 0 ? bulletizeCaption(captionRows) : [];
166
+ if (anchorAnnotation) {
167
+ captionBullets.push({
168
+ text: anchorAnnotation,
169
+ level: 0,
170
+ italic: true
171
+ });
172
+ }
173
+ const analysisLayer = computeAnalysisLayer(resolved, captionBullets, {
174
+ showSummary: options.showSummary ?? true,
175
+ showTornado: options.showTornado ?? false,
176
+ showScurve: options.showScurve ?? false,
177
+ showFieldLegend: options.showFieldLegend ?? false
178
+ });
179
+ const standaloneFieldLegendWidthForExport = layout.width;
180
+ const analysisBlockHeight = analysisLayer.analysisHasContent ? CAPTION_TOP_GAP + analysisLayer.analysisRowHeight : 0;
181
+ const fieldLegendBlockHeight = analysisLayer.fieldLegendStandalone ? CAPTION_TOP_GAP + fieldLegendHeightFor(standaloneFieldLegendWidthForExport) : 0;
182
+ const showLegend = options.showLegend ?? true;
183
+ const tagLegendActive = resolveActiveTagGroup(
184
+ resolved.tagGroups,
185
+ resolved.options.activeTag,
186
+ options.activeTagOverride
187
+ );
188
+ const showTagLegend = showLegend && resolved.tagGroups.length > 0;
189
+ const legendBlockHeight = showTagLegend ? LEGEND_TOP_GAP + LEGEND_PILL_HEIGHT + LEGEND_BOTTOM_GAP : 0;
190
+ const naturalChartWidth = layout.width + DIAGRAM_PADDING * 2;
191
+ const minAnalysisRowW = analysisLayer.analysisHasContent ? analysisLayer.minContentWidth + 2 * DIAGRAM_PADDING : 0;
192
+ const naturalWidth = Math.max(naturalChartWidth, minAnalysisRowW);
193
+ const naturalHeight = layout.height + DIAGRAM_PADDING * 2 + titleHeight + legendBlockHeight + analysisBlockHeight + fieldLegendBlockHeight;
194
+ const exportWidth = Math.max(
195
+ options.exportDims?.width ?? naturalWidth,
196
+ naturalWidth
197
+ );
198
+ const exportHeight = Math.max(
199
+ options.exportDims?.height ?? naturalHeight,
200
+ naturalHeight
201
+ );
202
+ if (exportWidth <= 0 || exportHeight <= 0) return;
203
+ const ctx = options.exportDims ? ScaleContext.identity() : options.containerWidth != null ? ScaleContext.from(options.containerWidth, naturalWidth) : ScaleContext.identity();
204
+ const sDiagramPad = ctx.aesthetic(DIAGRAM_PADDING);
205
+ const sTitleHeight = ctx.aesthetic(titleHeight);
206
+ const sTitleFontSize = ctx.text(TITLE_FONT_SIZE);
207
+ const sTitleY = ctx.aesthetic(TITLE_Y);
208
+ const sSubtitleFontSize = ctx.text(13);
209
+ const sLegendTopGap = ctx.aesthetic(LEGEND_TOP_GAP);
210
+ const sLegendBottomGap = ctx.aesthetic(LEGEND_BOTTOM_GAP);
211
+ const sLegendPillHeight = ctx.structural(LEGEND_PILL_HEIGHT);
212
+ const sLegendBlockHeight = showTagLegend ? sLegendTopGap + sLegendPillHeight + sLegendBottomGap : 0;
213
+ const sNodeRadius = ctx.structural(NODE_RADIUS);
214
+ const sNodeStrokeWidth = ctx.structural(NODE_STROKE_WIDTH);
215
+ const sNodeFontSize = ctx.text(NODE_FONT_SIZE);
216
+ const sNodeCellFontSize = ctx.text(NODE_CELL_FONT_SIZE);
217
+ const sNodeTopRowHeight = ctx.structural(NODE_TOP_ROW_HEIGHT);
218
+ const sNodeBottomRowHeight = ctx.structural(NODE_BOTTOM_ROW_HEIGHT);
219
+ const sEdgeStrokeWidth = ctx.structural(EDGE_STROKE_WIDTH);
220
+ const sArrowheadW = ctx.structural(ARROWHEAD_W);
221
+ const sArrowheadH = ctx.structural(ARROWHEAD_H);
222
+ const sContainerRadius = ctx.structural(CONTAINER_RADIUS);
223
+ const sContainerLabelFontSize = ctx.text(CONTAINER_LABEL_FONT_SIZE);
224
+ const sContainerHeaderHeight = ctx.structural(CONTAINER_HEADER_HEIGHT);
225
+ const sCollapseBarHeight = ctx.structural(COLLAPSE_BAR_HEIGHT);
226
+ const sPinIconW = ctx.structural(PIN_ICON_W);
227
+ const sPinIconH = ctx.structural(PIN_ICON_H);
228
+ const scaledWidth = layout.width + sDiagramPad * 2;
229
+ const scaledHeight = layout.height + sDiagramPad * 2 + sTitleHeight + sLegendBlockHeight + analysisBlockHeight + fieldLegendBlockHeight;
230
+ const svgW = ctx.isBelowFloor ? exportWidth : scaledWidth;
231
+ const svgH = ctx.isBelowFloor ? exportHeight : scaledHeight;
232
+ const svg = d3Selection.select(container).append("svg").attr("width", ctx.isBelowFloor ? "100%" : svgW).attr("height", svgH).attr("viewBox", `0 0 ${svgW} ${svgH}`).attr("preserveAspectRatio", "xMidYMin meet").style("font-family", FONT_FAMILY);
233
+ const defs = svg.append("defs");
234
+ buildArrowheads(defs, palette, sArrowheadW, sArrowheadH);
235
+ if (effectiveTitle) {
236
+ svg.append("text").attr("class", "pert-title chart-title").attr("x", svgW / 2).attr("y", sTitleY).attr("text-anchor", "middle").attr("fill", palette.text).attr("font-size", sTitleFontSize).attr("font-weight", TITLE_FONT_WEIGHT).text(effectiveTitle);
237
+ }
238
+ if (effectiveSubtitle) {
239
+ const subtitleY = effectiveTitle ? sTitleY + ctx.aesthetic(26) : sTitleY;
240
+ svg.append("text").attr("class", "pert-subtitle").attr("x", svgW / 2).attr("y", subtitleY).attr("text-anchor", "middle").attr("fill", palette.textMuted).attr("font-size", sSubtitleFontSize).attr("font-weight", 400).text(effectiveSubtitle);
241
+ }
242
+ const offsetX = Math.max(sDiagramPad, (svgW - layout.width) / 2);
243
+ const offsetY = sDiagramPad + sTitleHeight + sLegendBlockHeight;
244
+ if (showTagLegend) {
245
+ const tagLegendY = sDiagramPad + sTitleHeight + sLegendTopGap;
246
+ renderTagLegendRow(svg, resolved, palette, isDark, {
247
+ x: 0,
248
+ y: tagLegendY,
249
+ width: svgW,
250
+ activeGroup: tagLegendActive,
251
+ ...options.exportMode !== void 0 && {
252
+ exportMode: options.exportMode
253
+ }
254
+ });
255
+ }
256
+ const root = svg.append("g").attr("transform", `translate(${offsetX}, ${offsetY})`);
257
+ const sizing = computeNodeSizing(resolved);
258
+ renderGroups(root, resolved, layout, palette, isDark, collapsedSet, sizing, {
259
+ nodeRadius: sNodeRadius,
260
+ nodeStrokeWidth: sNodeStrokeWidth,
261
+ containerRadius: sContainerRadius,
262
+ containerLabelFontSize: sContainerLabelFontSize,
263
+ containerHeaderHeight: sContainerHeaderHeight,
264
+ collapseBarHeight: sCollapseBarHeight,
265
+ nodeTopRowHeight: sNodeTopRowHeight,
266
+ nodeBottomRowHeight: sNodeBottomRowHeight,
267
+ nodeFontSize: sNodeFontSize,
268
+ nodeCellFontSize: sNodeCellFontSize,
269
+ pinIconW: sPinIconW,
270
+ pinIconH: sPinIconH
271
+ });
272
+ renderEdges(root, resolved, layout, palette, collapsedSet, {
273
+ edgeStrokeWidth: sEdgeStrokeWidth,
274
+ edgeLabelFontSize: ctx.text(10)
275
+ });
276
+ renderNodes(
277
+ root,
278
+ defs,
279
+ resolved,
280
+ layout,
281
+ palette,
282
+ isDark,
283
+ sizing,
284
+ options.onClickItem,
285
+ collapsedSet,
286
+ options.activeTagOverride,
287
+ {
288
+ nodeRadius: sNodeRadius,
289
+ nodeStrokeWidth: sNodeStrokeWidth,
290
+ nodeTopRowHeight: sNodeTopRowHeight,
291
+ nodeBottomRowHeight: sNodeBottomRowHeight,
292
+ nodeFontSize: sNodeFontSize,
293
+ nodeCellFontSize: sNodeCellFontSize,
294
+ pinIconW: sPinIconW,
295
+ pinIconH: sPinIconH
296
+ }
297
+ );
298
+ paintAnalysisLayer(
299
+ svg,
300
+ resolved,
301
+ palette,
302
+ isDark,
303
+ analysisLayer,
304
+ captionBullets,
305
+ sDiagramPad,
306
+ offsetY + layout.height,
307
+ svgW - 2 * sDiagramPad
308
+ );
309
+ }
310
+ function renderPertForExport(content, theme, palette, now) {
311
+ const parsed = parsePert(content, {
312
+ ...now !== void 0 && { now },
313
+ palette
314
+ });
315
+ if (parsed.error || parsed.activities.length === 0) return "";
316
+ const resolved = analyzePert(parsed);
317
+ const layout = layoutPert(resolved);
318
+ const isDark = theme === "dark";
319
+ const hasTitle = !!parsed.title && !resolved.options.noTitle;
320
+ const hasSubtitle = resolved.projectSubtitle !== null;
321
+ const titleHeight = hasTitle ? 80 : hasSubtitle ? 50 : 0;
322
+ const captionBullets = resolved.summaryRows !== null && resolved.summaryRows.length > 0 ? bulletizeCaption(resolved.summaryRows) : [];
323
+ const anchorNote = anchorAnnotationText(resolved);
324
+ if (anchorNote) {
325
+ captionBullets.push({ text: anchorNote, level: 0, italic: true });
326
+ }
327
+ const captionBoxHeight = captionBullets.length > 0 ? captionBullets.length * CAPTION_LINE_HEIGHT + 2 * CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT : 0;
328
+ const captionBlockHeight = captionBullets.length > 0 ? CAPTION_TOP_GAP + captionBoxHeight : 0;
329
+ const legendBlockHeight = resolved.tagGroups.length > 0 ? LEGEND_TOP_GAP + LEGEND_PILL_HEIGHT + LEGEND_BOTTOM_GAP : 0;
330
+ const exportWidth = layout.width + DIAGRAM_PADDING * 2;
331
+ const exportHeight = layout.height + DIAGRAM_PADDING * 2 + titleHeight + legendBlockHeight + captionBlockHeight;
332
+ const container = document.createElement("div");
333
+ container.style.width = `${exportWidth}px`;
334
+ container.style.height = `${exportHeight}px`;
335
+ container.style.position = "absolute";
336
+ container.style.left = "-9999px";
337
+ document.body.appendChild(container);
338
+ try {
339
+ renderPert(container, resolved, layout, palette, isDark, {
340
+ title: hasTitle ? parsed.title : null,
341
+ subtitle: resolved.projectSubtitle,
342
+ exportDims: { width: exportWidth, height: exportHeight },
343
+ exportMode: true
344
+ });
345
+ const svgEl = container.querySelector("svg");
346
+ if (!svgEl) return "";
347
+ if (theme === "transparent") svgEl.style.background = "none";
348
+ else svgEl.style.background = palette.bg;
349
+ svgEl.setAttribute("xmlns", "http://www.w3.org/2000/svg");
350
+ svgEl.style.fontFamily = FONT_FAMILY;
351
+ return svgEl.outerHTML;
352
+ } finally {
353
+ document.body.removeChild(container);
354
+ }
355
+ }
356
+ function computeAnalysisLayer(resolved, captionBullets, opts) {
357
+ const summaryRendered = opts.showSummary && captionBullets.length > 0;
358
+ const captionBoxHeight = summaryRendered ? captionBullets.length * CAPTION_LINE_HEIGHT + 2 * CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT : 0;
359
+ let tornadoRows = opts.showTornado ? buildTornadoRows(resolved) : [];
360
+ const showTornado = tornadoRows.length > 0;
361
+ let tornadoBoxHeight = showTornado ? tornadoBoxHeightFor(tornadoRows) : 0;
362
+ const scurveData = opts.showScurve ? buildScurveData(resolved) : null;
363
+ const showScurve = scurveData !== null;
364
+ const scurveBoxHeight = showScurve ? SCURVE_BOX_HEIGHT : 0;
365
+ const fieldLegendInAnalysisRow = opts.showFieldLegend && (summaryRendered || showTornado || showScurve);
366
+ const col1Width = summaryRendered ? Math.max(
367
+ SUMMARY_MIN_W,
368
+ Math.min(SUMMARY_MAX_W, captionNaturalWidth(captionBullets))
369
+ ) : fieldLegendInAnalysisRow ? SUMMARY_MAX_W : 0;
370
+ const fieldLegendCol1Height = fieldLegendInAnalysisRow ? fieldLegendHeightFor(col1Width) : 0;
371
+ const col1Items = [];
372
+ if (summaryRendered) col1Items.push(captionBoxHeight);
373
+ if (fieldLegendInAnalysisRow) col1Items.push(fieldLegendCol1Height);
374
+ const col1Height = col1Items.length ? col1Items.reduce((a, b) => a + b, 0) + (col1Items.length - 1) * COL1_VSTACK_GAP : 0;
375
+ let analysisRowHeight = Math.max(
376
+ col1Height,
377
+ scurveBoxHeight,
378
+ tornadoBoxHeight
379
+ );
380
+ if (showTornado) {
381
+ const maxRows = tornadoMaxRowsFor(analysisRowHeight);
382
+ if (maxRows > tornadoRows.length) {
383
+ tornadoRows = buildTornadoRows(resolved, maxRows);
384
+ tornadoBoxHeight = tornadoBoxHeightFor(tornadoRows);
385
+ analysisRowHeight = Math.max(
386
+ col1Height,
387
+ scurveBoxHeight,
388
+ tornadoBoxHeight
389
+ );
390
+ }
391
+ }
392
+ const analysisCharts = [];
393
+ if (showTornado)
394
+ analysisCharts.push({ kind: "tornado", contentHeight: tornadoBoxHeight });
395
+ if (showScurve)
396
+ analysisCharts.push({ kind: "scurve", contentHeight: scurveBoxHeight });
397
+ const analysisHasContent = summaryRendered || analysisCharts.length > 0 || fieldLegendInAnalysisRow;
398
+ const fieldLegendStandalone = opts.showFieldLegend && !fieldLegendInAnalysisRow;
399
+ let minContentWidth = 0;
400
+ if (analysisHasContent) {
401
+ const col1Used = summaryRendered || fieldLegendInAnalysisRow;
402
+ if (col1Used) minContentWidth += col1Width;
403
+ for (const w of analysisCharts) {
404
+ minContentWidth += w.kind === "tornado" ? TORNADO_MIN_W : SCURVE_MIN_W;
405
+ }
406
+ const colCount = (col1Used ? 1 : 0) + analysisCharts.length;
407
+ if (colCount > 1) minContentWidth += (colCount - 1) * ANALYSIS_GAP;
408
+ }
409
+ return {
410
+ summaryRendered,
411
+ showTornado,
412
+ showScurve,
413
+ fieldLegendInAnalysisRow,
414
+ fieldLegendStandalone,
415
+ analysisHasContent,
416
+ tornadoRows,
417
+ scurveData,
418
+ analysisCharts,
419
+ captionBoxHeight,
420
+ fieldLegendCol1Height,
421
+ tornadoBoxHeight,
422
+ scurveBoxHeight,
423
+ col1Width,
424
+ col1Height,
425
+ analysisRowHeight,
426
+ minContentWidth
427
+ };
428
+ }
429
+ function analysisLayerHeightAt(state, availableWidth) {
430
+ if (!state.analysisHasContent) {
431
+ return state.fieldLegendStandalone ? CAPTION_TOP_GAP + fieldLegendHeightFor(availableWidth) : 0;
432
+ }
433
+ if (availableWidth >= state.minContentWidth) {
434
+ return CAPTION_TOP_GAP + state.analysisRowHeight;
435
+ }
436
+ const rows = packRows(state, availableWidth);
437
+ let total = 0;
438
+ rows.forEach((row, i) => {
439
+ let rowHeight = 0;
440
+ for (const item of row) {
441
+ rowHeight = Math.max(
442
+ rowHeight,
443
+ itemContentHeight(state, item.kind, item.paintWidth)
444
+ );
445
+ }
446
+ total += rowHeight;
447
+ if (i < rows.length - 1) total += ANALYSIS_GAP;
448
+ });
449
+ return CAPTION_TOP_GAP + total;
450
+ }
451
+ function paintAnalysisLayer(svg, resolved, palette, isDark, state, captionBullets, x, y, availableWidth) {
452
+ if (!state.analysisHasContent) {
453
+ if (!state.fieldLegendStandalone) return 0;
454
+ const bandY = y + CAPTION_TOP_GAP;
455
+ const h = fieldLegendHeightFor(availableWidth);
456
+ renderFieldLegendBlock(svg, {
457
+ x,
458
+ y: bandY,
459
+ width: availableWidth,
460
+ height: h,
461
+ palette,
462
+ isDark
463
+ });
464
+ return CAPTION_TOP_GAP + h;
465
+ }
466
+ if (availableWidth >= state.minContentWidth) {
467
+ return paintAnalysisRowMode(
468
+ svg,
469
+ resolved,
470
+ palette,
471
+ isDark,
472
+ state,
473
+ captionBullets,
474
+ x,
475
+ y,
476
+ availableWidth
477
+ );
478
+ }
479
+ return paintAnalysisStackMode(
480
+ svg,
481
+ resolved,
482
+ palette,
483
+ isDark,
484
+ state,
485
+ captionBullets,
486
+ x,
487
+ y,
488
+ availableWidth
489
+ );
490
+ }
491
+ function paintAnalysisRowMode(svg, resolved, palette, isDark, state, captionBullets, x, y, availableWidth) {
492
+ const bandY = y + CAPTION_TOP_GAP;
493
+ const col1Used = state.summaryRendered || state.fieldLegendInAnalysisRow;
494
+ const colCount = (col1Used ? 1 : 0) + state.analysisCharts.length;
495
+ const nGaps = Math.max(0, colCount - 1);
496
+ const usableWidth = availableWidth - nGaps * ANALYSIS_GAP;
497
+ const chartWidth = state.analysisCharts.length > 0 ? (usableWidth - state.col1Width) / state.analysisCharts.length : 0;
498
+ let cursorX = x;
499
+ for (const w of state.analysisCharts) {
500
+ const args = {
501
+ x: cursorX,
502
+ y: bandY,
503
+ width: chartWidth,
504
+ height: state.analysisRowHeight,
505
+ palette,
506
+ isDark
507
+ };
508
+ if (w.kind === "tornado") {
509
+ renderTornadoBlock(svg, state.tornadoRows, args);
510
+ } else {
511
+ const scurveTitle = !state.summaryRendered && captionBullets.length > 0 ? (
512
+ // In-bounds by length check.
513
+ captionBullets[0].text
514
+ ) : void 0;
515
+ renderScurveBlock(svg, state.scurveData, {
516
+ ...args,
517
+ unit: resolved.options.timeUnit,
518
+ ...scurveTitle !== void 0 && { title: scurveTitle }
519
+ });
520
+ }
521
+ cursorX += chartWidth + ANALYSIS_GAP;
522
+ }
523
+ if (col1Used) {
524
+ let stackY = bandY;
525
+ if (state.summaryRendered) {
526
+ renderCaptionBlock(svg, captionBullets, {
527
+ x: cursorX,
528
+ y: stackY,
529
+ width: state.col1Width,
530
+ height: state.captionBoxHeight,
531
+ palette,
532
+ isDark
533
+ });
534
+ stackY += state.captionBoxHeight + COL1_VSTACK_GAP;
535
+ }
536
+ if (state.fieldLegendInAnalysisRow) {
537
+ renderFieldLegendBlock(svg, {
538
+ x: cursorX,
539
+ y: stackY,
540
+ width: state.col1Width,
541
+ height: state.fieldLegendCol1Height,
542
+ palette,
543
+ isDark
544
+ });
545
+ }
546
+ }
547
+ return CAPTION_TOP_GAP + state.analysisRowHeight;
548
+ }
549
+ var FIELD_LEGEND_MIN_W = 220;
550
+ function packRows(state, availableWidth) {
551
+ const rows = [];
552
+ const charts = state.analysisCharts;
553
+ if (charts.length === 2) {
554
+ const minTwo = (charts[0].kind === "tornado" ? TORNADO_MIN_W : SCURVE_MIN_W) + ANALYSIS_GAP + (charts[1].kind === "tornado" ? TORNADO_MIN_W : SCURVE_MIN_W);
555
+ if (availableWidth >= minTwo) {
556
+ const itemW = (availableWidth - ANALYSIS_GAP) / 2;
557
+ rows.push([
558
+ { kind: charts[0].kind, paintWidth: itemW },
559
+ { kind: charts[1].kind, paintWidth: itemW }
560
+ ]);
561
+ } else {
562
+ for (const c of charts) {
563
+ rows.push([{ kind: c.kind, paintWidth: availableWidth }]);
564
+ }
565
+ }
566
+ } else if (charts.length === 1) {
567
+ rows.push([{ kind: charts[0].kind, paintWidth: availableWidth }]);
568
+ }
569
+ const hasSummary = state.summaryRendered;
570
+ const hasField = state.fieldLegendInAnalysisRow;
571
+ if (hasSummary && hasField) {
572
+ const summaryW = state.col1Width;
573
+ const fieldW = availableWidth - summaryW - ANALYSIS_GAP;
574
+ if (fieldW >= FIELD_LEGEND_MIN_W) {
575
+ rows.push([
576
+ { kind: "summary", paintWidth: summaryW },
577
+ { kind: "field", paintWidth: fieldW }
578
+ ]);
579
+ } else {
580
+ rows.push([{ kind: "summary", paintWidth: summaryW }]);
581
+ rows.push([{ kind: "field", paintWidth: availableWidth }]);
582
+ }
583
+ } else if (hasSummary) {
584
+ rows.push([{ kind: "summary", paintWidth: state.col1Width }]);
585
+ } else if (hasField) {
586
+ rows.push([{ kind: "field", paintWidth: availableWidth }]);
587
+ }
588
+ return rows;
589
+ }
590
+ function itemContentHeight(state, kind, paintWidth) {
591
+ switch (kind) {
592
+ case "tornado":
593
+ return state.tornadoBoxHeight;
594
+ case "scurve":
595
+ return state.scurveBoxHeight;
596
+ case "summary":
597
+ return state.captionBoxHeight;
598
+ case "field":
599
+ return fieldLegendHeightFor(paintWidth);
600
+ }
601
+ }
602
+ function paintAnalysisStackMode(svg, resolved, palette, isDark, state, captionBullets, x, y, availableWidth) {
603
+ const rows = packRows(state, availableWidth);
604
+ let cursorY = y + CAPTION_TOP_GAP;
605
+ rows.forEach((row, rowIndex) => {
606
+ const gaps = Math.max(0, row.length - 1) * ANALYSIS_GAP;
607
+ const totalRowW = row.reduce((a, it) => a + it.paintWidth, 0) + gaps;
608
+ const rowOffset = Math.max(0, (availableWidth - totalRowW) / 2);
609
+ let rowHeight = 0;
610
+ for (const item of row) {
611
+ rowHeight = Math.max(
612
+ rowHeight,
613
+ itemContentHeight(state, item.kind, item.paintWidth)
614
+ );
615
+ }
616
+ let cursorX = x + rowOffset;
617
+ for (const item of row) {
618
+ const args = {
619
+ x: cursorX,
620
+ y: cursorY,
621
+ width: item.paintWidth,
622
+ height: rowHeight,
623
+ palette,
624
+ isDark
625
+ };
626
+ switch (item.kind) {
627
+ case "tornado":
628
+ renderTornadoBlock(svg, state.tornadoRows, args);
629
+ break;
630
+ case "scurve": {
631
+ const scurveTitle = !state.summaryRendered && captionBullets.length > 0 ? (
632
+ // In-bounds by length check.
633
+ captionBullets[0].text
634
+ ) : void 0;
635
+ renderScurveBlock(svg, state.scurveData, {
636
+ ...args,
637
+ unit: resolved.options.timeUnit,
638
+ ...scurveTitle !== void 0 && { title: scurveTitle }
639
+ });
640
+ break;
641
+ }
642
+ case "summary":
643
+ renderCaptionBlock(svg, captionBullets, args);
644
+ break;
645
+ case "field":
646
+ renderFieldLegendBlock(svg, args);
647
+ break;
648
+ }
649
+ cursorX += item.paintWidth + ANALYSIS_GAP;
650
+ }
651
+ cursorY += rowHeight;
652
+ if (rowIndex < rows.length - 1) cursorY += ANALYSIS_GAP;
653
+ });
654
+ return cursorY - y;
655
+ }
656
+ function measurePertAnalysisBlock(resolved, width, options) {
657
+ const captionRows = resolved.error !== null ? null : resolved.summaryRows;
658
+ const captionBullets = captionRows !== null && captionRows.length > 0 ? bulletizeCaption(captionRows) : [];
659
+ const anchorAnnotation = anchorAnnotationText(resolved);
660
+ if (anchorAnnotation) {
661
+ captionBullets.push({ text: anchorAnnotation, level: 0, italic: true });
662
+ }
663
+ const state = computeAnalysisLayer(resolved, captionBullets, {
664
+ showSummary: options.showSummary ?? true,
665
+ showTornado: options.showTornado ?? false,
666
+ showScurve: options.showScurve ?? false,
667
+ showFieldLegend: options.showFieldLegend ?? false
668
+ });
669
+ if (!state.analysisHasContent && !state.fieldLegendStandalone) {
670
+ return { width: 0, height: 0 };
671
+ }
672
+ const itemMinW = Math.max(
673
+ state.summaryRendered ? SUMMARY_MIN_W : 0,
674
+ state.showTornado ? TORNADO_MIN_W : 0,
675
+ state.showScurve ? SCURVE_MIN_W : 0,
676
+ 0
677
+ );
678
+ const w = Math.max(width, itemMinW);
679
+ return { width: w, height: analysisLayerHeightAt(state, w) };
680
+ }
681
+ function renderPertAnalysisBlock(container, resolved, palette, isDark, options) {
682
+ d3Selection.select(container).selectAll(":not([data-d3-tooltip])").remove();
683
+ const captionRows = resolved.error !== null ? null : resolved.summaryRows;
684
+ const captionBullets = captionRows !== null && captionRows.length > 0 ? bulletizeCaption(captionRows) : [];
685
+ const anchorAnnotation = anchorAnnotationText(resolved);
686
+ if (anchorAnnotation) {
687
+ captionBullets.push({ text: anchorAnnotation, level: 0, italic: true });
688
+ }
689
+ const state = computeAnalysisLayer(resolved, captionBullets, {
690
+ showSummary: options.showSummary ?? true,
691
+ showTornado: options.showTornado ?? false,
692
+ showScurve: options.showScurve ?? false,
693
+ showFieldLegend: options.showFieldLegend ?? false
694
+ });
695
+ if (!state.analysisHasContent && !state.fieldLegendStandalone) return;
696
+ const itemMinW = Math.max(
697
+ state.summaryRendered ? SUMMARY_MIN_W : 0,
698
+ state.showTornado ? TORNADO_MIN_W : 0,
699
+ state.showScurve ? SCURVE_MIN_W : 0,
700
+ // Field labels has no hard min — it wraps to whatever width it gets.
701
+ 0
702
+ );
703
+ const width = Math.max(options.width, itemMinW);
704
+ const totalHeight = analysisLayerHeightAt(state, width);
705
+ if (totalHeight <= 0 || width <= 0) return;
706
+ const svg = d3Selection.select(container).append("svg").attr("width", width).attr("height", totalHeight).attr("viewBox", `0 0 ${width} ${totalHeight}`).attr("preserveAspectRatio", "xMidYMin meet").style("font-family", FONT_FAMILY).style("overflow", "visible");
707
+ paintAnalysisLayer(
708
+ svg,
709
+ resolved,
710
+ palette,
711
+ isDark,
712
+ state,
713
+ captionBullets,
714
+ 0,
715
+ 0,
716
+ width
717
+ );
718
+ }
719
+ function buildArrowheads(defs, palette, arrowW = ARROWHEAD_W, arrowH = ARROWHEAD_H) {
720
+ const mk = (id, fill) => {
721
+ defs.append("marker").attr("id", id).attr("viewBox", `0 0 ${arrowW} ${arrowH}`).attr("refX", arrowW).attr("refY", arrowH / 2).attr("markerWidth", arrowW).attr("markerHeight", arrowH).attr("orient", "auto").append("polygon").attr("points", `0,0 ${arrowW},${arrowH / 2} 0,${arrowH}`).attr("fill", fill);
722
+ };
723
+ mk("pert-arrow", palette.textMuted);
724
+ mk("pert-arrow-red", palette.colors.red);
725
+ mk("pert-arrow-orange", palette.colors.orange);
726
+ mk("pert-arrow-yellow", palette.colors.yellow);
727
+ mk("pert-arrow-green", palette.colors.green);
728
+ mk("pert-arrow-blue", palette.colors.blue);
729
+ }
730
+ function renderGroups(root, resolved, layout, palette, isDark, collapsedSet, sizing, sc = {}) {
731
+ if (layout.groups.length === 0) return;
732
+ const layer = root.append("g").attr("class", "pert-groups");
733
+ const unit = resolved.options.timeUnit;
734
+ const solid = resolved.options.solidFill === true;
735
+ const containerFill = mix(palette.surface, palette.bg, 40);
736
+ const containerStroke = palette.textMuted;
737
+ const mcOn = resolved.monteCarloResult !== null;
738
+ const groupHasCritical = (groupId) => resolved.activities.some(
739
+ (a) => a.activity.groupId === groupId && a.isCriticalPath
740
+ );
741
+ const groupBand = (groupId, mcCriticality) => mcOn ? criticalityBand(mcCriticality) : groupHasCritical(groupId) ? "red" : null;
742
+ for (const grp of layout.groups) {
743
+ if (grp.width <= 0 || grp.height <= 0) continue;
744
+ const resolvedGroup = resolved.groups.find((rg) => rg.group.id === grp.id);
745
+ const label = resolvedGroup?.group.name ?? grp.id;
746
+ const isCollapsed = collapsedSet.has(grp.id);
747
+ const memberBand = groupBand(grp.id, resolvedGroup?.criticality ?? null);
748
+ const memberCritical = groupHasCritical(grp.id);
749
+ const g = layer.append("g").attr(
750
+ "class",
751
+ isCollapsed ? "pert-group pert-group-collapsed" : "pert-group"
752
+ ).attr("data-group-id", grp.id).attr("data-group-toggle", grp.id).attr("data-collapsed", String(isCollapsed)).attr("data-line-number", String(resolvedGroup?.group.lineNumber ?? 0)).attr("data-critical-path", String(memberCritical)).attr("data-criticality-band", memberBand ?? "").style("cursor", "pointer");
753
+ if (isCollapsed) {
754
+ const projectStart = resolved.projectStart;
755
+ const muStr = formatDuration(resolvedGroup?.rolledMu ?? null, unit, "?");
756
+ const slackStr = formatSlackValue(
757
+ resolvedGroup?.slack ?? null,
758
+ projectStart,
759
+ unit,
760
+ "?"
761
+ );
762
+ const esStr = formatScheduleValue(
763
+ resolvedGroup?.es ?? null,
764
+ projectStart,
765
+ unit,
766
+ "?"
767
+ );
768
+ const efStr = formatScheduleValue(
769
+ resolvedGroup?.ef ?? null,
770
+ projectStart,
771
+ unit,
772
+ "?"
773
+ );
774
+ const lsStr = formatScheduleValue(
775
+ resolvedGroup?.ls ?? null,
776
+ projectStart,
777
+ unit,
778
+ "?"
779
+ );
780
+ const lfStr = formatScheduleValue(
781
+ resolvedGroup?.lf ?? null,
782
+ projectStart,
783
+ unit,
784
+ "?"
785
+ );
786
+ const cardBaseColor = bandColor(memberBand, palette, palette.primary);
787
+ const cardFill = shapeFill(palette, cardBaseColor, isDark, { solid });
788
+ const cardLabelColor = contrastText(
789
+ cardFill,
790
+ palette.textOnFillLight,
791
+ palette.textOnFillDark
792
+ );
793
+ const sNR = sc.nodeRadius ?? NODE_RADIUS;
794
+ const sCBH = sc.collapseBarHeight ?? COLLAPSE_BAR_HEIGHT;
795
+ drawTextbookCard(g, {
796
+ width: grp.width,
797
+ height: grp.height,
798
+ x: grp.x,
799
+ y: grp.y,
800
+ name: label,
801
+ es: esStr,
802
+ dur: muStr,
803
+ ef: efStr,
804
+ ls: lsStr,
805
+ slack: slackStr,
806
+ lf: lfStr,
807
+ fill: cardFill,
808
+ stroke: cardBaseColor,
809
+ labelColor: cardLabelColor,
810
+ highlightColor: palette.colors.blue,
811
+ outerColW: sizing.outerColW,
812
+ midColW: sizing.midColW,
813
+ sNodeRadius: sc.nodeRadius,
814
+ sNodeStrokeWidth: sc.nodeStrokeWidth,
815
+ sNodeTopRowHeight: sc.nodeTopRowHeight,
816
+ sNodeBottomRowHeight: sc.nodeBottomRowHeight,
817
+ sNodeFontSize: sc.nodeFontSize,
818
+ sNodeCellFontSize: sc.nodeCellFontSize,
819
+ sPinIconW: sc.pinIconW,
820
+ sPinIconH: sc.pinIconH
821
+ });
822
+ const safeGroupId = grp.id.replace(/[^A-Za-z0-9_-]/g, "_");
823
+ const clipId = `pert-group-clip-${safeGroupId}`;
824
+ g.append("clipPath").attr("id", clipId).append("rect").attr("x", grp.x).attr("y", grp.y).attr("width", grp.width).attr("height", grp.height).attr("rx", sNR).attr("ry", sNR);
825
+ g.append("rect").attr("class", "pert-collapse-bar").attr("x", grp.x).attr("y", grp.y + grp.height - sCBH).attr("width", grp.width).attr("height", sCBH).attr("fill", cardBaseColor).attr("clip-path", `url(#${clipId})`);
826
+ continue;
827
+ }
828
+ const sCR = sc.containerRadius ?? CONTAINER_RADIUS;
829
+ const sCLFS = sc.containerLabelFontSize ?? CONTAINER_LABEL_FONT_SIZE;
830
+ const sCHH = sc.containerHeaderHeight ?? CONTAINER_HEADER_HEIGHT;
831
+ const sNSW = sc.nodeStrokeWidth ?? NODE_STROKE_WIDTH;
832
+ g.append("rect").attr("x", grp.x).attr("y", grp.y).attr("width", grp.width).attr("height", grp.height).attr("rx", sCR).attr("ry", sCR).attr("fill", containerFill).attr("stroke", containerStroke).attr("stroke-opacity", 0.35).attr("stroke-width", sNSW);
833
+ g.append("text").attr("x", grp.x + grp.width / 2).attr("y", grp.y + sCHH / 2 + sCLFS / 2 - 2).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("fill", palette.text).attr("font-size", sCLFS).attr("font-weight", "bold").text(label);
834
+ }
835
+ }
836
+ function renderEdges(root, resolved, layout, palette, collapsedSet, sc = {}) {
837
+ const layer = root.append("g").attr("class", "pert-edges");
838
+ const criticalSet = new Set(resolved.criticalPath);
839
+ const mcOn = resolved.monteCarloResult !== null;
840
+ const edgeByKey = /* @__PURE__ */ new Map();
841
+ for (const e of resolved.edges) {
842
+ edgeByKey.set(`${e.source}->${e.target}`, e);
843
+ }
844
+ const activityGroup = /* @__PURE__ */ new Map();
845
+ const critById = /* @__PURE__ */ new Map();
846
+ for (const a of resolved.activities) {
847
+ activityGroup.set(a.activity.id, a.activity.groupId);
848
+ critById.set(a.activity.id, a.criticality);
849
+ }
850
+ for (const rg of resolved.groups) {
851
+ if (!collapsedSet.has(rg.group.id)) continue;
852
+ let anyCritical = false;
853
+ let maxC = null;
854
+ for (const aid of rg.group.activityIds) {
855
+ if (criticalSet.has(aid)) anyCritical = true;
856
+ const c = critById.get(aid);
857
+ if (typeof c === "number") {
858
+ maxC = maxC === null ? c : Math.max(maxC, c);
859
+ }
860
+ }
861
+ if (anyCritical) criticalSet.add(rg.group.id);
862
+ critById.set(rg.group.id, maxC);
863
+ }
864
+ for (const e of layout.edges) {
865
+ if (e.points.length < 2) continue;
866
+ const srcGroup = activityGroup.get(e.source);
867
+ const tgtGroup = activityGroup.get(e.target);
868
+ if (srcGroup && tgtGroup && srcGroup === tgtGroup && collapsedSet.has(srcGroup)) {
869
+ continue;
870
+ }
871
+ const isCritical = criticalSet.has(e.source) && criticalSet.has(e.target);
872
+ let band;
873
+ if (mcOn) {
874
+ const sc2 = critById.get(e.source);
875
+ const tc = critById.get(e.target);
876
+ const minC = sc2 === null || tc === null || sc2 === void 0 || tc === void 0 ? null : Math.min(sc2, tc);
877
+ band = criticalityBand(minC);
878
+ if (band === null && isCritical) band = "red";
879
+ } else {
880
+ band = isCritical ? "red" : null;
881
+ }
882
+ const path = lineGenerator(e.points);
883
+ if (!path) continue;
884
+ const sESW = sc.edgeStrokeWidth ?? EDGE_STROKE_WIDTH;
885
+ const sELFS = sc.edgeLabelFontSize ?? 10;
886
+ layer.append("path").attr("class", "pert-edge").attr("d", path).attr("fill", "none").attr("stroke", bandColor(band, palette, palette.textMuted)).attr("stroke-width", sESW).attr("marker-end", `url(#${bandArrow(band)})`).attr("data-source", e.source).attr("data-target", e.target).attr("data-critical", String(isCritical)).attr("data-critical-path", String(isCritical)).attr("data-criticality-band", band ?? "");
887
+ const parsedEdge = edgeByKey.get(`${e.source}->${e.target}`);
888
+ const labelText = parsedEdge ? formatEdgeLabel(parsedEdge) : null;
889
+ if (labelText) {
890
+ const mid = e.points[Math.floor(e.points.length / 2)];
891
+ layer.append("text").attr("class", "pert-edge-label").attr("x", mid.x).attr("y", mid.y - 4).attr("text-anchor", "middle").attr("fill", palette.textMuted).attr("font-size", sELFS).attr("paint-order", "stroke").attr("stroke", palette.bg).attr("stroke-width", 3).attr("stroke-linejoin", "round").attr("data-edge-source", e.source).attr("data-edge-target", e.target).text(labelText);
892
+ }
893
+ }
894
+ }
895
+ function formatEdgeLabel(edge) {
896
+ if (edge.type === "FS" && edge.lag === null) return null;
897
+ const parts = [];
898
+ if (edge.type !== "FS") parts.push(edge.type);
899
+ if (edge.lag) {
900
+ const sign = edge.lag.amount >= 0 ? "+" : "-";
901
+ const amount = Math.abs(edge.lag.amount);
902
+ parts.push(`${sign}${amount}${edge.lag.unit}`);
903
+ }
904
+ return parts.join(" ");
905
+ }
906
+ function renderNodes(root, _defs, resolved, layout, palette, isDark, sizing, onClickItem, collapsedSet = /* @__PURE__ */ new Set(), activeTagOverride, sc = {}) {
907
+ const layer = root.append("g").attr("class", "pert-nodes");
908
+ const byId = new Map(resolved.activities.map((r) => [r.activity.id, r]));
909
+ const tbdSet = new Set(
910
+ resolved.activities.filter((r) => r.es === null).map((r) => r.activity.id)
911
+ );
912
+ const unit = resolved.options.timeUnit;
913
+ const sprintMode = resolved.options.sprintMode;
914
+ const sprintNumber = resolved.options.sprintNumber ?? 1;
915
+ const solid = resolved.options.solidFill === true;
916
+ const activeTagGroup = resolveActiveTagGroup(
917
+ resolved.tagGroups,
918
+ resolved.options.activeTag,
919
+ activeTagOverride
920
+ );
921
+ const projectStart = resolved.projectStart;
922
+ const fmtSchedule = (v, isTbd) => {
923
+ if (sprintMode)
924
+ return formatSprintCell(v, sprintNumber, isTbd ? "?" : null);
925
+ return formatScheduleValue(v, projectStart, unit, isTbd ? "?" : null);
926
+ };
927
+ const fmtSlack = (v, isTbd) => formatSlackValue(v, projectStart, unit, isTbd ? "?" : null);
928
+ const fmtDur = (v, isTbd) => formatDuration(v, unit, isTbd ? "?" : null);
929
+ const mcOn = resolved.monteCarloResult !== null;
930
+ const { topMuIds, bottomMuIds } = computeDurationEmphasis(
931
+ resolved.activities
932
+ );
933
+ const pinnedSet = computeAnchorPinSet(resolved);
934
+ const anchorKind = resolved.options.anchor?.kind ?? null;
935
+ for (const node of layout.nodes) {
936
+ const r = byId.get(node.id);
937
+ if (!r) continue;
938
+ if (r.activity.groupId && collapsedSet.has(r.activity.groupId)) continue;
939
+ const isCritical = r.isCriticalPath;
940
+ const isTbd = tbdSet.has(node.id);
941
+ const dashArray = isTbd ? "4,3" : "none";
942
+ const isTopMu = topMuIds.has(node.id);
943
+ const isBottomMu = bottomMuIds.has(node.id);
944
+ let band;
945
+ if (mcOn) {
946
+ band = criticalityBand(r.criticality);
947
+ if (band === null && isCritical) band = "red";
948
+ } else {
949
+ band = isCritical ? "red" : null;
950
+ }
951
+ const g = layer.append("g").attr("class", "pert-node").attr("transform", `translate(${node.x}, ${node.y})`).attr("data-activity-id", node.id).attr("data-line-number", String(r.activity.lineNumber)).attr(
952
+ "data-group-id",
953
+ r.activity.groupId !== void 0 ? r.activity.groupId : ""
954
+ ).attr("data-critical-path", String(isCritical)).attr("data-criticality-band", band ?? "").attr("data-duration-rank", isTopMu ? "top" : isBottomMu ? "bottom" : "");
955
+ if (r.activity.tags) {
956
+ for (const [tagKey, tagValue] of Object.entries(r.activity.tags)) {
957
+ g.attr(`data-tag-${tagKey}`, String(tagValue).toLowerCase());
958
+ }
959
+ }
960
+ if (pinnedSet.has(node.id) && anchorKind) {
961
+ g.attr("data-anchor", anchorKind);
962
+ }
963
+ if (onClickItem) {
964
+ g.style("cursor", "pointer").on(
965
+ "click",
966
+ () => onClickItem(r.activity.lineNumber)
967
+ );
968
+ }
969
+ const baseColor = bandColor(band, palette, palette.primary);
970
+ const fill = shapeFill(palette, baseColor, isDark, { solid });
971
+ const labelColor = contrastText(
972
+ fill,
973
+ palette.textOnFillLight,
974
+ palette.textOnFillDark
975
+ );
976
+ const tagColor = resolveTagColor(
977
+ r.activity.tags ?? {},
978
+ resolved.tagGroups,
979
+ activeTagGroup
980
+ );
981
+ const hasTagColor = tagColor !== void 0 && tagColor !== "#999999";
982
+ const tagBandFill = hasTagColor ? shapeFill(palette, tagColor, isDark, { solid }) : void 0;
983
+ const tagLabelColor = hasTagColor ? contrastText(
984
+ tagBandFill,
985
+ palette.textOnFillLight,
986
+ palette.textOnFillDark
987
+ ) : void 0;
988
+ if (r.activity.isMilestone) {
989
+ const slackText = fmtSlack(r.slack, isTbd);
990
+ const slackHidden = !isTbd && /^0[a-z]?$/.test(slackText);
991
+ g.attr("data-milestone", "true");
992
+ if (slackHidden) g.attr("data-milestone-slack-hidden", "true");
993
+ drawMilestonePill(g, {
994
+ width: node.width,
995
+ height: node.height,
996
+ x: -node.width / 2,
997
+ y: -node.height / 2,
998
+ name: `\u25C6 ${r.activity.name}`,
999
+ date: fmtSchedule(r.es, isTbd),
1000
+ slack: slackText,
1001
+ slackHidden,
1002
+ fill: tagBandFill ?? fill,
1003
+ stroke: baseColor,
1004
+ labelColor: tagLabelColor ?? labelColor,
1005
+ highlightColor: palette.colors.blue,
1006
+ dashArray,
1007
+ pinned: pinnedSet.has(node.id) ? anchorKind : null,
1008
+ sNodeRadius: sc.nodeRadius,
1009
+ sNodeStrokeWidth: sc.nodeStrokeWidth,
1010
+ sNodeTopRowHeight: sc.nodeTopRowHeight,
1011
+ sNodeBottomRowHeight: sc.nodeBottomRowHeight,
1012
+ sNodeCellFontSize: sc.nodeCellFontSize,
1013
+ sPinIconW: sc.pinIconW,
1014
+ sPinIconH: sc.pinIconH
1015
+ });
1016
+ continue;
1017
+ }
1018
+ drawTextbookCard(g, {
1019
+ width: node.width,
1020
+ height: node.height,
1021
+ x: -node.width / 2,
1022
+ y: -node.height / 2,
1023
+ name: r.activity.name,
1024
+ es: fmtSchedule(r.es, isTbd),
1025
+ dur: fmtDur(r.mu, isTbd),
1026
+ ef: fmtSchedule(r.ef, isTbd),
1027
+ ls: fmtSchedule(r.ls, isTbd),
1028
+ slack: fmtSlack(r.slack, isTbd),
1029
+ lf: fmtSchedule(r.lf, isTbd),
1030
+ fill,
1031
+ stroke: baseColor,
1032
+ highlightColor: palette.colors.blue,
1033
+ labelColor,
1034
+ dashArray,
1035
+ emphasis: isTopMu ? "top" : isBottomMu ? "bottom" : null,
1036
+ pinned: pinnedSet.has(node.id) ? anchorKind : null,
1037
+ outerColW: sizing.outerColW,
1038
+ midColW: sizing.midColW,
1039
+ ...tagBandFill !== void 0 && { midBandFill: tagBandFill },
1040
+ ...tagLabelColor !== void 0 && { midBandLabelColor: tagLabelColor },
1041
+ sNodeRadius: sc.nodeRadius,
1042
+ sNodeStrokeWidth: sc.nodeStrokeWidth,
1043
+ sNodeTopRowHeight: sc.nodeTopRowHeight,
1044
+ sNodeBottomRowHeight: sc.nodeBottomRowHeight,
1045
+ sNodeFontSize: sc.nodeFontSize,
1046
+ sNodeCellFontSize: sc.nodeCellFontSize,
1047
+ sPinIconW: sc.pinIconW,
1048
+ sPinIconH: sc.pinIconH
1049
+ });
1050
+ }
1051
+ }
1052
+ function computeDurationEmphasis(activities) {
1053
+ const ranked = activities.filter(
1054
+ (r) => !r.activity.isMilestone && r.mu !== null && r.mu > 0
1055
+ ).map((r) => ({ id: r.activity.id, mu: r.mu })).sort((a, b) => a.mu - b.mu);
1056
+ if (ranked.length < 5) {
1057
+ return { topMuIds: /* @__PURE__ */ new Set(), bottomMuIds: /* @__PURE__ */ new Set() };
1058
+ }
1059
+ const tierCount = Math.max(1, Math.floor(ranked.length * 0.2));
1060
+ const bottomMuIds = new Set(ranked.slice(0, tierCount).map((b) => b.id));
1061
+ const topMuIds = new Set(ranked.slice(-tierCount).map((b) => b.id));
1062
+ return { topMuIds, bottomMuIds };
1063
+ }
1064
+ function drawTextbookCard(g, a) {
1065
+ const { width: w, height: h, x, y } = a;
1066
+ const sNR = a.sNodeRadius ?? NODE_RADIUS;
1067
+ const sNSW = a.sNodeStrokeWidth ?? NODE_STROKE_WIDTH;
1068
+ const sTRH = a.sNodeTopRowHeight ?? NODE_TOP_ROW_HEIGHT;
1069
+ const sBRH = a.sNodeBottomRowHeight ?? NODE_BOTTOM_ROW_HEIGHT;
1070
+ const sNFS = a.sNodeFontSize ?? NODE_FONT_SIZE;
1071
+ const sNCFS = a.sNodeCellFontSize ?? NODE_CELL_FONT_SIZE;
1072
+ const sPIW = a.sPinIconW ?? PIN_ICON_W;
1073
+ const sPIH = a.sPinIconH ?? PIN_ICON_H;
1074
+ const outerColW = a.outerColW;
1075
+ const midColW = a.midColW;
1076
+ const topY = y + sTRH;
1077
+ const bottomY = y + h - sBRH;
1078
+ const colX1 = x + outerColW;
1079
+ const colX2 = x + outerColW + midColW;
1080
+ g.append("rect").attr("x", x).attr("y", y).attr("width", w).attr("height", h).attr("rx", sNR).attr("ry", sNR).attr("fill", a.fill).attr("stroke", a.stroke).attr("stroke-width", sNSW).attr("stroke-dasharray", a.dashArray ?? "none");
1081
+ if (a.midBandFill) {
1082
+ g.append("rect").attr("x", x).attr("y", topY).attr("width", w).attr("height", bottomY - topY).attr("fill", a.midBandFill).attr("pointer-events", "none");
1083
+ }
1084
+ const gridColor = a.gridStroke ?? a.stroke;
1085
+ const grid = (x1, y1, x2, y2) => {
1086
+ g.append("line").attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2).attr("stroke", gridColor).attr("stroke-opacity", 0.3).attr("stroke-width", 1);
1087
+ };
1088
+ grid(x, topY, x + w, topY);
1089
+ grid(x, bottomY, x + w, bottomY);
1090
+ grid(colX1, y, colX1, topY);
1091
+ grid(colX2, y, colX2, topY);
1092
+ grid(colX1, bottomY, colX1, y + h);
1093
+ grid(colX2, bottomY, colX2, y + h);
1094
+ const drawCellHighlight = (field, cx, cy, cw, ch) => {
1095
+ g.append("rect").attr("class", "pert-cell-highlight").attr("data-field", field).attr("x", cx).attr("y", cy).attr("width", cw).attr("height", ch).attr("fill", a.highlightColor).attr("fill-opacity", 0).attr("pointer-events", "none");
1096
+ };
1097
+ drawCellHighlight("es", x, y, outerColW, sTRH);
1098
+ drawCellHighlight("dur", x + outerColW, y, midColW, sTRH);
1099
+ drawCellHighlight("ef", x + outerColW + midColW, y, outerColW, sTRH);
1100
+ drawCellHighlight("ls", x, bottomY, outerColW, sBRH);
1101
+ drawCellHighlight("slack", x + outerColW, bottomY, midColW, sBRH);
1102
+ drawCellHighlight("lf", x + outerColW + midColW, bottomY, outerColW, sBRH);
1103
+ const drawCell = (cx, cy, text, weight = "normal", size = sNCFS, opacity = 1, colorOverride) => {
1104
+ const t = g.append("text").attr("x", cx).attr("y", cy + size / 2 - 2).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("fill", colorOverride ?? a.labelColor).attr("font-size", size).attr("font-weight", weight).text(text);
1105
+ if (opacity !== 1) t.attr("opacity", String(opacity));
1106
+ };
1107
+ const topMid = y + sTRH / 2;
1108
+ const durWeight = a.emphasis === "top" ? "bold" : "normal";
1109
+ const durOpacity = a.emphasis === "bottom" ? DURATION_FADE_OPACITY : 1;
1110
+ const esWeight = a.pinned === "forward" ? "bold" : "normal";
1111
+ const efWeight = a.pinned === "backward" ? "bold" : "normal";
1112
+ drawCell(x + outerColW / 2, topMid, a.es, esWeight);
1113
+ drawCell(
1114
+ x + outerColW + midColW / 2,
1115
+ topMid,
1116
+ a.dur,
1117
+ durWeight,
1118
+ sNCFS,
1119
+ durOpacity
1120
+ );
1121
+ drawCell(x + outerColW + midColW + outerColW / 2, topMid, a.ef, efWeight);
1122
+ const midRowTop = y + sTRH;
1123
+ const midRowH = h - sTRH - sBRH;
1124
+ const midCenterY = midRowTop + midRowH / 2;
1125
+ const NAME_PAD_X = 6;
1126
+ const NAME_PIN_GAP = 4;
1127
+ const pinReserve = a.pinned ? sPIW + NAME_PIN_GAP : 0;
1128
+ const availTextW = Math.max(0, w - 2 * NAME_PAD_X - pinReserve);
1129
+ const displayName = truncateText(a.name, sNFS, availTextW);
1130
+ const nameColor = a.midBandLabelColor ?? a.labelColor;
1131
+ if (a.pinned) {
1132
+ drawAnchorPin(g, x + NAME_PAD_X, midCenterY, nameColor, sPIW, sPIH);
1133
+ const textAreaLeft = x + NAME_PAD_X + sPIW + NAME_PIN_GAP;
1134
+ const textAreaRight = x + w - NAME_PAD_X;
1135
+ const textCx = (textAreaLeft + textAreaRight) / 2;
1136
+ drawCell(
1137
+ textCx,
1138
+ midCenterY,
1139
+ displayName,
1140
+ "bold",
1141
+ sNFS,
1142
+ 1,
1143
+ a.midBandLabelColor
1144
+ );
1145
+ } else {
1146
+ drawCell(
1147
+ x + w / 2,
1148
+ midCenterY,
1149
+ displayName,
1150
+ "bold",
1151
+ sNFS,
1152
+ 1,
1153
+ a.midBandLabelColor
1154
+ );
1155
+ }
1156
+ const botMid = y + h - sBRH / 2;
1157
+ const lsWeight = esWeight;
1158
+ const lfWeight = efWeight;
1159
+ drawCell(x + outerColW / 2, botMid, a.ls, lsWeight);
1160
+ drawCell(x + outerColW + midColW / 2, botMid, a.slack);
1161
+ drawCell(x + outerColW + midColW + outerColW / 2, botMid, a.lf, lfWeight);
1162
+ }
1163
+ function drawMilestonePill(g, a) {
1164
+ const { width: w, height: h, x, y } = a;
1165
+ const sNR = a.sNodeRadius ?? NODE_RADIUS;
1166
+ const sNSW = a.sNodeStrokeWidth ?? NODE_STROKE_WIDTH;
1167
+ const topRowH = a.sNodeTopRowHeight ?? NODE_TOP_ROW_HEIGHT;
1168
+ const botRowH = a.sNodeBottomRowHeight ?? NODE_BOTTOM_ROW_HEIGHT;
1169
+ const sNCFS = a.sNodeCellFontSize ?? NODE_CELL_FONT_SIZE;
1170
+ const sPIW = a.sPinIconW ?? PIN_ICON_W;
1171
+ const sPIH = a.sPinIconH ?? PIN_ICON_H;
1172
+ const topY = y + topRowH;
1173
+ const bottomY = y + h - botRowH;
1174
+ g.append("rect").attr("x", x).attr("y", y).attr("width", w).attr("height", h).attr("rx", sNR).attr("ry", sNR).attr("fill", a.fill).attr("stroke", a.stroke).attr("stroke-width", sNSW).attr("stroke-dasharray", a.dashArray ?? "none");
1175
+ const grid = (x1, y1, x2, y2) => {
1176
+ g.append("line").attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2).attr("stroke", a.stroke).attr("stroke-opacity", 0.3).attr("stroke-width", 1);
1177
+ };
1178
+ grid(x, topY, x + w, topY);
1179
+ if (!a.slackHidden) grid(x, bottomY, x + w, bottomY);
1180
+ const addCellHighlight = (field, cx, cy, cw, ch) => {
1181
+ g.append("rect").attr("class", "pert-cell-highlight").attr("data-field", field).attr("x", cx).attr("y", cy).attr("width", cw).attr("height", ch).attr("fill", a.highlightColor).attr("fill-opacity", 0).attr("pointer-events", "none");
1182
+ };
1183
+ addCellHighlight("es", x, y, w, topRowH);
1184
+ addCellHighlight("ef", x, y, w, topRowH);
1185
+ if (!a.slackHidden) {
1186
+ addCellHighlight("slack", x, bottomY, w, botRowH);
1187
+ }
1188
+ const drawCenteredText = (cx, cy, text, weight, size) => {
1189
+ g.append("text").attr("x", cx).attr("y", cy + size / 2 - 2).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("fill", a.labelColor).attr("font-size", size).attr("font-weight", weight).text(text);
1190
+ };
1191
+ drawCenteredText(x + w / 2, y + topRowH / 2, a.date, "normal", sNCFS);
1192
+ const midRowTop = y + topRowH;
1193
+ const midRowH = h - topRowH - botRowH;
1194
+ const midCenterY = midRowTop + midRowH / 2;
1195
+ const nameSize = 12;
1196
+ const NAME_PAD_X = 6;
1197
+ const NAME_PIN_GAP = 4;
1198
+ const NAME_LINE_HEIGHT = 14;
1199
+ let textAreaLeft = x + NAME_PAD_X;
1200
+ const textAreaRight = x + w - NAME_PAD_X;
1201
+ if (a.pinned) {
1202
+ drawAnchorPin(g, x + NAME_PAD_X, midCenterY, a.labelColor, sPIW, sPIH);
1203
+ textAreaLeft = x + NAME_PAD_X + sPIW + NAME_PIN_GAP;
1204
+ }
1205
+ const textCx = (textAreaLeft + textAreaRight) / 2;
1206
+ const availW = textAreaRight - textAreaLeft;
1207
+ const lines = wrapTextToWidth(a.name, nameSize, availW, { hardBreak: true });
1208
+ const maxLines = Math.max(1, Math.floor(midRowH / NAME_LINE_HEIGHT));
1209
+ const visibleLines = lines.slice(0, maxLines);
1210
+ if (lines.length > maxLines && visibleLines.length > 0) {
1211
+ const last = visibleLines[visibleLines.length - 1];
1212
+ const withEllipsis = `${last}\u2026`;
1213
+ visibleLines[visibleLines.length - 1] = measureText(withEllipsis, nameSize) <= availW ? withEllipsis : truncateText(last, nameSize, availW);
1214
+ }
1215
+ const startCy = midCenterY - (visibleLines.length - 1) * NAME_LINE_HEIGHT / 2;
1216
+ visibleLines.forEach((line2, i) => {
1217
+ drawCenteredText(
1218
+ textCx,
1219
+ startCy + i * NAME_LINE_HEIGHT,
1220
+ line2,
1221
+ "bold",
1222
+ nameSize
1223
+ );
1224
+ });
1225
+ if (!a.slackHidden) {
1226
+ drawCenteredText(x + w / 2, y + h - botRowH / 2, a.slack, "normal", sNCFS);
1227
+ }
1228
+ }
1229
+ function drawAnchorPin(g, left, centerY, color, pinW = PIN_ICON_W, pinH = PIN_ICON_H) {
1230
+ const scale = pinW / 24;
1231
+ const top = centerY - pinH / 2;
1232
+ const pin = g.append("g").attr("class", "pert-pin").attr("data-pert-pin", "").attr("transform", `translate(${left}, ${top}) scale(${scale})`);
1233
+ pin.append("path").attr("d", "M12 22V8 M5 12H2a10 10 0 0 0 20 0h-3").attr("fill", "none").attr("stroke", color).attr("stroke-width", 2).attr("stroke-linecap", "round").attr("stroke-linejoin", "round");
1234
+ pin.append("circle").attr("cx", 12).attr("cy", 5).attr("r", 3).attr("fill", "none").attr("stroke", color).attr("stroke-width", 2);
1235
+ }
1236
+ function computeAnchorPinSet(resolved) {
1237
+ const anchor = resolved.options.anchor;
1238
+ if (anchor === null) return /* @__PURE__ */ new Set();
1239
+ const inDeg = /* @__PURE__ */ new Map();
1240
+ const outDeg = /* @__PURE__ */ new Map();
1241
+ for (const a of resolved.activities) {
1242
+ inDeg.set(a.activity.id, 0);
1243
+ outDeg.set(a.activity.id, 0);
1244
+ }
1245
+ for (const e of resolved.edges) {
1246
+ outDeg.set(e.source, (outDeg.get(e.source) ?? 0) + 1);
1247
+ inDeg.set(e.target, (inDeg.get(e.target) ?? 0) + 1);
1248
+ }
1249
+ const pinned = /* @__PURE__ */ new Set();
1250
+ for (const a of resolved.activities) {
1251
+ if (anchor.kind === "forward" && (inDeg.get(a.activity.id) ?? 0) === 0) {
1252
+ pinned.add(a.activity.id);
1253
+ } else if (anchor.kind === "backward" && (outDeg.get(a.activity.id) ?? 0) === 0) {
1254
+ pinned.add(a.activity.id);
1255
+ }
1256
+ }
1257
+ return pinned;
1258
+ }
1259
+ function anchorAnnotationText(resolved) {
1260
+ const anchor = resolved.options.anchor;
1261
+ if (anchor === null) return null;
1262
+ const today = resolved.options.today;
1263
+ if (anchor.kind === "forward") {
1264
+ return `Forward from start-date ${anchor.date}`;
1265
+ }
1266
+ const asOf = today ? ` (as of ${today})` : "";
1267
+ if (resolved.projectStart) {
1268
+ return `Backward-anchored from end-date ${anchor.date}${asOf}`;
1269
+ }
1270
+ return `Backward-anchored from end-date ${anchor.date}${asOf} \u2014 upstream activities still need estimates`;
1271
+ }
1272
+ function bulletizeCaption(rows) {
1273
+ return rows.map((row) => {
1274
+ const out = { text: row.text, level: row.level };
1275
+ if (row.italic) out.italic = true;
1276
+ if (row.isPast) out.isPast = true;
1277
+ return out;
1278
+ });
1279
+ }
1280
+ var SUB_BULLET_INDENT = 20;
1281
+ var CAPTION_HEADER_BAND_HEIGHT = CAPTION_LINE_HEIGHT + 8;
1282
+ function captionNaturalWidth(bullets) {
1283
+ const charW = CAPTION_FONT_SIZE * 0.55;
1284
+ let max = "Summary".length * charW;
1285
+ for (const b of bullets) {
1286
+ const indent = b.level === 1 ? SUB_BULLET_INDENT : 0;
1287
+ const w = indent + `\u2022 ${b.text}`.length * charW;
1288
+ if (w > max) max = w;
1289
+ }
1290
+ return Math.ceil(max + 2 * CAPTION_BOX_PADDING_X);
1291
+ }
1292
+ var TORNADO_TOP_N = 10;
1293
+ var TORNADO_ROW_HEIGHT = 26;
1294
+ var TORNADO_NAME_COL_W = 160;
1295
+ var TORNADO_BAR_FONT_SIZE = 13;
1296
+ var TORNADO_BAR_HEIGHT = 16;
1297
+ var SUMMARY_MIN_W = 260;
1298
+ var SUMMARY_MAX_W = 420;
1299
+ var ANALYSIS_GAP = 16;
1300
+ var COL1_VSTACK_GAP = 8;
1301
+ var TORNADO_MIN_W = 340;
1302
+ var SCURVE_MIN_W = 320;
1303
+ var SCURVE_BOX_HEIGHT = 220;
1304
+ var SCURVE_PLOT_PADDING_X = 64;
1305
+ var SCURVE_PLOT_PADDING_RIGHT = 16;
1306
+ var SCURVE_PLOT_PADDING_BOTTOM = 44;
1307
+ var SCURVE_TICK_FONT_SIZE = 13;
1308
+ var SCURVE_PERCENTILE_RADIUS = 4;
1309
+ function renderCaptionBlock(svg, bullets, args) {
1310
+ const { x, y, width, height, palette, isDark } = args;
1311
+ const { fill, stroke: chromeStroke } = analysisBlockChrome(palette, isDark);
1312
+ const labelColor = contrastText(
1313
+ fill,
1314
+ palette.textOnFillLight,
1315
+ palette.textOnFillDark
1316
+ );
1317
+ const block = svg.append("g").attr("class", "pert-caption-block").attr("data-pert-caption", "");
1318
+ block.append("rect").attr("class", "pert-caption-rect").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("rx", NODE_RADIUS).attr("ry", NODE_RADIUS).attr("fill", fill).attr("stroke", chromeStroke).attr("stroke-width", NODE_STROKE_WIDTH);
1319
+ block.append("text").attr("class", "pert-caption-header").attr("x", x + width / 2).attr("y", y + CAPTION_BOX_PADDING_Y + CAPTION_FONT_SIZE).attr("text-anchor", "middle").attr("fill", labelColor).attr("font-size", CAPTION_FONT_SIZE).attr("font-weight", "700").text("Summary");
1320
+ const textX = x + CAPTION_BOX_PADDING_X;
1321
+ const firstBaselineY = y + CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT + CAPTION_FONT_SIZE;
1322
+ const text = block.append("text").attr("class", "pert-caption").attr("x", textX).attr("y", firstBaselineY).attr("text-anchor", "start").attr("fill", labelColor).attr("font-size", CAPTION_FONT_SIZE).attr("font-weight", CAPTION_FONT_WEIGHT);
1323
+ bullets.forEach((bullet, i) => {
1324
+ const indent = bullet.level === 1 ? SUB_BULLET_INDENT : 0;
1325
+ const tspan = text.append("tspan").attr("x", textX + indent).text(`\u2022 ${bullet.text}`);
1326
+ if (bullet.italic) tspan.attr("font-style", "italic");
1327
+ if (i > 0) tspan.attr("dy", CAPTION_LINE_HEIGHT);
1328
+ });
1329
+ }
1330
+ function renderTagLegendRow(svg, resolved, palette, isDark, args) {
1331
+ if (resolved.tagGroups.length === 0) return;
1332
+ const { x, y, width, activeGroup, exportMode } = args;
1333
+ const groups = resolved.tagGroups.map((g) => ({
1334
+ name: g.name,
1335
+ entries: g.entries.map((e) => ({ value: e.value, color: e.color }))
1336
+ }));
1337
+ const block = svg.append("g").attr("class", "pert-tag-legend").attr("transform", `translate(${x}, ${y})`);
1338
+ renderIntegratedLegend(block, {
1339
+ groups,
1340
+ mode: exportMode ? "export" : "preview",
1341
+ palette,
1342
+ isDark,
1343
+ width,
1344
+ activeGroup
1345
+ });
1346
+ }
1347
+ function renderFieldLegendBlock(svg, args) {
1348
+ const { x, y, width, height, palette, isDark } = args;
1349
+ const baseColor = palette.textMuted;
1350
+ const labelColor = contrastText(
1351
+ shapeFill(palette, baseColor, isDark),
1352
+ palette.textOnFillLight,
1353
+ palette.textOnFillDark
1354
+ );
1355
+ const headerY = y + CAPTION_BOX_PADDING_Y + CAPTION_FONT_SIZE;
1356
+ const colW = width / 3;
1357
+ const gridTop = y + CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT;
1358
+ const gridBottom = y + height;
1359
+ const rowH = (gridBottom - gridTop) / 2;
1360
+ const block = svg.append("g").attr("class", "pert-field-legend").attr("data-pert-field-legend", "");
1361
+ block.append("rect").attr("class", "pert-field-legend-rect").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("rx", NODE_RADIUS).attr("ry", NODE_RADIUS).attr("fill", "none").attr("stroke", baseColor).attr("stroke-opacity", 0.4).attr("stroke-width", 1);
1362
+ block.append("text").attr("class", "pert-field-legend-header").attr("x", x + width / 2).attr("y", headerY).attr("text-anchor", "middle").attr("fill", labelColor).attr("font-size", CAPTION_FONT_SIZE).attr("font-weight", "700").text("Field labels");
1363
+ const grid = (x1, y1, x2, y2) => {
1364
+ block.append("line").attr("x1", x1).attr("y1", y1).attr("x2", x2).attr("y2", y2).attr("stroke", baseColor).attr("stroke-opacity", 0.3).attr("stroke-width", 1);
1365
+ };
1366
+ grid(x, gridTop + rowH, x + width, gridTop + rowH);
1367
+ grid(x + colW, gridTop, x + colW, gridBottom);
1368
+ grid(x + colW * 2, gridTop, x + colW * 2, gridBottom);
1369
+ const FIELD_BY_INDEX = ["es", "dur", "ef", "ls", "slack", "lf"];
1370
+ FIELD_LEGEND_CELLS.forEach((cell, i) => {
1371
+ const col = i % 3;
1372
+ const row = Math.floor(i / 3);
1373
+ const cx = x + col * colW + colW / 2;
1374
+ const cellTop = gridTop + row * rowH;
1375
+ const field = FIELD_BY_INDEX[i];
1376
+ const cellG = block.append("g").attr("class", "pert-field-legend-cell").attr("data-field", field);
1377
+ cellG.append("rect").attr("class", "pert-cell-highlight").attr("data-field", field).attr("x", x + col * colW).attr("y", cellTop).attr("width", colW).attr("height", rowH).attr("fill", palette.colors.blue).attr("fill-opacity", 0).attr("pointer-events", "all");
1378
+ const descLines = wrapTextToWidth(
1379
+ cell.desc,
1380
+ FIELD_LEGEND_DESC_FONT_SIZE,
1381
+ fieldLegendDescWidth(colW)
1382
+ );
1383
+ const descBlockHeight = FIELD_LEGEND_DESC_FONT_SIZE + Math.max(descLines.length - 1, 0) * FIELD_LEGEND_DESC_LINE_HEIGHT;
1384
+ const stackHeight = FIELD_LEGEND_LABEL_FONT_SIZE + FIELD_LEGEND_LABEL_DESC_GAP + descBlockHeight;
1385
+ const stackTop = cellTop + Math.max((rowH - stackHeight) / 2, 0);
1386
+ const labelY = stackTop + FIELD_LEGEND_LABEL_FONT_SIZE;
1387
+ const firstDescY = labelY + FIELD_LEGEND_LABEL_DESC_GAP + FIELD_LEGEND_DESC_FONT_SIZE;
1388
+ cellG.append("text").attr("class", "pert-field-legend-label").attr("x", cx).attr("y", labelY).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", FIELD_LEGEND_LABEL_FONT_SIZE).attr("font-weight", 600).attr("fill", labelColor).text(cell.label);
1389
+ const descText = cellG.append("text").attr("class", "pert-field-legend-desc").attr("x", cx).attr("y", firstDescY).attr("text-anchor", "middle").attr("font-family", FONT_FAMILY).attr("font-size", FIELD_LEGEND_DESC_FONT_SIZE).attr("fill", labelColor).attr("opacity", 0.85);
1390
+ descLines.forEach((line2, idx) => {
1391
+ const tspan = descText.append("tspan").attr("x", cx).text(line2);
1392
+ if (idx > 0) tspan.attr("dy", FIELD_LEGEND_DESC_LINE_HEIGHT);
1393
+ });
1394
+ });
1395
+ }
1396
+ function buildTornadoRows(resolved, maxN = TORNADO_TOP_N) {
1397
+ if (resolved.monteCarloResult === null) return [];
1398
+ const swings = resolved.monteCarloResult.tornadoSwings ?? [];
1399
+ if (swings.length === 0) return [];
1400
+ const sprintDays = resolveSprintDaysFromOptions(resolved.options);
1401
+ const unit = resolved.options.timeUnit;
1402
+ const rows = swings.map((s) => ({
1403
+ id: s.id,
1404
+ name: s.name,
1405
+ lowSwing: fromDisplayUnit(s.lowSwing, unit, sprintDays),
1406
+ highSwing: fromDisplayUnit(s.highSwing, unit, sprintDays),
1407
+ band: criticalityBand(s.criticality)
1408
+ }));
1409
+ return rows.slice(0, Math.max(1, maxN));
1410
+ }
1411
+ function fromDisplayUnit(days, unit, sprintDays) {
1412
+ const unitDays = unit === "s" && sprintDays !== void 0 ? sprintDays : DAYS_PER_UNIT[unit];
1413
+ return days / unitDays;
1414
+ }
1415
+ function resolveSprintDaysFromOptions(opts) {
1416
+ if (!opts.sprintMode || !opts.sprintLength) return void 0;
1417
+ return opts.sprintLength.amount * DAYS_PER_UNIT[opts.sprintLength.unit];
1418
+ }
1419
+ var DAYS_PER_UNIT = {
1420
+ min: 1 / (60 * 24),
1421
+ h: 1 / 24,
1422
+ d: 1,
1423
+ bd: 1,
1424
+ w: 7,
1425
+ m: 30,
1426
+ q: 90,
1427
+ y: 365,
1428
+ s: 14
1429
+ };
1430
+ function tornadoMaxRowsFor(boxHeight) {
1431
+ const rowSpace = boxHeight - 2 * CAPTION_BOX_PADDING_Y - CAPTION_HEADER_BAND_HEIGHT;
1432
+ return Math.max(1, Math.floor(rowSpace / TORNADO_ROW_HEIGHT));
1433
+ }
1434
+ function tornadoBoxHeightFor(rows) {
1435
+ return rows.length * TORNADO_ROW_HEIGHT + 2 * CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT;
1436
+ }
1437
+ function renderTornadoBlock(svg, rows, args) {
1438
+ const { x, y, width, height, palette, isDark } = args;
1439
+ const { fill, stroke: chromeStroke } = analysisBlockChrome(palette, isDark);
1440
+ const labelColor = contrastText(
1441
+ fill,
1442
+ palette.textOnFillLight,
1443
+ palette.textOnFillDark
1444
+ );
1445
+ const block = svg.append("g").attr("class", "pert-tornado-block").attr("data-pert-tornado", "");
1446
+ block.append("rect").attr("class", "pert-tornado-rect").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("rx", NODE_RADIUS).attr("ry", NODE_RADIUS).attr("fill", fill).attr("stroke", chromeStroke).attr("stroke-width", NODE_STROKE_WIDTH);
1447
+ block.append("text").attr("class", "pert-tornado-header").attr("x", x + width / 2).attr("y", y + CAPTION_BOX_PADDING_Y + CAPTION_FONT_SIZE).attr("text-anchor", "middle").attr("fill", labelColor).attr("font-size", CAPTION_FONT_SIZE).attr("font-weight", "700").text("Activity Risk");
1448
+ const fmt = (v) => {
1449
+ const r = Math.round(v * 100) / 100;
1450
+ return r.toFixed(2).replace(/\.?0+$/, "");
1451
+ };
1452
+ const maxLow = rows.reduce((acc, r) => Math.max(acc, r.lowSwing), 0);
1453
+ const maxHigh = rows.reduce((acc, r) => Math.max(acc, r.highSwing), 0);
1454
+ const totalRange = maxLow + maxHigh || 1;
1455
+ const nameX = x + CAPTION_BOX_PADDING_X;
1456
+ const plotLeft = nameX + TORNADO_NAME_COL_W;
1457
+ const plotRight = x + width - CAPTION_BOX_PADDING_X;
1458
+ const VALUE_GAP = 6;
1459
+ const CHAR_W = TORNADO_BAR_FONT_SIZE * 0.6;
1460
+ const longestLeftLabelChars = rows.reduce(
1461
+ (acc, r) => r.lowSwing > 0 ? Math.max(acc, `\u2212${fmt(r.lowSwing)}`.length) : acc,
1462
+ 0
1463
+ );
1464
+ const longestRightLabelChars = rows.reduce(
1465
+ (acc, r) => r.highSwing > 0 ? Math.max(acc, `+${fmt(r.highSwing)}`.length) : acc,
1466
+ 0
1467
+ );
1468
+ const leftGutter = longestLeftLabelChars > 0 ? longestLeftLabelChars * CHAR_W + VALUE_GAP + 2 : 0;
1469
+ const rightGutter = longestRightLabelChars > 0 ? longestRightLabelChars * CHAR_W + VALUE_GAP + 2 : 0;
1470
+ const innerLeft = plotLeft + leftGutter;
1471
+ const innerRight = plotRight - rightGutter;
1472
+ const plotWidth = Math.max(innerRight - innerLeft, 0);
1473
+ const pixelsPerUnit = plotWidth / totalRange;
1474
+ const leftWidth = maxLow * pixelsPerUnit;
1475
+ const centerX = innerLeft + leftWidth;
1476
+ const firstRowY = y + CAPTION_BOX_PADDING_Y + CAPTION_HEADER_BAND_HEIGHT;
1477
+ rows.forEach((row, i) => {
1478
+ const rowY = firstRowY + i * TORNADO_ROW_HEIGHT;
1479
+ const labelY = rowY + TORNADO_ROW_HEIGHT / 2 + TORNADO_BAR_FONT_SIZE / 2 - 2;
1480
+ const barColor = bandColor(row.band, palette, palette.primary);
1481
+ const barFill = shapeFill(palette, barColor, isDark);
1482
+ const lowW = row.lowSwing * pixelsPerUnit;
1483
+ const highW = row.highSwing * pixelsPerUnit;
1484
+ const rowG = block.append("g").attr("class", "pert-tornado-row").attr("data-activity-id", row.id).attr("data-tornado-swing", String(row.lowSwing + row.highSwing));
1485
+ rowG.append("rect").attr("class", "pert-tornado-row-hit").attr("x", nameX).attr("y", rowY).attr("width", plotRight - nameX).attr("height", TORNADO_ROW_HEIGHT).attr("fill", "transparent").attr("pointer-events", "all");
1486
+ const truncated = row.name.length > 22 ? row.name.slice(0, 21) + "\u2026" : row.name;
1487
+ rowG.append("text").attr("class", "pert-tornado-name").attr("x", nameX).attr("y", labelY).attr("text-anchor", "start").attr("fill", labelColor).attr("font-size", TORNADO_BAR_FONT_SIZE).text(truncated);
1488
+ if (lowW > 0) {
1489
+ rowG.append("rect").attr("class", "pert-tornado-bar pert-tornado-bar-low").attr("x", centerX - lowW).attr("y", rowY + (TORNADO_ROW_HEIGHT - TORNADO_BAR_HEIGHT) / 2).attr("width", lowW).attr("height", TORNADO_BAR_HEIGHT).attr("rx", 2).attr("ry", 2).attr("fill", barFill).attr("stroke", barColor).attr("stroke-width", 1);
1490
+ rowG.append("text").attr("class", "pert-tornado-value pert-tornado-value-low").attr("x", centerX - lowW - VALUE_GAP).attr("y", labelY).attr("text-anchor", "end").attr("fill", labelColor).attr("font-size", TORNADO_BAR_FONT_SIZE).text(`\u2212${fmt(row.lowSwing)}`);
1491
+ }
1492
+ if (highW > 0) {
1493
+ rowG.append("rect").attr("class", "pert-tornado-bar pert-tornado-bar-high").attr("x", centerX).attr("y", rowY + (TORNADO_ROW_HEIGHT - TORNADO_BAR_HEIGHT) / 2).attr("width", highW).attr("height", TORNADO_BAR_HEIGHT).attr("rx", 2).attr("ry", 2).attr("fill", barFill).attr("stroke", barColor).attr("stroke-width", 1);
1494
+ rowG.append("text").attr("class", "pert-tornado-value pert-tornado-value-high").attr("x", centerX + highW + VALUE_GAP).attr("y", labelY).attr("text-anchor", "start").attr("fill", labelColor).attr("font-size", TORNADO_BAR_FONT_SIZE).text(`+${fmt(row.highSwing)}`);
1495
+ }
1496
+ });
1497
+ if (rows.length > 0) {
1498
+ const axisTop = firstRowY;
1499
+ const axisBottom = firstRowY + rows.length * TORNADO_ROW_HEIGHT;
1500
+ block.append("line").attr("class", "pert-tornado-axis").attr("x1", centerX).attr("x2", centerX).attr("y1", axisTop).attr("y2", axisBottom).attr("stroke", labelColor).attr("stroke-width", 1).attr("opacity", 0.5);
1501
+ }
1502
+ }
1503
+ function buildScurveData(resolved) {
1504
+ const mc = resolved.monteCarloResult;
1505
+ if (mc === null) return null;
1506
+ const p5 = Math.max(0, 2 * mc.p50 - mc.p95);
1507
+ const durationSamples = [p5, mc.p50, mc.p80, mc.p95];
1508
+ if (durationSamples.every((v) => v === durationSamples[0])) return null;
1509
+ const anchor = resolved.options.anchor;
1510
+ const mode = anchor?.kind === "backward" ? "backward" : "forward";
1511
+ const yAxisLabel = "Probability of completion";
1512
+ const today = resolved.options.today;
1513
+ let deadlineDays = null;
1514
+ let deadlineDate = null;
1515
+ if (anchor !== null && anchor.kind === "backward" && resolved.projectStart !== null) {
1516
+ const startMs = Date.parse(resolved.projectStart);
1517
+ const endMs = Date.parse(anchor.date);
1518
+ if (!isNaN(startMs) && !isNaN(endMs)) {
1519
+ deadlineDays = (endMs - startMs) / (1e3 * 60 * 60 * 24);
1520
+ deadlineDate = anchor.date;
1521
+ }
1522
+ }
1523
+ const projectSmooth = (durationDays) => mode === "backward" && deadlineDays !== null ? deadlineDays - durationDays : durationDays;
1524
+ const projectRounded = (durationDays) => mode === "backward" && deadlineDays !== null ? deadlineDays - Math.ceil(durationDays) : durationDays;
1525
+ const durationProbPairs = [
1526
+ // In-bounds: MC always produces samples; consumers gate on `mc.minDurationDays !== null`.
1527
+ { d: durationSamples[0], p: 0.05 },
1528
+ { d: mc.p50, p: 0.5 },
1529
+ { d: mc.p80, p: 0.8 },
1530
+ { d: mc.p95, p: 0.95 }
1531
+ ];
1532
+ const curvePoints = durationProbPairs.map(({ d, p }) => ({ x: projectSmooth(d), y: p })).sort((a, b) => a.x - b.x);
1533
+ const samples = durationSamples.map(projectSmooth).sort((a, b) => a - b);
1534
+ const p16Proj = projectSmooth(mc.p16);
1535
+ const p84Proj = projectSmooth(mc.p84);
1536
+ const bandLeft = Math.min(p16Proj, p84Proj);
1537
+ const bandRight = Math.max(p16Proj, p84Proj);
1538
+ const referenceLines = [
1539
+ { pct: 50, days: mc.p50 },
1540
+ { pct: 80, days: mc.p80 },
1541
+ { pct: 95, days: mc.p95 }
1542
+ ].map(({ pct, days }) => {
1543
+ const yFrac = pct / 100;
1544
+ if (mode === "backward" && anchor?.kind === "backward") {
1545
+ const offsetDays = Math.ceil(days);
1546
+ const date = addCalendarDays(anchor.date, -offsetDays);
1547
+ const isPast = today.length > 0 && date < today;
1548
+ const label = `P${pct} latest-safe start${isPast ? " (past)" : ""}`;
1549
+ return {
1550
+ x: projectRounded(days),
1551
+ y: yFrac,
1552
+ durationDays: days,
1553
+ label,
1554
+ isPast
1555
+ };
1556
+ }
1557
+ return {
1558
+ x: days,
1559
+ y: yFrac,
1560
+ durationDays: days,
1561
+ label: `P${pct} finish`,
1562
+ isPast: false
1563
+ };
1564
+ });
1565
+ const xMinDays = mode === "backward" && deadlineDays !== null ? deadlineDays - mc.maxDurationDays : (
1566
+ // In-bounds: MC always produces samples.
1567
+ Math.min(durationSamples[0], mc.minDurationDays)
1568
+ );
1569
+ const xMaxDays = mode === "backward" && deadlineDays !== null ? deadlineDays : Math.max(mc.p95, mc.maxDurationDays);
1570
+ return {
1571
+ mode,
1572
+ yAxisLabel,
1573
+ curvePoints,
1574
+ samples,
1575
+ p16Days: bandLeft,
1576
+ p84Days: bandRight,
1577
+ // Percentile dots/date-labels — `projectRounded` matches the
1578
+ // analyzer's `roundConservative` (Math.ceil of the duration), so
1579
+ // each dot's date label is byte-identical to the caption's
1580
+ // "P{X} latest-safe start: <date>" row.
1581
+ p50Days: projectRounded(mc.p50),
1582
+ p80Days: projectRounded(mc.p80),
1583
+ p95Days: projectRounded(mc.p95),
1584
+ xMinDays,
1585
+ xMaxDays,
1586
+ referenceLines,
1587
+ framingNote: anchorAnnotationText(resolved),
1588
+ anchorDate: resolved.projectStart,
1589
+ deadlineDays,
1590
+ deadlineDate
1591
+ };
1592
+ }
1593
+ function renderScurveBlock(svg, data, args) {
1594
+ const { x, y, width, height, palette, isDark, unit, title } = args;
1595
+ const { fill, stroke: chromeStroke } = analysisBlockChrome(palette, isDark);
1596
+ const labelColor = contrastText(
1597
+ fill,
1598
+ palette.textOnFillLight,
1599
+ palette.textOnFillDark
1600
+ );
1601
+ const block = svg.append("g").attr("class", "pert-scurve-block").attr("data-pert-scurve", "");
1602
+ block.append("rect").attr("class", "pert-scurve-rect").attr("x", x).attr("y", y).attr("width", width).attr("height", height).attr("rx", NODE_RADIUS).attr("ry", NODE_RADIUS).attr("fill", fill).attr("stroke", chromeStroke).attr("stroke-width", NODE_STROKE_WIDTH);
1603
+ const hasTitle = typeof title === "string" && title.length > 0;
1604
+ if (hasTitle) {
1605
+ const titleText = title.replace(/\.$/, "");
1606
+ block.append("text").attr("class", "pert-scurve-header").attr("x", x + width / 2).attr("y", y + CAPTION_BOX_PADDING_Y + CAPTION_FONT_SIZE).attr("text-anchor", "middle").attr("fill", labelColor).attr("font-size", CAPTION_FONT_SIZE).attr("font-weight", "700").text(titleText);
1607
+ }
1608
+ const SCURVE_DEADLINE_LABEL_HEIGHT = 16;
1609
+ const hasDeadline = data.deadlineDays !== null;
1610
+ const plotLeft = x + SCURVE_PLOT_PADDING_X;
1611
+ const plotRight = x + width - SCURVE_PLOT_PADDING_RIGHT;
1612
+ const plotTop = y + CAPTION_BOX_PADDING_Y + (hasTitle ? CAPTION_HEADER_BAND_HEIGHT : 0) + (hasDeadline ? SCURVE_DEADLINE_LABEL_HEIGHT : 0);
1613
+ const isAnchored = data.anchorDate !== null;
1614
+ const plotBottom = y + height - SCURVE_PLOT_PADDING_BOTTOM;
1615
+ const plotW = plotRight - plotLeft;
1616
+ const plotH = plotBottom - plotTop;
1617
+ const dotPositions = [data.p50Days, data.p80Days, data.p95Days];
1618
+ const dotMin = Math.min(...dotPositions);
1619
+ const dotMax = Math.max(...dotPositions);
1620
+ const dotSpan = Math.max(1, dotMax - dotMin);
1621
+ const xMin = Math.min(data.p16Days, dotMin - 0.2 * dotSpan);
1622
+ const xMax = data.mode === "backward" && data.deadlineDays !== null ? data.deadlineDays : Math.max(data.p84Days, dotMax + 0.2 * dotSpan);
1623
+ const xRange = xMax - xMin || 1;
1624
+ const xScale = (v) => plotLeft + (v - xMin) / xRange * plotW;
1625
+ const yScale = (frac) => plotBottom - frac * plotH;
1626
+ const yTicks = [0, 0.25, 0.5, 0.75, 1];
1627
+ for (const t of yTicks) {
1628
+ const yy = yScale(t);
1629
+ block.append("line").attr("class", "pert-scurve-grid").attr("x1", plotLeft).attr("x2", plotRight).attr("y1", yy).attr("y2", yy).attr("stroke", palette.textMuted).attr("stroke-width", 1).attr("opacity", t === 0 || t === 1 ? 0.4 : 0.15);
1630
+ block.append("text").attr("class", "pert-scurve-ytick").attr("x", plotLeft - 6).attr("y", yy + SCURVE_TICK_FONT_SIZE / 3).attr("text-anchor", "end").attr("fill", labelColor).attr("font-size", SCURVE_TICK_FONT_SIZE).text(`${Math.round(t * 100)}%`);
1631
+ }
1632
+ const yAxisLabelCx = x + 14;
1633
+ const yAxisLabelCy = plotTop + plotH / 2;
1634
+ block.append("text").attr("class", "pert-scurve-y-axis-title").attr(
1635
+ "transform",
1636
+ `translate(${yAxisLabelCx}, ${yAxisLabelCy}) rotate(-90)`
1637
+ ).attr("text-anchor", "middle").attr("fill", labelColor).attr("font-size", SCURVE_TICK_FONT_SIZE - 1).attr("font-weight", "600").attr("opacity", 0.85).text(data.yAxisLabel);
1638
+ if (data.p84Days > data.p16Days) {
1639
+ const bandLeftRaw = xScale(data.p16Days);
1640
+ const bandRightRaw = xScale(data.p84Days);
1641
+ const bandLeft = Math.max(plotLeft, bandLeftRaw);
1642
+ const bandRight = Math.min(plotRight, bandRightRaw);
1643
+ if (bandRight > bandLeft) {
1644
+ block.append("rect").attr("class", "pert-scurve-likely-band").attr("x", bandLeft).attr("y", plotTop).attr("width", bandRight - bandLeft).attr("height", plotH).attr("fill", palette.colors.blue).attr("opacity", 0.12);
1645
+ }
1646
+ }
1647
+ if (data.deadlineDays !== null && data.deadlineDate !== null) {
1648
+ const dx = xScale(data.deadlineDays);
1649
+ if (dx >= plotLeft - 1 && dx <= plotRight + 1) {
1650
+ const deadlineColor = palette.colors.purple;
1651
+ const edgePad = 4;
1652
+ let anchor = "middle";
1653
+ if (dx <= plotLeft + edgePad) anchor = "start";
1654
+ else if (dx >= plotRight - edgePad) anchor = "end";
1655
+ block.append("text").attr("class", "pert-scurve-deadline-label").attr("x", dx).attr("y", plotTop - 4).attr("text-anchor", anchor).attr("fill", deadlineColor).attr("font-size", SCURVE_TICK_FONT_SIZE).attr("font-weight", "700").text(`Deadline \xB7 ${formatScurveDate(data.deadlineDate)}`);
1656
+ block.append("line").attr("class", "pert-scurve-deadline-line").attr("x1", dx).attr("x2", dx).attr("y1", plotTop).attr("y2", plotBottom).attr("stroke", deadlineColor).attr("stroke-width", 1.5).attr("opacity", 0.9);
1657
+ }
1658
+ }
1659
+ const points = data.curvePoints.map((pt) => ({
1660
+ x: xScale(pt.x),
1661
+ y: yScale(pt.y)
1662
+ }));
1663
+ const curve = d3Shape.line().x((d) => d.x).y((d) => d.y).curve(d3Shape.curveMonotoneX)(points);
1664
+ if (curve) {
1665
+ const clipId = `pert-scurve-clip-${Math.random().toString(36).slice(2, 10)}`;
1666
+ block.append("clipPath").attr("id", clipId).append("rect").attr("x", plotLeft).attr("y", plotTop).attr("width", plotW).attr("height", plotH);
1667
+ block.append("path").attr("class", "pert-scurve-line").attr("d", curve).attr("fill", "none").attr("stroke", palette.colors.red).attr("stroke-width", 2).attr("clip-path", `url(#${clipId})`);
1668
+ }
1669
+ const dots = [
1670
+ {
1671
+ value: data.p50Days,
1672
+ durationDays: data.referenceLines[0]?.durationDays ?? data.p50Days,
1673
+ pct: 0.5,
1674
+ label: "P50",
1675
+ band: "yellow",
1676
+ isPast: data.referenceLines[0]?.isPast ?? false
1677
+ },
1678
+ {
1679
+ value: data.p80Days,
1680
+ durationDays: data.referenceLines[1]?.durationDays ?? data.p80Days,
1681
+ pct: 0.8,
1682
+ label: "P80",
1683
+ band: "orange",
1684
+ isPast: data.referenceLines[1]?.isPast ?? false
1685
+ },
1686
+ {
1687
+ value: data.p95Days,
1688
+ durationDays: data.referenceLines[2]?.durationDays ?? data.p95Days,
1689
+ pct: 0.95,
1690
+ label: "P95",
1691
+ band: "red",
1692
+ isPast: data.referenceLines[2]?.isPast ?? false
1693
+ }
1694
+ ];
1695
+ block.append("style").text(
1696
+ ".pert-scurve-percentile-verbose{opacity:0;pointer-events:none}.pert-scurve-percentile:hover .pert-scurve-percentile-label{opacity:0}.pert-scurve-percentile:hover .pert-scurve-percentile-verbose{opacity:1}"
1697
+ );
1698
+ const dotXs = dots.map((d) => xScale(d.value));
1699
+ for (const d of dots) {
1700
+ const cx = xScale(d.value);
1701
+ const cy = yScale(d.pct);
1702
+ const color = palette.colors[d.band];
1703
+ const valueText = isAnchored ? formatScurveDate(addCalendarDays(data.anchorDate, d.value)) : formatScurveTick(d.durationDays, unit);
1704
+ const inlineText = `${d.label} \xB7 ${valueText}`;
1705
+ const pctInt = Math.round(d.pct * 100);
1706
+ const verboseText = data.mode === "backward" ? `${pctInt}% chance of meeting deadline` : isAnchored ? `${pctInt}% chance to finish by ${valueText}` : `${pctInt}% chance within ${valueText}`;
1707
+ const verboseCharW = SCURVE_TICK_FONT_SIZE * 0.55;
1708
+ const verboseW = verboseText.length * verboseCharW;
1709
+ const inlineGap = SCURVE_PERCENTILE_RADIUS + 6;
1710
+ const roomRight = plotRight - cx - inlineGap;
1711
+ const roomLeft = cx - plotLeft - inlineGap;
1712
+ let labelX;
1713
+ let labelAnchor;
1714
+ if (verboseW <= roomRight) {
1715
+ labelX = cx + inlineGap;
1716
+ labelAnchor = "start";
1717
+ } else if (verboseW <= roomLeft) {
1718
+ labelX = cx - inlineGap;
1719
+ labelAnchor = "end";
1720
+ } else if (roomRight >= roomLeft) {
1721
+ labelX = plotRight;
1722
+ labelAnchor = "end";
1723
+ } else {
1724
+ labelX = plotLeft;
1725
+ labelAnchor = "start";
1726
+ }
1727
+ const labelFill = mix(color, palette.text, 25);
1728
+ const dotGroup = block.append("g").attr("class", "pert-scurve-percentile").attr("data-percentile", d.label);
1729
+ dotGroup.append("line").attr("class", "pert-scurve-percentile-tick").attr("x1", cx).attr("x2", cx).attr("y1", cy).attr("y2", plotBottom).attr("stroke", color).attr("stroke-width", 1).attr("stroke-dasharray", d.isPast ? "4,2" : "3 3").attr("opacity", 0.7);
1730
+ dotGroup.append("circle").attr("class", "pert-scurve-percentile-dot").attr("cx", cx).attr("cy", cy).attr("r", SCURVE_PERCENTILE_RADIUS).attr("fill", color).attr("stroke", fill).attr("stroke-width", 1.5).attr("data-percentile", d.label);
1731
+ dotGroup.append("circle").attr("class", "pert-scurve-percentile-hit").attr("cx", cx).attr("cy", cy).attr("r", 14).attr("fill", "transparent").attr("pointer-events", "all");
1732
+ dotGroup.append("text").attr("class", "pert-scurve-percentile-label").attr("x", labelX).attr("y", cy + SCURVE_TICK_FONT_SIZE / 3).attr("text-anchor", labelAnchor).attr("fill", labelFill).attr("font-size", SCURVE_TICK_FONT_SIZE).attr("font-weight", "700").attr("paint-order", "stroke fill").attr("stroke", fill).attr("stroke-width", 3).attr("stroke-linejoin", "round").attr("stroke-opacity", 0.95).text(inlineText);
1733
+ dotGroup.append("text").attr("class", "pert-scurve-percentile-verbose").attr("x", labelX).attr("y", cy + SCURVE_TICK_FONT_SIZE / 3).attr("text-anchor", labelAnchor).attr("fill", labelFill).attr("font-size", SCURVE_TICK_FONT_SIZE).attr("font-weight", "700").attr("paint-order", "stroke fill").attr("stroke", fill).attr("stroke-width", 3).attr("stroke-linejoin", "round").attr("stroke-opacity", 0.95).text(verboseText);
1734
+ }
1735
+ const N_X_TICKS = isAnchored ? 5 : 6;
1736
+ const LABEL_W_EST = isAnchored ? 48 : 36;
1737
+ const TICK_MIN_GAP = 6;
1738
+ const footprint = (t) => {
1739
+ if (t.anchor === "start") return [t.x, t.x + LABEL_W_EST];
1740
+ if (t.anchor === "end") return [t.x - LABEL_W_EST, t.x];
1741
+ return [t.x - LABEL_W_EST / 2, t.x + LABEL_W_EST / 2];
1742
+ };
1743
+ const all = [];
1744
+ for (let i = 0; i < N_X_TICKS; i++) {
1745
+ const v = xMin + xRange * i / (N_X_TICKS - 1);
1746
+ all.push({
1747
+ v,
1748
+ x: xScale(v),
1749
+ anchor: i === 0 ? "start" : i === N_X_TICKS - 1 ? "end" : "middle"
1750
+ });
1751
+ }
1752
+ const TICK_DOT_PROXIMITY = 28;
1753
+ const collidesWithDot = (t) => dotXs.some((dx) => Math.abs(t.x - dx) < TICK_DOT_PROXIMITY);
1754
+ const kept = [all[0]];
1755
+ const last = all[all.length - 1];
1756
+ const lastLeft = footprint(last)[0];
1757
+ let rightEdge = footprint(all[0])[1];
1758
+ for (let i = 1; i < all.length - 1; i++) {
1759
+ const t = all[i];
1760
+ if (collidesWithDot(t)) continue;
1761
+ const [l, r] = footprint(t);
1762
+ if (r + TICK_MIN_GAP > lastLeft) continue;
1763
+ if (l - TICK_MIN_GAP < rightEdge) continue;
1764
+ kept.push(t);
1765
+ rightEdge = r;
1766
+ }
1767
+ kept.push(last);
1768
+ for (const t of kept) {
1769
+ const labelText = isAnchored ? formatScurveDate(addCalendarDays(data.anchorDate, t.v)) : formatScurveTick(t.v, unit);
1770
+ block.append("text").attr("class", "pert-scurve-xtick").attr("x", t.x).attr("y", plotBottom + SCURVE_TICK_FONT_SIZE + 6).attr("text-anchor", t.anchor).attr("fill", labelColor).attr("font-size", SCURVE_TICK_FONT_SIZE).text(labelText);
1771
+ }
1772
+ }
1773
+ function formatScurveTick(days, unit) {
1774
+ const value = days / UNIT_TO_DAYS_LOCAL[unit];
1775
+ const display = (Math.round(value * 10) / 10).toFixed(1).replace(/\.0$/, "");
1776
+ return `${display}${unit}`;
1777
+ }
1778
+ var SCURVE_MONTH_NAMES = [
1779
+ "Jan",
1780
+ "Feb",
1781
+ "Mar",
1782
+ "Apr",
1783
+ "May",
1784
+ "Jun",
1785
+ "Jul",
1786
+ "Aug",
1787
+ "Sep",
1788
+ "Oct",
1789
+ "Nov",
1790
+ "Dec"
1791
+ ];
1792
+ function formatScurveDate(iso) {
1793
+ const parts = iso.split("-");
1794
+ if (parts.length !== 3) return iso;
1795
+ const month = parseInt(parts[1], 10) - 1;
1796
+ const day = parseInt(parts[2], 10);
1797
+ if (month < 0 || month > 11 || isNaN(day)) return iso;
1798
+ return `${SCURVE_MONTH_NAMES[month]} ${day}`;
1799
+ }
1800
+ var UNIT_TO_DAYS_LOCAL = {
1801
+ min: 1 / (60 * 24),
1802
+ h: 1 / 24,
1803
+ d: 1,
1804
+ bd: 1,
1805
+ w: 7,
1806
+ m: 30,
1807
+ q: 90,
1808
+ y: 365,
1809
+ s: 14
1810
+ };
1811
+
1812
+ export {
1813
+ renderPert,
1814
+ renderPertForExport,
1815
+ measurePertAnalysisBlock,
1816
+ renderPertAnalysisBlock
1817
+ };
1818
+ //# sourceMappingURL=chunk-CI2G3OEB.js.map