@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
@@ -1,1580 +0,0 @@
1
- import { tagAttrKey } from '../utils/tag-groups';
2
- import * as d3 from 'd3-selection';
3
- import * as d3Shape from 'd3-shape';
4
- import type { PaletteColors } from '../palettes';
5
- import { contrastText, mix, shapeFill } from '../palettes/color-utils';
6
- import { FONT_FAMILY } from '../fonts';
7
- import { parseJourneyMap } from './parser';
8
- import {
9
- layoutJourneyMap,
10
- scoreToColor,
11
- scoreToCurveY,
12
- TAG_STRIP_HEIGHT,
13
- type CurvePoint,
14
- type StepLayout,
15
- } from './layout';
16
- import type {
17
- ParsedJourneyMap,
18
- JourneyMapAnnotation,
19
- JourneyMapStep,
20
- } from './types';
21
- import { renderInlineText } from '../utils/inline-markdown';
22
- import { wrapNoteBody, NOTE_BULLET_INDENT } from '../utils/note-box';
23
- import { renderIntegratedLegend } from '../utils/legend-integration';
24
- import { resolveActiveTagGroup } from '../utils/tag-groups';
25
- import { ScaleContext } from '../utils/scaling';
26
- import {
27
- measureText,
28
- wrapTextToWidth,
29
- truncateText as truncateToWidth,
30
- } from '../utils/text-measure';
31
-
32
- // ============================================================
33
- // Interactive Options
34
- // ============================================================
35
-
36
- export interface JourneyMapInteractiveOptions {
37
- onNavigateToLine?: (line: number) => void;
38
- exportDims?: { width: number; height: number };
39
- activeTagGroup?: string | null;
40
- onActiveTagGroupChange?: (group: string | null) => void;
41
- /** Current editor cursor line — highlights the matching face + card, dims the rest */
42
- currentLine?: number | null;
43
- /** Set of collapsed phase names */
44
- collapsedPhases?: Set<string>;
45
- /** Called when a phase is toggled */
46
- onPhaseToggle?: (phaseName: string) => void;
47
- exportMode?: boolean;
48
- }
49
-
50
- // ============================================================
51
- // Constants
52
- // ============================================================
53
-
54
- // Match kanban styling constants
55
- const DIAGRAM_PADDING = 20;
56
- const PADDING = DIAGRAM_PADDING;
57
- import { CARD_RADIUS } from '../utils/visual-conventions'; // shared (Story 111.1)
58
- const CARD_PADDING_X = 10;
59
- const CARD_PADDING_Y = 6;
60
- const CARD_HEADER_HEIGHT = 24;
61
- const CARD_STROKE_WIDTH = 1.5;
62
- const CARD_META_LINE_HEIGHT = 14;
63
- const CARD_GAP_INTERNAL = 8;
64
- const COLUMN_RADIUS = 8;
65
- const COLUMN_HEADER_HEIGHT = 36;
66
- const COLUMN_PADDING = 12;
67
- const FONT_SIZE_TITLE = 18;
68
- const FONT_SIZE_PHASE = 13;
69
- const FONT_SIZE_STEP = 12;
70
- const FONT_SIZE_META = 10;
71
- const GRID_LINE_OPACITY = 0.15;
72
- const CURVE_STROKE_WIDTH = 2.5;
73
- const FACE_RADIUS = 14;
74
- // Distance from curveAreaBottom down to the filled band's bottom edge/border.
75
- // The score-1 face sits ~10px above curveAreaBottom; its emotion caption hangs
76
- // FACE_RADIUS + 5 + label-height (~29px) below the face center, so the band
77
- // must drop far enough that the caption clears the bottom border.
78
- const CURVE_AREA_BOTTOM_GAP = 28;
79
- // Faces grow on hover/active; the thought bubble + connector must clear the
80
- // enlarged outer edge (radius + ring halo), not the base radius.
81
- const FACE_HOVER_SCALE = 1.5;
82
- const FACE_HOVER_R = (FACE_RADIUS + 1) * FACE_HOVER_SCALE;
83
- const DIM_HOVER = 0.25;
84
- const TITLE_LINE_HEIGHT = 16;
85
-
86
- // ============================================================
87
- // Renderer
88
- // ============================================================
89
-
90
- export function renderJourneyMap(
91
- container: HTMLElement,
92
- parsed: ParsedJourneyMap,
93
- palette: PaletteColors,
94
- isDark: boolean,
95
- options?: JourneyMapInteractiveOptions
96
- ): void {
97
- const exportDims = options?.exportDims;
98
- const onNavigateToLine = options?.onNavigateToLine;
99
- const activeTagGroup = options?.activeTagGroup ?? null;
100
- const onActiveTagGroupChange = options?.onActiveTagGroupChange;
101
- const collapsedPhases = options?.collapsedPhases ?? new Set<string>();
102
- const onPhaseToggle = options?.onPhaseToggle;
103
- const solid = parsed.options['solid-fill'] === 'on';
104
-
105
- const layout = layoutJourneyMap(parsed, palette, {
106
- collapsedPhases,
107
- ...(exportDims !== undefined && { exportDims }),
108
- isDark,
109
- });
110
-
111
- container.innerHTML = '';
112
-
113
- const containerW = exportDims?.width ?? container.clientWidth;
114
- const containerH = exportDims?.height ?? container.clientHeight;
115
- const useContainerFit = !exportDims && containerW > 0 && containerH > 0;
116
-
117
- const sctx = exportDims
118
- ? ScaleContext.identity()
119
- : ScaleContext.from(containerW, layout.totalWidth);
120
-
121
- const svg = d3
122
- .select(container)
123
- .append('svg')
124
- .attr('xmlns', 'http://www.w3.org/2000/svg')
125
- .attr(
126
- 'width',
127
- useContainerFit ? containerW : (exportDims?.width ?? layout.totalWidth)
128
- )
129
- .attr(
130
- 'height',
131
- useContainerFit ? containerH : (exportDims?.height ?? layout.totalHeight)
132
- )
133
- .attr('viewBox', `0 0 ${layout.totalWidth} ${layout.totalHeight}`)
134
- .attr('preserveAspectRatio', 'xMidYMin meet')
135
- .attr('font-family', FONT_FAMILY);
136
-
137
- if (sctx.isBelowFloor) {
138
- svg.attr('width', '100%');
139
- }
140
-
141
- // Background
142
- svg
143
- .append('rect')
144
- .attr('width', layout.totalWidth)
145
- .attr('height', layout.totalHeight)
146
- .attr('fill', palette.bg);
147
-
148
- // Defs for gradients
149
- const defs = svg.append('defs');
150
-
151
- // Curve area gradient (green top, red bottom)
152
- const curveGradient = defs
153
- .append('linearGradient')
154
- .attr('id', 'journey-curve-gradient')
155
- .attr('x1', '0')
156
- .attr('y1', '0')
157
- .attr('x2', '0')
158
- .attr('y2', '1');
159
- curveGradient
160
- .append('stop')
161
- .attr('offset', '0%')
162
- .attr('stop-color', palette.colors.green)
163
- .attr('stop-opacity', 0.3);
164
- curveGradient
165
- .append('stop')
166
- .attr('offset', '100%')
167
- .attr('stop-color', palette.colors.red)
168
- .attr('stop-opacity', 0.3);
169
-
170
- // ── Title ────────────────────────────────────────────────
171
- const showTitle = !!parsed.title && parsed.options['no-title'] !== 'on';
172
- if (showTitle) {
173
- const titleG = svg.append('g').attr('class', 'chart-title');
174
- if (parsed.titleLineNumber) {
175
- titleG.attr('data-line-number', parsed.titleLineNumber);
176
- }
177
- titleG
178
- .append('text')
179
- .attr('x', PADDING)
180
- .attr('y', PADDING + FONT_SIZE_TITLE)
181
- .attr('font-size', FONT_SIZE_TITLE)
182
- .attr('font-weight', 'bold')
183
- .attr('fill', palette.text)
184
- .text(parsed.title!);
185
-
186
- if (onNavigateToLine && parsed.titleLineNumber) {
187
- titleG.style('cursor', 'pointer').on('click', () => {
188
- onNavigateToLine(parsed.titleLineNumber!);
189
- });
190
- }
191
- }
192
-
193
- // ── Persona ──────────────────────────────────────────────
194
- if (parsed.persona) {
195
- const personaColor = parsed.persona.color ?? palette.textMuted;
196
- const personaG = svg
197
- .append('g')
198
- .attr('class', 'journey-persona')
199
- .attr('data-line-number', parsed.persona.lineNumber);
200
-
201
- // Panel dimensions
202
- const titleRowH = CARD_HEADER_HEIGHT;
203
- const silhouetteZone = 60; // right-side space reserved for silhouette
204
- const panelWidth = 280;
205
- const textAreaWidth = panelWidth - silhouetteZone - CARD_PADDING_X;
206
- const descLineH = 14;
207
-
208
- // Wrap description text into lines — bullet-aware (`- `/`* ` → hanging
209
- // "•") + inline markdown, matching how note boxes render rich bodies.
210
- const descLines = parsed.persona.description
211
- ? wrapNoteBody(parsed.persona.description, textAreaWidth, FONT_SIZE_META)
212
- : [];
213
- const descRowH =
214
- descLines.length > 0 ? descLines.length * descLineH + 8 : 0;
215
- const panelHeight = titleRowH + descRowH;
216
- const panelX = layout.totalWidth - PADDING - panelWidth;
217
- const panelY = PADDING;
218
- const textX = panelX + CARD_PADDING_X;
219
-
220
- // Clip path so silhouette stays inside the card
221
- const clipId = 'persona-clip';
222
- defs
223
- .append('clipPath')
224
- .attr('id', clipId)
225
- .append('rect')
226
- .attr('x', panelX)
227
- .attr('y', panelY)
228
- .attr('width', panelWidth)
229
- .attr('height', panelHeight)
230
- .attr('rx', CARD_RADIUS);
231
-
232
- // Card — canonical 25% tint via shapeFill() (or full intent when solid-fill is on)
233
- const personaFill = shapeFill(palette, personaColor, isDark, { solid });
234
- // Text drawn on top of the card must contrast against the fill, not against bg/surface.
235
- const onPersonaText = contrastText(
236
- personaFill,
237
- palette.textOnFillLight,
238
- palette.textOnFillDark
239
- );
240
-
241
- personaG
242
- .append('rect')
243
- .attr('x', panelX)
244
- .attr('y', panelY)
245
- .attr('width', panelWidth)
246
- .attr('height', panelHeight)
247
- .attr('rx', CARD_RADIUS)
248
- .attr('fill', personaFill);
249
-
250
- // Divider line (drawn BEFORE silhouette so it doesn't cut through)
251
- if (descLines.length > 0) {
252
- personaG
253
- .append('line')
254
- .attr('x1', panelX + 1)
255
- .attr('x2', panelX + panelWidth - silhouetteZone)
256
- .attr('y1', panelY + titleRowH)
257
- .attr('y2', panelY + titleRowH)
258
- .attr('stroke', solid ? onPersonaText : personaColor)
259
- .attr('stroke-opacity', 0.3)
260
- .attr('stroke-width', 1);
261
- }
262
-
263
- // Silhouette (clipped inside card, more right padding, taller)
264
- const silX = panelX + panelWidth - 32;
265
- const silY = panelY + panelHeight / 2 - 6;
266
- const silClip = personaG.append('g').attr('clip-path', `url(#${clipId})`);
267
- renderPersonaSilhouette(silClip, silX, silY, personaColor, palette, 1.2);
268
-
269
- // Card border (drawn on top so outline is clean all around)
270
- personaG
271
- .append('rect')
272
- .attr('x', panelX)
273
- .attr('y', panelY)
274
- .attr('width', panelWidth)
275
- .attr('height', panelHeight)
276
- .attr('rx', CARD_RADIUS)
277
- .attr('fill', 'none')
278
- .attr('stroke', personaColor)
279
- .attr('stroke-width', CARD_STROKE_WIDTH);
280
-
281
- // Name (left-aligned in title row, matches kanban card title)
282
- personaG
283
- .append('text')
284
- .attr('x', textX)
285
- .attr('y', panelY + CARD_PADDING_Y + FONT_SIZE_STEP)
286
- .attr('font-size', FONT_SIZE_STEP)
287
- .attr('font-weight', '500')
288
- .attr('fill', onPersonaText)
289
- .text(parsed.persona.name);
290
-
291
- // Description — wrapped lines below divider, with inline markdown.
292
- // Bullet first-lines get a "•" glyph at the left edge with the body
293
- // hanging-indented; continuation lines align under the body.
294
- for (let li = 0; li < descLines.length; li++) {
295
- // In-bounds by loop guard.
296
- const line = descLines[li]!;
297
- const indent = line.kind === 'plain' ? 0 : NOTE_BULLET_INDENT;
298
- const lineY = panelY + titleRowH + descLineH * (li + 1);
299
- if (line.kind === 'bullet-first') {
300
- personaG
301
- .append('text')
302
- .attr('x', textX)
303
- .attr('y', lineY)
304
- .attr('font-size', FONT_SIZE_META)
305
- .attr('fill', onPersonaText)
306
- .text('•');
307
- }
308
- const lineEl = personaG
309
- .append('text')
310
- .attr('x', textX + indent)
311
- .attr('y', lineY)
312
- .attr('font-size', FONT_SIZE_META)
313
- .attr('fill', onPersonaText);
314
- renderInlineText(lineEl, line.text, palette, FONT_SIZE_META);
315
- }
316
-
317
- if (onNavigateToLine) {
318
- personaG.style('cursor', 'pointer').on('click', () => {
319
- onNavigateToLine(parsed.persona!.lineNumber);
320
- });
321
- }
322
- }
323
-
324
- // ── Score group + active group (shared by legend and card coloring) ──
325
- const scoreGroup = {
326
- name: 'Score',
327
- entries: [1, 2, 3, 4, 5].map((s) => ({
328
- value: String(s),
329
- color: scoreToColor(s, palette),
330
- lineNumber: 0,
331
- })),
332
- lineNumber: 0,
333
- };
334
- const allLegendGroups = [...parsed.tagGroups, scoreGroup];
335
- const effectiveActiveGroup =
336
- activeTagGroup ??
337
- resolveActiveTagGroup(allLegendGroups, parsed.options['active-tag']);
338
-
339
- // ── Legend ──────────────────────────────────────────────
340
- if (parsed.options['no-legend'] !== 'on') {
341
- const legendX = PADDING;
342
- const legendY = PADDING + (showTitle ? FONT_SIZE_TITLE + 8 : 0);
343
- const legendG = svg
344
- .append('g')
345
- .attr('class', 'journey-legend')
346
- .attr('transform', `translate(${legendX},${legendY})`);
347
-
348
- const legendCallbacks: import('../utils/legend-types').LegendCallbacks = {
349
- ...(onActiveTagGroupChange
350
- ? {
351
- onGroupToggle: (groupName: string) => {
352
- const isDeactivating =
353
- effectiveActiveGroup?.toLowerCase() === groupName.toLowerCase();
354
- onActiveTagGroupChange(isDeactivating ? null : groupName);
355
- },
356
- }
357
- : {}),
358
- ...(!exportDims
359
- ? {
360
- onEntryHover: (groupName: string, entryValue: string | null) => {
361
- if (!entryValue) {
362
- // Hover out — restore all
363
- svg.selectAll('.journey-step').style('opacity', null);
364
- svg.selectAll('.journey-face').style('opacity', null);
365
- svg.selectAll('.journey-face-icon').attr('transform', null);
366
- svg.selectAll('.journey-thought').style('opacity', null);
367
- return;
368
- }
369
-
370
- const isScore = groupName === 'Score';
371
- const attrName = isScore
372
- ? 'data-score'
373
- : `data-tag-${tagAttrKey(groupName)}`;
374
-
375
- const matches = (el: Element) =>
376
- el.getAttribute(attrName) === entryValue;
377
-
378
- svg
379
- .selectAll<SVGGElement, unknown>('.journey-step')
380
- .each(function () {
381
- const hit = matches(this);
382
- d3.select(this).style(
383
- 'opacity',
384
- hit ? '1' : String(DIM_HOVER)
385
- );
386
- });
387
-
388
- svg
389
- .selectAll<SVGGElement, unknown>('.journey-face')
390
- .each(function () {
391
- const hit = matches(this);
392
- const sel = d3.select(this);
393
- sel.style('opacity', hit ? '1' : String(DIM_HOVER));
394
- const icon = sel.select('.journey-face-icon');
395
- if (hit) {
396
- const fcx = parseFloat(sel.attr('data-cx') ?? '0');
397
- const fcy = parseFloat(sel.attr('data-cy') ?? '0');
398
- icon.attr(
399
- 'transform',
400
- `translate(${fcx},${fcy}) scale(1.3) translate(${-fcx},${-fcy})`
401
- );
402
- } else {
403
- icon.attr('transform', null);
404
- }
405
- });
406
-
407
- // Dim thought bubbles that aren't associated with matching faces
408
- svg
409
- .selectAll<SVGGElement, unknown>('.journey-thought')
410
- .style('opacity', String(DIM_HOVER));
411
- },
412
- }
413
- : {}),
414
- };
415
-
416
- renderIntegratedLegend(legendG, {
417
- groups: parsed.tagGroups,
418
- activeGroup: effectiveActiveGroup,
419
- mode: options?.exportMode ? 'export' : 'preview',
420
- position: { placement: 'top-center', titleRelation: 'inline-with-title' },
421
- titleWidth: 0,
422
- callbacks: legendCallbacks,
423
- palette,
424
- isDark,
425
- // Reduce available width if persona card exists to avoid collision
426
- width: parsed.persona
427
- ? layout.totalWidth - legendX - PADDING - 280 - PADDING
428
- : layout.totalWidth - legendX - PADDING,
429
- });
430
- }
431
-
432
- // ── Curve Area ───────────────────────────────────────────
433
- const curveG = svg.append('g').attr('class', 'journey-curve-area');
434
-
435
- // Grid lines at score levels 1-5
436
- for (let score = 1; score <= 5; score++) {
437
- const y = scoreToCurveY(score, layout.curveAreaBottom);
438
-
439
- curveG
440
- .append('line')
441
- .attr('x1', PADDING)
442
- .attr('x2', layout.totalWidth - PADDING)
443
- .attr('y1', y)
444
- .attr('y2', y)
445
- .attr('stroke', palette.textMuted)
446
- .attr('stroke-opacity', GRID_LINE_OPACITY)
447
- .attr('stroke-dasharray', '4,4');
448
- }
449
-
450
- // Emotion curve (area fill + line)
451
- if (layout.curvePoints.length >= 2) {
452
- // Extend curve to edges with flat continuations
453
- // In-bounds by length >= 2 check above.
454
- const first = layout.curvePoints[0]!;
455
- const last = layout.curvePoints[layout.curvePoints.length - 1]!;
456
- const extendedPoints: CurvePoint[] = [
457
- {
458
- x: PADDING,
459
- y: first.y,
460
- score: first.score,
461
- stepIndex: first.stepIndex,
462
- },
463
- ...layout.curvePoints,
464
- {
465
- x: layout.totalWidth - PADDING,
466
- y: last.y,
467
- score: last.score,
468
- stepIndex: last.stepIndex,
469
- },
470
- ];
471
-
472
- // Bottom of the filled band. Sits clear of the lowest face's emotion
473
- // caption (score-1 face + FACE_RADIUS + EMOTION_LABEL gap) so the caption
474
- // doesn't collide with the bottom border.
475
- const areaBottomY = layout.curveAreaBottom + CURVE_AREA_BOTTOM_GAP;
476
-
477
- const areaGen = d3Shape
478
- .area<CurvePoint>()
479
- .x((d) => d.x)
480
- .y0(areaBottomY)
481
- .y1((d) => d.y)
482
- .curve(d3Shape.curveMonotoneX);
483
-
484
- curveG
485
- .append('path')
486
- .attr('d', areaGen(extendedPoints) ?? '')
487
- .attr('fill', 'url(#journey-curve-gradient)')
488
- .attr('stroke', 'none');
489
-
490
- // Frame the filled area on three sides (left, bottom, right) — the curve
491
- // line itself forms the top edge. Polishes the plot into a contained box.
492
- const leftX = PADDING;
493
- const rightX = layout.totalWidth - PADDING;
494
- curveG
495
- .append('path')
496
- .attr(
497
- 'd',
498
- `M${leftX},${first.y} L${leftX},${areaBottomY} ` +
499
- `L${rightX},${areaBottomY} L${rightX},${last.y}`
500
- )
501
- .attr('fill', 'none')
502
- .attr('stroke', palette.primary)
503
- .attr('stroke-width', CURVE_STROKE_WIDTH)
504
- .attr('stroke-linecap', 'round')
505
- .attr('stroke-linejoin', 'round');
506
-
507
- // Curve line on top
508
- const lineGen = d3Shape
509
- .line<CurvePoint>()
510
- .x((d) => d.x)
511
- .y((d) => d.y)
512
- .curve(d3Shape.curveMonotoneX);
513
-
514
- curveG
515
- .append('path')
516
- .attr('d', lineGen(extendedPoints) ?? '')
517
- .attr('fill', 'none')
518
- .attr('stroke', palette.primary)
519
- .attr('stroke-width', CURVE_STROKE_WIDTH)
520
- .attr('stroke-linecap', 'round');
521
-
522
- // Curve face icons (clickable → navigate to step line)
523
- const allSteps =
524
- parsed.phases.length > 0
525
- ? parsed.phases.flatMap((p) => p.steps)
526
- : parsed.steps;
527
-
528
- for (const pt of layout.curvePoints) {
529
- const step = allSteps[pt.stepIndex];
530
- const faceG = renderScoreFace(
531
- curveG,
532
- pt.x,
533
- pt.y,
534
- pt.score,
535
- palette,
536
- isDark
537
- );
538
- addEmotionLabel(faceG, pt, palette);
539
- if (step) {
540
- faceG.attr('data-line-number', step.lineNumber);
541
- faceG.attr('data-score', pt.score);
542
- for (const [key, value] of Object.entries(step.tags)) {
543
- faceG.attr(`data-tag-${key.toLowerCase()}`, value);
544
- }
545
- // Store thought text for hover-to-reveal
546
- const thoughts = step.annotations.filter((a) => a.type === 'thought');
547
- if (thoughts.length > 0) {
548
- faceG.attr(
549
- 'data-thought',
550
- thoughts.map((t) => t.text).join(' \u2022 ')
551
- );
552
- }
553
- if (onNavigateToLine) {
554
- faceG.style('cursor', 'pointer').on('click', () => {
555
- onNavigateToLine(step.lineNumber);
556
- });
557
- }
558
- }
559
- }
560
- } else if (layout.curvePoints.length === 1) {
561
- // Single point — face only, no curve
562
- // In-bounds by length === 1 check above.
563
- const pt = layout.curvePoints[0]!;
564
- const allSteps =
565
- parsed.phases.length > 0
566
- ? parsed.phases.flatMap((p) => p.steps)
567
- : parsed.steps;
568
- const step = allSteps[pt.stepIndex];
569
- const faceG = renderScoreFace(
570
- curveG,
571
- pt.x,
572
- pt.y,
573
- pt.score,
574
- palette,
575
- isDark
576
- );
577
- addEmotionLabel(faceG, pt, palette);
578
- if (step) {
579
- faceG.attr('data-line-number', step.lineNumber);
580
- faceG.attr('data-score', pt.score);
581
- for (const [key, value] of Object.entries(step.tags)) {
582
- faceG.attr(`data-tag-${key.toLowerCase()}`, value);
583
- }
584
- const thoughts = step.annotations.filter((a) => a.type === 'thought');
585
- if (thoughts.length > 0) {
586
- faceG.attr(
587
- 'data-thought',
588
- thoughts.map((t) => t.text).join(' \u2022 ')
589
- );
590
- }
591
- if (onNavigateToLine) {
592
- faceG.style('cursor', 'pointer').on('click', () => {
593
- onNavigateToLine(step.lineNumber);
594
- });
595
- }
596
- }
597
- }
598
-
599
- // ── Phases + Cards ───────────────────────────────────────
600
- const phasesG = svg.append('g').attr('class', 'journey-phases');
601
-
602
- if (layout.phases.length > 0) {
603
- for (const pl of layout.phases) {
604
- const isCollapsed = collapsedPhases.has(pl.phase.name);
605
- const phaseG = phasesG
606
- .append('g')
607
- .attr('class', 'journey-phase')
608
- .attr('data-line-number', pl.phase.lineNumber);
609
-
610
- // Column background (no stroke — matches kanban)
611
- const colBg = isDark
612
- ? mix(palette.surface, palette.bg, 50)
613
- : mix(palette.surface, palette.bg, 30);
614
- phaseG
615
- .append('rect')
616
- .attr('x', pl.x)
617
- .attr('y', pl.y)
618
- .attr('width', pl.width)
619
- .attr('height', pl.height)
620
- .attr('rx', COLUMN_RADIUS)
621
- .attr('fill', colBg);
622
-
623
- // Column header (no stroke — matches kanban)
624
- phaseG
625
- .append('rect')
626
- .attr('x', pl.x)
627
- .attr('y', pl.y)
628
- .attr('width', pl.width)
629
- .attr('height', COLUMN_HEADER_HEIGHT)
630
- .attr('rx', COLUMN_RADIUS)
631
- .attr('fill', pl.headerColor);
632
-
633
- // Clip bottom corners of header
634
- phaseG
635
- .append('rect')
636
- .attr('x', pl.x)
637
- .attr('y', pl.y + COLUMN_HEADER_HEIGHT - COLUMN_RADIUS)
638
- .attr('width', pl.width)
639
- .attr('height', COLUMN_RADIUS)
640
- .attr('fill', pl.headerColor);
641
-
642
- // Column header text — must contrast against pl.headerColor, not bg.
643
- // (palette.text is dark in light themes, illegible on a saturated header.)
644
- const onHeaderText = contrastText(
645
- pl.headerColor,
646
- palette.textOnFillLight,
647
- palette.textOnFillDark
648
- );
649
- phaseG
650
- .append('text')
651
- .attr('x', pl.x + COLUMN_PADDING)
652
- .attr('y', pl.y + COLUMN_HEADER_HEIGHT / 2 + FONT_SIZE_PHASE / 2 - 2)
653
- .attr('font-size', FONT_SIZE_PHASE)
654
- .attr('font-weight', 'bold')
655
- .attr('fill', onHeaderText)
656
- .text(
657
- isCollapsed
658
- ? truncateText(
659
- pl.phase.name,
660
- pl.width - COLUMN_PADDING * 2,
661
- FONT_SIZE_PHASE
662
- )
663
- : pl.phase.name
664
- );
665
-
666
- // Click header to toggle collapse
667
- if (onPhaseToggle) {
668
- phaseG.style('cursor', 'pointer').on('click', (event: MouseEvent) => {
669
- const target = event.target as Element;
670
- if (
671
- !target.closest('.journey-step') &&
672
- !target.closest('.journey-face')
673
- ) {
674
- onPhaseToggle(pl.phase.name);
675
- }
676
- });
677
- } else if (onNavigateToLine) {
678
- phaseG.style('cursor', 'pointer').on('click', (event: MouseEvent) => {
679
- const target = event.target as Element;
680
- if (!target.closest('.journey-step')) {
681
- onNavigateToLine(pl.phase.lineNumber);
682
- }
683
- });
684
- }
685
-
686
- if (isCollapsed) {
687
- // Collapsed: mini card rows with colored border matching active tag
688
- const COLLAPSED_CARD_H = 26;
689
- const COLLAPSED_GAP = 6;
690
- const COLLAPSED_FACE_R = 7;
691
- const listX = pl.x + COLUMN_PADDING;
692
- const cardW = pl.width - COLUMN_PADDING * 2;
693
- let itemY = pl.y + COLUMN_HEADER_HEIGHT + CARD_GAP_INTERNAL + 4;
694
-
695
- for (const step of pl.phase.steps) {
696
- const itemG = phaseG
697
- .append('g')
698
- .attr('class', 'journey-step')
699
- .attr('data-line-number', step.lineNumber);
700
-
701
- // Data attributes for legend hover highlighting
702
- if (step.score !== undefined) {
703
- itemG.attr('data-score', step.score);
704
- }
705
- for (const [key, value] of Object.entries(step.tags)) {
706
- itemG.attr(`data-tag-${key.toLowerCase()}`, value);
707
- }
708
-
709
- // Resolve card color from active tag group
710
- const stepColor = resolveStepColor(
711
- step,
712
- step.score !== undefined
713
- ? scoreToColor(step.score, palette)
714
- : palette.surface,
715
- effectiveActiveGroup,
716
- parsed.tagGroups,
717
- palette
718
- );
719
- // Canonical 25% tint via shapeFill() (or full intent when solid-fill is on)
720
- const rowFill = shapeFill(
721
- palette,
722
- stepColor ?? palette.primary,
723
- isDark,
724
- { solid }
725
- );
726
- const rowStroke = stepColor ?? palette.textMuted;
727
-
728
- // Card background
729
- itemG
730
- .append('rect')
731
- .attr('x', listX)
732
- .attr('y', itemY)
733
- .attr('width', cardW)
734
- .attr('height', COLLAPSED_CARD_H)
735
- .attr('rx', CARD_RADIUS)
736
- .attr('fill', rowFill)
737
- .attr('stroke', rowStroke)
738
- .attr('stroke-width', CARD_STROKE_WIDTH);
739
-
740
- // Face icon (small, left side)
741
- const faceCx = listX + CARD_PADDING_X + COLLAPSED_FACE_R;
742
- const faceCy = itemY + COLLAPSED_CARD_H / 2;
743
- if (step.score !== undefined) {
744
- const faceG = renderScoreFace(
745
- itemG,
746
- faceCx,
747
- faceCy,
748
- step.score,
749
- palette,
750
- isDark,
751
- COLLAPSED_FACE_R
752
- );
753
- faceG.attr('data-line-number', step.lineNumber);
754
- faceG.attr('data-score', step.score);
755
- for (const [key, value] of Object.entries(step.tags)) {
756
- faceG.attr(`data-tag-${key.toLowerCase()}`, value);
757
- }
758
- }
759
-
760
- // Step title
761
- const textX = listX + CARD_PADDING_X + COLLAPSED_FACE_R * 2 + 6;
762
- const maxTextW =
763
- cardW - CARD_PADDING_X * 2 - COLLAPSED_FACE_R * 2 - 6;
764
- itemG
765
- .append('text')
766
- .attr('x', textX)
767
- .attr('y', itemY + COLLAPSED_CARD_H / 2 + FONT_SIZE_META / 2 - 1)
768
- .attr('font-size', FONT_SIZE_META)
769
- .attr('fill', palette.text)
770
- .text(truncateText(step.title, maxTextW, FONT_SIZE_META));
771
-
772
- if (onNavigateToLine) {
773
- itemG.style('cursor', 'pointer').on('click', (event: Event) => {
774
- event.stopPropagation();
775
- onNavigateToLine(step.lineNumber);
776
- });
777
- }
778
-
779
- itemY += COLLAPSED_CARD_H + COLLAPSED_GAP;
780
- }
781
- } else {
782
- // Expanded: render step cards
783
- for (const sl of pl.stepLayouts) {
784
- renderStepCard(
785
- phaseG,
786
- sl,
787
- palette,
788
- isDark,
789
- effectiveActiveGroup,
790
- parsed.tagGroups,
791
- onNavigateToLine,
792
- solid
793
- );
794
- }
795
- }
796
- }
797
- } else {
798
- // Flat mode
799
- for (const sl of layout.flatStepLayouts) {
800
- renderStepCard(
801
- phasesG,
802
- sl,
803
- palette,
804
- isDark,
805
- effectiveActiveGroup,
806
- parsed.tagGroups,
807
- onNavigateToLine,
808
- solid
809
- );
810
- }
811
- }
812
-
813
- // Top-level overlay group for hover elements (renders above everything)
814
- const overlayG = svg.append('g').attr('class', 'journey-overlay');
815
-
816
- // ── Hover + click-to-lock dimming ─────────────────────
817
- if (!exportDims) {
818
- const DIM_OPACITY = 0.35;
819
- let lockedLine: number | null = null;
820
-
821
- // Helper: dim everything except elements matching a line number
822
- const applyDimming = (activeLine: number) => {
823
- svg.selectAll('.journey-step').each(function () {
824
- const el = d3.select(this);
825
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
826
- el.style('opacity', ln === activeLine ? '1' : String(DIM_OPACITY));
827
- });
828
- svg.selectAll('.journey-face').each(function () {
829
- const el = d3.select(this);
830
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
831
- const isActive = ln === activeLine;
832
- el.style('opacity', isActive ? '1' : String(DIM_OPACITY));
833
- const icon = el.select('.journey-face-icon');
834
- if (isActive) {
835
- const fcx = parseFloat(el.attr('data-cx') ?? '0');
836
- const fcy = parseFloat(el.attr('data-cy') ?? '0');
837
- icon.attr(
838
- 'transform',
839
- `translate(${fcx},${fcy}) scale(${FACE_HOVER_SCALE}) translate(${-fcx},${-fcy})`
840
- );
841
- } else {
842
- icon.attr('transform', null);
843
- }
844
- });
845
- // Dim phases slightly (but not as much)
846
- svg.selectAll('.journey-phase').each(function () {
847
- const el = d3.select(this);
848
- const hasActive = el.select(
849
- `.journey-step[data-line-number="${activeLine}"]`
850
- );
851
- if (!hasActive.node()) {
852
- el.style('opacity', String(DIM_OPACITY + 0.3));
853
- }
854
- });
855
- };
856
-
857
- const clearDimming = () => {
858
- svg.selectAll('.journey-step').style('opacity', null);
859
- svg.selectAll('.journey-face').style('opacity', null);
860
- svg.selectAll('.journey-face-icon').attr('transform', null);
861
- svg.selectAll('.journey-phase').style('opacity', null);
862
- overlayG.selectAll('.journey-thought-hover').remove();
863
- };
864
-
865
- // Show thought bubble for a face in the overlay layer
866
- const THOUGHT_FONT = 11;
867
- const THOUGHT_PAD_X = 10;
868
- const THOUGHT_PAD_Y = 6;
869
- const THOUGHT_MAX_W = 200;
870
- const THOUGHT_LINE_H = 14;
871
- const THOUGHT_GAP = 10;
872
-
873
- const showThoughtBubble = (
874
- faceEl: d3.Selection<SVGGElement, unknown, null, undefined>
875
- ) => {
876
- overlayG.selectAll('.journey-thought-hover').remove();
877
-
878
- const thoughtText = faceEl.attr('data-thought');
879
- if (!thoughtText || !layout.hasThoughts) return;
880
-
881
- const fcx = parseFloat(faceEl.attr('data-cx') ?? '0');
882
- const fcy = parseFloat(faceEl.attr('data-cy') ?? '0');
883
- const score = parseInt(faceEl.attr('data-score') ?? '3', 10);
884
-
885
- const lines = wrapText(thoughtText, THOUGHT_MAX_W, THOUGHT_FONT);
886
- const textW = Math.min(
887
- THOUGHT_MAX_W,
888
- Math.max(...lines.map((l) => measureText(l, THOUGHT_FONT)))
889
- );
890
- const bw = textW + THOUGHT_PAD_X * 2;
891
- const bh = lines.length * THOUGHT_LINE_H + THOUGHT_PAD_Y * 2;
892
-
893
- // Position above the face, overlaying the curve area (clamp to stay in
894
- // view). The layout reserves top headroom so the bubble clears the title
895
- // and persona band even above the highest face — no flip needed.
896
- const bx = Math.max(
897
- PADDING,
898
- Math.min(fcx - bw / 2, layout.totalWidth - PADDING - bw)
899
- );
900
- const by = Math.max(PADDING, fcy - FACE_HOVER_R - THOUGHT_GAP - bh);
901
-
902
- const scoreColor = scoreToColor(score, palette);
903
- const tintedBg = mix(scoreColor, palette.surface, 20);
904
-
905
- const g = overlayG.append('g').attr('class', 'journey-thought-hover');
906
-
907
- g.append('rect')
908
- .attr('x', bx)
909
- .attr('y', by)
910
- .attr('width', bw)
911
- .attr('height', bh)
912
- .attr('rx', CARD_RADIUS)
913
- .attr('fill', tintedBg)
914
- .attr('stroke', scoreColor)
915
- .attr('stroke-width', CARD_STROKE_WIDTH);
916
-
917
- // Connector line from bubble bottom to face top
918
- g.append('line')
919
- .attr('x1', fcx)
920
- .attr('y1', by + bh)
921
- .attr('x2', fcx)
922
- .attr('y2', fcy - FACE_HOVER_R - 1)
923
- .attr('stroke', scoreColor)
924
- .attr('stroke-width', CARD_STROKE_WIDTH);
925
-
926
- const centerX = bx + bw / 2;
927
- for (let i = 0; i < lines.length; i++) {
928
- g.append('text')
929
- .attr('x', centerX)
930
- .attr('y', by + THOUGHT_PAD_Y + (i + 1) * THOUGHT_LINE_H - 2)
931
- .attr('text-anchor', 'middle')
932
- .attr('font-size', THOUGHT_FONT)
933
- .attr('font-style', 'italic')
934
- .attr('fill', palette.textMuted)
935
- // In-bounds by loop guard.
936
- .text(lines[i]!);
937
- }
938
- };
939
-
940
- // Click background to unlock
941
- svg.on('click', (event: MouseEvent) => {
942
- const target = event.target as Element;
943
- if (
944
- !target.closest('.journey-face') &&
945
- !target.closest('.journey-step') &&
946
- !target.closest('.journey-phase')
947
- ) {
948
- lockedLine = null;
949
- clearDimming();
950
- }
951
- });
952
-
953
- // Find the curve face for a line number and show its thought bubble
954
- const showThoughtForLine = (ln: number) => {
955
- svg
956
- .selectAll<SVGGElement, unknown>('.journey-curve-area .journey-face')
957
- .each(function () {
958
- const face = d3.select<SVGGElement, unknown>(this);
959
- if (parseInt(face.attr('data-line-number') ?? '0', 10) === ln) {
960
- showThoughtBubble(face);
961
- }
962
- });
963
- };
964
-
965
- // Hover + click on faces
966
- svg.selectAll<SVGGElement, unknown>('.journey-face').each(function () {
967
- const el = d3.select<SVGGElement, unknown>(this);
968
- el.on('mouseenter', () => {
969
- if (lockedLine !== null) return;
970
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
971
- if (ln) {
972
- applyDimming(ln);
973
- showThoughtForLine(ln);
974
- }
975
- })
976
- .on('mouseleave', () => {
977
- if (lockedLine !== null) return;
978
- clearDimming();
979
- })
980
- .on('click', (event: MouseEvent) => {
981
- event.stopPropagation();
982
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
983
- if (lockedLine === ln) {
984
- lockedLine = null;
985
- clearDimming();
986
- } else {
987
- lockedLine = ln;
988
- applyDimming(ln);
989
- showThoughtForLine(ln);
990
- if (onNavigateToLine && ln) onNavigateToLine(ln);
991
- }
992
- });
993
- });
994
-
995
- // Hover + click on step cards
996
- svg.selectAll('.journey-step').each(function () {
997
- const el = d3.select(this);
998
- el.on('mouseenter', () => {
999
- if (lockedLine !== null) return;
1000
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
1001
- if (ln) {
1002
- applyDimming(ln);
1003
- showThoughtForLine(ln);
1004
- }
1005
- })
1006
- .on('mouseleave', () => {
1007
- if (lockedLine !== null) return;
1008
- clearDimming();
1009
- })
1010
- .on('click', (event: MouseEvent) => {
1011
- event.stopPropagation();
1012
- const ln = parseInt(el.attr('data-line-number') ?? '0', 10);
1013
- if (lockedLine === ln) {
1014
- lockedLine = null;
1015
- clearDimming();
1016
- } else {
1017
- lockedLine = ln;
1018
- applyDimming(ln);
1019
- showThoughtForLine(ln);
1020
- if (onNavigateToLine && ln) onNavigateToLine(ln);
1021
- }
1022
- });
1023
- });
1024
- }
1025
- }
1026
-
1027
- // ============================================================
1028
- // Step Card Renderer
1029
- // ============================================================
1030
-
1031
- function resolveStepColor(
1032
- step: JourneyMapStep,
1033
- scoreColor: string,
1034
- activeGroup: string | null,
1035
- tagGroups: readonly import('../utils/tag-groups').TagGroup[],
1036
- _palette: PaletteColors
1037
- ): string | undefined {
1038
- if (!activeGroup) return undefined;
1039
-
1040
- // "Score" is a synthetic group — use the score-to-color mapping
1041
- if (activeGroup.toLowerCase() === 'score') {
1042
- return step.score !== undefined ? scoreColor : undefined;
1043
- }
1044
-
1045
- // Tag group — find the matching group and look up the step's tag value
1046
- const group = tagGroups.find(
1047
- (g) => g.name.toLowerCase() === activeGroup.toLowerCase()
1048
- );
1049
- if (!group) return undefined;
1050
-
1051
- const tagValue = step.tags[tagAttrKey(group.name)];
1052
- if (!tagValue) return undefined;
1053
-
1054
- const entry = group.entries.find(
1055
- (e) => e.value.toLowerCase() === tagValue.toLowerCase()
1056
- );
1057
- return entry?.color;
1058
- }
1059
-
1060
- function renderStepCard(
1061
- parent: d3.Selection<SVGGElement, unknown, null, undefined>,
1062
- sl: StepLayout,
1063
- palette: PaletteColors,
1064
- isDark: boolean,
1065
- activeGroup: string | null,
1066
- tagGroups: readonly import('../utils/tag-groups').TagGroup[],
1067
- onNavigateToLine?: (line: number) => void,
1068
- solid?: boolean
1069
- ): void {
1070
- const stepG = parent
1071
- .append('g')
1072
- .attr('class', 'journey-step')
1073
- .attr('data-line-number', sl.step.lineNumber);
1074
-
1075
- // Data attributes for legend hover highlighting
1076
- if (sl.step.score !== undefined) {
1077
- stepG.attr('data-score', sl.step.score);
1078
- }
1079
- for (const [key, value] of Object.entries(sl.step.tags)) {
1080
- stepG.attr(`data-tag-${key.toLowerCase()}`, value);
1081
- }
1082
-
1083
- const cx = sl.x;
1084
- const cy = sl.y;
1085
-
1086
- // Card colors — driven by active legend group (matches kanban pattern)
1087
- const resolvedColor = resolveStepColor(
1088
- sl.step,
1089
- sl.color,
1090
- activeGroup,
1091
- tagGroups,
1092
- palette
1093
- );
1094
- // Canonical 25% tint via shapeFill() (or full intent when solid-fill is on)
1095
- const cardFill = shapeFill(
1096
- palette,
1097
- resolvedColor ?? palette.primary,
1098
- isDark,
1099
- { ...(solid !== undefined && { solid }) }
1100
- );
1101
- const cardStroke = resolvedColor ?? palette.textMuted;
1102
- // Text drawn on top of the card must contrast against the fill,
1103
- // not against bg/surface (otherwise textMuted is illegible on solid fills).
1104
- const onCardText = contrastText(
1105
- cardFill,
1106
- palette.textOnFillLight,
1107
- palette.textOnFillDark
1108
- );
1109
-
1110
- // Card background
1111
- stepG
1112
- .append('rect')
1113
- .attr('x', cx)
1114
- .attr('y', cy)
1115
- .attr('width', sl.width)
1116
- .attr('height', sl.height)
1117
- .attr('rx', CARD_RADIUS)
1118
- .attr('fill', cardFill)
1119
- .attr('stroke', cardStroke)
1120
- .attr('stroke-width', CARD_STROKE_WIDTH);
1121
-
1122
- // Title (wrapped)
1123
- const titleMaxW = sl.width - CARD_PADDING_X * 2;
1124
- const titleLines = wrapTextToWidth(sl.step.title, FONT_SIZE_STEP, titleMaxW);
1125
-
1126
- for (let i = 0; i < titleLines.length; i++) {
1127
- stepG
1128
- .append('text')
1129
- .attr('x', cx + CARD_PADDING_X)
1130
- .attr('y', cy + CARD_PADDING_Y + FONT_SIZE_STEP + i * TITLE_LINE_HEIGHT)
1131
- .attr('font-size', FONT_SIZE_STEP)
1132
- .attr('font-weight', '500')
1133
- .attr('fill', onCardText)
1134
- // In-bounds by loop guard.
1135
- .text(titleLines[i]!);
1136
- }
1137
-
1138
- const titleBlockH =
1139
- CARD_PADDING_Y + titleLines.length * TITLE_LINE_HEIGHT + CARD_PADDING_Y;
1140
- const cardAnnotations = sl.step.annotations;
1141
-
1142
- // Separator line between title and content (matches kanban)
1143
- const hasContent = sl.step.description || cardAnnotations.length > 0;
1144
-
1145
- if (hasContent) {
1146
- stepG
1147
- .append('line')
1148
- .attr('x1', cx)
1149
- .attr('y1', cy + titleBlockH)
1150
- .attr('x2', cx + sl.width)
1151
- .attr('y2', cy + titleBlockH)
1152
- // Solid mode: cardStroke matches the fill, so the divider is invisible.
1153
- // Use the contrast text color at low opacity instead.
1154
- .attr('stroke', solid ? onCardText : cardStroke)
1155
- .attr('stroke-opacity', 0.3)
1156
- .attr('stroke-width', 1);
1157
- }
1158
-
1159
- let metaY = cy + titleBlockH + CARD_META_LINE_HEIGHT;
1160
-
1161
- // Description (wrapped text, matches kanban metadata style)
1162
- if (sl.step.description) {
1163
- const descLines = wrapText(
1164
- sl.step.description,
1165
- sl.width - CARD_PADDING_X * 2,
1166
- FONT_SIZE_META
1167
- );
1168
- for (const line of descLines) {
1169
- stepG
1170
- .append('text')
1171
- .attr('x', cx + CARD_PADDING_X)
1172
- .attr('y', metaY)
1173
- .attr('font-size', FONT_SIZE_META)
1174
- .attr('fill', onCardText)
1175
- .text(line);
1176
- metaY += CARD_META_LINE_HEIGHT;
1177
- }
1178
- }
1179
-
1180
- // Annotations (icon bullet + indented text)
1181
- const ANNO_ICON_SIZE = 10;
1182
- const ANNO_ICON_GAP = 4;
1183
- const annoIconIndent = ANNO_ICON_SIZE + ANNO_ICON_GAP;
1184
- const annoTextW = sl.width - CARD_PADDING_X * 2 - annoIconIndent;
1185
- for (const anno of cardAnnotations) {
1186
- const annoColor = annotationColor(anno.type, palette);
1187
- const iconPaths = annotationIconPaths(anno.type);
1188
- const annoLines = wrapText(anno.text, annoTextW, FONT_SIZE_META);
1189
- // Icon color: semantic in tint mode (red pain / green opportunity reads
1190
- // fine on a 25% tinted card). In solid mode the semantic color often
1191
- // matches the card fill (red icon on red card → invisible), so fall back
1192
- // to the contrast color — the icon SHAPE still differentiates the type.
1193
- const iconColor = solid ? onCardText : annoColor;
1194
- // Icon as bullet, aligned to first line
1195
- renderAnnotationIcon(
1196
- stepG,
1197
- cx + CARD_PADDING_X,
1198
- metaY - ANNO_ICON_SIZE + 1,
1199
- ANNO_ICON_SIZE,
1200
- iconPaths,
1201
- iconColor
1202
- );
1203
- // All text lines indented past the icon. Text uses the same
1204
- // contrast color as the rest of the card body — the icon already
1205
- // signals the annotation type. Without this, "thought" lines
1206
- // (palette.textMuted) and "pain"/"opportunity" lines (red/green)
1207
- // are illegible on solid fills.
1208
- for (let li = 0; li < annoLines.length; li++) {
1209
- stepG
1210
- .append('text')
1211
- .attr('x', cx + CARD_PADDING_X + annoIconIndent)
1212
- .attr('y', metaY)
1213
- .attr('font-size', FONT_SIZE_META)
1214
- .attr('fill', onCardText)
1215
- // In-bounds by loop guard.
1216
- .text(annoLines[li]!);
1217
- metaY += CARD_META_LINE_HEIGHT;
1218
- }
1219
- }
1220
-
1221
- // Tag strip — colored bar above the card
1222
- for (const [key, value] of Object.entries(sl.step.tags)) {
1223
- const group = tagGroups.find(
1224
- (g) => g.name.toLowerCase() === key.toLowerCase()
1225
- );
1226
- const entry = group?.entries.find(
1227
- (e) => e.value.toLowerCase() === value.toLowerCase()
1228
- );
1229
- const stripColor = entry?.color ?? palette.textMuted;
1230
- const TAG_GAP = 6;
1231
- const stripY = cy - TAG_STRIP_HEIGHT - TAG_GAP;
1232
- // Canonical 25% tint via shapeFill() (or full intent when solid-fill is on)
1233
- const stripFill = shapeFill(palette, stripColor, isDark, {
1234
- ...(solid !== undefined && { solid }),
1235
- });
1236
-
1237
- stepG
1238
- .append('rect')
1239
- .attr('x', cx)
1240
- .attr('y', stripY)
1241
- .attr('width', sl.width)
1242
- .attr('height', TAG_STRIP_HEIGHT)
1243
- .attr('rx', CARD_RADIUS)
1244
- .attr('fill', stripFill)
1245
- .attr('stroke', stripColor)
1246
- .attr('stroke-width', CARD_STROKE_WIDTH);
1247
-
1248
- // Tag strip text — contrast against the strip fill, not against bg.
1249
- const stripTextColor = contrastText(
1250
- stripFill,
1251
- palette.textOnFillLight,
1252
- palette.textOnFillDark
1253
- );
1254
- stepG
1255
- .append('text')
1256
- .attr('x', cx + sl.width / 2)
1257
- .attr('y', stripY + TAG_STRIP_HEIGHT / 2 + FONT_SIZE_META / 2 - 1)
1258
- .attr('text-anchor', 'middle')
1259
- .attr('font-size', FONT_SIZE_META)
1260
- .attr('fill', stripTextColor)
1261
- .text(value);
1262
- }
1263
-
1264
- if (onNavigateToLine) {
1265
- stepG.style('cursor', 'pointer').on('click', (event: MouseEvent) => {
1266
- event.stopPropagation();
1267
- onNavigateToLine(sl.step.lineNumber);
1268
- });
1269
- }
1270
- }
1271
-
1272
- // ============================================================
1273
- // Helpers
1274
- // ============================================================
1275
-
1276
- // ============================================================
1277
- // Persona Silhouette
1278
- // ============================================================
1279
-
1280
- function renderPersonaSilhouette(
1281
- parent: d3.Selection<SVGGElement, unknown, null, undefined>,
1282
- cx: number,
1283
- cy: number,
1284
- color: string,
1285
- palette: PaletteColors,
1286
- scale = 1
1287
- ): void {
1288
- // Solid color border, muted fill that stands out slightly from card bg
1289
- const fill = mix(color, palette.bg, 70);
1290
- const stroke = color;
1291
- const s = scale;
1292
-
1293
- // Torso + neck (drawn first so head overlaps the junction cleanly)
1294
- parent
1295
- .append('path')
1296
- .attr(
1297
- 'd',
1298
- `M ${cx - 5 * s} ${cy + 6 * s}` +
1299
- ` L ${cx - 5 * s} ${cy + 11 * s}` +
1300
- ` L ${cx - 8 * s} ${cy + 11 * s}` +
1301
- ` Q ${cx - 20 * s} ${cy + 12 * s}, ${cx - 20 * s} ${cy + 22 * s}` +
1302
- ` L ${cx - 20 * s} ${cy + 36 * s}` +
1303
- ` L ${cx + 20 * s} ${cy + 36 * s}` +
1304
- ` L ${cx + 20 * s} ${cy + 22 * s}` +
1305
- ` Q ${cx + 20 * s} ${cy + 12 * s}, ${cx + 8 * s} ${cy + 11 * s}` +
1306
- ` L ${cx + 5 * s} ${cy + 11 * s}` +
1307
- ` L ${cx + 5 * s} ${cy + 6 * s}` +
1308
- ` Z`
1309
- )
1310
- .attr('fill', fill)
1311
- .attr('stroke', stroke)
1312
- .attr('stroke-width', 1.2);
1313
-
1314
- // Head — oval (drawn on top, covers neck junction)
1315
- parent
1316
- .append('path')
1317
- .attr(
1318
- 'd',
1319
- `M ${cx} ${cy - 12 * s}` +
1320
- ` C ${cx + 10 * s} ${cy - 12 * s}, ${cx + 9 * s} ${cy + 2 * s}, ${cx + 6 * s} ${cy + 6 * s}` +
1321
- ` Q ${cx} ${cy + 9 * s}, ${cx - 6 * s} ${cy + 6 * s}` +
1322
- ` C ${cx - 9 * s} ${cy + 2 * s}, ${cx - 10 * s} ${cy - 12 * s}, ${cx} ${cy - 12 * s}` +
1323
- ` Z`
1324
- )
1325
- .attr('fill', fill)
1326
- .attr('stroke', stroke)
1327
- .attr('stroke-width', 1.2);
1328
- }
1329
-
1330
- // ============================================================
1331
- // Score Face Icon (SVG smiley)
1332
- // ============================================================
1333
-
1334
- function renderScoreFace(
1335
- parent: d3.Selection<SVGGElement, unknown, null, undefined>,
1336
- cx: number,
1337
- cy: number,
1338
- score: number,
1339
- palette: PaletteColors,
1340
- isDark: boolean,
1341
- radius?: number
1342
- ): d3.Selection<SVGGElement, unknown, null, undefined> {
1343
- const r = radius ?? FACE_RADIUS;
1344
- const color = scoreToColor(score, palette);
1345
- const g = parent
1346
- .append('g')
1347
- .attr('class', 'journey-face')
1348
- .attr('data-cx', cx)
1349
- .attr('data-cy', cy);
1350
-
1351
- // Inner group holding only the face visuals. Hover/focus scaling is applied
1352
- // to THIS group, not the outer `g`, so the emotion caption (appended into the
1353
- // outer group later) never grows or shifts down into the bottom border.
1354
- const iconG = g.append('g').attr('class', 'journey-face-icon');
1355
-
1356
- // Face: a solid colored ring over the canonical tinted fill (the same
1357
- // shapeFill() tint used for unsolid shapes elsewhere), with the eyes and
1358
- // mouth drawn in the full score color.
1359
- const faceFill = shapeFill(palette, color, isDark);
1360
-
1361
- // Thin bg halo so the colored ring reads crisply where it crosses the line.
1362
- iconG
1363
- .append('circle')
1364
- .attr('cx', cx)
1365
- .attr('cy', cy)
1366
- .attr('r', r + 1)
1367
- .attr('fill', palette.bg);
1368
-
1369
- iconG
1370
- .append('circle')
1371
- .attr('cx', cx)
1372
- .attr('cy', cy)
1373
- .attr('r', r)
1374
- .attr('fill', faceFill)
1375
- .attr('stroke', color)
1376
- .attr('stroke-width', 2);
1377
-
1378
- // Eyes & mouth share the solid score color.
1379
- const eyeColor = color;
1380
- const eyeY = cy - r * 0.15;
1381
- const eyeSpacing = r * 0.32;
1382
- const eyeR = r * 0.12;
1383
- iconG
1384
- .append('circle')
1385
- .attr('cx', cx - eyeSpacing)
1386
- .attr('cy', eyeY)
1387
- .attr('r', eyeR)
1388
- .attr('fill', eyeColor);
1389
- iconG
1390
- .append('circle')
1391
- .attr('cx', cx + eyeSpacing)
1392
- .attr('cy', eyeY)
1393
- .attr('r', eyeR)
1394
- .attr('fill', eyeColor);
1395
-
1396
- // Mouth — arc curvature based on score
1397
- // score 5: big smile, score 3: straight, score 1: deep frown
1398
- const mouthW = r * 0.46;
1399
- // Curve amount: positive = smile, negative = frown
1400
- const curve = ((score - 3) / 2) * r * 0.42;
1401
- // Pin the mouth's visual apex (its mid-point) to a fixed Y and let the
1402
- // curvature swing symmetrically about it. Anchoring the corners instead made
1403
- // the frown's arch ride up into the eyes and read as a cramped grimace.
1404
- const apexY = cy + r * 0.32;
1405
- const mouthY = apexY - curve / 2;
1406
-
1407
- iconG
1408
- .append('path')
1409
- .attr(
1410
- 'd',
1411
- `M ${cx - mouthW} ${mouthY} Q ${cx} ${mouthY + curve} ${cx + mouthW} ${mouthY}`
1412
- )
1413
- .attr('fill', 'none')
1414
- .attr('stroke', eyeColor)
1415
- .attr('stroke-width', 1.2)
1416
- .attr('stroke-linecap', 'round');
1417
-
1418
- return g;
1419
- }
1420
-
1421
- // Max width an emotion caption may occupy. Curve faces sit at card centers
1422
- // (columns are ~190px wide and never overlap), so clamping each caption below
1423
- // the column width guarantees adjacent captions can never collide horizontally,
1424
- // however tight the journey gets.
1425
- const EMOTION_LABEL_MAX_WIDTH = 180;
1426
- const EMOTION_LABEL_FONT_SIZE = FONT_SIZE_META;
1427
-
1428
- /**
1429
- * Caption a curve face with its emotion word. Appended INTO the face group so
1430
- * it dims / navigates with the face. Always placed BELOW the face: the curve
1431
- * band reserves a gap beneath the lowest face before the cards, and — crucially
1432
- * — the hover thought-bubble always pops ABOVE the face, so a below-caption is
1433
- * never occluded on hover (above-captions were). Below also keeps every caption
1434
- * clear of the persona box / title at the top of the band.
1435
- */
1436
- function addEmotionLabel(
1437
- faceG: d3.Selection<SVGGElement, unknown, null, undefined>,
1438
- pt: CurvePoint,
1439
- palette: PaletteColors
1440
- ): void {
1441
- if (!pt.emotionLabel) return;
1442
- const text = truncateText(
1443
- pt.emotionLabel,
1444
- EMOTION_LABEL_MAX_WIDTH,
1445
- EMOTION_LABEL_FONT_SIZE
1446
- );
1447
- const y = pt.y + FACE_RADIUS + 5 + EMOTION_LABEL_FONT_SIZE;
1448
-
1449
- faceG
1450
- .append('text')
1451
- .attr('class', 'journey-emotion-label')
1452
- .attr('x', pt.x)
1453
- .attr('y', y)
1454
- .attr('text-anchor', 'middle')
1455
- .attr('font-family', FONT_FAMILY)
1456
- .attr('font-size', EMOTION_LABEL_FONT_SIZE)
1457
- .attr('font-weight', 500)
1458
- .attr('fill', palette.text)
1459
- .attr('stroke', palette.bg)
1460
- .attr('stroke-width', 3)
1461
- .attr('stroke-linejoin', 'round')
1462
- .attr('stroke-opacity', 0.8)
1463
- .attr('paint-order', 'stroke')
1464
- .attr('pointer-events', 'none')
1465
- .text(text);
1466
- }
1467
-
1468
- function wrapText(text: string, maxWidth: number, fontSize: number): string[] {
1469
- return wrapTextToWidth(text, fontSize, maxWidth);
1470
- }
1471
-
1472
- function truncateText(
1473
- text: string,
1474
- maxWidth: number,
1475
- fontSize: number
1476
- ): string {
1477
- return truncateToWidth(text, fontSize, maxWidth);
1478
- }
1479
-
1480
- function annotationColor(
1481
- type: JourneyMapAnnotation['type'],
1482
- palette: PaletteColors
1483
- ): string {
1484
- switch (type) {
1485
- case 'pain':
1486
- return palette.colors.red;
1487
- case 'opportunity':
1488
- return palette.colors.green;
1489
- case 'thought':
1490
- return palette.textMuted;
1491
- }
1492
- }
1493
-
1494
- // Lucide icon paths (24×24 viewBox, ISC license)
1495
- const ICON_THUMBS_DOWN: string[] = [
1496
- 'M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z',
1497
- 'M17 14V2',
1498
- ];
1499
- const ICON_THUMBS_UP: string[] = [
1500
- 'M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z',
1501
- 'M7 10v12',
1502
- ];
1503
- const ICON_THOUGHT: string[] = [
1504
- 'M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5',
1505
- 'M9 18h6',
1506
- 'M10 22h4',
1507
- ];
1508
-
1509
- function annotationIconPaths(type: JourneyMapAnnotation['type']): string[] {
1510
- switch (type) {
1511
- case 'pain':
1512
- return ICON_THUMBS_DOWN;
1513
- case 'opportunity':
1514
- return ICON_THUMBS_UP;
1515
- case 'thought':
1516
- return ICON_THOUGHT;
1517
- }
1518
- }
1519
-
1520
- /** Render a lucide-style icon (24×24 viewBox) scaled to fit `size` px. */
1521
- function renderAnnotationIcon(
1522
- parent: d3.Selection<SVGGElement, unknown, null, undefined>,
1523
- x: number,
1524
- y: number,
1525
- size: number,
1526
- paths: string[],
1527
- color: string
1528
- ): void {
1529
- const g = parent.append('g').attr('transform', `translate(${x}, ${y})`);
1530
- const scale = size / 24;
1531
- const inner = g.append('g').attr('transform', `scale(${scale})`);
1532
- for (const d of paths) {
1533
- inner
1534
- .append('path')
1535
- .attr('d', d)
1536
- .attr('fill', 'none')
1537
- .attr('stroke', color)
1538
- .attr('stroke-width', 2)
1539
- .attr('stroke-linecap', 'round')
1540
- .attr('stroke-linejoin', 'round');
1541
- }
1542
- }
1543
-
1544
- // ============================================================
1545
- // Export Renderer
1546
- // ============================================================
1547
-
1548
- export function renderJourneyMapForExport(
1549
- content: string,
1550
- theme: 'light' | 'dark' | 'transparent',
1551
- palette: PaletteColors
1552
- ): string {
1553
- const parsed = parseJourneyMap(content, palette);
1554
- if (
1555
- parsed.error ||
1556
- (parsed.phases.length === 0 && parsed.steps.length === 0)
1557
- ) {
1558
- return '';
1559
- }
1560
-
1561
- const isDark = theme === 'dark';
1562
- const layout = layoutJourneyMap(parsed, palette, { isDark });
1563
-
1564
- const container = document.createElement('div');
1565
- renderJourneyMap(container, parsed, palette, isDark, {
1566
- exportDims: { width: layout.totalWidth, height: layout.totalHeight },
1567
- exportMode: true,
1568
- });
1569
-
1570
- const svgEl = container.querySelector('svg');
1571
- if (!svgEl) return '';
1572
-
1573
- // Handle transparent background
1574
- if (theme === 'transparent') {
1575
- const bgRect = svgEl.querySelector('rect:first-child');
1576
- if (bgRect) bgRect.remove();
1577
- }
1578
-
1579
- return svgEl.outerHTML;
1580
- }