boardplot 0.0.0-stage → 0.53.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 (818) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE.md +180 -0
  4. package/README.md +208 -2
  5. package/THIRD_PARTY_NOTICES.md +1110 -0
  6. package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
  7. package/dist/ReaderBox-VOJSJ66R.js +137 -0
  8. package/dist/annotateEngine-DLMFJZ67.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24BHMKDD.js +83 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QADBDV.js +211 -0
  13. package/dist/chunk-2CVH5E57.js +128 -0
  14. package/dist/chunk-2DOR5SS6.js +446 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2FNNAPCI.js +24 -0
  17. package/dist/chunk-2L2Q53EP.js +251 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2ND7ZITT.js +3069 -0
  20. package/dist/chunk-2QT5ZUHO.js +2937 -0
  21. package/dist/chunk-2RSG7JYI.js +24 -0
  22. package/dist/chunk-2V6CLH33.js +1392 -0
  23. package/dist/chunk-2VWJ5BGO.js +566 -0
  24. package/dist/chunk-2WNYRWHG.js +51 -0
  25. package/dist/chunk-323YZWYJ.js +548 -0
  26. package/dist/chunk-33PB4V6K.js +382 -0
  27. package/dist/chunk-33PLBIMA.js +176 -0
  28. package/dist/chunk-3A2IEBCN.js +195 -0
  29. package/dist/chunk-3D3D3D23.js +25 -0
  30. package/dist/chunk-3EZRM4YM.js +92 -0
  31. package/dist/chunk-3H2W76TB.js +2353 -0
  32. package/dist/chunk-3JEQGGVD.js +19 -0
  33. package/dist/chunk-3QWZAEW5.js +26 -0
  34. package/dist/chunk-3SIRPKMP.js +12 -0
  35. package/dist/chunk-3SQCCESO.js +1592 -0
  36. package/dist/chunk-3XHJHQWU.js +42 -0
  37. package/dist/chunk-4G2O2ZPJ.js +83 -0
  38. package/dist/chunk-4JLBVIGW.js +24 -0
  39. package/dist/chunk-4RRNJLCM.js +746 -0
  40. package/dist/chunk-4UVW5WU6.js +76 -0
  41. package/dist/chunk-4X66BTP5.js +344 -0
  42. package/dist/chunk-53OYF4ZT.js +687 -0
  43. package/dist/chunk-57ZGVAU3.js +179 -0
  44. package/dist/chunk-5HECRVXJ.js +62 -0
  45. package/dist/chunk-5LGSRWFC.js +63 -0
  46. package/dist/chunk-5LYXD6ME.js +1112 -0
  47. package/dist/chunk-66RFKRGO.js +28 -0
  48. package/dist/chunk-6KWIQ5KF.js +18 -0
  49. package/dist/chunk-6OCR6ITN.js +72 -0
  50. package/dist/chunk-6RBTTCQD.js +802 -0
  51. package/dist/chunk-6Y7EXYLR.js +563 -0
  52. package/dist/chunk-7CTKTIPF.js +613 -0
  53. package/dist/chunk-7EVIIADO.js +185 -0
  54. package/dist/chunk-7X2ZYVAX.js +89 -0
  55. package/dist/chunk-7X65ZQN4.js +38 -0
  56. package/dist/chunk-A4QZXLXF.js +7 -0
  57. package/dist/chunk-A6CQPJWR.js +49 -0
  58. package/dist/chunk-A7IEVBYI.js +35 -0
  59. package/dist/chunk-ACXX2JNL.js +6 -0
  60. package/dist/chunk-ADKCLH3Z.js +98 -0
  61. package/dist/chunk-ADWSGPH5.js +23 -0
  62. package/dist/chunk-AG2CJ4JY.js +203 -0
  63. package/dist/chunk-AHQ4L3BE.js +30 -0
  64. package/dist/chunk-AOQ6VF5H.js +6 -0
  65. package/dist/chunk-AQROQDLR.js +3303 -0
  66. package/dist/chunk-AWTG3RFF.js +85 -0
  67. package/dist/chunk-B54RN2FD.js +692 -0
  68. package/dist/chunk-B67K6OWJ.js +48 -0
  69. package/dist/chunk-B6GFKYBZ.js +40 -0
  70. package/dist/chunk-BBL3R5YZ.js +186 -0
  71. package/dist/chunk-BBRBCMNR.js +28 -0
  72. package/dist/chunk-BIDIGDGH.js +6 -0
  73. package/dist/chunk-BLFWUMTD.js +12 -0
  74. package/dist/chunk-BM6SFFWF.js +6 -0
  75. package/dist/chunk-BMRD6MAH.js +24 -0
  76. package/dist/chunk-BPKXEMRE.js +197 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BW5VLBSZ.js +15 -0
  79. package/dist/chunk-BWGRWGVA.js +295 -0
  80. package/dist/chunk-BWLOXQDV.js +131 -0
  81. package/dist/chunk-BWTX7LUG.js +203 -0
  82. package/dist/chunk-C54QLNE4.js +69 -0
  83. package/dist/chunk-CAQ5P4VN.js +296 -0
  84. package/dist/chunk-CCCEBIUZ.js +296 -0
  85. package/dist/chunk-CDZHNLO6.js +42 -0
  86. package/dist/chunk-CJGSJKPO.js +25 -0
  87. package/dist/chunk-CN7JRHST.js +25 -0
  88. package/dist/chunk-CNX7EGSU.js +266 -0
  89. package/dist/chunk-COYOTQC2.js +75 -0
  90. package/dist/chunk-CRNMNZJD.js +1161 -0
  91. package/dist/chunk-CUVUDK4O.js +68 -0
  92. package/dist/chunk-CWDHCSL2.js +2919 -0
  93. package/dist/chunk-CYOJZ3GQ.js +631 -0
  94. package/dist/chunk-D4SOADBD.js +19 -0
  95. package/dist/chunk-D7SHZDA3.js +1808 -0
  96. package/dist/chunk-DAVHGK27.js +657 -0
  97. package/dist/chunk-DCCJRLAJ.js +422 -0
  98. package/dist/chunk-DCTCUZ5L.js +51 -0
  99. package/dist/chunk-DDCB7ZA5.js +2511 -0
  100. package/dist/chunk-DDI2W4TR.js +149 -0
  101. package/dist/chunk-DIHUGBZO.js +61 -0
  102. package/dist/chunk-DJHIQWSG.js +25 -0
  103. package/dist/chunk-DO5OZJAO.js +302 -0
  104. package/dist/chunk-DOFYKPTC.js +18 -0
  105. package/dist/chunk-DRTA6JG5.js +160 -0
  106. package/dist/chunk-DRW6KGBK.js +1062 -0
  107. package/dist/chunk-DU4A5AOY.js +1156 -0
  108. package/dist/chunk-DYS7EIXY.js +294 -0
  109. package/dist/chunk-E4IQ6M4S.js +24 -0
  110. package/dist/chunk-EFUWFB64.js +24 -0
  111. package/dist/chunk-EHBB2Z4D.js +290 -0
  112. package/dist/chunk-EHVESNLV.js +30 -0
  113. package/dist/chunk-EJPVVGD7.js +67 -0
  114. package/dist/chunk-EKQK5D6G.js +14 -0
  115. package/dist/chunk-EUADDXAV.js +30 -0
  116. package/dist/chunk-F6CNPC4L.js +47 -0
  117. package/dist/chunk-FBAYZSFC.js +2806 -0
  118. package/dist/chunk-FBB4BWKN.js +30 -0
  119. package/dist/chunk-FF23FYQD.js +1269 -0
  120. package/dist/chunk-FG6EDGMI.js +53 -0
  121. package/dist/chunk-FHA3KMFC.js +43 -0
  122. package/dist/chunk-FIANWJXX.js +19 -0
  123. package/dist/chunk-FIWNDOMO.js +6 -0
  124. package/dist/chunk-FV3VF36K.js +2721 -0
  125. package/dist/chunk-G5FMTRG5.js +37 -0
  126. package/dist/chunk-GCBOHVDZ.js +229 -0
  127. package/dist/chunk-GDOW2KNP.js +19 -0
  128. package/dist/chunk-GTG3IGLF.js +2674 -0
  129. package/dist/chunk-GZTNTHSW.js +21 -0
  130. package/dist/chunk-H4H4O62O.js +46 -0
  131. package/dist/chunk-H5G7T35P.js +24 -0
  132. package/dist/chunk-H63XQ3OO.js +942 -0
  133. package/dist/chunk-H67RTX46.js +43 -0
  134. package/dist/chunk-HA4IPWMM.js +841 -0
  135. package/dist/chunk-HKYTOJLV.js +33 -0
  136. package/dist/chunk-HOAH5XBR.js +542 -0
  137. package/dist/chunk-HTYFQHRC.js +24 -0
  138. package/dist/chunk-HYY5V2KL.js +19 -0
  139. package/dist/chunk-HZI56ASJ.js +79 -0
  140. package/dist/chunk-I6VAWNNU.js +24 -0
  141. package/dist/chunk-IBXXZVG7.js +80 -0
  142. package/dist/chunk-IDDA5INB.js +60 -0
  143. package/dist/chunk-IK4BHOPZ.js +33 -0
  144. package/dist/chunk-IL5T7I2A.js +27 -0
  145. package/dist/chunk-ILSXT6KT.js +24 -0
  146. package/dist/chunk-IV2UXZXX.js +16 -0
  147. package/dist/chunk-IYEFEBRN.js +41 -0
  148. package/dist/chunk-IYMI7YI4.js +829 -0
  149. package/dist/chunk-J6I2YFJH.js +58 -0
  150. package/dist/chunk-JFBEAUJ6.js +24 -0
  151. package/dist/chunk-JR7Y5ONB.js +27 -0
  152. package/dist/chunk-JSEYUJUQ.js +836 -0
  153. package/dist/chunk-JYBT2JNY.js +61 -0
  154. package/dist/chunk-K3HSQPSM.js +24 -0
  155. package/dist/chunk-KAXJFL7N.js +43 -0
  156. package/dist/chunk-KDMKHR5A.js +32 -0
  157. package/dist/chunk-KKWZWP67.js +24 -0
  158. package/dist/chunk-KOJ5QETJ.js +8 -0
  159. package/dist/chunk-KPKXJYQH.js +19 -0
  160. package/dist/chunk-KSJVENRU.js +113 -0
  161. package/dist/chunk-KZJOV4QW.js +33 -0
  162. package/dist/chunk-KZS46KDY.js +58 -0
  163. package/dist/chunk-L3JWM7FR.js +50 -0
  164. package/dist/chunk-L4S6UFTL.js +26 -0
  165. package/dist/chunk-L6DJ4ZY5.js +2008 -0
  166. package/dist/chunk-L7RHB734.js +23 -0
  167. package/dist/chunk-LCWJS34U.js +38 -0
  168. package/dist/chunk-LFTAMH7I.js +24 -0
  169. package/dist/chunk-LFX7W4B7.js +113 -0
  170. package/dist/chunk-LINZPU5D.js +8 -0
  171. package/dist/chunk-LIWLBLCT.js +83 -0
  172. package/dist/chunk-LNKY5Z2X.js +23 -0
  173. package/dist/chunk-LS7HVBI7.js +24 -0
  174. package/dist/chunk-M4EUXOLU.js +170 -0
  175. package/dist/chunk-M4SPKUZE.js +7 -0
  176. package/dist/chunk-M4YLED7M.js +17 -0
  177. package/dist/chunk-MBKZYJRC.js +1424 -0
  178. package/dist/chunk-MCYM3RNF.js +227 -0
  179. package/dist/chunk-MF6IVSBJ.js +48 -0
  180. package/dist/chunk-MIAPBQCA.js +24 -0
  181. package/dist/chunk-MJZHFH5R.js +1075 -0
  182. package/dist/chunk-MQFCG4KS.js +1467 -0
  183. package/dist/chunk-MVV6RQMG.js +128 -0
  184. package/dist/chunk-MYMT5KJL.js +1182 -0
  185. package/dist/chunk-MZL6LGKO.js +587 -0
  186. package/dist/chunk-N23YFPPI.js +47 -0
  187. package/dist/chunk-N3G2FYDL.js +300 -0
  188. package/dist/chunk-N3TPMXS3.js +161 -0
  189. package/dist/chunk-N73IBH55.js +58 -0
  190. package/dist/chunk-N7J7CZS6.js +43 -0
  191. package/dist/chunk-NCB3YLHF.js +28 -0
  192. package/dist/chunk-NHQGRKEA.js +63 -0
  193. package/dist/chunk-NKIYLFXZ.js +2774 -0
  194. package/dist/chunk-NOSDEJ3K.js +25934 -0
  195. package/dist/chunk-NQDVMUHX.js +433 -0
  196. package/dist/chunk-NSSNYY6Y.js +58 -0
  197. package/dist/chunk-NY5NUFDZ.js +117 -0
  198. package/dist/chunk-O3S2KNIW.js +25 -0
  199. package/dist/chunk-O3VN6BTL.js +24 -0
  200. package/dist/chunk-ONZLC47B.js +88 -0
  201. package/dist/chunk-OQEBOVUO.js +30 -0
  202. package/dist/chunk-OUEGGWH7.js +24 -0
  203. package/dist/chunk-OURX73UJ.js +728 -0
  204. package/dist/chunk-P25VEGGX.js +24 -0
  205. package/dist/chunk-P26Z62UV.js +24 -0
  206. package/dist/chunk-P5RNWMZC.js +2984 -0
  207. package/dist/chunk-P6KZIZDV.js +987 -0
  208. package/dist/chunk-PEUSKIFV.js +168 -0
  209. package/dist/chunk-PFVTYFSL.js +24 -0
  210. package/dist/chunk-PWROWDZS.js +137 -0
  211. package/dist/chunk-Q3CV2JJ2.js +3650 -0
  212. package/dist/chunk-QBR6IKIX.js +50 -0
  213. package/dist/chunk-QGCEHR6S.js +13 -0
  214. package/dist/chunk-QHRE2M6V.js +26 -0
  215. package/dist/chunk-QKL7IY42.js +38 -0
  216. package/dist/chunk-QO6HEXIZ.js +272 -0
  217. package/dist/chunk-QOIVXZUF.js +24 -0
  218. package/dist/chunk-QPWRHDLZ.js +17 -0
  219. package/dist/chunk-QSXK6PJL.js +19 -0
  220. package/dist/chunk-QTZVVZ2A.js +54 -0
  221. package/dist/chunk-QWXWVPNE.js +18 -0
  222. package/dist/chunk-QY5ZKUWY.js +383 -0
  223. package/dist/chunk-QZAT46PP.js +95 -0
  224. package/dist/chunk-RA66JA3D.js +24 -0
  225. package/dist/chunk-REOPXBUR.js +600 -0
  226. package/dist/chunk-RGZGLKFB.js +648 -0
  227. package/dist/chunk-RL3NUWMY.js +3378 -0
  228. package/dist/chunk-RNOJSEES.js +16 -0
  229. package/dist/chunk-ROXO4R3J.js +16 -0
  230. package/dist/chunk-RPIW5T55.js +40 -0
  231. package/dist/chunk-RQ5DNYLG.js +10 -0
  232. package/dist/chunk-RZNYW7UP.js +133 -0
  233. package/dist/chunk-S32YYDIB.js +420 -0
  234. package/dist/chunk-S4QSJAGY.js +44 -0
  235. package/dist/chunk-S6UX7KB6.js +335 -0
  236. package/dist/chunk-SDSONLMZ.js +2546 -0
  237. package/dist/chunk-SGD3ZHID.js +250 -0
  238. package/dist/chunk-SKRSCTT5.js +28 -0
  239. package/dist/chunk-SMCDXUIO.js +24 -0
  240. package/dist/chunk-SPTPFY4S.js +528 -0
  241. package/dist/chunk-SREWFAAJ.js +90 -0
  242. package/dist/chunk-SS42FJVN.js +3875 -0
  243. package/dist/chunk-SVZDXFPX.js +891 -0
  244. package/dist/chunk-SZPTTNW7.js +16 -0
  245. package/dist/chunk-T3IGJARD.js +22 -0
  246. package/dist/chunk-TA3TFKYZ.js +86 -0
  247. package/dist/chunk-TBGUEF3M.js +939 -0
  248. package/dist/chunk-TGK6KUGN.js +331 -0
  249. package/dist/chunk-TJSND556.js +1783 -0
  250. package/dist/chunk-TKOJZQAJ.js +24 -0
  251. package/dist/chunk-TM4OC53S.js +97 -0
  252. package/dist/chunk-TNEHPP3H.js +18 -0
  253. package/dist/chunk-TWOREVKJ.js +1760 -0
  254. package/dist/chunk-TXS3U77A.js +60 -0
  255. package/dist/chunk-UB6ODJHO.js +134 -0
  256. package/dist/chunk-UBZXQIDR.js +24 -0
  257. package/dist/chunk-ULTSSIOU.js +38 -0
  258. package/dist/chunk-UMDEWWXT.js +33 -0
  259. package/dist/chunk-V6O6KVOA.js +347 -0
  260. package/dist/chunk-VABRPZVC.js +43 -0
  261. package/dist/chunk-VDAKTZQP.js +18 -0
  262. package/dist/chunk-VDAZPGR2.js +79 -0
  263. package/dist/chunk-VERLFNWR.js +25 -0
  264. package/dist/chunk-VH2UUU7K.js +24 -0
  265. package/dist/chunk-VJ3FCGQF.js +12 -0
  266. package/dist/chunk-VK5ZDV67.js +47 -0
  267. package/dist/chunk-VKQNDOAI.js +40 -0
  268. package/dist/chunk-VTEV3WVF.js +690 -0
  269. package/dist/chunk-VXZFQKBJ.js +21 -0
  270. package/dist/chunk-WI5ITCOH.js +22 -0
  271. package/dist/chunk-WLZ54FWG.js +120 -0
  272. package/dist/chunk-WYJEOMNY.js +31 -0
  273. package/dist/chunk-WZGJSQKN.js +29 -0
  274. package/dist/chunk-WZL4EEBS.js +11 -0
  275. package/dist/chunk-X4YNDLVA.js +54 -0
  276. package/dist/chunk-X6SUFTD7.js +17 -0
  277. package/dist/chunk-XB4KZ6WO.js +81 -0
  278. package/dist/chunk-XJI6SWFS.js +569 -0
  279. package/dist/chunk-XJP5DKIL.js +29 -0
  280. package/dist/chunk-XN4ARQ2W.js +47 -0
  281. package/dist/chunk-XN7MQO45.js +359 -0
  282. package/dist/chunk-XQCQZBGX.js +100 -0
  283. package/dist/chunk-XXOHXA3A.js +69 -0
  284. package/dist/chunk-XZOHR765.js +127 -0
  285. package/dist/chunk-YCNLQYTC.js +133 -0
  286. package/dist/chunk-YCRGWQBS.js +526 -0
  287. package/dist/chunk-YF2PYLC4.js +210 -0
  288. package/dist/chunk-YG5GUELW.js +935 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YWP7XFKD.js +12 -0
  291. package/dist/chunk-Z2MGTKDR.js +20 -0
  292. package/dist/chunk-Z6CL7AR6.js +24 -0
  293. package/dist/chunk-Z7X3RGGA.js +22 -0
  294. package/dist/chunk-ZF43WRG3.js +29 -0
  295. package/dist/chunk-ZMF7WEGG.js +60 -0
  296. package/dist/chunk-ZNHFLJSY.js +375 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZQF34VPS.js +72 -0
  299. package/dist/chunk-ZU425HNM.js +24 -0
  300. package/dist/chunk-ZZU5R5UU.js +24 -0
  301. package/dist/cli/index.js +9 -0
  302. package/dist/core-3VCCUFVX.js +32 -0
  303. package/dist/core-4BZQQSHS.js +33 -0
  304. package/dist/core-4VT4MHNB.js +38 -0
  305. package/dist/core-5535KXRD.js +40 -0
  306. package/dist/core-5HQBPCHL.js +35 -0
  307. package/dist/core-6RYHWUJO.js +35 -0
  308. package/dist/core-7BZJCIXN.js +35 -0
  309. package/dist/core-AJTVU6X7.js +37 -0
  310. package/dist/core-C6YUSTZI.js +57 -0
  311. package/dist/core-EEB7HTCL.js +33 -0
  312. package/dist/core-EFMVDWNH.js +38 -0
  313. package/dist/core-ETAGQBZO.js +34 -0
  314. package/dist/core-FVR3WZEC.js +36 -0
  315. package/dist/core-GCTFVYMH.js +29 -0
  316. package/dist/core-GES44OTS.js +33 -0
  317. package/dist/core-GGQREDSI.js +47 -0
  318. package/dist/core-HRYOV6QD.js +38 -0
  319. package/dist/core-IKD3EE3S.js +38 -0
  320. package/dist/core-JM4R426L.js +32 -0
  321. package/dist/core-KKQS3WI2.js +40 -0
  322. package/dist/core-LA6XDYG7.js +40 -0
  323. package/dist/core-MJ7JWQT5.js +37 -0
  324. package/dist/core-MLROKJ2M.js +53 -0
  325. package/dist/core-MR52YBRX.js +31 -0
  326. package/dist/core-NP4VHWXL.js +29 -0
  327. package/dist/core-NQLNZDX5.js +41 -0
  328. package/dist/core-NSIJEKLI.js +44 -0
  329. package/dist/core-OJUQLIQ5.js +35 -0
  330. package/dist/core-PB3VUQSS.js +32 -0
  331. package/dist/core-Q6VLFFYC.js +56 -0
  332. package/dist/core-QY7AVIKZ.js +51 -0
  333. package/dist/core-SBQMHWTA.js +52 -0
  334. package/dist/core-UHECQHJ2.js +38 -0
  335. package/dist/core-V5FV4NWL.js +56 -0
  336. package/dist/core-WGM4XUN3.js +58 -0
  337. package/dist/core-WUQVFARS.js +34 -0
  338. package/dist/core-Z2F3IGSR.js +42 -0
  339. package/dist/dataTable-3CPPIHB3.js +58 -0
  340. package/dist/engine-FXFBCWHB.js +961 -0
  341. package/dist/fixtures.d.ts +1 -0
  342. package/dist/fixtures.js +41 -0
  343. package/dist/fontTables-WYCZNRE7.js +18 -0
  344. package/dist/fonts.d.ts +1 -0
  345. package/dist/fonts.js +19 -0
  346. package/dist/geo/dach.d.ts +1 -0
  347. package/dist/geo/dach.js +14 -0
  348. package/dist/geo/de-states.d.ts +1 -0
  349. package/dist/geo/de-states.js +14 -0
  350. package/dist/geo/eu27.d.ts +1 -0
  351. package/dist/geo/eu27.js +14 -0
  352. package/dist/geo/europe.d.ts +1 -0
  353. package/dist/geo/europe.js +14 -0
  354. package/dist/geo/index.d.ts +1 -0
  355. package/dist/geo/index.js +41 -0
  356. package/dist/geo/us-states.d.ts +1 -0
  357. package/dist/geo/us-states.js +14 -0
  358. package/dist/geo/world.d.ts +1 -0
  359. package/dist/geo/world.js +14 -0
  360. package/dist/index.d.ts +1 -0
  361. package/dist/index.js +364 -0
  362. package/dist/main-YLKBTHJP.js +569 -0
  363. package/dist/mcp/server.js +1025 -0
  364. package/dist/module-SVEW5ZUE.js +137233 -0
  365. package/dist/react/bar.d.ts +1 -0
  366. package/dist/react/bar.js +81 -0
  367. package/dist/react/bartable.d.ts +1 -0
  368. package/dist/react/bartable.js +70 -0
  369. package/dist/react/box.d.ts +1 -0
  370. package/dist/react/box.js +65 -0
  371. package/dist/react/bullet.d.ts +1 -0
  372. package/dist/react/bullet.js +72 -0
  373. package/dist/react/butterfly.d.ts +1 -0
  374. package/dist/react/butterfly.js +66 -0
  375. package/dist/react/choropleth.d.ts +1 -0
  376. package/dist/react/choropleth.js +67 -0
  377. package/dist/react/cohort.d.ts +1 -0
  378. package/dist/react/cohort.js +70 -0
  379. package/dist/react/column.d.ts +1 -0
  380. package/dist/react/column.js +86 -0
  381. package/dist/react/combo.d.ts +1 -0
  382. package/dist/react/combo.js +86 -0
  383. package/dist/react/creative.d.ts +1 -0
  384. package/dist/react/creative.js +61 -0
  385. package/dist/react/diagram.d.ts +1 -0
  386. package/dist/react/diagram.js +60 -0
  387. package/dist/react/dimswitch.d.ts +1 -0
  388. package/dist/react/dimswitch.js +72 -0
  389. package/dist/react/dot.d.ts +1 -0
  390. package/dist/react/dot.js +70 -0
  391. package/dist/react/export.d.ts +1 -0
  392. package/dist/react/export.js +658 -0
  393. package/dist/react/funnel.d.ts +1 -0
  394. package/dist/react/funnel.js +63 -0
  395. package/dist/react/gantt.d.ts +1 -0
  396. package/dist/react/gantt.js +62 -0
  397. package/dist/react/grid.d.ts +1 -0
  398. package/dist/react/grid.js +67 -0
  399. package/dist/react/heatmap.d.ts +1 -0
  400. package/dist/react/heatmap.js +68 -0
  401. package/dist/react/histogram.d.ts +1 -0
  402. package/dist/react/histogram.js +86 -0
  403. package/dist/react/index.d.ts +1 -0
  404. package/dist/react/index.js +504 -0
  405. package/dist/react/kpi.d.ts +1 -0
  406. package/dist/react/kpi.js +67 -0
  407. package/dist/react/likert.d.ts +1 -0
  408. package/dist/react/likert.js +83 -0
  409. package/dist/react/line.d.ts +1 -0
  410. package/dist/react/line.js +81 -0
  411. package/dist/react/mekko.d.ts +1 -0
  412. package/dist/react/mekko.js +71 -0
  413. package/dist/react/pareto.d.ts +1 -0
  414. package/dist/react/pareto.js +90 -0
  415. package/dist/react/pie.d.ts +1 -0
  416. package/dist/react/pie.js +64 -0
  417. package/dist/react/prepare.d.ts +1 -0
  418. package/dist/react/prepare.js +278 -0
  419. package/dist/react/pvm.d.ts +1 -0
  420. package/dist/react/pvm.js +68 -0
  421. package/dist/react/pyramid.d.ts +1 -0
  422. package/dist/react/pyramid.js +67 -0
  423. package/dist/react/sankey.d.ts +1 -0
  424. package/dist/react/sankey.js +59 -0
  425. package/dist/react/scatter.d.ts +1 -0
  426. package/dist/react/scatter.js +63 -0
  427. package/dist/react/slope.d.ts +1 -0
  428. package/dist/react/slope.js +64 -0
  429. package/dist/react/sparkline.d.ts +1 -0
  430. package/dist/react/sparkline.js +59 -0
  431. package/dist/react/spec.d.ts +1 -0
  432. package/dist/react/spec.js +379 -0
  433. package/dist/react/status.d.ts +1 -0
  434. package/dist/react/status.js +64 -0
  435. package/dist/react/story.d.ts +1 -0
  436. package/dist/react/story.js +140 -0
  437. package/dist/react/table.d.ts +1 -0
  438. package/dist/react/table.js +69 -0
  439. package/dist/react/theme.d.ts +1 -0
  440. package/dist/react/theme.js +53 -0
  441. package/dist/react/tilemap.d.ts +1 -0
  442. package/dist/react/tilemap.js +66 -0
  443. package/dist/react/treemap.d.ts +1 -0
  444. package/dist/react/treemap.js +61 -0
  445. package/dist/react/variance.d.ts +1 -0
  446. package/dist/react/variance.js +65 -0
  447. package/dist/react/waffle.d.ts +1 -0
  448. package/dist/react/waffle.js +62 -0
  449. package/dist/react/waterfall.d.ts +1 -0
  450. package/dist/react/waterfall.js +68 -0
  451. package/dist/resvg-ZOVDIZTV.js +23 -0
  452. package/dist/rows.d.ts +1 -0
  453. package/dist/rows.js +23 -0
  454. package/dist/rowsModule-YVLAROIP.js +27 -0
  455. package/dist/schema-2K6C3U24.js +23 -0
  456. package/dist/schema-2KIHLTYI.js +23 -0
  457. package/dist/schema-4HY2MWZC.js +30 -0
  458. package/dist/schema-4S5CXHAO.js +24 -0
  459. package/dist/schema-5BKQV56C.js +27 -0
  460. package/dist/schema-5HA5DSYN.js +24 -0
  461. package/dist/schema-5NKJPSBD.js +23 -0
  462. package/dist/schema-65FOKNHK.js +43 -0
  463. package/dist/schema-6OHZWHUI.js +23 -0
  464. package/dist/schema-6RYJS2GM.js +24 -0
  465. package/dist/schema-6W4M3WJ4.js +23 -0
  466. package/dist/schema-7TLSFG6M.js +24 -0
  467. package/dist/schema-AMFRKUFS.js +27 -0
  468. package/dist/schema-B7CZPPB4.js +28 -0
  469. package/dist/schema-BNRNHGHQ.js +26 -0
  470. package/dist/schema-E4MRCGPZ.js +24 -0
  471. package/dist/schema-F3WYTR65.js +26 -0
  472. package/dist/schema-FA6XIHTW.js +23 -0
  473. package/dist/schema-GZNOW4LX.js +23 -0
  474. package/dist/schema-HEIDGCSL.js +23 -0
  475. package/dist/schema-JB2H6KPA.js +23 -0
  476. package/dist/schema-MPXZNWV3.js +23 -0
  477. package/dist/schema-NHNQK6XO.js +23 -0
  478. package/dist/schema-NN6UPDPW.js +23 -0
  479. package/dist/schema-O4YNAGIY.js +23 -0
  480. package/dist/schema-O7AKK232.js +29 -0
  481. package/dist/schema-OJCML6LV.js +24 -0
  482. package/dist/schema-ORTRMYI6.js +24 -0
  483. package/dist/schema-PJ6P52BC.js +23 -0
  484. package/dist/schema-RTWES6NR.js +24 -0
  485. package/dist/schema-S36SRYGO.js +24 -0
  486. package/dist/schema-S3TCLTYD.js +23 -0
  487. package/dist/schema-SWWMOLOR.js +54 -0
  488. package/dist/schema-WOSEZNKG.js +26 -0
  489. package/dist/schema-Y6KBWUUR.js +23 -0
  490. package/dist/schema-YQYTLKSW.js +23 -0
  491. package/dist/schema-ZUUUY3QS.js +33 -0
  492. package/dist/specValidation-VNWIKLHH.js +49 -0
  493. package/dist/theme.d.ts +1 -0
  494. package/dist/theme.js +24 -0
  495. package/dist/themeShapeRules-2D3KWSPQ.js +11 -0
  496. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  497. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  498. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  499. package/dist/types/core/a11y/types.d.ts +116 -0
  500. package/dist/types/core/annotate.d.ts +300 -0
  501. package/dist/types/core/annotateArms.d.ts +37 -0
  502. package/dist/types/core/annotateFields.d.ts +30 -0
  503. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  504. package/dist/types/core/annotateLinks.d.ts +47 -0
  505. package/dist/types/core/annotateTargets.d.ts +90 -0
  506. package/dist/types/core/axis.d.ts +179 -0
  507. package/dist/types/core/bandSelect.d.ts +10 -0
  508. package/dist/types/core/bands.d.ts +14 -0
  509. package/dist/types/core/calendarLabels.d.ts +101 -0
  510. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  511. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  512. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  513. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  514. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  515. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  516. package/dist/types/core/charts/box/types.d.ts +110 -0
  517. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  518. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  519. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  520. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  521. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  522. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  523. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  524. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  525. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  526. package/dist/types/core/charts/column/layout.d.ts +116 -0
  527. package/dist/types/core/charts/column/model.d.ts +295 -0
  528. package/dist/types/core/charts/column/types.d.ts +56 -0
  529. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  530. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  531. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  532. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  533. package/dist/types/core/charts/creative/types.d.ts +73 -0
  534. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  535. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  536. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  537. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  538. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  540. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  541. package/dist/types/core/charts/gantt/layout.d.ts +63 -0
  542. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  543. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  544. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  545. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  546. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  547. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  548. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  549. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  550. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  551. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  552. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  553. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  554. package/dist/types/core/charts/line/types.d.ts +6 -0
  555. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  556. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  557. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  558. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  559. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  560. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  561. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  562. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  563. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  564. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  565. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  566. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  567. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  568. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  569. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  570. package/dist/types/core/charts/status/layout.d.ts +71 -0
  571. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  572. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  573. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  574. package/dist/types/core/charts/table/view.d.ts +156 -0
  575. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  576. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  577. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  578. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  579. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  580. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  581. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  582. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  583. package/dist/types/core/claims/browser.d.ts +49 -0
  584. package/dist/types/core/claims/manifest.d.ts +22 -0
  585. package/dist/types/core/dateFormat.d.ts +39 -0
  586. package/dist/types/core/deferred.d.ts +121 -0
  587. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  588. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  589. package/dist/types/core/doc/bareChart.d.ts +2 -0
  590. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  591. package/dist/types/core/doc/docExpand.d.ts +39 -0
  592. package/dist/types/core/doc/document.d.ts +43 -0
  593. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  594. package/dist/types/core/doc/specError.d.ts +6 -0
  595. package/dist/types/core/emptyData.d.ts +27 -0
  596. package/dist/types/core/eventLane.d.ts +208 -0
  597. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  598. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  599. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  600. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  601. package/dist/types/core/footer.d.ts +59 -0
  602. package/dist/types/core/format.d.ts +149 -0
  603. package/dist/types/core/formatPrecision.d.ts +136 -0
  604. package/dist/types/core/formatSpec.d.ts +304 -0
  605. package/dist/types/core/frame.d.ts +583 -0
  606. package/dist/types/core/geo/packs/all.d.ts +7 -0
  607. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  608. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  609. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  610. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  611. package/dist/types/core/geo/packs/index.d.ts +22 -0
  612. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  613. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  614. package/dist/types/core/geo/packs/world.d.ts +16 -0
  615. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  616. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  617. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  618. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  619. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  620. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  621. package/dist/types/core/geo/types.d.ts +146 -0
  622. package/dist/types/core/geometry.d.ts +102 -0
  623. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  624. package/dist/types/core/icons.d.ts +227 -0
  625. package/dist/types/core/inputError.d.ts +14 -0
  626. package/dist/types/core/isoDate.d.ts +2 -0
  627. package/dist/types/core/isoTime.d.ts +7 -0
  628. package/dist/types/core/label/categoryRow.d.ts +332 -0
  629. package/dist/types/core/label/occupied.d.ts +41 -0
  630. package/dist/types/core/label/ownership.d.ts +83 -0
  631. package/dist/types/core/label/solver.d.ts +384 -0
  632. package/dist/types/core/label/tickRow.d.ts +78 -0
  633. package/dist/types/core/live/types.d.ts +50 -0
  634. package/dist/types/core/normalize/shared.d.ts +56 -0
  635. package/dist/types/core/notes.d.ts +174 -0
  636. package/dist/types/core/othersShade.d.ts +9 -0
  637. package/dist/types/core/periodYears.d.ts +9 -0
  638. package/dist/types/core/polyline.d.ts +11 -0
  639. package/dist/types/core/rangeRules.d.ts +19 -0
  640. package/dist/types/core/ratioTier.d.ts +120 -0
  641. package/dist/types/core/readerStrings.d.ts +13 -0
  642. package/dist/types/core/reading.d.ts +120 -0
  643. package/dist/types/core/registry.d.ts +178 -0
  644. package/dist/types/core/repaintGeometry.d.ts +19 -0
  645. package/dist/types/core/request.d.ts +124 -0
  646. package/dist/types/core/rows.d.ts +47 -0
  647. package/dist/types/core/scale.d.ts +106 -0
  648. package/dist/types/core/schema/capability.d.ts +229 -0
  649. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  650. package/dist/types/core/schema/reference.d.ts +31 -0
  651. package/dist/types/core/schema/refusals.d.ts +45 -0
  652. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  653. package/dist/types/core/seriesIdentity.d.ts +120 -0
  654. package/dist/types/core/shareRounding.d.ts +49 -0
  655. package/dist/types/core/sizing.d.ts +330 -0
  656. package/dist/types/core/staticFooter.d.ts +6 -0
  657. package/dist/types/core/story.d.ts +41 -0
  658. package/dist/types/core/structureCounts.d.ts +10 -0
  659. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  660. package/dist/types/core/target.d.ts +89 -0
  661. package/dist/types/core/text.d.ts +113 -0
  662. package/dist/types/core/theme.d.ts +478 -0
  663. package/dist/types/core/themeFields.d.ts +11 -0
  664. package/dist/types/core/themeRules.d.ts +111 -0
  665. package/dist/types/core/themeShape.d.ts +87 -0
  666. package/dist/types/core/themeValidate.d.ts +15 -0
  667. package/dist/types/core/timeAxis.d.ts +106 -0
  668. package/dist/types/core/types/annotations.d.ts +227 -0
  669. package/dist/types/core/types/cell.d.ts +82 -0
  670. package/dist/types/core/types/data.d.ts +314 -0
  671. package/dist/types/core/types/diagram.d.ts +234 -0
  672. package/dist/types/core/types/index.d.ts +8 -0
  673. package/dist/types/core/types/options.d.ts +1583 -0
  674. package/dist/types/core/types/scene.d.ts +990 -0
  675. package/dist/types/core/types/sizing.d.ts +51 -0
  676. package/dist/types/core/types/table.d.ts +873 -0
  677. package/dist/types/core/types/theme.d.ts +806 -0
  678. package/dist/types/core/zoom.d.ts +106 -0
  679. package/dist/types/fixtures/index.d.ts +40 -0
  680. package/dist/types/fixtures/registry.d.ts +15 -0
  681. package/dist/types/fonts.d.ts +10 -0
  682. package/dist/types/index.d.ts +70 -0
  683. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  684. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  685. package/dist/types/react/ScaleGroup.d.ts +31 -0
  686. package/dist/types/react/SceneRenderer.d.ts +23 -0
  687. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  688. package/dist/types/react/StoryFrame.d.ts +42 -0
  689. package/dist/types/react/TableChart.d.ts +220 -0
  690. package/dist/types/react/a11ySurface.d.ts +20 -0
  691. package/dist/types/react/barrelCharts.d.ts +1023 -0
  692. package/dist/types/react/charts/bar.d.ts +28 -0
  693. package/dist/types/react/charts/bartable.d.ts +27 -0
  694. package/dist/types/react/charts/box.d.ts +27 -0
  695. package/dist/types/react/charts/bullet.d.ts +28 -0
  696. package/dist/types/react/charts/butterfly.d.ts +28 -0
  697. package/dist/types/react/charts/choropleth.d.ts +27 -0
  698. package/dist/types/react/charts/cohort.d.ts +52 -0
  699. package/dist/types/react/charts/column.d.ts +27 -0
  700. package/dist/types/react/charts/combo.d.ts +7 -0
  701. package/dist/types/react/charts/creative.d.ts +27 -0
  702. package/dist/types/react/charts/diagram.d.ts +162 -0
  703. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  704. package/dist/types/react/charts/dot.d.ts +28 -0
  705. package/dist/types/react/charts/funnel.d.ts +28 -0
  706. package/dist/types/react/charts/gantt.d.ts +28 -0
  707. package/dist/types/react/charts/grid.d.ts +29 -0
  708. package/dist/types/react/charts/heatmap.d.ts +28 -0
  709. package/dist/types/react/charts/histogram.d.ts +27 -0
  710. package/dist/types/react/charts/kpi.d.ts +28 -0
  711. package/dist/types/react/charts/likert.d.ts +27 -0
  712. package/dist/types/react/charts/line.d.ts +28 -0
  713. package/dist/types/react/charts/mekko.d.ts +28 -0
  714. package/dist/types/react/charts/pareto.d.ts +28 -0
  715. package/dist/types/react/charts/pie.d.ts +28 -0
  716. package/dist/types/react/charts/pvm.d.ts +27 -0
  717. package/dist/types/react/charts/pyramid.d.ts +27 -0
  718. package/dist/types/react/charts/sankey.d.ts +27 -0
  719. package/dist/types/react/charts/scatter.d.ts +28 -0
  720. package/dist/types/react/charts/slope.d.ts +28 -0
  721. package/dist/types/react/charts/sparkline.d.ts +28 -0
  722. package/dist/types/react/charts/status.d.ts +27 -0
  723. package/dist/types/react/charts/table.d.ts +6 -0
  724. package/dist/types/react/charts/tilemap.d.ts +27 -0
  725. package/dist/types/react/charts/treemap.d.ts +27 -0
  726. package/dist/types/react/charts/variance.d.ts +28 -0
  727. package/dist/types/react/charts/waffle.d.ts +28 -0
  728. package/dist/types/react/charts/waterfall.d.ts +28 -0
  729. package/dist/types/react/createChartComponent.d.ts +135 -0
  730. package/dist/types/react/export/clipboard.d.ts +8 -0
  731. package/dist/types/react/export/csv.d.ts +2 -0
  732. package/dist/types/react/export/frame.d.ts +35 -0
  733. package/dist/types/react/export/index.d.ts +7 -0
  734. package/dist/types/react/export/png.d.ts +14 -0
  735. package/dist/types/react/export/svg.d.ts +5 -0
  736. package/dist/types/react/export/types.d.ts +69 -0
  737. package/dist/types/react/export/useExport.d.ts +17 -0
  738. package/dist/types/react/exportLink.d.ts +49 -0
  739. package/dist/types/react/footerFrame.d.ts +25 -0
  740. package/dist/types/react/hover/dataTable.d.ts +13 -0
  741. package/dist/types/react/hover/engine.d.ts +210 -0
  742. package/dist/types/react/hover/keyboard.d.ts +44 -0
  743. package/dist/types/react/hover/labelCard.d.ts +170 -0
  744. package/dist/types/react/hover/placement.d.ts +49 -0
  745. package/dist/types/react/index.d.ts +16 -0
  746. package/dist/types/react/parseChartSpec.d.ts +16 -0
  747. package/dist/types/react/prepare.d.ts +32 -0
  748. package/dist/types/react/prepared.d.ts +53 -0
  749. package/dist/types/react/preparedTable.d.ts +15 -0
  750. package/dist/types/react/rowsInput.d.ts +55 -0
  751. package/dist/types/react/rowsModule.d.ts +18 -0
  752. package/dist/types/react/rowsStore.d.ts +50 -0
  753. package/dist/types/react/scale-group.d.ts +2 -0
  754. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  755. package/dist/types/react/scenePaint.d.ts +10 -0
  756. package/dist/types/react/scrollState.d.ts +26 -0
  757. package/dist/types/react/spec.d.ts +82 -0
  758. package/dist/types/react/specValidation.d.ts +45 -0
  759. package/dist/types/react/story.d.ts +15 -0
  760. package/dist/types/react/theme.d.ts +9 -0
  761. package/dist/types/react/themeContext.d.ts +44 -0
  762. package/dist/types/react/useChartLayout.d.ts +22 -0
  763. package/dist/types/react/useContainerSize.d.ts +57 -0
  764. package/dist/types/react/useHover.d.ts +100 -0
  765. package/dist/types/react/useZoom.d.ts +50 -0
  766. package/dist/types/rows.d.ts +63 -0
  767. package/dist/types/tableLooks.d.ts +6 -0
  768. package/dist/types/theme.d.ts +3 -0
  769. package/dist/types/validate.d.ts +3 -0
  770. package/dist/validate.d.ts +1 -0
  771. package/dist/validate.js +223 -0
  772. package/docs/FONTS.md +68 -0
  773. package/docs/TELEMETRY.md +94 -0
  774. package/docs/manual.md +850 -0
  775. package/docs/reference/bar.md +222 -0
  776. package/docs/reference/bartable.md +143 -0
  777. package/docs/reference/box.md +93 -0
  778. package/docs/reference/bullet.md +118 -0
  779. package/docs/reference/butterfly.md +117 -0
  780. package/docs/reference/choropleth.md +148 -0
  781. package/docs/reference/cohort.md +149 -0
  782. package/docs/reference/column.md +275 -0
  783. package/docs/reference/combo.md +219 -0
  784. package/docs/reference/creative.md +147 -0
  785. package/docs/reference/diagram.md +191 -0
  786. package/docs/reference/dimswitch.md +1395 -0
  787. package/docs/reference/dot.md +117 -0
  788. package/docs/reference/fixtures.md +1089 -0
  789. package/docs/reference/funnel.md +121 -0
  790. package/docs/reference/gantt.md +138 -0
  791. package/docs/reference/grid.md +302 -0
  792. package/docs/reference/heatmap.md +127 -0
  793. package/docs/reference/histogram.md +77 -0
  794. package/docs/reference/kpi.md +115 -0
  795. package/docs/reference/likert.md +113 -0
  796. package/docs/reference/line.md +436 -0
  797. package/docs/reference/mekko.md +114 -0
  798. package/docs/reference/options.md +313 -0
  799. package/docs/reference/pareto.md +102 -0
  800. package/docs/reference/pie.md +114 -0
  801. package/docs/reference/pvm.md +114 -0
  802. package/docs/reference/pyramid.md +99 -0
  803. package/docs/reference/react.md +706 -0
  804. package/docs/reference/reading.md +28 -0
  805. package/docs/reference/sankey.md +110 -0
  806. package/docs/reference/scatter.md +211 -0
  807. package/docs/reference/slope.md +126 -0
  808. package/docs/reference/sparkline.md +74 -0
  809. package/docs/reference/status.md +107 -0
  810. package/docs/reference/table.md +673 -0
  811. package/docs/reference/theme.md +361 -0
  812. package/docs/reference/tilemap.md +121 -0
  813. package/docs/reference/treemap.md +86 -0
  814. package/docs/reference/variance.md +126 -0
  815. package/docs/reference/waffle.md +106 -0
  816. package/docs/reference/waterfall.md +164 -0
  817. package/llms.txt +57 -0
  818. package/package.json +437 -4
@@ -0,0 +1,3069 @@
1
+ import {
2
+ clipTrendToDomain,
3
+ olsFit,
4
+ olsMoments
5
+ } from "./chunk-7X65ZQN4.js";
6
+ import {
7
+ preparePolyline
8
+ } from "./chunk-ADKCLH3Z.js";
9
+ import {
10
+ DEFAULT_OTHERS_SHADE
11
+ } from "./chunk-RQ5DNYLG.js";
12
+ import {
13
+ restValueHiding
14
+ } from "./chunk-EKQK5D6G.js";
15
+ import {
16
+ warnSliverLabels
17
+ } from "./chunk-27QADBDV.js";
18
+ import {
19
+ gapMarkerNode
20
+ } from "./chunk-5LGSRWFC.js";
21
+ import {
22
+ chartString as chartString2,
23
+ localeStrings,
24
+ planNearZeroTails
25
+ } from "./chunk-7EVIIADO.js";
26
+ import {
27
+ withUnit
28
+ } from "./chunk-IK4BHOPZ.js";
29
+ import {
30
+ categoryBandFromCenters
31
+ } from "./chunk-CDZHNLO6.js";
32
+ import {
33
+ trendTimeUnit
34
+ } from "./chunk-QY5ZKUWY.js";
35
+ import {
36
+ emptyIdRecord
37
+ } from "./chunk-LINZPU5D.js";
38
+ import {
39
+ categoryLineAlign,
40
+ dayUnit,
41
+ layoutValueAxis,
42
+ noteName,
43
+ rotatedClaimRect,
44
+ spread1D,
45
+ spread1DResult,
46
+ straightBreakGlyph,
47
+ sweepHide,
48
+ valueAxisTitleRequest,
49
+ warnSpreadOverflow,
50
+ yearRowRequests
51
+ } from "./chunk-RL3NUWMY.js";
52
+ import {
53
+ AREA_FILL_PART,
54
+ LAST_RESORT_PENALTY,
55
+ PRIORITY,
56
+ SWATCH_RESERVE,
57
+ adjacentSeriesWarnings,
58
+ composedTextRole,
59
+ createOccupiedIndex,
60
+ defaultAnnotationId,
61
+ fitText,
62
+ inflate,
63
+ othersShadeUnavailableWarnings,
64
+ partialKeyForced,
65
+ polylineYAt,
66
+ resolvePaintWarnings,
67
+ retainAdjacentWarningRule,
68
+ round2,
69
+ saysToDate,
70
+ segmentHitsRect,
71
+ sideAwayFrom,
72
+ toDateFits,
73
+ toDateLabel,
74
+ unitPrinted
75
+ } from "./chunk-SS42FJVN.js";
76
+ import {
77
+ disclosureNote
78
+ } from "./chunk-BPKXEMRE.js";
79
+ import {
80
+ defaultFormatSpec,
81
+ formatWithSpec,
82
+ parseISODate,
83
+ seriesRasterFormatter,
84
+ trendRateFormatter
85
+ } from "./chunk-RGZGLKFB.js";
86
+ import {
87
+ NOT_AVAILABLE,
88
+ NOT_MEANINGFUL,
89
+ chartString,
90
+ distinctDecimalLift,
91
+ formatAutomaticNumber,
92
+ formatAutomaticPercent,
93
+ formatExactNumber,
94
+ notApplicableGlyph,
95
+ numberRange,
96
+ shareDecimals,
97
+ stringFields
98
+ } from "./chunk-53OYF4ZT.js";
99
+ import {
100
+ HATCH_STRENGTH_DEFAULT,
101
+ LABEL_PLATE_RADIUS,
102
+ bumpStoryPaints,
103
+ dashToken,
104
+ effectiveFill,
105
+ emphasisWeight,
106
+ fanPaintSteps,
107
+ hatchGapFactor,
108
+ isOthersFill,
109
+ labelPlate,
110
+ labelsOffKeepsNames,
111
+ linePath,
112
+ markRolePaint,
113
+ markRoleToken,
114
+ mixedPaint,
115
+ orderedRampPaint,
116
+ othersSeparation,
117
+ paintColor,
118
+ rampSlots,
119
+ readerFloorPx,
120
+ secondaryFont,
121
+ separatedWashPaint,
122
+ seriesPaint,
123
+ strokeToken,
124
+ textScaleOf
125
+ } from "./chunk-CWDHCSL2.js";
126
+ import {
127
+ PALETTE_NORMAL_FLOOR,
128
+ palettePerceptualDistance
129
+ } from "./chunk-HA4IPWMM.js";
130
+ import {
131
+ cubicPoint,
132
+ curvePathFromSegments,
133
+ drawnStroke,
134
+ fmtPathNumber,
135
+ monotonePath,
136
+ monotoneSegments,
137
+ monotoneYAt,
138
+ splitCurve,
139
+ splitCurveSegmentsAtX
140
+ } from "./chunk-WLZ54FWG.js";
141
+ import {
142
+ DEFAULT_TARGET,
143
+ NormalizeError,
144
+ resolveSubtitle
145
+ } from "./chunk-SGD3ZHID.js";
146
+ import {
147
+ maxOf,
148
+ minOf,
149
+ pushAll
150
+ } from "./chunk-WYJEOMNY.js";
151
+
152
+ // src/core/charts/line/trend.ts
153
+ var DAY = 864e5;
154
+ function datesOf(cats) {
155
+ let dates = cats.map((c) => c.date ? parseISODate(c.date) : void 0);
156
+ if (!(dates.length < 2 || dates.some((d, i) => !d || i > 0 && d.getTime() <= dates[i - 1].getTime())))
157
+ return dates;
158
+ }
159
+ function trendUnit(cats) {
160
+ let dates = datesOf(cats);
161
+ if (!dates) return "period";
162
+ let months = dates.map((d) => d.getUTCFullYear() * 12 + d.getUTCMonth()), steps = months.slice(1).map((m, i) => m - months[i]), calendar = dates.every((d) => d.getUTCDate() === dates[0].getUTCDate()) || dayUnit(dates) !== "day";
163
+ return calendar && steps.every((step) => step > 0 && step % 12 === 0) ? "year" : calendar && steps.every((step) => step > 0 && step % 3 === 0) ? "quarter" : calendar && steps.every((step) => step > 0) ? "month" : dates.slice(1).every((d, i) => d.getTime() - dates[i].getTime() === 7 * DAY) ? "week" : "day";
164
+ }
165
+ function trendXs(cats, unit) {
166
+ let dates = cats.map((c) => parseISODate(c.date)), months = (d) => d.getUTCFullYear() * 12 + d.getUTCMonth(), per = { month: 1, quarter: 3, year: 12 };
167
+ return dates.map((d) => unit === "day" || unit === "week" ? (d.getTime() - dates[0].getTime()) / DAY / (unit === "week" ? 7 : 1) : (months(d) - months(dates[0])) / per[unit]);
168
+ }
169
+ function trendTimeline(cats, source = cats) {
170
+ let unit = trendUnit(source);
171
+ if (unit === "period") return;
172
+ let all = trendXs(source, unit), steps = all.slice(1).map((x, i) => x - all[i]), step = minOf(steps);
173
+ if (cats === source && steps.every((gap) => gap === step)) return;
174
+ let xs = trendXs(cats, unit);
175
+ return { positions: xs.map((x) => x / step), span: xs[xs.length - 1] / step + 1 };
176
+ }
177
+ function fitLineTrends(domain, warnings) {
178
+ if (!domain.options.trend) return [];
179
+ if (domain.isStacked || domain.bumpDerived)
180
+ throw new NormalizeError("trend-unsupported", "options.trend", "trend needs variant 'line' or 'area'; a stack or rank is not a series value");
181
+ let population = domain.population, lo = population ? population.indexes[0] : 0, hi = population ? population.indexes[population.indexes.length - 1] : domain.cats.length - 1, cats = population ? population.categories.slice(lo, hi + 1) : domain.cats, rows = population ? population.plotted : domain.pv, continuous = domain.x ? continuousTrend(domain.x, lo, hi) : void 0, unit = continuous?.unit ?? trendUnit(cats), xs = continuous?.xs ?? (unit === "period" ? cats.map((_, i) => population ? i : domain.timeline?.positions[i] ?? i) : trendXs(cats, unit));
182
+ return domain.drawnSeries.flatMap((s) => {
183
+ let row = rows[domain.rowOf.get(s)], points = xs.flatMap((x, i) => row[lo + i] === null ? [] : [{ x, y: row[lo + i] }]), moments = olsMoments(points), fit = moments.n >= 3 ? olsFit(moments) : null;
184
+ return fit ? [{ id: s.id, ...moments, ...fit, x0: points[0].x, x1: points[points.length - 1].x, unit }] : (warnings.push({
185
+ code: "trend-undefined",
186
+ severity: "warn",
187
+ field: ["options", "trend"],
188
+ owner: { seriesId: s.id },
189
+ message: `no trend line for series '${s.id}': a fit needs at least 3 non-null points at distinct x positions; it has ${moments.n}`
190
+ }), []);
191
+ });
192
+ }
193
+ function continuousTrend(x, lo, hi) {
194
+ let source = x.model.xs.slice(lo, hi + 1);
195
+ if (!x.model.clock) return { unit: "x", xs: source };
196
+ let { unit, ms } = trendTimeUnit(source[source.length - 1] - source[0]);
197
+ return { unit, xs: source.map((v) => (v - source[0]) / ms) };
198
+ }
199
+ function drawnXs(domain, unit) {
200
+ if (domain.x) {
201
+ let first = domain.x.model.xs[domain.population?.indexes[0] ?? 0], ms = domain.x.model.clock ? { second: 1e3, minute: 6e4, hour: 36e5, day: 864e5, week: 6048e5 }[unit] : 1;
202
+ return domain.x.shown.map((v) => domain.x.model.clock ? (v - first) / ms : v);
203
+ }
204
+ return unit === "period" ? domain.cats.map((_, ci) => domain.population?.positions[ci] ?? domain.timeline?.positions[ci] ?? ci) : trendXs(domain.cats, unit);
205
+ }
206
+ var TREND_UNIT_KEY = { day: "trendPerDay", week: "trendPerWeek", month: "trendPerMonth", quarter: "trendPerQuarter", year: "trendPerYear", period: "trendPerPeriod", second: "trendPerSecond", minute: "trendPerMinute", hour: "trendPerHour" };
207
+ function lineTrendLabel(domain, fit) {
208
+ let { options } = domain, label = typeof options.trend == "object" ? options.trend.label : void 0, series = domain.drawnSeries.find((s) => s.id === fit.id), example = domain.rebased ? void 0 : series.format ?? options.format, unit = domain.rebased ? void 0 : series.unit ?? options.unit, percent = !domain.rebased && series.vals.some((v) => v.isPct), slope = trendRateFormatter(example, options.locale?.language, percent ? "%" : unit, !0)(fit.slope), r2 = fit.r2 === null ? chartString2(options, "trendUndefined") : formatAutomaticNumber(fit.r2, { decimals: 2, locale: options.locale?.language });
209
+ return chartString2(options, "lineTrendKey", {
210
+ v1: label ?? chartString2(options, "linearTrend"),
211
+ v2: series.label,
212
+ v3: slope,
213
+ v4: fit.unit === "x" ? options.xAxis?.unit ? chartString2(options, "trendPerXUnit", { v1: options.xAxis.unit }) : chartString2(options, "trendPerUnitOfX") : chartString2(options, TREND_UNIT_KEY[fit.unit]),
214
+ v5: r2
215
+ });
216
+ }
217
+ function lineTrendKeys(theme, domain, paints) {
218
+ return domain.trends.map((fit) => {
219
+ let i = domain.drawnSeries.findIndex((s) => s.id === fit.id);
220
+ return {
221
+ id: `trend:${fit.id}`,
222
+ label: lineTrendLabel(domain, fit),
223
+ paint: paints.series(domain.drawnSeries[i], i),
224
+ key: "line",
225
+ width: strokeToken(theme, "rule"),
226
+ dash: dashToken(theme, "reference")
227
+ };
228
+ });
229
+ }
230
+ function drawLineTrends(theme, domain, area, paints, nodes, claims) {
231
+ for (let fit of domain.trends) {
232
+ let span = clipTrendToDomain(fit, [fit.x0, fit.x1], [domain.dLo, domain.dHi]);
233
+ if (!span) continue;
234
+ let xs = drawnXs(domain, fit.unit), n = xs.length - 1;
235
+ if (n < 1 || xs[n] === xs[0]) continue;
236
+ let x = (value) => area.xOf(0) + (value - xs[0]) / (xs[n] - xs[0]) * (area.xOf(n) - area.xOf(0)), x1 = x(span[0]), x2 = x(span[1]), y1 = area.y(fit.intercept + fit.slope * span[0]), y2 = area.y(fit.intercept + fit.slope * span[1]), i = domain.drawnSeries.findIndex((s) => s.id === fit.id), owner = { seriesId: fit.id };
237
+ nodes.push({
238
+ t: "line",
239
+ id: `trend:${fit.id}`,
240
+ x1,
241
+ y1,
242
+ x2,
243
+ y2,
244
+ owner,
245
+ part: "trendLine",
246
+ stroke: paints.series(domain.drawnSeries[i], i),
247
+ width: strokeToken(theme, "rule"),
248
+ dash: dashToken(theme, "reference")
249
+ });
250
+ for (let k = 0; k < 12; k++) {
251
+ let a = y1 + (y2 - y1) * k / 12, b = y1 + (y2 - y1) * (k + 1) / 12;
252
+ claims.claim(
253
+ { x: x1 + (x2 - x1) * k / 12, y: Math.min(a, b) - 1.5, w: Math.max((x2 - x1) / 12, 1), h: Math.abs(b - a) + 3 },
254
+ "annotation",
255
+ { annotationId: `trend:${fit.id}` },
256
+ "trendLine"
257
+ );
258
+ }
259
+ }
260
+ }
261
+
262
+ // src/core/label/areaGround.ts
263
+ function polylineYAt2(line, x) {
264
+ if (x <= line[0].x) return line[0].y;
265
+ for (let i = 1; i < line.length; i++) {
266
+ let a = line[i - 1], b = line[i];
267
+ if (x <= b.x) return b.x === a.x ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
268
+ }
269
+ return line[line.length - 1].y;
270
+ }
271
+ function screenEdges(a, b) {
272
+ let lo = Math.max(a[0].x, b[0].x), hi = Math.min(a[a.length - 1].x, b[b.length - 1].x), points = [...a.map((p) => ({ x: p.x, ya: p.y, yb: polylineYAt2(b, p.x) })), ...b.map((p) => ({ x: p.x, ya: polylineYAt2(a, p.x), yb: p.y }))].filter((p) => p.x >= lo && p.x <= hi).sort((p, q) => p.x - q.x), top = [], bottom = [];
273
+ return points.forEach((q, i) => {
274
+ let p = points[i - 1], dp = p ? p.ya - p.yb : 0, dq = q.ya - q.yb;
275
+ if (p && dp * dq < 0) {
276
+ let t = dp / (dp - dq), cross = { x: p.x + t * (q.x - p.x), y: p.ya + t * (q.ya - p.ya) };
277
+ top.push(cross), bottom.push(cross);
278
+ }
279
+ top.push({ x: q.x, y: Math.min(q.ya, q.yb) }), bottom.push({ x: q.x, y: Math.max(q.ya, q.yb) });
280
+ }), { top, bottom };
281
+ }
282
+ var edgeYs = (edge, x0, x1) => [polylineYAt2(edge, x0), polylineYAt2(edge, x1), ...edge.filter((point) => point.x > x0 && point.x < x1).map((point) => point.y)], spanOf = (ground, x0, x1) => {
283
+ let a = Math.max(x0, ground.top[0].x, ground.bottom[0].x), b = Math.min(x1, ground.top[ground.top.length - 1].x, ground.bottom[ground.bottom.length - 1].x);
284
+ return a < b ? [a, b] : void 0;
285
+ };
286
+ function groundUnder(rect, pad, grounds) {
287
+ let x0 = rect.x, x1 = rect.x + rect.w, y0 = rect.y - pad, y1 = rect.y + rect.h + pad;
288
+ for (let i = grounds.length - 1; i >= 0; i--) {
289
+ let ground = grounds[i];
290
+ if (ground.top.length < 2 || ground.bottom.length < 2) continue;
291
+ let span = spanOf(ground, x0, x1);
292
+ if (span) {
293
+ if (span[0] <= x0 && x1 <= span[1] && edgeYs(ground.top, x0, x1).every((y) => y <= y0) && edgeYs(ground.bottom, x0, x1).every((y) => y >= y1)) return ground;
294
+ if (reachesInto(ground, span, y0, y1)) return;
295
+ }
296
+ }
297
+ }
298
+ var reachesInto = (ground, span, y0, y1) => Math.min(...edgeYs(ground.top, ...span)) < y1 && Math.max(...edgeYs(ground.bottom, ...span)) > y0;
299
+ function straddlesOwn(rect, grounds, own) {
300
+ return grounds.some((ground) => {
301
+ if (ground.seriesId !== own || ground.top.length < 2 || ground.bottom.length < 2) return !1;
302
+ let span = spanOf(ground, rect.x, rect.x + rect.w);
303
+ return span !== void 0 && reachesInto(ground, span, rect.y, rect.y + rect.h);
304
+ });
305
+ }
306
+ function seatValuesOnGround(requests, grounds, pad, cssOf, others = !0, kinds = ["point"]) {
307
+ if (grounds.length !== 0)
308
+ for (let request of requests) {
309
+ let own = request.owner.seriesId ?? "";
310
+ if (!kinds.includes(request.kind) || own === "" && request.kind === "point") continue;
311
+ let rank = /* @__PURE__ */ new Map();
312
+ if (request.candidates = request.candidates.map((candidate) => {
313
+ if (candidate.leaderFrom || candidate.insideFill !== void 0 || candidate.needsBacking) return candidate;
314
+ let under = groundUnder(candidate.rect, pad, grounds), ownUnder = groundUnder(candidate.rect, 0, grounds), ground = under && (others || under.seriesId === own) ? under : ownUnder?.seriesId === own ? ownUnder : void 0;
315
+ if (ground) {
316
+ let seated = { ...candidate, onFill: { seriesId: ground.seriesId, fill: cssOf(ground), paint: ground.paint, ...ground.pattern ? { pattern: ground.pattern } : {} } };
317
+ return ground.seriesId === own && rank.set(seated, 1), seated;
318
+ }
319
+ return straddlesOwn(candidate.rect, grounds, own) && rank.set(candidate, 2), candidate;
320
+ }), rank.size === 0) continue;
321
+ let tier = (candidate) => (candidate.leaderFrom || candidate.penalty >= LAST_RESORT_PENALTY ? 3 : 0) + (rank.get(candidate) ?? 0);
322
+ request.candidates = request.candidates.map((candidate, index) => ({ candidate, index })).sort((a, b) => tier(a.candidate) - tier(b.candidate) || a.index - b.index).map(({ candidate }) => candidate);
323
+ }
324
+ }
325
+
326
+ // src/core/charts/line/labels.ts
327
+ var BUMP_NAME_MAX_FRACTION = 0.18, BUMP_NAME_MAX_LINES = 2, ENDPOINT_LEADER_CLEARANCE = 4, ENDPOINT_LEADER_MIN_DY = 3, END_LABEL_MAX_DISPLACEMENT_LINES = 3, SLIVER_MIN_H = 10, END_NAME_GAP = 16, NAME_PRIORITY = PRIORITY.endpoint + 1, END_LABEL_KEY = /* @__PURE__ */ Symbol("lineEndLabelKey"), END_LABEL_WIDE = /* @__PURE__ */ Symbol("lineEndLabelWide"), INLINE_FALLBACK = /* @__PURE__ */ Symbol("lineInlineFallback"), usesInlineFallback = (options) => options[INLINE_FALLBACK] === !0, usesEndLabelKey = (options) => options[END_LABEL_KEY] !== void 0, fanEdgeInKey = (domain) => domain.fan !== null && domain.x?.range?.cut.hi === !0 && usesEndLabelKey(domain.options), usesWideEndLabels = (options) => options[END_LABEL_WIDE] === !0;
328
+ function lineFocusFont(env, domain, font, weight) {
329
+ return !env.isBump && env.anyHighlight && domain.variant === "line" && !domain.isArea && domain.options.highlightMode !== "fade" ? { ...font, weight } : void 0;
330
+ }
331
+ function areaLeaderGap(labelHeight) {
332
+ return Math.max(12, ENDPOINT_LEADER_CLEARANCE + Math.ceil(labelHeight) + 1);
333
+ }
334
+ var ENDPOINT_LABEL_GUTTER_MAX_FRACTION = 0.18, STACKED_AREA_GUTTER_MAX_FRACTION = 0.21, ENDPOINT_LABEL_MAX_LINES = 2;
335
+ function wrapEndpointLabel(text, font, maxWidth, measure) {
336
+ let words = text.trim().split(/\s+/).filter(Boolean);
337
+ if (words.length === 0) return { lines: [], w: 0 };
338
+ let lines = [], current = "";
339
+ for (let word of words) {
340
+ let next = current ? `${current} ${word}` : word;
341
+ if (current && measure(next, font).width > maxWidth) {
342
+ if (lines.push(current), current = word, lines.length >= ENDPOINT_LABEL_MAX_LINES) return null;
343
+ } else current = next;
344
+ }
345
+ return current && lines.push(current), lines.length > ENDPOINT_LABEL_MAX_LINES ? null : { lines, w: Math.max(...lines.map((line) => measure(line, font).width)) };
346
+ }
347
+ function endUnitSuffix(options, unitless) {
348
+ return !unitless && options.unit && !unitPrinted({ subtitle: resolveSubtitle(options.subtitle), unit: options.unit, unitShown: options.unitShown }) ? options.unit : "";
349
+ }
350
+ function valueUnit(options, isBump, rebased) {
351
+ return isBump ? { endUnitSuffix: options.unit ?? "", unitOnEvery: !0 } : { endUnitSuffix: endUnitSuffix(options, rebased), unitOnEvery: !1 };
352
+ }
353
+ function authoredCellText(override, value) {
354
+ let number = value.composeText(
355
+ value.variant === "stacked100-area" ? ["percent"] : ["absolute"],
356
+ value.abs,
357
+ value.pct,
358
+ "",
359
+ "",
360
+ value.unitSuffix,
361
+ value.isPct,
362
+ value.source,
363
+ value.categoryId
364
+ );
365
+ return override.replace(/\$\{value\}/g, number);
366
+ }
367
+ function buildEndpointSeeds(input) {
368
+ let { endUnitSuffix: endUnitSuffix2, drawnSeries, cats, lastIdxOf, pv, rowOf, rebased, variant, absOf, composeText, printsZero, labelOnly } = input, valueParts = input.valueContent.filter((part) => part === "absolute" || part === "percent"), seeds = [];
369
+ return drawnSeries.forEach((series, dataIdx) => {
370
+ if (labelOnly !== void 0 && !labelOnly.has(series.id)) return;
371
+ let ci = lastIdxOf.get(series.id);
372
+ if (ci === void 0) return;
373
+ let plotted = pv[rowOf.get(series)][ci], abs = rebased ? plotted : absOf(series, ci), pct = variant === "stacked100-area" && !input.sharesWithheld.has(cats[ci].id) ? plotted : null, source = rebased ? void 0 : series.vals[ci]?.format ? { ...series, format: series.vals[ci].format } : series, compose = (content, seriesLabel) => composeText(content, abs, pct, cats[ci].label ?? cats[ci].id, seriesLabel, endUnitSuffix2, series.vals[ci].isPct, source, cats[ci].id);
374
+ seeds.push({
375
+ id: `series:${series.id}`,
376
+ kind: "series",
377
+ compose,
378
+ s: series,
379
+ dataIdx,
380
+ ci,
381
+ fullText: series.label,
382
+ ...series.shortLabel ? { shortText: series.shortLabel } : {},
383
+ valueText: typeof series.vals[ci].labelOverride == "string" ? authoredCellText(series.vals[ci].labelOverride, { composeText, variant, abs, pct, isPct: series.vals[ci].isPct, unitSuffix: endUnitSuffix2, source, categoryId: cats[ci].id }) : series.vals[ci].labelOverride === !1 ? "" : compose(valueParts, ""),
384
+ zeroText: composeText(valueParts, 0, 0, "", "", endUnitSuffix2, !1, source),
385
+ // Every printed part is zero at its precision: the absolute value by
386
+ // its raw number, a share by its printed text.
387
+ printsZero: valueParts.length > 0 && valueParts.every((part) => part === "absolute" ? abs !== null && printsZero(abs, series.vals[ci].isPct, source) : pct !== null && (pct === 0 || composeText(["percent"], abs, pct, "", "", "", series.vals[ci].isPct, source, cats[ci].id) === composeText(["percent"], 0, 0, "", "", "", !1, source))),
388
+ exactZero: abs === 0
389
+ });
390
+ }), seeds;
391
+ }
392
+ function toEndLabel(seed, text, lines, width, labelH) {
393
+ return { id: seed.id, kind: seed.kind, ...seed.shared ? { shared: !0 } : {}, s: seed.s, dataIdx: seed.dataIdx, ci: seed.ci, text, w: width, lines, h: Math.max(1, lines.length) * labelH, ...seed.valueText ? { valueText: seed.valueText } : {} };
394
+ }
395
+ function oneLineLabels(seeds, textOf, labelFont, labelH, measure) {
396
+ return seeds.flatMap((seed) => {
397
+ let text = textOf(seed);
398
+ return text ? [toEndLabel(seed, text, [text], measure(text, labelFont).width, labelH)] : [];
399
+ });
400
+ }
401
+ function wrappedLabels(seeds, textOf, labelFont, labelH, maxWidth, measure) {
402
+ let labels = [];
403
+ for (let seed of seeds) {
404
+ let text = textOf(seed);
405
+ if (!text) continue;
406
+ let block = wrapEndpointLabel(text, labelFont, maxWidth, measure);
407
+ if (!block) return null;
408
+ labels.push(toEndLabel(seed, text, block.lines, block.w, labelH));
409
+ }
410
+ return labels.some((label) => label.lines.length > 1) ? labels : null;
411
+ }
412
+ function prepareEndpointLabels(input) {
413
+ let { options, isBump, isArea, size, labelFont, labelH, measure } = input, endContent = input.names === "end" ? ["series"] : null, built = endContent ? buildEndpointSeeds({ ...input, endUnitSuffix: endUnitSuffix(options, isBump || input.rebased) }) : [], nearZero = planNearZeroTails({
414
+ strings: options.strings,
415
+ seeds: built,
416
+ endContent,
417
+ pinned: (id) => options.labelPlacements?.[id] !== void 0
418
+ }), seeds = nearZero.seeds, nameFloor = readerFloorPx(options.target ?? DEFAULT_TARGET, "label", textScaleOf(options)), fitName = (text, cap, nameFont = labelFont) => {
419
+ let wrapped = fitText(text, nameFont, cap, BUMP_NAME_MAX_LINES, measure, { target: options.target, textScale: textScaleOf(options), typeRole: "label", ...nameFloor < nameFont.size ? { shrink: { ...nameFont, size: nameFloor } } : {} }), lines = wrapped.lines.length > 0 ? wrapped.lines : [text], font = wrapped.lines.length > 0 && wrapped.font.size < nameFont.size ? wrapped.font : void 0, widest = Math.max(...lines.map((line) => measure(line, font ?? nameFont).width));
420
+ return { lines, w: Math.min(widest, cap), h: lines.length * (font ? labelH * font.size / labelFont.size : labelH), ...wrapped.title !== void 0 ? { title: wrapped.title } : {}, ...font ? { font } : {} };
421
+ }, nameBlock = (text, seriesId) => {
422
+ if (!isBump) return { lines: [text], w: measure(text, labelFont).width, h: labelH };
423
+ let nameFont = seriesId !== void 0 && input.bumpStory?.ids.has(seriesId) ? input.bumpStory.font : labelFont, cap = Math.max(size.width * BUMP_NAME_MAX_FRACTION, (input.bumpNameRoom ?? 0) / 2), block = fitName(text, cap, nameFont);
424
+ if (!input.bumpOneColumn || block.title === void 0) return block;
425
+ let wide = fitName(text, Math.max(size.width * BUMP_NAME_MAX_FRACTION * 2, input.bumpNameRoom ?? 0), nameFont);
426
+ return wide.title === void 0 ? wide : block;
427
+ }, endpointSwatches = !isBump && !isArea && (input.heroMode || input.anyHighlight && !(input.variant === "line" && options.highlightMode !== "fade")), endSwatchReserve = isArea || endpointSwatches ? SWATCH_RESERVE : 0, effectiveWidth = typeof options.embed?.width == "number" && options.embed.width > 0 ? options.embed.width : size.width, effectiveScale = effectiveWidth / size.width, effectiveBudget = effectiveWidth * (input.variant === "stacked-area" ? STACKED_AREA_GUTTER_MAX_FRACTION : ENDPOINT_LABEL_GUTTER_MAX_FRACTION), svgBudget = effectiveBudget / effectiveScale, endpointPadding = isArea ? areaLeaderGap(labelH * ENDPOINT_LABEL_MAX_LINES) + 8 : 14, textBudget = Math.max(0, svgBudget - endSwatchReserve - endpointPadding), full = oneLineLabels(seeds, (seed) => seed.fullText, labelFont, labelH, measure), fullWrapped = wrappedLabels(seeds, (seed) => seed.fullText, labelFont, labelH, textBudget, measure), hasShort = seeds.some((seed) => seed.shortText !== void 0), short = hasShort ? oneLineLabels(seeds, (seed) => seed.shortText ?? seed.fullText, labelFont, labelH, measure) : null, shortWrapped = hasShort ? wrappedLabels(seeds, (seed) => seed.shortText ?? seed.fullText, labelFont, labelH, textBudget, measure) : null, legendPosition = typeof options.legend == "object" ? options.legend.position : options.legend, gridLegend = options.gridEndpointIdentity === "legend", legend = !isBump && endContent !== null && legendPosition !== "none" && legendPosition !== "right" && !seeds.some((seed) => options.labelPlacements?.[seed.id] !== void 0) || gridLegend ? [] : null, candidates = [
428
+ { strategy: "full", labels: full },
429
+ ...fullWrapped ? [{ strategy: "wrapped", labels: fullWrapped }] : [],
430
+ ...legendPosition !== "none" && short ? [{ strategy: "short", labels: short }] : [],
431
+ ...legendPosition !== "none" && shortWrapped ? [{ strategy: "short", labels: shortWrapped }] : [],
432
+ ...legend ? [{ strategy: "legend", labels: legend }] : []
433
+ ], gutter = (labels) => labels.length > 0 ? maxOf(labels.map((label) => label.w)) + endSwatchReserve + (isArea ? areaLeaderGap(maxOf(labels.map((label) => label.h))) + 8 : endpointPadding) : 0, chosen = usesEndLabelKey(options) ? { strategy: "legend", labels: [] } : gridLegend && legend ? { strategy: "legend", labels: legend } : candidates.find((candidate) => gutter(candidate.labels) <= svgBudget + 1e-9) ?? candidates.reduce((best, candidate) => gutter(candidate.labels) < gutter(best.labels) ? candidate : best), endLabels = isBump ? full.map((label) => ({ ...label, ...foldBumpValue(label.text, input.bumpFolded?.get(`point:${label.s.id}:${input.cats[label.ci].id}`), (text) => nameBlock(text, label.s.id)) })) : chosen.labels, nameGutter = gutter(endLabels), columnGap = isBump ? 6 : Math.max(isArea ? areaLeaderGap(Math.max(0, maxOf(endLabels.map((label) => label.h)))) : END_NAME_GAP, input.endRoom), endReserve = isBump || endLabels.length === 0 ? nameGutter : maxOf(endLabels.map((label) => usesWideEndLabels(options) && input.mergeEndValues && label.valueText && !label.shared ? Math.max(label.w, measure(`${label.text} `, labelFont).width + measure(label.valueText, labelFont).width) : label.w)) + endSwatchReserve + columnGap + 8, economy = !isBump && seeds.length > 0 ? { strategy: chosen.strategy, maxGutterFraction: ENDPOINT_LABEL_GUTTER_MAX_FRACTION, requiredGutter: nameGutter, appliedGutter: nameGutter, effectiveRequiredGutter: nameGutter * effectiveScale, effectiveBudget, overflow: nameGutter > svgBudget + 1e-9 } : void 0;
434
+ return { inlineNamesEnabled: input.names === "inline", endContent, nameBlock, endLabels, endSwatchReserve, endpointSwatches, endReserve, columnGap, ...economy ? { endpointLabelEconomy: economy } : {}, ...nearZero.tail ? { nearZeroTail: nearZero.tail } : {}, endpointLegendFallback: economy?.strategy === "legend" || economy?.strategy === "short" || nearZero.tail?.mode === "dropped" && legendPosition === void 0 };
435
+ }
436
+ function foldBumpValue(name, value, nameBlock) {
437
+ let folded = value === void 0 ? void 0 : `${name} \xB7 ${value}`, block = folded === void 0 ? void 0 : nameBlock(folded);
438
+ return block && block.lines.join(" ").includes(`\xB7 ${value}`) ? { text: folded, ...block } : { text: name, ...nameBlock(name) };
439
+ }
440
+ var BESIDE_PENALTY = 5;
441
+ function containedRect(plot, centerX, y, width, height) {
442
+ return width > plot.w || height > plot.h || y < plot.y || y + height > plot.y + plot.h ? null : { x: Math.max(plot.x + width / 2, Math.min(centerX, plot.x + plot.w - width / 2)) - width / 2, y, w: width, h: height };
443
+ }
444
+ function inlineAnchors(series, mark, interpolation, categoryOrder) {
445
+ let vertices = mark.points.map((point) => ({ ...point, order: categoryOrder.get(point.categoryId) ?? -1, tier: 2 })), stroke = drawnStroke(vertices, interpolation), along = (share, tier, suffix) => vertices.flatMap((point, index) => {
446
+ let next = vertices[index + 1];
447
+ if (!next || !series.interpolateGaps && next.order !== point.order + 1) return [];
448
+ let x = point.x + (next.x - point.x) * share;
449
+ return [{ categoryId: `${point.categoryId}->${next.categoryId}${suffix}`, x, y: polylineYAt(stroke, x), order: point.order, tier }];
450
+ });
451
+ return [...along(0.5, 0, ""), ...along(0.25, 1, ":q1"), ...along(0.75, 1, ":q3"), ...vertices];
452
+ }
453
+ function placeInlineSeriesLabels(input) {
454
+ if (!input.enabled) return;
455
+ let plotCenter = input.plot.x + input.plot.w / 2;
456
+ input.drawnSeries.forEach((series) => {
457
+ let mark = input.marks.series.find((entry) => entry.seriesId === series.id);
458
+ if (!mark || mark.points.length === 0) return;
459
+ let ordered = [...inlineAnchors(series, mark, input.interpolationFor(series), input.categoryOrder)].sort((a, b) => a.tier - b.tier || Math.abs(a.x - plotCenter) - Math.abs(b.x - plotCenter) || a.order - b.order), text = series.label, nameFont = input.focusFont && input.highlights.has(series.id) ? input.focusFont : input.labelFont, width = input.measure(text, nameFont).width, onLine = [], beside = [], clear = (rect) => !input.marks.series.some((entry) => entry.points.some((point, i) => {
460
+ let next = entry.points[i + 1];
461
+ return next !== void 0 && segmentHitsRect(point, next, rect, 1);
462
+ }));
463
+ input.beside || ordered.forEach((point, index) => {
464
+ let rect = containedRect(input.plot, point.x, point.y - input.labelH / 2, width, input.labelH);
465
+ rect && !input.dividerXs.some((x) => x > rect.x - 3.5 && x < rect.x + rect.w + 3.5) && onLine.push({ slot: `inline:${point.categoryId}`, rect, penalty: input.beside ? 2 * ordered.length + index : index, needsBacking: !0 });
466
+ });
467
+ let others = input.marks.series.filter((entry) => entry.seriesId !== series.id && entry.points.length > 0), yAt = (points, x) => {
468
+ for (let i = 1; i < points.length; i++) {
469
+ let a = points[i - 1], b = points[i];
470
+ if (x >= Math.min(a.x, b.x) && x <= Math.max(a.x, b.x)) return b.x === a.x ? a.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
471
+ }
472
+ }, roomOf = (rect, above, lineY) => {
473
+ let xs = [rect.x, rect.x + rect.w / 2, rect.x + rect.w], ys = others.flatMap((entry) => xs.flatMap((x) => yAt(entry.points, x) ?? []));
474
+ if (xs.flatMap((x) => yAt(mark.points, x) ?? []).some((y) => above ? y < rect.y + rect.h + 2 : y > rect.y - 2)) return -1;
475
+ let edge = above ? rect.y - input.plot.y : input.plot.y + input.plot.h - rect.y - rect.h;
476
+ return Math.min(edge, minOf(ys.filter((y) => above ? y < lineY : y > lineY).map((y) => above ? rect.y - y : y - rect.y - rect.h)));
477
+ }, roomy = [];
478
+ ordered.forEach((point, index) => {
479
+ for (let [side, y] of [["over", point.y - input.labelH - 3], ["under", point.y + 3]]) {
480
+ let rect = containedRect(input.plot, point.x, y, width, input.labelH);
481
+ if (rect && !input.dividerXs.some((x) => x > rect.x - 3.5 && x < rect.x + rect.w + 3.5) && (!input.beside || clear(rect))) {
482
+ let cand = { slot: `inline:${side}:${point.categoryId}`, rect, penalty: input.beside ? index : ordered.length + index };
483
+ input.beside ? roomy.push({ cand, room: roomOf(rect, side === "over", point.y), index: roomy.length }) : beside.push(cand);
484
+ }
485
+ }
486
+ }), pushAll(beside, roomy.sort((a, b) => b.room - a.room || a.index - b.index).map(({ cand }, i) => ({ ...cand, penalty: i })));
487
+ let overSeats = beside.length;
488
+ if (input.beside && ordered.forEach((point) => {
489
+ for (let [side, x, y] of [["left", point.x - 4 - width, point.y - input.labelH], ["right", point.x + 4, point.y], ["left", point.x - 4 - width, point.y], ["right", point.x + 4, point.y - input.labelH], ["left", point.x - 6 - width, point.y - input.labelH / 2], ["right", point.x + 6, point.y - input.labelH / 2]]) {
490
+ let rect = { x, y, w: width, h: input.labelH };
491
+ rect.x < input.plot.x || rect.x + rect.w > input.plot.x + input.plot.w || rect.y < input.plot.y || rect.y + rect.h > input.plot.y + input.plot.h || input.dividerXs.some((d) => d > rect.x - 3.5 && d < rect.x + rect.w + 3.5) || !clear(rect) || beside.some((cand) => cand.rect.x === rect.x && cand.rect.y === rect.y) || beside.push({ slot: `inline:${side}:${point.categoryId}:${beside.length}`, rect, penalty: beside.length });
492
+ }
493
+ }), input.beside) {
494
+ let airOf = (rect) => Math.min(1 / 0, minOf(others.flatMap((entry) => [rect.x, rect.x + rect.w / 2, rect.x + rect.w].flatMap((x) => {
495
+ let y = yAt(entry.points, x);
496
+ return y === void 0 ? [] : [y < rect.y ? rect.y - y : y > rect.y + rect.h ? y - rect.y - rect.h : 0];
497
+ })))), side = beside.splice(overSeats), airy = side.filter((cand) => airOf(cand.rect) >= input.labelH);
498
+ pushAll(beside, [...airy, ...side.filter((cand) => !airy.includes(cand))].map((cand, i) => ({ ...cand, penalty: overSeats + i })));
499
+ }
500
+ let candidates = input.beside ? [...beside, ...onLine] : [...onLine, ...beside];
501
+ input.labelRequests.push({
502
+ id: `series:${series.id}`,
503
+ kind: "series",
504
+ owner: { seriesId: series.id },
505
+ text,
506
+ lines: [text],
507
+ typeRole: "label",
508
+ font: nameFont,
509
+ priority: NAME_PRIORITY + (input.highlights.has(series.id) || input.heroId === series.id ? PRIORITY.highlightBonus : 0),
510
+ candidates
511
+ });
512
+ });
513
+ }
514
+ function endpointAnchor(label, marks, cats, isStacked, y, cumTop, cumBot) {
515
+ let point = marks.series.find((item) => item.seriesId === label.s.id)?.points.find((item) => item.categoryId === cats[label.ci].id);
516
+ return point ? isStacked ? { x: point.x, y: (y(cumTop[label.dataIdx][label.ci]) + y(cumBot[label.dataIdx][label.ci])) / 2 } : point : null;
517
+ }
518
+ function endpointCandidate(input) {
519
+ let { rect, size, leaderFrom } = input;
520
+ return rect.x < 0 || rect.y < 0 || rect.x + rect.w > size.width || rect.y + rect.h > size.height || input.outsideRankBand(rect) ? null : {
521
+ slot: input.slot,
522
+ rect,
523
+ penalty: input.penalty,
524
+ ...leaderFrom && input.leaderClearsAreaFill && (input.isArea || input.isStacked || input.keepLeader || Math.abs(rect.y + rect.h / 2 - input.desiredY) > ENDPOINT_LEADER_MIN_DY) ? { leaderFrom } : {}
525
+ };
526
+ }
527
+ function nameSpreadSizes(heights, rankYs) {
528
+ let loose = heights.map((h) => h + 2);
529
+ if (!rankYs) return loose;
530
+ let ys = rankYs.filter((y) => y !== void 0), rows = [...new Set(ys)].sort((a, b) => a - b);
531
+ if (rows.length < ys.length || rows.length < 2) return loose;
532
+ let pitch = minOf(rows.slice(1).map((y, i) => y - rows[i]));
533
+ return heights.every((h) => h + 2 <= pitch) ? heights.map((h) => Math.min(h + 2, pitch - 2)) : loose;
534
+ }
535
+ function placeEndpointLabels(input) {
536
+ let leaders = /* @__PURE__ */ new Map();
537
+ if (input.endLabels.length === 0) return leaders;
538
+ let anchors = input.endLabels.map((label) => endpointAnchor(label, input.marks, input.cats, input.isStacked, input.y, input.cumTop, input.cumBot)), swatched = /* @__PURE__ */ new Set(), pairs = /* @__PURE__ */ new Set();
539
+ if (input.crowdedEnds && !input.isStacked && !input.isArea) {
540
+ let atLast = input.endLabels.flatMap((label, index) => label.ci === input.cats.length - 1 && !label.shared && anchors[index] ? [index] : []).sort((a, b) => anchors[a].y - anchors[b].y), clusters = [];
541
+ for (let index of atLast) {
542
+ let cluster = clusters[clusters.length - 1];
543
+ cluster && anchors[index].y - anchors[cluster[cluster.length - 1]].y < input.endLabels[index].h + 5 ? cluster.push(index) : clusters.push([index]);
544
+ }
545
+ let joinEvery = input.joinEvery === !0 && input.bounded !== void 0;
546
+ for (let cluster of clusters.filter((members) => joinEvery || members.length >= (input.bounded ? 2 : 3))) {
547
+ let fits = [];
548
+ for (let index of cluster) {
549
+ let label = input.endLabels[index], w = label.w;
550
+ if (input.valuesAtEnd && label.valueText) {
551
+ let valueText = label.valueText, lineH = label.h / Math.max(1, label.lines.length);
552
+ w = Math.max(label.w, input.valuesAtEnd.measure(valueText, input.labelFont).width), input.endLabels[index] = { ...label, text: `${label.text} ${valueText}`, lines: [...label.lines, valueText], h: label.h + lineH, w }, input.valuesAtEnd.merged.add(label.s.id), (cluster.length === 2 || joinEvery) && pairs.add(label.s.id);
553
+ }
554
+ !input.bounded && !input.endpointSwatches && input.endSwatchReserve === 0 && input.columnX + w + SWATCH_RESERVE <= input.size.width && fits.push(label.id);
555
+ }
556
+ if (fits.length === cluster.length) for (let id of fits) swatched.add(id);
557
+ }
558
+ }
559
+ let endsEarly = input.endLabels.map((label, index) => !input.isArea && anchors[index] !== null && label.ci < input.cats.length - 1), early = endsEarly.map((ends) => ends && input.atLineEnd === !0), sizes = nameSpreadSizes(input.endLabels.map((label) => label.h), input.rankLadder ? anchors.map((anchor) => anchor?.y) : void 0), items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? input.plot.y + input.plot.h / 2, size: sizes[index] })), edgeIndices = items.flatMap((_, index) => early[index] ? [] : [index]), edgeItems = edgeIndices.map((index) => items[index]), range = [input.plot.y, input.plot.y + input.plot.h - (input.columnX < input.plot.x + input.plot.w ? 3 : 0)], spread = spread1DResult(edgeItems, range, 2);
560
+ if (input.bounded) {
561
+ let bound = input.bounded.lineHeight * END_LABEL_MAX_DISPLACEMENT_LINES, fits = () => spread.fits && edgeIndices.every((index, k) => Math.abs(spread.positions[k] - items[index].desired) <= bound), joinAll = !fits();
562
+ if (input.valuesAtEnd && (joinAll || pairs.size > 0)) {
563
+ for (let index of edgeIndices) {
564
+ let label = input.endLabels[index];
565
+ if (!input.valuesAtEnd.merged.has(label.s.id) || !label.valueText || !joinAll && !pairs.has(label.s.id)) continue;
566
+ let name = label.lines.slice(0, -1).join(" "), text = `${name} ${label.valueText}`;
567
+ input.endLabels[index] = {
568
+ ...label,
569
+ text,
570
+ lines: [text],
571
+ h: input.bounded.lineHeight,
572
+ w: input.valuesAtEnd.measure(`${name} `, input.labelFont).width + input.valuesAtEnd.measure(label.valueText, input.labelFont).width
573
+ };
574
+ }
575
+ items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? input.plot.y + input.plot.h / 2, size: input.endLabels[index].h + 2 })), edgeItems = edgeIndices.map((index) => items[index]), spread = spread1DResult(edgeItems, range, 2);
576
+ }
577
+ let tooWide = edgeIndices.some((index) => input.columnX + input.endLabels[index].w + input.endSwatchReserve > input.size.width - 8);
578
+ if (fits() && tooWide && !input.bounded.wide && input.valuesAtEnd?.merged.size)
579
+ return input.bounded.widen = !0, leaders;
580
+ if (!fits() || tooWide)
581
+ return input.bounded.fallback = !0, leaders;
582
+ }
583
+ warnSpreadOverflow(input.warnings, spread.fits, "endpoint labels exceed the plot height even after spreading \u2014 labels stay bounded but overlap; fewer series or a larger canvas fixes it");
584
+ let edgePositions = spread.fits ? spread.positions : spread1D(edgeItems, range, 2), positions = items.map((item) => item.desired);
585
+ return edgeIndices.forEach((index, k) => {
586
+ positions[index] = edgePositions[k];
587
+ }), input.endLabels.forEach((label, index) => {
588
+ let anchor = anchors[index], desiredY = anchor?.y ?? input.plot.y + input.plot.h / 2, rect = { x: input.columnX, y: positions[index] - label.h / 2, w: label.w + (swatched.has(label.id) ? SWATCH_RESERVE : input.endSwatchReserve), h: label.h }, leaderFrom = anchor ? { x: Math.min(anchor.x + ENDPOINT_LEADER_CLEARANCE, rect.x - 2), y: anchor.y } : void 0;
589
+ leaderFrom && leaders.set(label.id, leaderFrom);
590
+ let common = { size: input.size, outsideRankBand: input.outsideRankBand, leaderFrom, leaderClearsAreaFill: !input.isArea || !input.paintedAreaCats.has(label.s.id) || label.ci === input.cats.length - 1 && input.paintedAreaCats.get(label.s.id)?.has(label.ci) === !0, isArea: input.isArea, isStacked: input.isStacked, keepLeader: endsEarly[index], desiredY }, atPoint = early[index] && anchor ? [
591
+ { slot: "besideEnd", rect: { ...rect, x: anchor.x + 8, y: anchor.y - label.h / 2 }, penalty: 0 },
592
+ { slot: "aboveEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y - label.h - 6 }, penalty: 1 },
593
+ { slot: "belowEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y + 6 }, penalty: 1 },
594
+ { slot: "overValueEnd", rect: { ...rect, x: anchor.x + 4, y: anchor.y - 2 * label.h - 8 }, penalty: 2 },
595
+ // Left of the point, where the lines that run on leave the right side
596
+ // no room: a line that ends at its first category.
597
+ { slot: "beforeEnd", rect: { ...rect, x: anchor.x - 8 - rect.w, y: anchor.y - label.h / 2 }, penalty: 2.5 },
598
+ { slot: "belowBeforeEnd", rect: { ...rect, x: anchor.x - 4 - rect.w, y: anchor.y + 6 }, penalty: 2.5 },
599
+ // A row further from the point, where other lines crowd the near rows
600
+ // and the value took the row above: over the value, as "Jun 26" reads
601
+ // over "60%", or under the rows below. Only then the right-hand rail,
602
+ // whose leader would cross the plot ("Mar 26" beside "Sep 25").
603
+ ...[1, 2].flatMap((k) => [
604
+ { slot: `overValueEnd${k}`, rect: { ...rect, x: anchor.x - rect.w / 2, y: anchor.y - (2 + k) * (label.h + 2) - 8 }, penalty: 2.6 + k / 10 },
605
+ { slot: `belowEnd${k}`, rect: { ...rect, x: anchor.x + 4, y: anchor.y + 6 + k * (label.h + 2) }, penalty: 2.6 + k / 10 }
606
+ ])
607
+ ].map((candidate) => endpointCandidate({ ...candidate, ...common, leaderFrom: void 0 })) : [], candidates = [
608
+ ...atPoint,
609
+ endpointCandidate({ slot: "lineEnd", rect, penalty: atPoint.length > 0 ? 3 : 0, ...common }),
610
+ ...!input.bounded || early[index] ? [endpointCandidate({ slot: "lineEndShifted", rect: { ...rect, y: rect.y + label.h + 2 }, penalty: atPoint.length > 0 ? 4 : 1, ...common })] : []
611
+ ].filter((item) => item !== null && (!input.bounded || Math.abs(item.rect.y + item.rect.h / 2 - desiredY) <= input.bounded.lineHeight * END_LABEL_MAX_DISPLACEMENT_LINES));
612
+ input.labelRequests.push({
613
+ id: label.id,
614
+ kind: label.kind,
615
+ owner: { seriesId: label.s.id, categoryId: input.cats[label.ci].id },
616
+ text: label.text,
617
+ lines: label.lines,
618
+ ...label.valueText && label.text.endsWith(` ${label.valueText}`) ? { printsFor: [{ seriesId: label.s.id, categoryId: input.cats[label.ci].id }] } : {},
619
+ ...label.title !== void 0 ? { title: label.title } : {},
620
+ typeRole: "label",
621
+ font: label.font ?? input.labelFont,
622
+ ...label.font ? { fontStep: label.font } : {},
623
+ // A name at an early end shares its point with the last value, and the
624
+ // value places first so it sits at the point (cohort curves).
625
+ priority: (early[index] ? PRIORITY.endpoint - 1 : NAME_PRIORITY) + (input.highlights.has(label.s.id) ? PRIORITY.highlightBonus : 0),
626
+ candidates,
627
+ ...input.bounded ? { leaderClear: "includingPins" } : {},
628
+ // A name at an early end takes a seat only where it lies nearer its
629
+ // own end than another series' marks; the rows further out (over the
630
+ // value, under the rows below) can reach a crossing line.
631
+ ...early[index] && anchor ? { anchor: { x: anchor.x, y: anchor.y } } : {},
632
+ // A shared label names several series; one colour swatch would claim it belongs to one of them.
633
+ ...label.shared ? {} : input.isArea ? { swatch: input.keyPaint(label.s, label.dataIdx) } : input.endpointSwatches || swatched.has(label.id) ? { swatch: input.seriesPaint(label.s, label.dataIdx) } : {}
634
+ });
635
+ }), leaders;
636
+ }
637
+ function pointLabelSeeds(input) {
638
+ let { series, row, cats } = input, drawn = row.flatMap((value, ci) => value === null ? [] : [ci]), values = drawn.map((ci) => row[ci]), min = minOf(values), max = maxOf(values), last = drawn[drawn.length - 1], seeds = [];
639
+ for (let ci of input.categoryIndices ?? drawn) {
640
+ let category = cats[ci], value = row[ci];
641
+ if (value === null) continue;
642
+ let cell = series.vals[ci], source = input.rebased ? void 0 : cell.format ? { ...series, format: cell.format } : series, pct = input.variant === "stacked100-area" && !input.sharesWithheld.has(category.id) ? value : null, abs = input.rebased ? value : input.absOf(series, ci), unitSuffix = input.unitOnEvery || ci === last ? input.endUnitSuffix : "", composeText = ci === last ? input.composeEndText ?? input.composeText : input.composeText, text = composeText(input.content, abs, pct, category.label ?? category.id, series.label, unitSuffix, cell.isPct, source, category.id);
643
+ if (typeof cell.labelOverride == "string" && (text = authoredCellText(cell.labelOverride, {
644
+ composeText,
645
+ variant: input.variant,
646
+ abs,
647
+ pct,
648
+ isPct: cell.isPct,
649
+ unitSuffix,
650
+ source,
651
+ categoryId: category.id
652
+ })), !text && cell.labelOverride !== !1) continue;
653
+ let endpoint = ci === drawn[0] || ci === last, extreme = value === min || value === max, highlighted = input.highlights.has(series.id) || input.highlights.has(category.id), priority = cell.priority ?? (endpoint ? PRIORITY.endpoint : extreme ? PRIORITY.extreme : PRIORITY.interior + Math.min(99, Math.abs(value))) + (highlighted ? PRIORITY.highlightBonus : 0);
654
+ seeds.push({ ci, text, w: input.measure(text || "0", input.labelFont).width, priority, suppressed: cell.labelOverride === !1 });
655
+ }
656
+ return seeds;
657
+ }
658
+ function buildPointCandidates(input) {
659
+ let { series, dataIdx, row } = input;
660
+ return pointLabelSeeds(input).map((seed) => {
661
+ let { ci, w: width } = seed, value = row[ci], py = input.isStacked ? input.y(input.cumTop[dataIdx][ci]) : input.y(value), center = width <= input.plot.w ? Math.max(input.plot.x + width / 2, Math.min(input.xOf(ci), input.plot.x + input.plot.w - width / 2)) : input.xOf(ci), candidate = { ...seed, x: center, py };
662
+ return input.isStacked && (candidate.bandTop = input.y(input.cumTop[dataIdx][ci]), candidate.bandBot = input.y(input.cumBot[dataIdx][ci]), input.paintedAreaCats.get(series.id)?.has(ci) && (candidate.insidePaint = input.areaFillPaint(series, dataIdx), candidate.insideFill = input.paintCss(candidate.insidePaint))), candidate;
663
+ });
664
+ }
665
+ function insideBandEdges(rect, edges, labelH) {
666
+ let hits = (edge) => edge.some((point, i) => i > 0 && segmentHitsRect(edge[i - 1], point, rect, 2));
667
+ if (!hits(edges.top) && !hits(edges.bottom)) return rect;
668
+ let x0 = rect.x, x1 = rect.x + rect.w, within = (edge) => [polylineYAt(edge, x0), polylineYAt(edge, x1), ...edge.filter((p) => p.x > x0 && p.x < x1).map((p) => p.y)], top = maxOf(within(edges.top)), bottom = minOf(within(edges.bottom));
669
+ if (!(bottom - top < labelH + 4))
670
+ return { ...rect, y: (top + bottom) / 2 - labelH / 2 };
671
+ }
672
+ function drawnRuns(row, interpolateGaps) {
673
+ let runs = [], run = [];
674
+ return row.forEach((value, ci) => {
675
+ value !== null ? run.push(ci) : !interpolateGaps && run.length > 0 && (runs.push(run), run = []);
676
+ }), run.length > 0 && runs.push(run), runs;
677
+ }
678
+ function lineToDateIds(env, domain, text) {
679
+ let ids = /* @__PURE__ */ new Set(), { options, cats } = domain;
680
+ if (partialKeyForced(options) || !cats.some((c) => c.partial === !0) || domain.drawnSeries.length !== 1 || env.isBump || domain.isStacked || domain.fan || domain.labelModes.values === "none" || text.contentOf("point", ["absolute"]) === null) return ids;
681
+ let words = options.strings?.toDate ?? chartString(options, "toDate");
682
+ return !domain.x && !toDateFits(words, env.theme, env.measure, env.size.width / Math.max(1, cats.length)) || cats.forEach((c, ci) => {
683
+ c.partial === !0 && !saysToDate(c.label ?? c.id, words) && domain.drawnSeries.some((s) => (s.vals[ci]?.v ?? null) !== null) && ids.add(c.id);
684
+ }), ids;
685
+ }
686
+ function pushPointRequests(input) {
687
+ let keep = input.regularRow ? input.candidates.map((candidate) => !candidate.suppressed) : sweepHide(input.candidates.map((candidate) => ({ start: candidate.x - candidate.w / 2, size: candidate.w, priority: candidate.suppressed ? -1 / 0 : candidate.priority })), 4), lastDrawn = input.series.vals.reduce((last, cell, ci) => cell.v === null ? last : ci, -1), firstDrawn = input.series.vals.findIndex((cell) => cell.v !== null), { ownQueries, otherQueries } = input;
688
+ input.candidates.forEach((candidate, index) => {
689
+ let category = input.cats[candidate.ci], name = `${input.series.label} in ${category.label ?? category.id}`, words = !input.isStacked && input.toDate?.ids.has(category.id) ? toDateLabel(candidate.text, input.labelFont, input.toDate.words, input.toDate.theme, input.toDate.measure) : void 0, labelH = words?.size.height ?? input.labelH, w = words?.size.width ?? candidate.w, redundant = candidate.suppressed || !keep[index], authored = typeof input.series.vals[candidate.ci]?.labelOverride == "string", computed = !(input.namedEnd && candidate.ci === lastDrawn) && !authored, continuedEnd = input.continued && (candidate.ci === firstDrawn || candidate.ci === lastDrawn), beside = computed && input.step > w + 8, lost = candidate.suppressed ? {} : { suppressedAs: "density" }, rest = input.restHidden === !0 && !candidate.suppressed, restFields = rest ? restValueHiding(`${input.series.label} ${candidate.text} (${noteName(category)})`) : {}, slots;
690
+ if (input.isStacked) {
691
+ let bandH = candidate.bandBot - candidate.bandTop, fits = input.labelH + 2 <= bandH && candidate.w + 4 <= input.step, ends = input.bandEdges ? [input.bandEdges.top[0].x + 5, input.bandEdges.top[input.bandEdges.top.length - 1].x - 5] : [input.plot.x, input.plot.x + input.plot.w], painted = input.painted;
692
+ painted?.has(candidate.ci) && (candidate.ci > 0 && !painted.has(candidate.ci - 1) && (ends[0] = Math.max(ends[0], input.xOf(candidate.ci) + 5)), candidate.ci < input.cats.length - 1 && !painted.has(candidate.ci + 1) && (ends[1] = Math.min(ends[1], input.xOf(candidate.ci) - 5)));
693
+ let x = input.row !== void 0 && (input.row[candidate.ci - 1] ?? null) === null && (input.row[candidate.ci + 1] ?? null) === null ? candidate.x : Math.max(ends[0] + candidate.w / 2, Math.min(candidate.x, ends[1] - candidate.w / 2)), centred = containedRect(input.plot, x, (candidate.bandTop + candidate.bandBot) / 2 - input.labelH / 2, candidate.w, input.labelH), rect = centred && input.bandEdges ? insideBandEdges(centred, input.bandEdges, input.labelH) : centred;
694
+ slots = rect ? [{ slot: rect === centred ? "insideBand" : "insideBandFitted", rect, penalty: 0, insideFill: candidate.insideFill, insidePaint: candidate.insidePaint }] : [];
695
+ let aboveTop = input.topBand && authored ? containedRect(
696
+ { ...input.plot, y: input.plot.y - input.labelH - 8, h: input.plot.h + input.labelH + 8 },
697
+ candidate.x !== input.xOf(candidate.ci) ? candidate.x : input.xOf(candidate.ci) + 8 + candidate.w / 2,
698
+ candidate.bandTop - input.labelH - 6,
699
+ candidate.w,
700
+ input.labelH
701
+ ) : null;
702
+ if (aboveTop) {
703
+ let leaderFrom = { x: input.xOf(candidate.ci), y: (candidate.bandTop + candidate.bandBot) / 2 };
704
+ !fits || centred && !rect || input.density !== "full" && bandH < SLIVER_MIN_H ? slots = [{ slot: "aboveBand", rect: aboveTop, penalty: 0, leaderFrom }] : rect && slots.push({ slot: "aboveBand", rect: aboveTop, penalty: 1, leaderFrom });
705
+ }
706
+ if (!aboveTop && (!fits || centred && !rect || input.density !== "full" && bandH < SLIVER_MIN_H)) {
707
+ !candidate.suppressed && !rest && input.lost.sliver.push(name), input.labelRequests.push({
708
+ id: `point:${input.series.id}:${category.id}`,
709
+ kind: "point",
710
+ role: composedTextRole(candidate.text),
711
+ owner: { seriesId: input.series.id, categoryId: category.id },
712
+ text: candidate.text,
713
+ lines: [candidate.text],
714
+ typeRole: "label",
715
+ font: input.labelFont,
716
+ priority: candidate.priority,
717
+ redundant: !0,
718
+ ...lost,
719
+ ...restFields,
720
+ candidates: slots,
721
+ // sliver-labels-hidden reports it; the requested-row warn leaves it out.
722
+ quietWhenCrowded: !0
723
+ });
724
+ return;
725
+ }
726
+ } else {
727
+ let away = input.bump ? "above" : sideAwayFrom({ x: input.xOf(candidate.ci), y: candidate.py }, input.others), order = away === "below" ? ["below", "above", "belowShifted", "aboveShifted"] : away === "above" ? ["above", "below", "aboveShifted", "belowShifted"] : ["above", "aboveShifted", "below", "belowShifted"], px = input.xOf(candidate.ci), at = { x: px, y: candidate.py, w: 0, h: 0 }, rivals = otherQueries.filter((stroke) => stroke.distance(at) > 1e-6), last = candidate.ci === lastDrawn, lateFirst = candidate.ci === firstDrawn && firstDrawn > 0 && !input.bump, rescue = [
728
+ // The first focus value has the same level seat as the last value,
729
+ // mirrored left. A steep rise can block every seat over the point.
730
+ ...candidate.ci === firstDrawn && input.highlighted ? [
731
+ { slot: "left", rect: { x: px - w - 7, y: candidate.py - labelH / 2, w, h: labelH }, penalty: 4 }
732
+ ] : [],
733
+ // Use the plot's 8 px axis gutter, with 2 px left clear, when clamping
734
+ // a first endpoint inward would put it on the rising stroke.
735
+ ...candidate.ci === firstDrawn && !input.bump ? [
736
+ { slot: "aboveEdge", rect: { x: Math.max(px - w / 2, input.plot.x - 6), y: candidate.py - labelH - 5, w, h: labelH }, penalty: 3 }
737
+ ] : [],
738
+ // Where an area's edge climbs into that seat, the value lifts 4 px, as its raised seat does.
739
+ ...candidate.ci === firstDrawn && input.variant === "area" ? [
740
+ { slot: "aboveEdgeHigh", rect: { x: Math.max(px - w / 2, input.plot.x - 6), y: candidate.py - labelH - 9, w, h: labelH }, penalty: 3.05 }
741
+ ] : [],
742
+ // A gap divider can cross the inward-clamped last forecast value.
743
+ // The reserved canvas margin can hold that value over its own point.
744
+ ...last && input.variant === "area" && candidate.ci > 0 && input.series.vals.findIndex((cell) => cell.scenario === "FC") === candidate.ci ? [
745
+ { slot: "forecastAboveEdge", rect: { x: px - w / 2, y: candidate.py - labelH - 5, w, h: labelH }, penalty: 4.2 },
746
+ { slot: "forecastBelowEdge", rect: { x: px - w / 2, y: candidate.py + 5, w, h: labelH }, penalty: 4.3 }
747
+ ] : [],
748
+ ...last && input.besideLast ? [{ slot: "right", rect: { x: px + 7, y: candidate.py - labelH / 2, w, h: labelH }, penalty: 4 }] : [],
749
+ // Two lines that end a line apart share the seat right of their
750
+ // points; the second value steps half a line off it on a short leader.
751
+ ...last && input.besideLast ? [1, -1, 2, -2].map((step) => ({
752
+ slot: `rightStep${step}`,
753
+ rect: { x: px + 9, y: candidate.py - labelH / 2 + step * (labelH + 2), w, h: labelH },
754
+ penalty: 4.5 + Math.abs(step) / 10,
755
+ leaderFrom: { x: px, y: candidate.py }
756
+ })) : [],
757
+ ...last && candidate.py - labelH - 5 < input.plot.y ? [{ slot: "aboveOut", rect: { x: candidate.x - w / 2, y: candidate.py - labelH - 5, w, h: labelH }, penalty: order.indexOf("above") }] : []
758
+ ], early = last && candidate.ci < input.cats.length - 1, x = candidate.x, bounds = input.bump ? { ...input.plot, y: input.plot.y - input.bump.headroom, h: input.plot.h + input.bump.headroom } : input.plot, seats = [
759
+ { slot: "above", x, y: candidate.py - labelH - 5 },
760
+ { slot: "below", x, y: candidate.py + 5 },
761
+ { slot: "aboveShifted", x, y: candidate.py - 2 * labelH - 9 },
762
+ { slot: "belowShifted", x, y: candidate.py + labelH + 9 },
763
+ // An area's value reads over its edge, never on the fill
764
+ // under it; where the edge climbs into the seat over the point, the value lifts 4 px.
765
+ ...input.variant === "area" ? [{ slot: "aboveRaised", x, y: candidate.py - labelH - 9, penalty: 0.5 }] : [],
766
+ // A rank line that climbs or drops at the point crosses the seat over
767
+ // it: the value keeps over its point, beside the diagonal, before it
768
+ // gives the side up.
769
+ ...input.bump ? [
770
+ { slot: "aboveLeft", x: px - 1 - w / 2, y: candidate.py - labelH - 5, penalty: 0.4 },
771
+ { slot: "aboveRight", x: px + 1 + w / 2, y: candidate.py - labelH - 5, penalty: 0.5 }
772
+ ] : [
773
+ // The seats an early end name takes (placeEndpointLabels), which the
774
+ // value takes first; the name then reads over it. A last value at the
775
+ // last category keeps the seats right of its point above.
776
+ ...early || beside && !last ? [
777
+ { slot: "aboveRight", x: px + 4 + w / 2, y: candidate.py - labelH - 6, penalty: early ? 1.5 : BESIDE_PENALTY },
778
+ { slot: "belowRight", x: px + 4 + w / 2, y: candidate.py + 6, penalty: early ? 1.5 : BESIDE_PENALTY }
779
+ ] : [],
780
+ // a late first value mirrors the early last one. It may also end at its
781
+ // point, over or under it to the left, where its own line has not started yet.
782
+ ...lateFirst || beside ? [
783
+ { slot: "aboveLeft", x: px - 4 - w / 2, y: candidate.py - labelH - 6, penalty: lateFirst ? 1.5 : BESIDE_PENALTY },
784
+ { slot: "belowLeft", x: px - 4 - w / 2, y: candidate.py + 6, penalty: lateFirst ? 1.5 : BESIDE_PENALTY }
785
+ ] : []
786
+ ]
787
+ ], named = input.bump?.named?.has(`${input.series.id}:${candidate.ci}`) === !0;
788
+ slots = seats.filter((seat) => !last || continuedEnd || Math.max(seat.y - candidate.py, candidate.py - seat.y - labelH, 0) <= labelH).filter((seat) => !((named || input.bump) && seat.slot.startsWith("below"))).filter((seat) => input.fillTo === void 0 || (seat.y + labelH / 2 - candidate.py) * (input.fillTo - candidate.py) <= 0).map((seat) => ({ slot: seat.slot, rect: containedRect(bounds, seat.x, seat.y, w, labelH), penalty: seat.penalty ?? (seat.slot.endsWith("Right") ? 1.5 : order.indexOf(seat.slot)) })).concat(rescue).sort((a, b) => a.penalty - b.penalty).flatMap((seat) => {
789
+ let { slot, rect, penalty } = seat, leaderFrom = "leaderFrom" in seat ? seat.leaderFrom : void 0;
790
+ if (rect === null) return [];
791
+ if (ownQueries.some((stroke) => stroke.hits(rect, 2))) return [];
792
+ if (leaderFrom) return [{ slot, rect, penalty, leaderFrom }];
793
+ if (lateFirst || rivals.length === 0) return [{ slot, rect, penalty }];
794
+ let own = 1 / 0;
795
+ for (let stroke of ownQueries) own = Math.min(own, stroke.distance(rect));
796
+ return rivals.some((stroke) => stroke.distance(rect) < own) ? [] : [{ slot, rect, penalty }];
797
+ });
798
+ }
799
+ computed && !continuedEnd && (slots = slots.filter((slot) => !slot.leaderFrom && !/Shifted|Raised|Step/.test(slot.slot))), !candidate.suppressed && !rest && !keep[index] && input.lost.thinned.push(name), input.labelRequests.push({
800
+ id: `point:${input.series.id}:${category.id}`,
801
+ kind: "point",
802
+ role: composedTextRole(candidate.text),
803
+ owner: { seriesId: input.series.id, categoryId: category.id },
804
+ text: candidate.text,
805
+ lines: words?.lines ?? [candidate.text],
806
+ ...words?.request,
807
+ typeRole: "label",
808
+ font: input.labelFont,
809
+ priority: candidate.priority,
810
+ redundant,
811
+ ...lost,
812
+ ...restFields,
813
+ candidates: slots,
814
+ ...computed && !input.highlighted && !continuedEnd ? { noLeader: !0 } : {},
815
+ // A value over a neighbour's point reads as that point's value.
816
+ ...input.isStacked || input.bump ? {} : { anchor: { x: input.xOf(candidate.ci), y: candidate.py }, ...computed ? { ownStrokeClear: !0 } : {} }
817
+ });
818
+ });
819
+ }
820
+ function pointLabelSelection(input) {
821
+ let pointContent = input.contentOf("point", input.valueContent), content = pointContent ?? input.valueContent, mode = pointContent === null ? "none" : input.valueLabels;
822
+ return input.drawnSeries.flatMap((series, dataIdx) => {
823
+ if (input.labelOnly !== void 0 && !input.labelOnly.has(series.id)) return [];
824
+ let row = input.pv[input.rowOf.get(series)], drawn = row.flatMap((value, ci) => value === null ? [] : [ci]);
825
+ if (drawn.length === 0) return [];
826
+ let first = drawn[0], last = drawn[drawn.length - 1], values = drawn.map((ci) => row[ci]), [min, max] = [minOf(values), maxOf(values)], engine = mode === "all" ? drawn : mode === "extremes" ? drawn.filter((ci) => ci === first || ci === last || row[ci] === min || row[ci] === max) : mode === "ends" ? [first, last] : mode === "last" ? [last] : [], fcStart = mode === "none" || mode === "all" || input.variant === "line" || input.variant === "stacked-area" ? -1 : series.scenario === "FC" ? 0 : series.vals.findIndex((val) => val.scenario === "FC"), lastActual = fcStart > 0 ? lastActualIndex(series, fcStart, !1) : -1, extra = lastActual >= 0 && row[lastActual] !== null && !engine.includes(lastActual) ? lastActual : -1;
827
+ extra >= 0 && engine.push(extra);
828
+ let authored = input.valueLabelsAuthored && series.vals.every((cell) => cell.v === null || cell.labelOverride === !1 || typeof cell.labelOverride == "string") ? [] : drawn.filter((ci) => typeof series.vals[ci]?.labelOverride == "string"), flagged = input.flagged?.seriesId === series.id && pointContent !== null ? drawn.filter((ci) => input.flagged.at.has(ci)) : [], withheld = input.lastWithheld.has(series.id) ? last : -1, keepAuthoredLast = typeof series.vals[last]?.labelOverride == "string" && !input.lastCarried?.has(series.id), only = [.../* @__PURE__ */ new Set([...engine, ...authored, ...flagged])].filter((ci) => (ci !== withheld || keepAuthoredLast) && (ci !== first || !input.firstWithheld?.has(series.id))).sort((a, b) => a - b);
829
+ return only.length > 0 ? [{ series, dataIdx, row, content, only, ...extra >= 0 ? { lastActual: extra } : {} }] : [];
830
+ });
831
+ }
832
+ function defaultValueContent(variant, seriesValueContent) {
833
+ return seriesValueContent ?? (variant === "stacked100-area" ? ["percent"] : ["absolute"]);
834
+ }
835
+ var PLOT_END_AIR = 4;
836
+ function pointLabelEndRoom(input) {
837
+ let room = { left: 0, right: 0 }, last = input.cats.length - 1;
838
+ if (input.isStacked || last < 0) return room;
839
+ for (let pick of pointLabelSelection(input)) {
840
+ let categoryIndices = pick.only.filter((ci) => ci === 0 || ci === last);
841
+ for (let seed of pointLabelSeeds({ ...input, series: pick.series, row: pick.row, content: pick.content, categoryIndices })) {
842
+ if (seed.suppressed) continue;
843
+ seed.ci === 0 && (room.left = Math.max(room.left, seed.w / 2 + PLOT_END_AIR));
844
+ let words = seed.ci === last && input.endToDate?.ids.has(input.cats[last].id) ? toDateLabel(seed.text, input.labelFont, input.endToDate.words, input.endToDate.theme, input.endToDate.measure).size.width : seed.w;
845
+ seed.ci === last && (room.right = Math.max(room.right, words / 2 + PLOT_END_AIR));
846
+ }
847
+ }
848
+ return room;
849
+ }
850
+ function pointValueWidths(input) {
851
+ let widths = /* @__PURE__ */ new Map();
852
+ for (let { series, row, content, only } of pointLabelSelection(input))
853
+ for (let seed of pointLabelSeeds({ ...input, series, row, content, categoryIndices: only }))
854
+ seed.suppressed || widths.set(`${series.id}:${seed.ci}`, seed.w);
855
+ return widths;
856
+ }
857
+ function placePointValueLabels(input) {
858
+ let lost = { sliver: [], thinned: [] }, strokesOf = new Map(input.drawnSeries.map((series) => {
859
+ let row = input.pv[input.rowOf.get(series)], stroke = { runs: input.isStacked ? [] : input.drawnEdges?.get(series.id)?.runs ?? drawnRuns(row, series.interpolateGaps).map((run) => drawnStroke(run.map((ci) => ({ x: input.xOf(ci), y: input.y(row[ci]) })), input.interpolationFor(series))), queries: void 0 };
860
+ return [series.id, stroke];
861
+ }));
862
+ for (let { series, dataIdx, row, content, only, lastActual } of pointLabelSelection(input)) {
863
+ let seriesFont = input.focusFont && input.highlights.has(series.id) ? input.focusFont : input.labelFont, candidates = buildPointCandidates({ ...input, labelFont: seriesFont, series, dataIdx, row, content, categoryIndices: only });
864
+ for (let candidate of candidates) {
865
+ let divider = input.dividers.find((split) => split.ci === candidate.ci && Math.abs(split.x - candidate.x) < candidate.w / 2 + 3);
866
+ divider !== void 0 && (candidate.x = divider.x - 3 - candidate.w / 2);
867
+ }
868
+ let own = strokesOf.get(series.id), ownQueries = own.queries ??= own.runs.map(preparePolyline), others = [], otherQueries = [];
869
+ for (let [id, stroke] of strokesOf)
870
+ if (id !== series.id) {
871
+ for (let run of stroke.runs) others.push(run);
872
+ for (let query of stroke.queries ??= stroke.runs.map(preparePolyline)) otherQueries.push(query);
873
+ }
874
+ let edge = (cum) => drawnStroke(input.cats.map((_, ci) => ({ x: input.xOf(ci), y: input.y(cum[dataIdx][ci]) })), input.interpolationFor(series)), drawn = input.drawnEdges?.get(series.id), bandEdges = input.isStacked ? { top: drawn?.runs.flat() ?? edge(input.cumTop), bottom: drawn?.bottom ?? edge(input.cumBot) } : void 0, namedEnd = input.valueLabels !== "all" && !input.isStacked && !input.bump && (input.endNamed.has(series.id) || input.labelRequests.some((request) => request.kind === "series" && request.owner.seriesId === series.id));
875
+ pushPointRequests({ continued: input.drawnEdges !== void 0, highlighted: input.highlights.has(series.id) && !input.bump && input.variant === "line", regularRow: input.valueLabels === "all" && !input.isStacked, namedEnd, candidates, series, cats: input.cats, isStacked: input.isStacked, variant: input.variant, labelH: input.labelH, step: input.step, density: input.density, plot: input.plot, labelFont: seriesFont, labelRequests: input.labelRequests, ownQueries, others, otherQueries, xOf: input.xOf, besideLast: !input.endNamed.has(series.id), ...bandEdges ? { bandEdges } : {}, ...input.bump ? { bump: input.bump } : {}, topBand: input.isStacked && dataIdx === input.drawnSeries.length - 1, row, ...input.isStacked ? { painted: input.paintedAreaCats.get(series.id) } : {}, ...input.variant === "area" && input.drawnSeries.length > 1 && input.paintedAreaCats.has(series.id) ? { fillTo: input.y(0) } : {}, lost, restHidden: input.isStacked && input.restHidden?.(series) === !0, ...input.toDate ? { toDate: input.toDate } : {} });
876
+ let extra = lastActual === void 0 || typeof series.vals[lastActual]?.labelOverride == "string" ? void 0 : input.labelRequests.find((request) => request.id === `point:${series.id}:${input.cats[lastActual].id}`);
877
+ extra && (extra.quietWhenCrowded = !0, extra.redundant && extra.suppressedAs === "density" && delete extra.suppressedAs);
878
+ }
879
+ if (warnSliverLabels(input.warnings, lost.sliver, "widen or heighten the chart, or shorten the values with a coarser format"), lost.thinned.length > 0) {
880
+ let shown = lost.thinned.slice(0, 5).join(", ") + (lost.thinned.length > 5 ? ", ..." : "");
881
+ input.warnings.push({
882
+ code: "point-labels-thinned",
883
+ severity: "info",
884
+ message: `${lost.thinned.length} point value${lost.thinned.length === 1 ? " is" : "s are"} not printed because ${lost.thinned.length === 1 ? "it" : "each"} would overlap a neighbouring value of its series (${shown})`,
885
+ suggest: "widen the chart, or label fewer points"
886
+ });
887
+ }
888
+ }
889
+ function placeCategoryLabels(input) {
890
+ if (!input.show) return !1;
891
+ let rotated = input.plan.rotation !== 0, bottom = input.plot.y + input.plot.h;
892
+ return input.cats.forEach((category, ci) => {
893
+ let info = input.plan.infos[ci];
894
+ input.labelRequests.push({
895
+ id: `category:${category.id}`,
896
+ kind: "category",
897
+ owner: { categoryId: category.id },
898
+ text: category.label ?? category.id,
899
+ lines: info.lines,
900
+ ...categoryLineAlign(input.plan, ci),
901
+ ...info.title !== void 0 ? { title: info.title } : {},
902
+ typeRole: input.plan.typeRole,
903
+ font: input.plan.font,
904
+ priority: PRIORITY.endpoint,
905
+ redundant: !input.plan.keep[ci],
906
+ ...rotated ? { rotate: -45 } : {},
907
+ candidates: rotated ? [{ slot: "below", rect: rotatedClaimRect(input.xOf(ci), bottom + Math.max(9, info.h * Math.SQRT1_2 / 2 + 6), info.h), penalty: 0 }] : [{ slot: "below", rect: { x: input.plan.x(ci), y: bottom + 6, w: info.w, h: info.h }, penalty: 0 }]
908
+ });
909
+ }), pushAll(input.labelRequests, yearRowRequests(input.plan, bottom + 6)), !0;
910
+ }
911
+ function flaggedPoints(domain) {
912
+ let anomaly = domain.anomaly;
913
+ if (anomaly)
914
+ return { seriesId: anomaly.seriesId, at: new Set(domain.cats.flatMap((c, ci) => anomaly.model.flagByCategory.has(c.id) ? [ci] : [])) };
915
+ }
916
+
917
+ // src/core/charts/line/labelModes.ts
918
+ function lineLabelModes(options, variant, drawnSeries) {
919
+ let authored = options.seriesLabels, only = typeof authored == "object" && authored !== null ? authored.only : void 0, seriesSetting = options.labels === !1 ? !1 : options.labels?.series, content = Array.isArray(seriesSetting) ? seriesSetting : void 0, valueParts = content?.filter((part) => part !== "series"), series = seriesSetting === !1 ? "none" : typeof authored == "string" ? authored : content !== void 0 && !content.includes("series") ? "none" : only !== void 0 || content !== void 0 || !((variant === "line" || variant === "area") && drawnSeries === 1) ? "end" : "none", values = options.valueLabels ?? (valueParts?.length === 0 || variant === "bump" ? "none" : variant === "stacked100-area" || variant === "area" ? "ends" : "last");
920
+ return {
921
+ series,
922
+ values,
923
+ ...only !== void 0 && series === "end" ? { only: new Set(only) } : {},
924
+ ...valueParts !== void 0 && valueParts.length > 0 ? { seriesValueContent: valueParts } : {}
925
+ };
926
+ }
927
+
928
+ // src/core/charts/line/bump.ts
929
+ var BUMP_FOLDED = /* @__PURE__ */ Symbol("bumpFolded");
930
+ function validateBumpInput(input) {
931
+ let { options, targetsLength, dataSeries, cats } = input;
932
+ if (dataSeries.length < 2) throw new NormalizeError("bump-two-series", "series", "a rank chart needs at least two data-role series \u2014 one entity is a flat line at rank 1, which states nothing about who overtook whom");
933
+ if (cats.length < 2) throw new NormalizeError("bump-two-categories", "categories", "a rank chart needs at least two categories \u2014 crossings are the message and one period has none", "use chart type 'slope' for two points");
934
+ let conflicts = [
935
+ ["rebase100", !!options.rebase100],
936
+ ["ratioTier", options.ratioTier !== void 0],
937
+ ["gapFill", options.gapFill !== void 0],
938
+ ["fan", options.fan !== void 0],
939
+ ["targets", targetsLength > 0]
940
+ ];
941
+ for (let [name, present] of conflicts) if (present) throw new NormalizeError("bump-option-conflict", name, `'${name}' is defined on VALUES; variant 'bump' plots derived ranks, and applying it to a rank would produce a confident, wrong exhibit \u2014 remove '${name}' or drop variant 'bump'`);
942
+ }
943
+ function validateBumpIds(dataSeries) {
944
+ let idCounts = /* @__PURE__ */ new Map();
945
+ for (let series of dataSeries) idCounts.set(series.id, (idCounts.get(series.id) ?? 0) + 1);
946
+ let duplicateIds = [...idCounts.entries()].filter(([, count]) => count > 1).map(([id]) => id);
947
+ if (duplicateIds.length > 0) throw new NormalizeError(
948
+ "bump-duplicate-series-id",
949
+ "series",
950
+ `series id${duplicateIds.length === 1 ? "" : "s"} ${duplicateIds.map((id) => `'${id}'`).join(", ")} appear more than once \u2014 the ranking receipt is keyed by series id, so two entities under one id cannot both be ranked, drawn or described`,
951
+ "give every ranked entity its own id"
952
+ );
953
+ }
954
+ function warnBumpAxis(input) {
955
+ let { options, valueAxis, warnings } = input, sharedYDeclared = typeof options.scaleGroup?.y == "string", ignoredAxisOptions = [
956
+ valueAxis.min !== void 0 && !sharedYDeclared ? "min" : null,
957
+ valueAxis.max !== void 0 && !sharedYDeclared ? "max" : null,
958
+ valueAxis.break !== void 0 ? "break" : null
959
+ ].filter((name) => name !== null);
960
+ ignoredAxisOptions.length > 0 && warnings.push({
961
+ code: "bump-axis-option-ignored",
962
+ severity: "warn",
963
+ message: `valueAxis ${ignoredAxisOptions.map((name) => `'${name}'`).join(", ")} ignored \u2014 the rank domain is derived from the data (1 .. maxRank), not authored`
964
+ }), valueAxis.show === !1 && warnings.push({ code: "bump-axis-required", severity: "warn", message: "valueAxis.show:false ignored \u2014 a rank chart without rank ticks cannot be read; the axis is drawn" });
965
+ let printsValues = lineLabelModes(options, "bump", 0).values !== "none";
966
+ options.unit && !printsValues && warnings.push({ code: "bump-unit-ignored", severity: "warn", message: `unit '${options.unit}' ignored \u2014 the plotted quantity is rank, which has no unit`, suggest: "the plotted quantity is rank; put the measure in the subtitle" }), printsValues && !options.unit && !options.format && warnings.push({
967
+ code: "bump-values-unnamed",
968
+ severity: "warn",
969
+ message: "the printed values are the measure behind the ranks, and with no unit or format nothing on the page says what they are",
970
+ suggest: "set unit (each value carries it) or a format such as '1.0%', or valueLabels 'none'"
971
+ });
972
+ }
973
+ function prepareBump(input) {
974
+ let { isBump, options, valueAxis, targetsLength, seriesNorm, cats, warnings } = input, bumpDirection = options.bump?.direction ?? "higherIsBetter";
975
+ if (!isBump) return { bumpDirection, dataSeries: input.dataSeries, refSeries: input.refSeries };
976
+ validateBumpInput({ options, targetsLength, dataSeries: input.dataSeries, cats });
977
+ let refSeries = input.refSeries;
978
+ if (refSeries.length > 0) {
979
+ warnings.push({ code: "bump-reference-series-dropped", severity: "warn", message: `reference series ${refSeries.map((series) => `'${series.id}'`).join(", ")} name levels on the value scale, which the rank axis does not carry \u2014 dropped`, suggest: 'plot the reference on a value line chart, or give it role: "data" to rank it with the others' });
980
+ for (let series of refSeries) seriesNorm.splice(seriesNorm.indexOf(series), 1);
981
+ refSeries = [];
982
+ }
983
+ let empty = input.dataSeries.filter((series) => series.vals.every((cell) => cell.v === null));
984
+ if (empty.length > 0) {
985
+ warnings.push({ code: "bump-series-empty", severity: "warn", message: `${empty.map((series) => `'${series.id}'`).join(", ")} carry no value in any category and therefore hold no rank anywhere \u2014 dropped`, owner: { seriesId: empty[0].id } });
986
+ for (let series of empty) seriesNorm.splice(seriesNorm.indexOf(series), 1);
987
+ }
988
+ let dataSeries = seriesNorm.filter((series) => series.role !== "reference");
989
+ if (dataSeries.length < 2) throw new NormalizeError("bump-two-series", "series", `after dropping entities that hold no rank anywhere, ${dataSeries.length} data-role series remain \u2014 a rank chart needs at least two`);
990
+ validateBumpIds(dataSeries);
991
+ let bridging = dataSeries.filter((series) => series.interpolateGaps);
992
+ if (bridging.length > 0) {
993
+ warnings.push({ code: "bump-gap-bridging-disabled", severity: "warn", message: `gap bridging is forced off for ${bridging.map((series) => `'${series.id}'`).join(", ")} \u2014 bridging a period with no value would draw a rank the entity never held` });
994
+ for (let series of bridging) series.interpolateGaps = !1;
995
+ }
996
+ return warnBumpAxis({ options, valueAxis, warnings }), { bumpDirection, dataSeries, refSeries };
997
+ }
998
+ function deriveBumpRanks(input) {
999
+ let { isBump, direction, dataSeries, cats, pv, rowOf, fmt, format, warnings } = input;
1000
+ if (!isBump) return;
1001
+ let shown = /* @__PURE__ */ new Map(), read = (value) => {
1002
+ let key = Object.is(value, -0) ? "-0" : value, text = shown.get(key);
1003
+ return text === void 0 && (text = fmt(value), shown.set(key, text)), text;
1004
+ }, sameToTheReader = (a, b) => a === b || read(a) === read(b), better = (a, b) => sameToTheReader(a, b) ? !1 : direction === "higherIsBetter" ? a > b : a < b, ranks = emptyIdRecord(), participants = emptyIdRecord(), ties = [], maxRank = 1;
1005
+ for (let series of dataSeries) ranks[series.id] = cats.map(() => null);
1006
+ cats.forEach((category, ci) => {
1007
+ let present = dataSeries.map((series) => ({ series, value: series.vals[ci].v })).filter((entry) => entry.value !== null);
1008
+ participants[category.id] = present.length;
1009
+ let byRank = /* @__PURE__ */ new Map();
1010
+ for (let entry of present) {
1011
+ let rank = 1 + present.filter((other) => better(other.value, entry.value)).length;
1012
+ ranks[entry.series.id][ci] = rank, maxRank = Math.max(maxRank, rank), byRank.set(rank, [...byRank.get(rank) ?? [], entry.series.id]);
1013
+ }
1014
+ for (let [rank, seriesIds] of [...byRank.entries()].sort((a, b) => a[0] - b[0]))
1015
+ seriesIds.length < 2 || (ties.push({ categoryId: category.id, rank, seriesIds }), warnings.push({ code: "bump-rank-tie", severity: "warn", message: `category '${category.id}': ${seriesIds.map((id) => `'${id}'`).join(", ")} share rank ${rank} \u2014 drawn at the same height, and the next rank is skipped (competition ranking)`, owner: { categoryId: category.id } }));
1016
+ });
1017
+ let census = cats.map((category) => participants[category.id]);
1018
+ new Set(census).size > 1 && warnings.push({ code: "bump-participants-vary", severity: "info", message: `the ranked field changes size across periods (${cats.map((category) => `${category.label ?? category.id}: ${participants[category.id]}`).join(", ")}) \u2014 rank ${maxRank} out of ${maxOf(census)} is not the same standing as rank ${maxRank} out of ${minOf(census)}` });
1019
+ for (let series of dataSeries) {
1020
+ let row = pv[rowOf.get(series)], seriesRanks = ranks[series.id];
1021
+ for (let ci = 0; ci < cats.length; ci++) row[ci] = seriesRanks[ci];
1022
+ }
1023
+ return { direction, method: "competition", maxRank, ranks, ties, participants, comparedAt: format ?? "auto" };
1024
+ }
1025
+ function bumpMethodNote(bump, format, strings) {
1026
+ if (!bump) return [];
1027
+ let words = { ...localeStrings(), ...strings };
1028
+ return [stringFields(words.rankMethod, {
1029
+ direction: bump.direction === "higherIsBetter" ? words.higherBetter : words.lowerBetter,
1030
+ format: format ? stringFields(words.rankFormat, { format }) : "",
1031
+ ring: bump.ties.length > 0 ? words.rankRing : ""
1032
+ })];
1033
+ }
1034
+ function buildBumpStartLabels(input) {
1035
+ let { isBump, endContent, dataSeries, pv, rowOf, cats, composeText, nameBlock } = input, startLabels = [];
1036
+ isBump && endContent && dataSeries.forEach((series, dataIdx) => {
1037
+ let ci = pv[rowOf.get(series)].findIndex((value) => value !== null);
1038
+ if (ci === -1) return;
1039
+ let name = composeText(endContent, null, null, cats[ci].label ?? cats[ci].id, series.label);
1040
+ if (!name) return;
1041
+ let { text, ...block } = foldBumpValue(name, input.folded?.get(`point:${series.id}:${cats[ci].id}`), (line) => nameBlock(line, series.id));
1042
+ startLabels.push({ id: `series-start:${series.id}`, kind: "series", s: series, dataIdx, ci, text, w: block.w, lines: block.lines, h: block.h, ...block.title !== void 0 ? { title: block.title } : {}, ...block.font ? { font: block.font } : {} });
1043
+ });
1044
+ let railStartLabels = startLabels.filter((label) => label.ci === 0);
1045
+ return { startLabels, startReserve: railStartLabels.length > 0 ? maxOf(railStartLabels.map((label) => label.w)) + 14 : 0 };
1046
+ }
1047
+ function renderBumpTies(theme, input) {
1048
+ let { bump, marks, nodes, occupied } = input;
1049
+ if (!bump || bump.ties.length === 0) return;
1050
+ let radius = 7;
1051
+ for (let tie of bump.ties) {
1052
+ let point = marks.series.find((item) => tie.seriesIds.includes(item.seriesId))?.points.find((item) => item.categoryId === tie.categoryId);
1053
+ if (!point) continue;
1054
+ let id = `tie:${tie.categoryId}:${tie.rank}`;
1055
+ nodes.push({
1056
+ t: "path",
1057
+ id,
1058
+ d: `M${fmtPathNumber(point.x - radius)} ${fmtPathNumber(point.y)}A${radius} ${radius} 0 1 0 ${fmtPathNumber(point.x + radius)} ${fmtPathNumber(point.y)}A${radius} ${radius} 0 1 0 ${fmtPathNumber(point.x - radius)} ${fmtPathNumber(point.y)}`,
1059
+ stroke: { token: "markInk" },
1060
+ width: strokeToken(theme, "mark"),
1061
+ owner: { categoryId: tie.categoryId },
1062
+ part: "tie",
1063
+ display: { value: `rank ${tie.rank}`, state: `${tie.seriesIds.length} tied` }
1064
+ }), occupied.claim({ x: point.x - radius, y: point.y - radius, w: radius * 2, h: radius * 2 }, "mark", { categoryId: tie.categoryId });
1065
+ }
1066
+ }
1067
+ function placeBumpTieLabels(input) {
1068
+ let { bump, marks, outsideRankBand, labelRequests, font, measure } = input, pointOf = (tie2) => marks.series.find((item) => item.seriesId === tie2.seriesIds[0])?.points.find((item) => item.categoryId === tie2.categoryId), tie = bump?.ties.find(pointOf);
1069
+ if (!tie) return;
1070
+ let point = pointOf(tie), words = { ...localeStrings(), ...input.strings }, text = `${words.tiedSymbol} ${words.tied}`, { width: w, height: h } = measure(text, font), word = measure(words.tied, font).width, radius = 7, slots = [
1071
+ // First above and right of the ring, clear of its line.
1072
+ ["aboveRightOfRing", { x: point.x + radius + 2, y: point.y - radius - h + 2, w: word, h }],
1073
+ ["aboveRing", { x: point.x - w / 2, y: point.y - radius - 2 - h, w, h }],
1074
+ ["belowRing", { x: point.x - w / 2, y: point.y + radius + 2, w, h }],
1075
+ ["rightOfRing", { x: point.x + radius + 3, y: point.y - h / 2, w, h }],
1076
+ ["leftOfRing", { x: point.x - radius - 3 - w, y: point.y - h / 2, w, h }]
1077
+ ];
1078
+ for (let dx of [12, -12 - w, 28, -28 - w, 48, -48 - w])
1079
+ for (let dy of [-h - 3, 3, -h - 14, 14]) slots.push(["besideRing", { x: point.x + dx, y: point.y + dy, w, h }]);
1080
+ let keyY = minOf(marks.series.flatMap((series) => series.points.map((point2) => point2.y))) - h - 10;
1081
+ for (let x of [point.x - w / 2, point.x + 12, point.x - w - 12]) slots.push(["tieKey", { x, y: keyY, w, h }]);
1082
+ labelRequests.push({
1083
+ id: `tieLabel:${tie.categoryId}:${tie.rank}`,
1084
+ kind: "scale",
1085
+ owner: { categoryId: tie.categoryId },
1086
+ text,
1087
+ lines: [text],
1088
+ typeRole: "axis",
1089
+ font,
1090
+ // The explanation of a mark outranks any value, a highlighted one too:
1091
+ // under valueLabels 'all' a value gives way, never the word for the ring.
1092
+ priority: PRIORITY.grandTotal,
1093
+ candidates: slots.filter(([slot, rect]) => slot === "tieKey" || !outsideRankBand(rect)).map(([slot, rect], penalty) => ({
1094
+ slot,
1095
+ rect,
1096
+ penalty,
1097
+ ...slot === "besideRing" ? { leaderFrom: point } : {},
1098
+ ...slot === "aboveRightOfRing" ? { lines: [words.tied] } : {}
1099
+ }))
1100
+ });
1101
+ }
1102
+ function joinTieValues(input) {
1103
+ let { bump, labelRequests, font, measure } = input;
1104
+ for (let tie of bump?.ties ?? []) {
1105
+ let ids = new Set(tie.seriesIds.map((id) => `point:${id}:${tie.categoryId}`)), values = labelRequests.filter((request) => ids.has(request.id));
1106
+ if (values.length === 0) continue;
1107
+ let note = labelRequests.find((request) => request.id === `tieLabel:${tie.categoryId}:${tie.rank}`), keep = note ? void 0 : values[0];
1108
+ for (let index = labelRequests.length - 1; index >= 0; index--) {
1109
+ let request = labelRequests[index];
1110
+ ids.has(request.id) && request !== keep && labelRequests.splice(index, 1);
1111
+ }
1112
+ if (!note) continue;
1113
+ let text = `${note.text} \xB7 ${values[0].text}`, w = measure(text, font).width, before = note.candidates[0]?.rect.w ?? w;
1114
+ note.text = text, note.lines = [text];
1115
+ let bare = note.candidates.find((candidate) => candidate.lines)?.lines?.[0], bareText = bare === void 0 ? void 0 : `${bare} \xB7 ${values[0].text}`, bareW = bareText === void 0 ? 0 : measure(bareText, font).width;
1116
+ note.candidates = note.candidates.map((candidate) => candidate.lines && bareText !== void 0 ? {
1117
+ ...candidate,
1118
+ lines: [bareText],
1119
+ rect: { ...candidate.rect, w: bareW }
1120
+ } : {
1121
+ ...candidate,
1122
+ rect: {
1123
+ ...candidate.rect,
1124
+ w,
1125
+ x: candidate.slot === "rightOfRing" ? candidate.rect.x : candidate.slot === "leftOfRing" ? candidate.rect.x + before - w : candidate.rect.x + before / 2 - w / 2
1126
+ }
1127
+ });
1128
+ }
1129
+ }
1130
+ function startLabelCandidates(input) {
1131
+ let { slots, desiredY, leaderFrom, width, height, outsideRankBand } = input;
1132
+ return slots.flatMap(([slot, rect, penalty]) => rect.x < 0 || rect.y < 0 || rect.x + rect.w > width || rect.y + rect.h > height || outsideRankBand(rect) ? [] : [{ slot, rect, penalty, ...leaderFrom && Math.abs(rect.y + rect.h / 2 - desiredY) > 3 ? { leaderFrom } : {} }]);
1133
+ }
1134
+ function pushStartLabel(input) {
1135
+ let { label, desiredY, leaderFrom, slots, size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats } = input;
1136
+ leaderFrom && endpointLeaderAnchors.set(label.id, leaderFrom), labelRequests.push({
1137
+ id: label.id,
1138
+ kind: "series",
1139
+ owner: { seriesId: label.s.id, categoryId: cats[label.ci].id },
1140
+ text: label.text,
1141
+ lines: label.lines,
1142
+ ...label.title !== void 0 ? { title: label.title } : {},
1143
+ typeRole: "label",
1144
+ font: label.font ?? labelFont,
1145
+ ...label.font ? { fontStep: label.font } : {},
1146
+ // A name says whose line it is: an entrant's first value, which takes the
1147
+ // seat over its point under valueLabels 'all', gives way to it.
1148
+ priority: PRIORITY.endpoint + 50 + (highlights.has(label.s.id) ? PRIORITY.highlightBonus : 0),
1149
+ candidates: startLabelCandidates({ slots, desiredY, leaderFrom, width: size.width, height: size.height, outsideRankBand }),
1150
+ // a name off its rank row takes a leader only where the leader
1151
+ // crosses no name and no rank number; else its next seat, else none.
1152
+ leaderClear: !0,
1153
+ leaderClearsAxis: !0
1154
+ });
1155
+ }
1156
+ function placeBumpStartLabels(input) {
1157
+ let { startLabels, marks, cats, plot, size, leftMargin, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, warnings } = input, railLabels = startLabels.filter((label) => label.ci === 0), entrantLabels = startLabels.filter((label) => label.ci !== 0), anchorOf = (label) => marks.series.find((item) => item.seriesId === label.s.id)?.points.find((item) => item.categoryId === cats[label.ci].id) ?? null;
1158
+ if (railLabels.length > 0) {
1159
+ let anchors = railLabels.map(anchorOf), sizes = nameSpreadSizes(railLabels.map((label) => label.h), anchors.map((anchor) => anchor?.y)), items = anchors.map((anchor, index) => ({ desired: anchor?.y ?? plot.y + plot.h / 2, size: sizes[index] })), railSpread = spread1DResult(items, [plot.y, plot.y + plot.h], 2);
1160
+ warnSpreadOverflow(warnings, railSpread.fits, "start-rail labels exceed the plot height even after spreading \u2014 labels stay bounded but overlap; fewer series or a larger canvas fixes it");
1161
+ let spreadPositions = railSpread.fits ? railSpread.positions : spread1D(items, [plot.y, plot.y + plot.h], 2);
1162
+ railLabels.forEach((label, index) => {
1163
+ let anchor = anchors[index], desiredY = anchor?.y ?? plot.y + plot.h / 2, rect = { x: leftMargin - 6 - label.w, y: spreadPositions[index] - label.h / 2, w: label.w, h: label.h }, leaderFrom = anchor ? { x: Math.max(anchor.x - 4, rect.x + rect.w + 2), y: anchor.y } : void 0;
1164
+ pushStartLabel({ label, desiredY, leaderFrom, slots: [["lineStart", rect, 0], ["lineStartShifted", { ...rect, y: rect.y + label.h + 2 }, 1]], size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats });
1165
+ });
1166
+ }
1167
+ entrantLabels.forEach((label) => {
1168
+ let anchor = anchorOf(label), desiredY = anchor?.y ?? plot.y + plot.h / 2, rect = { x: (anchor?.x ?? plot.x) + 6, y: desiredY - label.h / 2, w: label.w, h: label.h }, leaderFrom = anchor ? { x: Math.min(anchor.x + 4, rect.x - 2), y: anchor.y } : void 0, left = { ...rect, x: (anchor?.x ?? plot.x) - Math.max(6, (input.valueWidth?.(label) ?? 0) / 2 + 4) - label.w };
1169
+ pushStartLabel({ label, desiredY, leaderFrom, slots: [["entrantStartLeft", left, 0], ["entrantStart", rect, 1], ["entrantStartAbove", { ...rect, y: rect.y - label.h - 4 }, 2], ["entrantStartBelow", { ...rect, y: rect.y + label.h + 4 }, 2]], size, outsideRankBand, endpointLeaderAnchors, labelRequests, labelFont, highlights, cats });
1170
+ });
1171
+ }
1172
+
1173
+ // src/core/charts/line/range.ts
1174
+ function cutEdge(edge, mode, lo, hi) {
1175
+ let points = edge.points;
1176
+ if (!points.length || points[0].x > hi || points[points.length - 1].x < lo) return { points: [] };
1177
+ let curve = edge.curve;
1178
+ for (let [x, start] of [[lo, !0], [hi, !1]]) {
1179
+ if (x < points[0].x || x > points[points.length - 1].x) continue;
1180
+ if (x === points[0].x) {
1181
+ if (!start) return { points: [points[0]] };
1182
+ continue;
1183
+ }
1184
+ if (x === points[points.length - 1].x) {
1185
+ if (start) return { points: [points[points.length - 1]] };
1186
+ continue;
1187
+ }
1188
+ let i = points.findIndex((p) => p.x >= x), a = points[i - 1], b = points[i], y = mode === "step-after" ? a.y : mode === "step-before" ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
1189
+ if (curve && (curve = splitCurveSegmentsAtX(curve, x)[start ? 1 : 0], y = start ? curve[0].from.y : curve[curve.length - 1].to.y), b.x === x) points = start ? points.slice(i) : points.slice(0, i + 1);
1190
+ else {
1191
+ let boundary = { x, y, ci: start ? b.ci : a.ci };
1192
+ points = start ? [boundary, ...points.slice(i)] : [...points.slice(0, i), boundary];
1193
+ }
1194
+ }
1195
+ return { points, ...curve ? { curve } : {} };
1196
+ }
1197
+ function rangeCut(xs, indexes, lo, hi) {
1198
+ let first = indexes[0], last = indexes[indexes.length - 1];
1199
+ return { lo: xs[first - 1] < lo && xs[first] > lo, hi: xs[last + 1] > hi && xs[last] < hi };
1200
+ }
1201
+ function rangeIndexes(range) {
1202
+ let first = range.indexes[0], last = range.indexes[range.indexes.length - 1], before = range.cut.lo ? [first - 2, first - 1] : [], after = range.cut.hi ? [last + 1, last + 2] : [];
1203
+ return [...before, ...range.indexes, ...after].filter((i) => i >= 0 && i < range.xs.length);
1204
+ }
1205
+ function rangeRuns(range, rows, mode, interpolateGaps = !1) {
1206
+ let first = range.indexes[0], last = range.indexes[range.indexes.length - 1], indexes = rangeIndexes(range), visible = new Map(range.indexes.map((source, ci) => [source, ci])), runs = [], current = rows.map(() => []), flush = () => {
1207
+ if (current[0].length) {
1208
+ let edges = current.map((points) => cutEdge({ points, ...mode === "monotone" ? { curve: monotoneSegments(points) } : {} }, mode, range.lo, range.hi));
1209
+ edges[0].points.length && runs.push(edges);
1210
+ }
1211
+ current = rows.map(() => []);
1212
+ };
1213
+ for (let source of indexes) {
1214
+ if (range.invalid.has(source) || rows.some((row) => row[source] === null)) {
1215
+ (!interpolateGaps || source < first || source > last || range.invalid.has(source)) && flush();
1216
+ continue;
1217
+ }
1218
+ let ci = visible.get(source) ?? (source < first ? 0 : range.indexes.length - 1);
1219
+ rows.forEach((row, k) => current[k].push({ x: range.xs[source], y: row[source], ci }));
1220
+ }
1221
+ return flush(), runs;
1222
+ }
1223
+ function mapEdge(edge, x, y) {
1224
+ let point = (p) => ({ x: x(p.x), y: y(p.y) });
1225
+ return {
1226
+ points: edge.points.map((p) => ({ ...point(p), ci: p.ci })),
1227
+ ...edge.curve ? { curve: edge.curve.map((c) => ({ from: point(c.from), c1: point(c.c1), c2: point(c.c2), to: point(c.to) })) } : {}
1228
+ };
1229
+ }
1230
+ function edgePath(edge, path) {
1231
+ return edge.curve ? curvePathFromSegments(edge.curve) : path(edge.points);
1232
+ }
1233
+
1234
+ // src/core/charts/line/marks.ts
1235
+ function pathFor(points, mode) {
1236
+ if (mode === "linear") return linePath(points.map((point) => ({ x: point.x, y: point.y })));
1237
+ if (mode === "monotone") return monotonePath(points);
1238
+ if (points.length === 0) return "";
1239
+ let path = `M${fmtPathNumber(points[0].x)} ${fmtPathNumber(points[0].y)}`;
1240
+ for (let index = 1; index < points.length; index++) {
1241
+ let previous = points[index - 1], point = points[index], elbow = mode === "step-after" ? { x: point.x, y: previous.y } : { x: previous.x, y: point.y };
1242
+ path += `L${fmtPathNumber(elbow.x)} ${fmtPathNumber(elbow.y)}L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`;
1243
+ }
1244
+ return path;
1245
+ }
1246
+ function reversePathTail(points, mode) {
1247
+ if (points.length < 2) return "";
1248
+ if (mode === "monotone")
1249
+ return [...monotoneSegments(points)].reverse().map((segment) => `C${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.from.x)} ${fmtPathNumber(segment.from.y)}`).join("");
1250
+ let expanded = [points[0]];
1251
+ for (let index = 1; index < points.length; index++) {
1252
+ let previous = points[index - 1], point = points[index];
1253
+ mode === "step-after" && expanded.push({ x: point.x, y: previous.y }), mode === "step-before" && expanded.push({ x: previous.x, y: point.y }), expanded.push(point);
1254
+ }
1255
+ return [...expanded].reverse().slice(1).map((point) => `L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("");
1256
+ }
1257
+ function createClaims(occupied, cats, inlineNamesEnabled) {
1258
+ let lineOwner = (seriesId, categoryId) => inlineNamesEnabled ? { seriesId } : { seriesId, categoryId }, segment = (a, b, categoryA, categoryB, seriesId, thick = 3) => {
1259
+ let chunks = Math.max(1, Math.min(8, Math.ceil(Math.max(Math.abs(b.x - a.x), Math.abs(b.y - a.y)) / 14)));
1260
+ for (let index = 0; index < chunks; index++) {
1261
+ let t0 = index / chunks, t1 = (index + 1) / chunks, x0 = a.x + (b.x - a.x) * t0, x1 = a.x + (b.x - a.x) * t1, y0 = a.y + (b.y - a.y) * t0, y1 = a.y + (b.y - a.y) * t1, category = (t0 + t1) / 2 < 0.5 ? categoryA : categoryB;
1262
+ occupied.claim({ x: Math.min(x0, x1) - thick / 2, y: Math.min(y0, y1) - thick / 2, w: Math.abs(x1 - x0) + thick, h: Math.abs(y1 - y0) + thick }, "mark", lineOwner(seriesId, category));
1263
+ }
1264
+ }, outline = (x0, x1, top0, top1, bot0, bot1, owner) => {
1265
+ let t = (top0 - bot0) / (top0 - bot0 - (top1 - bot1)), cross = { x: x0 + (x1 - x0) * t, y: top0 + (top1 - top0) * t }, polygons = t > 0 && t < 1 ? [[{ x: x0, y: top0 }, cross, { x: x0, y: bot0 }], [cross, { x: x1, y: top1 }, { x: x1, y: bot1 }]] : [[{ x: x0, y: top0 }, { x: x1, y: top1 }, { x: x1, y: bot1 }, { x: x0, y: bot0 }]];
1266
+ for (let polygon of polygons) {
1267
+ let xs = polygon.map((point) => point.x), ys = polygon.map((point) => point.y), x = minOf(xs), y = minOf(ys);
1268
+ occupied.claim({ x, y, w: maxOf(xs) - x, h: maxOf(ys) - y }, "mark", owner, AREA_FILL_PART, polygon);
1269
+ }
1270
+ };
1271
+ return { lineOwner, segment, areaPair: (xA, xB, topA, topB, botA, botB, categoryA, categoryB, seriesId, mode) => {
1272
+ let [t0, t1, b0, b1] = mode === "linear" ? [topA, topB, botA, botB] : mode === "step-after" ? [topA, topA, botA, botA] : [topB, topB, botB, botB], xM = (xA + xB) / 2, tM = (t0 + t1) / 2, bM = (b0 + b1) / 2;
1273
+ outline(xA, xM, t0, tM, b0, bM, lineOwner(seriesId, categoryA)), outline(xM, xB, tM, t1, bM, b1, lineOwner(seriesId, categoryB));
1274
+ }, linePair: (a, b, categoryA, categoryB, seriesId, mode) => {
1275
+ if (mode === "linear") return segment(a, b, categoryA, categoryB, seriesId);
1276
+ let elbow = mode === "step-after" ? { ci: b.ci, x: b.x, y: a.y } : { ci: a.ci, x: a.x, y: b.y };
1277
+ segment(a, elbow, categoryA, categoryA, seriesId), segment(elbow, b, categoryB, categoryB, seriesId);
1278
+ }, monotoneRun: (points, segments, seriesId) => {
1279
+ segments.forEach((curve) => {
1280
+ let index = 0;
1281
+ for (; index < points.length - 2 && points[index + 1].x <= curve.from.x; ) index++;
1282
+ let previous = curve.from;
1283
+ for (let sample = 1; sample <= 8; sample++) {
1284
+ let point = cubicPoint(curve, sample / 8);
1285
+ segment(previous, point, cats[points[index].ci].id, cats[points[index + 1].ci].id, seriesId), previous = point;
1286
+ }
1287
+ });
1288
+ } };
1289
+ }
1290
+ function forecastStart(series, cats) {
1291
+ return series.scenario === "FC" ? 0 : cats.findIndex((_, ci) => series.vals[ci].scenario === "FC");
1292
+ }
1293
+ function lastActualIndex(series, start, stacked) {
1294
+ let ci = start - 1;
1295
+ for (; !stacked && ci > 0 && series.vals[ci].v === null; ) ci--;
1296
+ return ci;
1297
+ }
1298
+ function forecastBoundaryX(boundary, xOf, at) {
1299
+ return at === "point" ? xOf(boundary.lastActualIndex) : (xOf(boundary.categoryIndex - 1) + xOf(boundary.categoryIndex)) / 2;
1300
+ }
1301
+ function buildSeriesGeometry(input, series, dataIdx) {
1302
+ let row = input.pv[input.rowOf.get(series)], runs = [], current = [];
1303
+ input.cats.forEach((_, ci) => {
1304
+ if (input.compositionInvalidAt(ci)) {
1305
+ current.length > 0 && runs.push(current), current = [];
1306
+ return;
1307
+ }
1308
+ if (row[ci] === null && !input.isStacked) {
1309
+ series.interpolateGaps || (current.length > 0 && runs.push(current), current = []);
1310
+ return;
1311
+ }
1312
+ let value = input.isStacked ? input.y(input.cumTop[dataIdx][ci]) : row[ci] === null ? null : input.y(row[ci]);
1313
+ value !== null && current.push({ ci, x: input.xOf(ci), y: value });
1314
+ }), current.length > 0 && runs.push(current);
1315
+ let interpolation = input.interpolationFor(series), allPoints = runs.flat();
1316
+ if (input.range && input.xOfValue) {
1317
+ let range = input.range, sourceRow = range.plotted[input.rowOf.get(series)], top = input.isStacked ? range.cumTop[dataIdx].map((v, i) => sourceRow[i] === null && (i <= range.indexes[0] || i >= range.indexes[range.indexes.length - 1]) ? null : v) : sourceRow, rows = input.isStacked ? [top, range.cumBot[dataIdx]] : [top], mapped = rangeRuns(range, rows, interpolation, series.interpolateGaps).map((edges) => edges.map((edge) => mapEdge(edge, input.xOfValue, input.y))), rangedRuns = mapped.map((edges) => edges[0].points), values = range.values.get(series.id), fc = series.scenario === "FC" ? 0 : values.findIndex((v) => v.scenario === "FC"), actual = fc - 1;
1318
+ for (; !input.isStacked && actual > 0 && values[actual].v === null; ) actual--;
1319
+ return {
1320
+ row,
1321
+ runs: rangedRuns,
1322
+ allPoints,
1323
+ interpolation,
1324
+ fcStart: forecastStart(series, input.cats),
1325
+ ...fc < 0 ? {} : { forecastX: input.xOfValue(fc === 0 ? range.lo : range.xs[actual]) },
1326
+ ...interpolation === "monotone" ? { monotoneByRun: new Map(rangedRuns.map((run, i) => [run, mapped[i][0].curve])) } : {},
1327
+ ...input.isStacked ? { bottomByRun: new Map(rangedRuns.map((run, i) => [run, { ...mapped[i][1], mode: interpolation }])) } : {}
1328
+ };
1329
+ }
1330
+ return {
1331
+ row,
1332
+ runs,
1333
+ allPoints,
1334
+ ...interpolation === "monotone" ? { monotoneByRun: new Map(runs.map((run) => [run, monotoneSegments(run)])) } : {},
1335
+ fcStart: forecastStart(series, input.cats),
1336
+ interpolation
1337
+ };
1338
+ }
1339
+ function splitAreaEdge(edge, x) {
1340
+ if (edge.curve) {
1341
+ let [before, after] = splitCurveSegmentsAtX(edge.curve, x);
1342
+ return [{ ...edge, curve: before }, { ...edge, curve: after }];
1343
+ }
1344
+ let index = edge.points.findIndex((point) => point.x >= x), to = edge.points[index];
1345
+ if (to.x === x)
1346
+ return [{ ...edge, points: edge.points.slice(0, index + 1) }, { ...edge, points: edge.points.slice(index) }];
1347
+ let from = edge.points[index - 1], y = edge.mode === "step-after" ? from.y : edge.mode === "step-before" ? to.y : from.y + (to.y - from.y) * ((x - from.x) / (to.x - from.x)), boundary = { x, y };
1348
+ return [
1349
+ { ...edge, points: [...edge.points.slice(0, index), boundary] },
1350
+ { ...edge, points: [boundary, ...edge.points.slice(index)] }
1351
+ ];
1352
+ }
1353
+ function closedAreaPath(upper, lower) {
1354
+ let top = upper.curve ? curvePathFromSegments(upper.curve) : pathFor(upper.points, upper.mode), end = lower.curve ? lower.curve[lower.curve.length - 1].to : lower.points[lower.points.length - 1], reverse = lower.curve ? [...lower.curve].reverse().map((segment) => `C${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.from.x)} ${fmtPathNumber(segment.from.y)}`).join("") : reversePathTail(lower.points, lower.mode);
1355
+ return `${top}L${fmtPathNumber(end.x)} ${fmtPathNumber(end.y)}${reverse}Z`;
1356
+ }
1357
+ function areaSections(upper, lower, forecastX) {
1358
+ let first = upper.points[0], last = upper.points[upper.points.length - 1];
1359
+ if (forecastX === void 0 || forecastX >= last.x) return [{ d: closedAreaPath(upper, lower), forecast: !1, upper, lower }];
1360
+ if (forecastX <= first.x) return [{ d: closedAreaPath(upper, lower), forecast: !0, upper, lower }];
1361
+ let [actualTop, forecastTop] = splitAreaEdge(upper, forecastX), [actualBottom, forecastBottom] = splitAreaEdge(lower, forecastX);
1362
+ return [
1363
+ { d: closedAreaPath(actualTop, actualBottom), forecast: !1, upper: actualTop, lower: actualBottom },
1364
+ { d: closedAreaPath(forecastTop, forecastBottom), forecast: !0, upper: forecastTop, lower: forecastBottom }
1365
+ ];
1366
+ }
1367
+ function edgePolyline(edge) {
1368
+ return edge.curve && edge.curve.length > 0 ? [edge.curve[0].from, ...edge.curve.flatMap((segment) => Array.from({ length: 16 }, (_, k) => cubicPoint(segment, (k + 1) / 16)))] : drawnStroke(edge.points, edge.mode);
1369
+ }
1370
+ function sideWalker(line) {
1371
+ let i = 1;
1372
+ return (x, side) => {
1373
+ if (x < line[0].x || x === line[0].x && side === "left") return line[0].y;
1374
+ for (; i < line.length && line[i].x < x; ) i++;
1375
+ let j = i;
1376
+ if (side === "right") for (; j < line.length && line[j].x <= x; ) j++;
1377
+ if (j >= line.length) return line[line.length - 1].y;
1378
+ let a = line[j - 1], b = line[j];
1379
+ return b.x === a.x ? b.y : a.y + (b.y - a.y) * (x - a.x) / (b.x - a.x);
1380
+ };
1381
+ }
1382
+ function areaInRect(top, bottom, rect) {
1383
+ let x0 = Math.max(top[0].x, bottom[0].x, rect.x), x1 = Math.min(top[top.length - 1].x, bottom[bottom.length - 1].x, rect.x + rect.w);
1384
+ if (!(x1 > x0)) return;
1385
+ let rows = [rect.y, rect.y + rect.h], crossings = (line) => line.flatMap((b, i) => {
1386
+ let a = line[i - 1];
1387
+ return a ? rows.flatMap((row) => (a.y - row) * (b.y - row) < 0 ? [a.x + (row - a.y) * (b.x - a.x) / (b.y - a.y)] : []) : [];
1388
+ }), sorted = (xs) => [...new Set(xs.filter((x) => x >= x0 && x <= x1))].sort((a, b) => a - b), breaks = sorted([x0, x1, ...top.map((p) => p.x), ...bottom.map((p) => p.x), ...crossings(top), ...crossings(bottom)]), [topA, bottomA] = [sideWalker(top), sideWalker(bottom)], gaps = breaks.map((x) => [topA(x, "left") - bottomA(x, "left"), topA(x, "right") - bottomA(x, "right")]), swaps = breaks.flatMap((p, i) => {
1389
+ let q = breaks[i + 1], gp = gaps[i][1], gq = gaps[i + 1]?.[0];
1390
+ return q !== void 0 && gq !== void 0 && gp * gq < 0 ? [p + (q - p) * gp / (gp - gq)] : [];
1391
+ }), clamp = (y) => Math.min(Math.max(y, rows[0]), rows[1]), [topB, bottomB] = [sideWalker(top), sideWalker(bottom)], upper = [], lower = [], open = !1;
1392
+ for (let x of sorted([...breaks, ...swaps]))
1393
+ for (let side of ["left", "right"]) {
1394
+ let t = topB(x, side), b = bottomB(x, side), u = { x, y: clamp(Math.min(t, b)) }, l = { x, y: clamp(Math.max(t, b)) };
1395
+ open ||= l.y - u.y > 0.01;
1396
+ let prevU = upper[upper.length - 1];
1397
+ (!prevU || prevU.x !== u.x || prevU.y !== u.y) && upper.push(u);
1398
+ let prevL = lower[lower.length - 1];
1399
+ (!prevL || prevL.x !== l.x || prevL.y !== l.y) && lower.push(l);
1400
+ }
1401
+ if (open)
1402
+ return { d: `${linePath(upper)}${[...lower].reverse().map((p) => `L${fmtPathNumber(p.x)} ${fmtPathNumber(p.y)}`).join("")}Z`, upper, lower };
1403
+ }
1404
+ function pieceHatchPath(upper, lower, gap) {
1405
+ let xs = [...new Set([...upper, ...lower].map((point) => point.x))].sort((a, b) => a - b), [up, low] = [sideWalker(upper), sideWalker(lower)];
1406
+ return xs.slice(0, -1).map((p, i) => {
1407
+ let q = xs[i + 1], stretch = (walk) => ({ points: [{ x: p, y: walk(p, "right") }, { x: q, y: walk(q, "left") }], mode: "linear" });
1408
+ return bandHatchPath(stretch(up), stretch(low), gap);
1409
+ }).join("");
1410
+ }
1411
+ var SHADING_OVER_FILL = 0.35;
1412
+ function shadingOverFills(shading, outlines, hatch) {
1413
+ return outlines.flatMap((outline, k) => {
1414
+ let piece = areaInRect(outline.top, outline.bottom, shading.rect);
1415
+ if (!piece) return [];
1416
+ let fill = mixedPaint(shading.fill, outline.paint, SHADING_OVER_FILL, "token" in outline.paint ? outline.paint.token : "background"), patterned = outline.forecast && !outline.stacked, node = { t: "path", id: `${shading.id}:over:${k}`, d: piece.d, fill, ...patterned ? { pattern: "hatch45" } : {}, owner: shading.owner, part: "shadingOverFill" };
1417
+ if (patterned || shading.pattern !== "hatch45" && !outline.forecast) return [node];
1418
+ let stripes = pieceHatchPath(piece.upper, piece.lower, hatch.gap);
1419
+ return stripes ? [node, {
1420
+ t: "path",
1421
+ id: `${shading.id}:over:${k}:hatch`,
1422
+ d: stripes,
1423
+ stroke: mixedPaint({ token: "background" }, fill, hatch.share, "token" in outline.paint ? outline.paint.token : "background"),
1424
+ width: hatch.width,
1425
+ owner: shading.owner,
1426
+ part: "shadingOverFill"
1427
+ }] : [node];
1428
+ });
1429
+ }
1430
+ function withoutEvents(annotations) {
1431
+ return annotations.filter((annotation) => annotation.kind !== "event");
1432
+ }
1433
+ function fillShadingKinds(annotations) {
1434
+ let kinds = /* @__PURE__ */ new Map();
1435
+ return annotations.forEach((annotation, index) => {
1436
+ let id = defaultAnnotationId(annotation, index);
1437
+ if (annotation.kind === "valueLine") kinds.set(id, "value");
1438
+ else {
1439
+ if (annotation.kind !== "band") return;
1440
+ annotation.style === "corridor" || annotation.style === "tolerance" || annotation.style === "attainment" ? kinds.set(id, "value") : (annotation.style ?? "shade") === "shade" && kinds.set(id, "era");
1441
+ }
1442
+ }), kinds;
1443
+ }
1444
+ function shadesFills(annotations) {
1445
+ return annotations.some((annotation) => annotation.kind === "band" && (annotation.style === "corridor" || annotation.style === "tolerance" || annotation.style === "attainment") || annotation.kind === "valueLine" && (annotation.tolerance !== void 0 || annotation.attainment !== void 0 && annotation.attainment !== !1));
1446
+ }
1447
+ function fillShadings(nodes, outlines, kinds, plot, ruleWidth, hatch) {
1448
+ let kindOf = (node) => node.t === "rect" && (node.part === "band" || node.part === "attainment") && !("token" in node.fill && node.fill.token === "background") ? kinds.get(node.owner.annotationId ?? "") : void 0, shadings = nodes.filter((node) => kindOf(node) === "value"), over = shadings.flatMap((node) => shadingOverFills(node, outlines, hatch)), grounds = shadings.flatMap((node) => outlines.flatMap((outline, k) => {
1449
+ let mix = over.find((piece) => piece.id === `${node.id}:over:${k}`);
1450
+ return mix && mix.t === "path" && mix.fill ? [{ seriesId: outline.seriesId, rect: node.rect, paint: mix.fill, ...mix.pattern === "hatch45" ? { pattern: "hatch45" } : {} }] : [];
1451
+ })), edges = nodes.filter((node) => kindOf(node) === "era").flatMap((node) => {
1452
+ let { x, y: top, w, h } = node.rect;
1453
+ return [x, x + w].filter((at) => at > plot.x + 0.5 && at < plot.x + plot.w - 0.5).map((at, k) => ({
1454
+ t: "line",
1455
+ id: `${node.id}:edge:${k}`,
1456
+ x1: at,
1457
+ y1: top,
1458
+ x2: at,
1459
+ y2: top + h,
1460
+ stroke: { token: "background" },
1461
+ width: ruleWidth,
1462
+ owner: node.owner,
1463
+ part: "bandEdge"
1464
+ }));
1465
+ });
1466
+ return { nodes: [...over, ...edges], grounds };
1467
+ }
1468
+ function regroundOnShadings(labels, grounds) {
1469
+ if (grounds.length !== 0)
1470
+ for (let label of labels) {
1471
+ let ink = label.ink;
1472
+ if (!("token" in ink) || ink.theme?.kind !== "contrast-ink" || label.owner.seriesId === void 0) continue;
1473
+ let { rect } = label, share = (ground) => {
1474
+ let w = Math.min(rect.x + rect.w, ground.rect.x + ground.rect.w) - Math.max(rect.x, ground.rect.x), h = Math.min(rect.y + rect.h, ground.rect.y + ground.rect.h) - Math.max(rect.y, ground.rect.y);
1475
+ return w > 0 && h > 0 ? w * h / Math.max(rect.w * rect.h, 1e-9) : 0;
1476
+ }, touched = grounds.filter((candidate) => candidate.seriesId === label.owner.seriesId && share(candidate) > 0), whole = touched.find((candidate) => share(candidate) > 0.999);
1477
+ whole ? label.ink = { ...ink, theme: { kind: "contrast-ink", fill: whole.paint, ...whole.pattern ? { pattern: whole.pattern } : {} } } : touched.length > 0 && (label.ink = { ...ink, theme: { ...ink.theme, also: touched.map((ground) => ground.paint) } });
1478
+ }
1479
+ }
1480
+ function bandHatchPath(upper, lower, gap) {
1481
+ let top = edgePolyline(upper), bottom = edgePolyline(lower);
1482
+ top.some((point) => point.y > polylineYAt2(bottom, point.x)) && ([top, bottom] = [bottom, top]);
1483
+ let x0 = Math.max(top[0].x, bottom[0].x), x1 = Math.min(top[top.length - 1].x, bottom[bottom.length - 1].x);
1484
+ if (!(x1 > x0)) return "";
1485
+ let breaks = [.../* @__PURE__ */ new Set([x0, x1, ...[...top, ...bottom].map((p) => p.x).filter((x) => x > x0 && x < x1)])].sort((a, b) => a - b), step = gap * Math.SQRT2, sums = breaks.flatMap((x) => [x + polylineYAt2(top, x), x + polylineYAt2(bottom, x)]), d = "";
1486
+ for (let c = Math.ceil(minOf(sums) / step) * step; c <= maxOf(sums); c += step) {
1487
+ let open, close, flush = () => {
1488
+ open !== void 0 && close !== void 0 && close - open > 0.01 && (d += `M${fmtPathNumber(open)} ${fmtPathNumber(c - open)}L${fmtPathNumber(close)} ${fmtPathNumber(c - close)}`), open = void 0, close = void 0;
1489
+ };
1490
+ for (let i = 0; i + 1 < breaks.length; i++) {
1491
+ let p = breaks[i], q = breaks[i + 1], over = (x) => c - x - polylineYAt2(top, x), under = (x) => polylineYAt2(bottom, x) - (c - x), lo = p, hi = q;
1492
+ for (let f of [over, under]) {
1493
+ let fp = f(p), fq = f(q);
1494
+ if (fp < 0 && fq < 0) {
1495
+ lo = 1 / 0;
1496
+ break;
1497
+ }
1498
+ if (fp < 0 || fq < 0) {
1499
+ let root = p + (q - p) * fp / (fp - fq);
1500
+ fp < 0 ? lo = Math.max(lo, root) : hi = Math.min(hi, root);
1501
+ }
1502
+ }
1503
+ if (lo >= hi) {
1504
+ flush();
1505
+ continue;
1506
+ }
1507
+ open !== void 0 && close !== void 0 && Math.abs(close - lo) < 1e-6 || (flush(), open = lo), close = hi;
1508
+ }
1509
+ flush();
1510
+ }
1511
+ return d;
1512
+ }
1513
+ function renderArea(input, series, dataIdx, entry, geometry, claims, paintedAreaCats, outlines) {
1514
+ if (input.isArea && input.isStacked && renderIsolatedStacks(input, series, dataIdx, entry, geometry, paintedAreaCats), !input.areaFilled(series) || !geometry.runs.some((run) => run.length >= 2)) return;
1515
+ let bottomAt = (ci) => input.isStacked ? input.y(input.cumBot[dataIdx][ci]) : input.baseY, fillRuns = !input.range && series.interpolateGaps && geometry.interpolation === "linear" && !input.hasSuppressed100 ? [geometry.allPoints] : geometry.runs.filter((run) => run.length >= 2), painted = paintedAreaCats.get(series.id) ?? /* @__PURE__ */ new Set();
1516
+ paintedAreaCats.set(series.id, painted);
1517
+ let forecastX = geometry.forecastX ?? (geometry.fcStart < 0 ? void 0 : geometry.fcStart === 0 ? input.xOf(0) : forecastBoundaryX({ categoryIndex: geometry.fcStart, lastActualIndex: lastActualIndex(series, geometry.fcStart, input.isStacked) }, input.xOf, "point"));
1518
+ fillRuns.forEach((run, runIndex) => {
1519
+ for (let point of run) painted.add(point.ci);
1520
+ let upper = { points: run, mode: geometry.interpolation, curve: geometry.monotoneByRun?.get(run) }, lower = geometry.bottomByRun?.get(run)?.points ?? run.map((point) => ({ x: point.x, y: bottomAt(point.ci) })), lowerMode = input.isStacked ? geometry.interpolation : "linear", lowerEdge = geometry.bottomByRun?.get(run) ?? { points: lower, mode: lowerMode, ...lowerMode === "monotone" ? { curve: monotoneSegments(lower) } : {} }, id = `mark:area:${series.id}${runIndex === 0 ? "" : `:${runIndex}`}`;
1521
+ areaSections(upper, lowerEdge, forecastX).forEach((section, index) => {
1522
+ let overlay = section.forecast && input.isStacked && input.hatch !== void 0, areaPaint = input.areaFillPaint(series, dataIdx, section.forecast), sep = section.forecast ? void 0 : othersSeparation(areaPaint, input.theme);
1523
+ outlines.push({ id: index === 0 ? id : `${id}:fc`, seriesId: series.id, top: edgePolyline(section.upper), bottom: edgePolyline(section.lower), paint: areaPaint, forecast: section.forecast, ...input.isStacked ? { stacked: !0 } : {} }), input.nodes.push({ t: "path", id: index === 0 ? id : `${id}:fc`, d: section.d, fill: areaPaint, ...section.forecast && !overlay ? { pattern: "hatch45" } : {}, ...sep ? { stroke: sep.stroke, width: sep.strokeWidth } : {}, ...!section.forecast && isOthersFill(areaPaint) ? { separation: { fill: areaPaint, backing: { token: "background" } } } : {}, owner: { seriesId: series.id }, part: "area" });
1524
+ let hatch = overlay ? bandHatchPath(section.upper, section.lower, input.hatch.gap) : "";
1525
+ hatch && input.nodes.push({ t: "path", id: `${id}:fc:hatch`, d: hatch, stroke: mixedPaint({ token: "background" }, areaPaint, input.hatch.share, "token" in areaPaint ? areaPaint.token : "background"), width: input.hatch.width, owner: { seriesId: series.id }, part: "forecastHatch" });
1526
+ }), entry.areaNodeId || (entry.areaNodeId = id);
1527
+ for (let index = 0; index + 1 < run.length; index++) {
1528
+ let from = run[index], to = run[index + 1];
1529
+ if (geometry.interpolation === "monotone") {
1530
+ let top = Math.min(from.y, to.y, lower[index].y, lower[index + 1].y), bottom = Math.max(from.y, to.y, lower[index].y, lower[index + 1].y);
1531
+ input.occupied.claim({ x: from.x, y: top, w: to.x - from.x, h: Math.max(bottom - top, 1) }, "mark", claims.lineOwner(series.id, input.cats[from.ci].id), AREA_FILL_PART);
1532
+ } else claims.areaPair(from.x, to.x, from.y, to.y, lower[index].y, lower[index + 1].y, input.cats[from.ci].id, input.cats[to.ci].id, series.id, geometry.interpolation);
1533
+ }
1534
+ });
1535
+ }
1536
+ function emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, points, curve, dashed, solidHasPath) {
1537
+ if (geometry.monotoneByRun ? curve.length === 0 : points.length < 2) return;
1538
+ let id = `mark:line:${series.id}:${runIndex}${dashed ? ":fc" : ""}`, separator = input.isArea && input.isStacked && input.hatch !== void 0, dash = separator ? void 0 : dashed ? dashToken(input.theme, "reference") : input.dashOf(series, dataIdx), path = geometry.monotoneByRun ? curvePathFromSegments(curve) : pathFor(points, geometry.interpolation), filled = input.areaFilled(series);
1539
+ if (filled || input.nodes.push({ t: "path", id: `casing:${id}`, d: path, stroke: { token: "background" }, width: strokeToken(input.theme, "casing"), owner: { seriesId: series.id }, part: "lineCasing" }), input.nodes.push({ t: "path", id, d: path, stroke: separator ? { token: "background" } : dashed ? input.forecastLinePaint(series, dataIdx) : input.seriesPaint(series, dataIdx), width: separator ? strokeToken(input.theme, "rule") : input.lineWidthOf(series), ...dash ? { dash, lineCap: dash.join(",") === dashToken(input.theme, "dotted").join(",") ? "round" : "butt" } : {}, owner: { seriesId: series.id }, part: "line" }), input.lineHollowOf(series) && input.nodes.push({
1540
+ t: "path",
1541
+ id: `${id}:inner`,
1542
+ d: path,
1543
+ stroke: { token: "background" },
1544
+ width: strokeToken(input.theme, "hair"),
1545
+ ...dash ? { dash, lineCap: dash.join(",") === dashToken(input.theme, "dotted").join(",") ? "round" : "butt" } : {},
1546
+ owner: { seriesId: series.id },
1547
+ part: "lineInterior"
1548
+ }), dashed && !entry.fcPathNodeId && (entry.fcPathNodeId = id), !dashed && !entry.pathNodeId && (entry.pathNodeId = id), dashed && !entry.pathNodeId && !solidHasPath && (entry.pathNodeId = id), !filled)
1549
+ if (geometry.monotoneByRun) claims.monotoneRun(run, curve, series.id);
1550
+ else for (let index = 0; index + 1 < points.length; index++) claims.linePair(points[index], points[index + 1], input.cats[points[index].ci].id, input.cats[points[index + 1].ci].id, series.id, geometry.interpolation);
1551
+ }
1552
+ function renderIsolatedStacks(input, series, dataIdx, entry, geometry, paintedAreaCats) {
1553
+ let lone = geometry.runs.filter((run) => run.length === 1).map((run) => run[0]);
1554
+ if (lone.length === 0 || geometry.interpolation === "linear" && !input.hasSuppressed100 && geometry.allPoints.length >= 2) return;
1555
+ let painted = paintedAreaCats.get(series.id) ?? /* @__PURE__ */ new Set();
1556
+ paintedAreaCats.set(series.id, painted);
1557
+ let w = 32;
1558
+ for (let point of lone) {
1559
+ let top = input.y(input.cumTop[dataIdx][point.ci]), bottom = input.y(input.cumBot[dataIdx][point.ci]);
1560
+ if (!(bottom - top > 0)) continue;
1561
+ painted.add(point.ci);
1562
+ let rect = { x: Math.max(input.plot.x, Math.min(point.x - w / 2, input.plot.x + input.plot.w - w)), y: top, w, h: bottom - top }, owner = { seriesId: series.id, categoryId: input.cats[point.ci].id }, id = `mark:stack:${series.id}:${owner.categoryId}`, fill = input.areaFillPaint(series, dataIdx, !1), sep = othersSeparation(fill, input.theme);
1563
+ input.nodes.push({ t: "rect", id, rect, fill, ...sep ? { stroke: sep.stroke, strokeWidth: sep.strokeWidth } : {}, ...isOthersFill(fill) ? { separation: { fill, backing: { token: "background" } } } : {}, owner, part: "segment" }), entry.areaNodeId || (entry.areaNodeId = id), input.occupied.claim(rect, "mark", owner);
1564
+ }
1565
+ }
1566
+ function renderLinePaths(input, series, dataIdx, entry, geometry, claims) {
1567
+ input.variant !== "stacked100-area" && geometry.runs.forEach((run, runIndex) => {
1568
+ if (run.length < 2) return;
1569
+ let solidPoints = run, fcPoints = [], solidCurve = geometry.monotoneByRun?.get(run) ?? [], fcCurve = [];
1570
+ if (input.range && geometry.forecastX !== void 0) {
1571
+ let edge = { points: run, ...geometry.monotoneByRun ? { curve: solidCurve } : {} }, before = cutEdge(edge, geometry.interpolation, -1 / 0, geometry.forecastX), after = cutEdge(edge, geometry.interpolation, geometry.forecastX, 1 / 0);
1572
+ solidPoints = before.points, fcPoints = after.points, solidCurve = before.curve ?? [], fcCurve = after.curve ?? [];
1573
+ } else if (geometry.fcStart !== -1) {
1574
+ let splitAt = run.findIndex((point) => point.ci >= geometry.fcStart);
1575
+ splitAt === 0 ? (solidPoints = [], fcPoints = run, fcCurve = solidCurve, solidCurve = []) : splitAt > 0 && (solidPoints = run.slice(0, splitAt), fcPoints = run.slice(splitAt - 1), geometry.monotoneByRun && ([solidCurve, fcCurve] = splitCurveSegmentsAtX(solidCurve, run[splitAt - 1].x)));
1576
+ }
1577
+ let solidHasPath = geometry.monotoneByRun ? solidCurve.length > 0 : solidPoints.length >= 2;
1578
+ emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, solidPoints, solidCurve, !1, solidHasPath), emitLinePath(input, series, dataIdx, entry, geometry, claims, run, runIndex, fcPoints, fcCurve, !0, solidHasPath), !input.areaFilled(series) && series.interpolateGaps && markBridgedGaps(input, series, dataIdx, geometry, run, runIndex);
1579
+ });
1580
+ }
1581
+ function markBridgedGaps(input, series, dataIdx, geometry, run, runIndex) {
1582
+ let curve = geometry.monotoneByRun?.get(run), paint = series.role === "reference" ? input.refPaintOf(series) : input.seriesPaint(series, dataIdx), width = series.role === "reference" ? strokeToken(input.theme, "rule") : input.lineWidthOf(series);
1583
+ for (let k = 0; k + 1 < run.length; k++) {
1584
+ let [a, b] = [run[k], run[k + 1]];
1585
+ if (b.ci - a.ci < 2) continue;
1586
+ let segment = curve?.[k], d = segment ? curvePathFromSegments([segment]) : pathFor([a, b], geometry.interpolation), id = `bridge:${series.id}:${runIndex}:${a.ci}`;
1587
+ input.nodes.push({ t: "path", id: `${id}:erase`, d, stroke: { token: "background" }, width: strokeToken(input.theme, "casing"), owner: { seriesId: series.id }, part: "lineCasing" }), input.nodes.push({ t: "path", id, d, stroke: paint, width, dash: dashToken(input.theme, "reference"), owner: { seriesId: series.id }, part: "gapBridge" });
1588
+ for (let ci = a.ci + 1; ci < b.ci; ci++) {
1589
+ let x = input.xOf(ci), t = (x - a.x) / (b.x - a.x), y = segment ? cubicPoint(segment, t).y : geometry.interpolation === "step-after" ? a.y : geometry.interpolation === "step-before" ? b.y : a.y + (b.y - a.y) * t;
1590
+ input.nodes.push(gapMarkerNode(input.theme, { id: `gap:${series.id}:${input.cats[ci].id}`, x, y, ink: paint, owner: { seriesId: series.id, categoryId: input.cats[ci].id } }));
1591
+ }
1592
+ }
1593
+ }
1594
+ function markerDisplay(input, series, row, ci) {
1595
+ let cell = series.vals[ci];
1596
+ return {
1597
+ value: input.rebased ? input.fmt(row[ci]) : cell.isPct ? cell.format ? input.seriesFmt({ ...series, format: cell.format })(cell.v) : input.authoredPctFmt(cell.v) : input.variant === "stacked100-area" ? input.shareTexts.get(`${input.cats[ci].id}\0${series.id}`) ?? input.pctFmt(row[ci]) : input.seriesFmt(cell.format ? { ...series, format: cell.format } : series)(input.absOf(series, ci)),
1598
+ ...input.bumpPointState(row, ci)
1599
+ };
1600
+ }
1601
+ function pushMarkerNode(input, series, dataIdx, row, point, shape, id) {
1602
+ let stroke = series.role === "reference" ? input.refPaintOf(series) : input.seriesPaint(series, dataIdx), hollow = input.hollowAt(series, point.ci), fill = hollow ? { token: "background" } : stroke, owner = { seriesId: series.id, categoryId: input.cats[point.ci].id }, display = markerDisplay(input, series, row, point.ci);
1603
+ shape === "circle" ? input.nodes.push({ t: "circle", id, cx: point.x, cy: point.y, r: 3, fill, ...hollow ? { stroke } : {}, owner, part: "marker", display }) : shape === "square" ? input.nodes.push({ t: "rect", id, rect: { x: point.x - 3, y: point.y - 3, w: 6, h: 6 }, fill, ...hollow ? { stroke, strokeWidth: strokeToken(input.theme, "mark") } : {}, owner, part: "marker", display }) : shape !== "none" && input.nodes.push({ t: "path", id, d: markerPath(shape, point), fill, ...hollow ? { stroke, width: strokeToken(input.theme, "mark") } : {}, owner, part: "marker", display });
1604
+ }
1605
+ function markerPath(shape, point) {
1606
+ return shape === "triangle" ? `M${fmtPathNumber(point.x)} ${fmtPathNumber(point.y - 3.5)}L${fmtPathNumber(point.x + 3.5)} ${fmtPathNumber(point.y + 3)}L${fmtPathNumber(point.x - 3.5)} ${fmtPathNumber(point.y + 3)}Z` : `M${fmtPathNumber(point.x)} ${fmtPathNumber(point.y - 4)}L${fmtPathNumber(point.x + 4)} ${fmtPathNumber(point.y)}L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y + 4)}L${fmtPathNumber(point.x - 4)} ${fmtPathNumber(point.y)}Z`;
1607
+ }
1608
+ function renderMarkers(input, series, dataIdx, entry, geometry, claims) {
1609
+ geometry.allPoints.forEach((point) => {
1610
+ let shape = input.markerOf(series, dataIdx, point.ci);
1611
+ if (input.isStacked && geometry.row[point.ci] === null) {
1612
+ entry.points.push({ categoryId: input.cats[point.ci].id, x: point.x, y: point.y });
1613
+ return;
1614
+ }
1615
+ let nodeId;
1616
+ shape !== "none" && (nodeId = `marker:${series.id}:${input.cats[point.ci].id}`, pushMarkerNode(input, series, dataIdx, geometry.row, point, shape, nodeId), input.occupied.claim({ x: point.x - 4, y: point.y - 4, w: 8, h: 8 }, "mark", claims.lineOwner(series.id, input.cats[point.ci].id))), entry.points.push({ categoryId: input.cats[point.ci].id, x: point.x, y: point.y, ...nodeId ? { nodeId } : {} });
1617
+ });
1618
+ }
1619
+ function renderSeries(input, series, dataIdx, marks, paintedAreaCats, claims, outlines) {
1620
+ let entry = { seriesId: series.id, points: [] }, geometry = buildSeriesGeometry(input, series, dataIdx);
1621
+ return renderArea(input, series, dataIdx, entry, geometry, claims, paintedAreaCats, outlines), renderLinePaths(input, series, dataIdx, entry, geometry, claims), renderMarkers(input, series, dataIdx, entry, geometry, claims), renderLatestPointRing(input, series, geometry, claims), marks.series.push(entry), geometry;
1622
+ }
1623
+ var LATEST_RING_R = 4.5, LATEST_DOT_R = 2, latestRingReach = (theme) => LATEST_RING_R + strokeToken(theme, "mark") / 2;
1624
+ function renderLatestPointRing(input, series, geometry, claims) {
1625
+ if (input.latestPointSeries === void 0 || input.latestPointSeries !== series.id) return;
1626
+ let observed = geometry.allPoints.filter((point2) => geometry.row[point2.ci] !== null), point = observed[observed.length - 1];
1627
+ if (point === void 0) return;
1628
+ let categoryId = input.cats[point.ci].id, owner = { seriesId: series.id, categoryId }, display = markerDisplay(input, series, geometry.row, point.ci);
1629
+ input.nodes.push({
1630
+ t: "circle",
1631
+ id: `latest-ring:${series.id}`,
1632
+ cx: point.x,
1633
+ cy: point.y,
1634
+ r: LATEST_RING_R,
1635
+ fill: { token: "background" },
1636
+ stroke: { token: "highlight" },
1637
+ strokeWidth: strokeToken(input.theme, "mark"),
1638
+ owner,
1639
+ part: "marker",
1640
+ display
1641
+ }), input.nodes.push({
1642
+ t: "circle",
1643
+ id: `latest-dot:${series.id}`,
1644
+ cx: point.x,
1645
+ cy: point.y,
1646
+ r: LATEST_DOT_R,
1647
+ fill: { token: "markInk" },
1648
+ owner,
1649
+ part: "marker",
1650
+ display
1651
+ }), input.occupied.claim(
1652
+ { x: point.x - latestRingReach(input.theme), y: point.y - latestRingReach(input.theme), w: latestRingReach(input.theme) * 2, h: latestRingReach(input.theme) * 2 },
1653
+ "mark",
1654
+ claims.lineOwner(series.id, categoryId)
1655
+ );
1656
+ }
1657
+ function renderAreaSeparators(input, geometries, paintedAreaCats) {
1658
+ input.variant === "stacked100-area" && input.drawnSeries.slice(0, -1).forEach((series, index) => {
1659
+ let geometry = geometries[index], next = input.drawnSeries[index + 1];
1660
+ if (geometry.interpolation !== geometries[index + 1].interpolation) return;
1661
+ let painted = (band, ci, cj) => input.cumTop[band][ci] !== input.cumBot[band][ci] || input.cumTop[band][cj] !== input.cumBot[band][cj];
1662
+ geometry.runs.forEach((run, runIndex) => {
1663
+ let start = 0, emit = (end) => {
1664
+ if (end <= start) return;
1665
+ let curve = geometry.monotoneByRun?.get(run)?.slice(start, end), d = curve ? curvePathFromSegments(curve) : pathFor(run.slice(start, end + 1), geometry.interpolation);
1666
+ input.nodes.push({
1667
+ t: "path",
1668
+ id: `area-separator:${series.id}:${runIndex}:${start}`,
1669
+ d,
1670
+ stroke: { token: "background" },
1671
+ width: strokeToken(input.theme, "rule"),
1672
+ owner: { seriesId: series.id },
1673
+ part: "areaSeparator"
1674
+ });
1675
+ };
1676
+ for (let pointIndex = 0; pointIndex + 1 < run.length; pointIndex++) {
1677
+ let from = run[pointIndex].ci, to = run[pointIndex + 1].ci;
1678
+ [series.id, next.id].every((id) => paintedAreaCats.get(id)?.has(from) && paintedAreaCats.get(id)?.has(to)) && painted(index, from, to) && painted(index + 1, from, to) || (emit(pointIndex), start = pointIndex + 1);
1679
+ }
1680
+ emit(run.length - 1);
1681
+ });
1682
+ });
1683
+ }
1684
+ function renderInvalidComposition(input) {
1685
+ input.variant === "stacked100-area" && input.cats.forEach((category, ci) => {
1686
+ let glyph = input.nmCats100.has(category.id) ? NOT_MEANINGFUL : input.naCats100.has(category.id) ? input.naGlyph : null;
1687
+ if (!glyph) return;
1688
+ let size = input.measure(glyph, input.labelFont), x = input.xOf(ci), rect = { x: x - size.width / 2, y: input.baseY - size.height - 6, w: size.width, h: size.height };
1689
+ input.nodes.push({ t: "text", id: `nm:${category.id}`, x, y: rect.y, lines: [glyph], align: "middle", typeRole: "label", font: input.labelFont, ink: { token: "inkMuted" }, owner: { categoryId: category.id }, part: "nmMarker", display: { state: input.nmCats100.has(category.id) ? NOT_MEANINGFUL : NOT_AVAILABLE } }), input.occupied.claim(rect, "label", { categoryId: category.id });
1690
+ });
1691
+ }
1692
+ function renderReferences(input, claims) {
1693
+ input.refSeries.forEach((series) => {
1694
+ let geometry = buildSeriesGeometry({ ...input, isStacked: !1 }, series, 0), { interpolation, runs } = geometry;
1695
+ runs.forEach((points, runIndex) => {
1696
+ if (points.length === 1) {
1697
+ let point = points[0], categoryId = input.cats[point.ci].id, shape = input.markerOf(series, 0, point.ci);
1698
+ pushMarkerNode(input, series, 0, geometry.row, point, shape === "none" ? "circle" : shape, `marker:${series.id}:${categoryId}`), input.occupied.claim({ x: point.x - 4, y: point.y - 4, w: 8, h: 8 }, "mark", claims.lineOwner(series.id, categoryId));
1699
+ return;
1700
+ }
1701
+ if (points.length < 2) return;
1702
+ let curve = geometry.monotoneByRun?.get(points) ?? [];
1703
+ if (input.nodes.push({ t: "path", id: `ref:${series.id}${runIndex === 0 ? "" : `:${runIndex}`}`, d: interpolation === "monotone" ? curvePathFromSegments(curve) : pathFor(points, interpolation), stroke: input.refPaintOf(series), width: strokeToken(input.theme, "rule"), dash: dashToken(input.theme, "reference"), owner: { seriesId: series.id }, part: "referenceLine" }), interpolation === "monotone") claims.monotoneRun(points, curve, series.id);
1704
+ else for (let index = 0; index + 1 < points.length; index++) claims.linePair(points[index], points[index + 1], input.cats[points[index].ci].id, input.cats[points[index + 1].ci].id, series.id, interpolation);
1705
+ series.interpolateGaps && markBridgedGaps(input, series, 0, geometry, points, runIndex);
1706
+ });
1707
+ });
1708
+ }
1709
+ function renderLineMarks(input) {
1710
+ let analyticalSceneStart = input.nodes.length, baselineId = "axis:baseline";
1711
+ input.nodes.push({ t: "line", id: baselineId, x1: input.plot.x, y1: input.baseY, x2: input.plot.x + input.plot.w, y2: input.baseY, stroke: { token: "axis" }, width: strokeToken(input.theme, "rule"), owner: {}, part: "baseline" }), input.occupied.claim({ x: input.plot.x, y: input.baseY - 1, w: input.plot.w, h: 2 }, "axis", {});
1712
+ let marks = { series: [] }, paintedAreaCats = /* @__PURE__ */ new Map(), claims = createClaims(input.occupied, input.cats, input.inlineNamesEnabled), seriesStart = input.nodes.length, areaOutlines = [], geometries = input.drawnSeries.map((series, dataIdx) => renderSeries(input, series, dataIdx, marks, paintedAreaCats, claims, areaOutlines));
1713
+ if (!input.isStacked) {
1714
+ let highlight = new Set(input.drawnSeries.filter((series) => series.colorRole === "highlight" || input.highlights.has(series.id)).map((series) => series.id)), ink = input.nodes.splice(seriesStart), fill = (node) => node.part === "area" || node.part === "forecastHatch", raised = (node) => highlight.has(node.owner.seriesId) && (node.id.startsWith("mark:line:") || node.id.startsWith("casing:mark:line:") || node.part === "marker");
1715
+ pushAll(input.nodes, ink.filter(fill)), pushAll(input.nodes, ink.filter((node) => !fill(node) && !raised(node))), pushAll(input.nodes, ink.filter(raised));
1716
+ }
1717
+ renderAreaSeparators(input, geometries, paintedAreaCats), renderBumpTies(input.theme, { bump: input.bump, marks, nodes: input.nodes, occupied: input.occupied });
1718
+ for (let series of input.bumpOmitted ?? []) {
1719
+ let row = input.pv[input.rowOf.get(series)];
1720
+ marks.series.push({ seriesId: series.id, points: row.flatMap((rank, ci) => rank === null ? [] : [{ categoryId: input.cats[ci].id, x: input.xOf(ci), y: input.y(rank) }]) });
1721
+ }
1722
+ renderInvalidComposition(input), renderReferences(input, claims);
1723
+ let rangeEdges = input.range ? new Map(input.drawnSeries.map((series, i) => {
1724
+ let geometry = geometries[i];
1725
+ return [series.id, {
1726
+ runs: geometry.runs.map((run) => edgePolyline({ points: run, mode: geometry.interpolation, curve: geometry.monotoneByRun?.get(run) })),
1727
+ ...geometry.bottomByRun ? { bottom: geometry.runs.flatMap((run) => edgePolyline(geometry.bottomByRun.get(run))) } : {}
1728
+ }];
1729
+ })) : void 0;
1730
+ return { marks, baselineId, analyticalSceneStart, paintedAreaCats, areaOutlines, ...rangeEdges ? { rangeEdges } : {} };
1731
+ }
1732
+ function linearYAt(points, x) {
1733
+ if (points.length === 0) throw new Error("linearYAt on an empty run");
1734
+ if (points.length === 1 || x <= points[0].x) return points[0].y;
1735
+ if (x >= points[points.length - 1].x) return points[points.length - 1].y;
1736
+ let index = 0;
1737
+ for (; index < points.length - 2 && points[index + 1].x < x; ) index++;
1738
+ let from = points[index], to = points[index + 1];
1739
+ return from.y + (to.y - from.y) * ((x - from.x) / (to.x - from.x));
1740
+ }
1741
+ function sliceCurve(segment, fromT, toT) {
1742
+ if (fromT <= 0 && toT >= 1) return segment;
1743
+ let right = fromT <= 0 ? segment : splitCurve(segment, fromT)[1], normalizedTo = fromT >= 1 ? 1 : (toT - fromT) / (1 - fromT);
1744
+ return normalizedTo >= 1 ? right : splitCurve(right, normalizedTo)[0];
1745
+ }
1746
+ function monotonePathBetween(points, start, end) {
1747
+ let pieces = monotoneSegments(points).flatMap((segment) => {
1748
+ if (segment.to.x <= start.x || segment.from.x >= end.x) return [];
1749
+ let span = segment.to.x - segment.from.x, fromT = Math.max(0, (start.x - segment.from.x) / span), toT = Math.min(1, (end.x - segment.from.x) / span);
1750
+ return toT > fromT ? [sliceCurve(segment, fromT, toT)] : [];
1751
+ });
1752
+ return pieces.length === 0 ? `M${fmtPathNumber(start.x)} ${fmtPathNumber(start.y)}` : (pieces[0] = { ...pieces[0], from: { x: start.x, y: start.y } }, pieces[pieces.length - 1] = { ...pieces[pieces.length - 1], to: { x: end.x, y: end.y } }, `M${fmtPathNumber(start.x)} ${fmtPathNumber(start.y)}${pieces.map((segment) => `C${fmtPathNumber(segment.c1.x)} ${fmtPathNumber(segment.c1.y)} ${fmtPathNumber(segment.c2.x)} ${fmtPathNumber(segment.c2.y)} ${fmtPathNumber(segment.to.x)} ${fmtPathNumber(segment.to.y)}`).join("")}`);
1753
+ }
1754
+ function phaseBoundaries(phases, row, cats, xOf, y, forecast) {
1755
+ let values = cats.map((_, ci) => ({ x: xOf(ci), y: row[ci] })), curvePoints = values.map((point) => ({ x: point.x, y: y(point.y) })), internal = phases.phases.slice(1).map((phase, index) => {
1756
+ let leftIndex = cats.findIndex((category) => category.id === phases.phases[index].to), rightIndex = cats.findIndex((category) => category.id === phase.from), split = forecast.find((boundary) => boundary.categoryIndex === rightIndex), x = split ? forecastBoundaryX(split, xOf, "point") : (xOf(leftIndex) + xOf(rightIndex)) / 2, value = phases.interpolation === "monotone" ? monotoneYAt(values, x) : linearYAt(values, x);
1757
+ return { x, y: y(value), value, leftCategoryId: cats[leftIndex].id, rightCategoryId: cats[rightIndex].id };
1758
+ }), boundaries = [
1759
+ { x: values[0].x, y: curvePoints[0].y, value: values[0].y, leftCategoryId: cats[0].id, rightCategoryId: cats[0].id },
1760
+ ...internal,
1761
+ { x: values[values.length - 1].x, y: curvePoints[curvePoints.length - 1].y, value: values[values.length - 1].y, leftCategoryId: cats[cats.length - 1].id, rightCategoryId: cats[cats.length - 1].id }
1762
+ ], derived = { seriesId: phases.series.id, interpolation: phases.interpolation, pointwiseExact: !0, boundaries: internal.map(({ x, y: boundaryY, leftCategoryId, rightCategoryId }) => ({ x, y: boundaryY, leftCategoryId, rightCategoryId })) };
1763
+ return { curvePoints, boundaries, derived };
1764
+ }
1765
+ function rangePhaseSpans(phases, range, row, cats, xOfValue, y) {
1766
+ let edge = rangeRuns(range, [row], phases.interpolation)[0][0], authored = phases.authored ?? phases.phases, source = new Map(range.categories.map((category, index) => [category.id, index])), values = range.values.get(phases.series.id), fc = phases.series.scenario === "FC" ? 0 : values.findIndex((value) => value.scenario === "FC"), splits = authored.slice(1).map((phase, index) => {
1767
+ let left = source.get(authored[index].to), right = source.get(phase.from);
1768
+ return right === fc && fc > 0 ? range.xs[right - 1] : (range.xs[left] + range.xs[right]) / 2;
1769
+ }), first = edge.points[0].x, last = edge.points[edge.points.length - 1].x, inView = new Map(phases.phases.map((phase) => [phase.id, phase])), drawn = authored.flatMap((phase, index) => {
1770
+ let from = Math.max(first, index === 0 ? -1 / 0 : splits[index - 1]), to = Math.min(last, index === splits.length ? 1 / 0 : splits[index]), visible = inView.get(phase.id);
1771
+ return visible ? [{ phase: visible, from, to }] : to > from ? [{ phase: { ...phase, rank: phase.rank ?? index + 1 }, from, to }] : [];
1772
+ }), spans = drawn.map(({ from, to }) => cutEdge(edge, phases.interpolation, from, to)), stop = (x, value, leftCategoryId, rightCategoryId) => ({ x: xOfValue(x), y: y(value), value, leftCategoryId, rightCategoryId }), boundaries = [
1773
+ stop(drawn[0].from, spans[0].points[0].y, cats[0].id, cats[0].id),
1774
+ ...drawn.map(({ phase, to }, index) => {
1775
+ let span = spans[index], next = drawn[index + 1]?.phase;
1776
+ return next ? stop(to, span.points[span.points.length - 1].y, phase.to, next.from) : stop(to, span.points[span.points.length - 1].y, cats[cats.length - 1].id, cats[cats.length - 1].id);
1777
+ })
1778
+ ], derived = { seriesId: phases.series.id, interpolation: phases.interpolation, pointwiseExact: !0, boundaries: boundaries.slice(1, -1).map(({ x, y: boundaryY, leftCategoryId, rightCategoryId }) => ({ x, y: boundaryY, leftCategoryId, rightCategoryId })) };
1779
+ return {
1780
+ phases: drawn.map(({ phase }) => phase),
1781
+ outside: new Set(drawn.flatMap(({ phase }) => inView.has(phase.id) ? [] : [phase.id])),
1782
+ boundaries,
1783
+ spans: spans.map((span) => mapEdge(span, xOfValue, y)),
1784
+ derived
1785
+ };
1786
+ }
1787
+ function phasePaint(phase, index, paletteRamp, palette) {
1788
+ if (phase.tone) return { ...markRolePaint(phase.tone === "muted" ? "neutral" : phase.tone, !0), tint: 0.62 };
1789
+ let rank = phase.rank ?? index + 1;
1790
+ return paletteRamp ? { ...seriesPaint(rank - 1, palette), tint: 0.62 } : { token: `series-${rank}`, tint: 0.62 };
1791
+ }
1792
+ var PHASE_BAND_TINT = 0.84;
1793
+ function renderPhaseFills(theme, input) {
1794
+ if (!input.phases) return;
1795
+ let phases = input.phases, row = input.pv[input.rowOf.get(phases.series)], ranged = input.range && input.xOfValue ? rangePhaseSpans(phases, input.range, input.range.plotted[input.rowOf.get(phases.series)], input.cats, input.xOfValue, input.y) : void 0, resolved = ranged ?? phaseBoundaries(phases, row, input.cats, input.xOf, input.y, input.forecast), curvePoints = "curvePoints" in resolved ? resolved.curvePoints : [], drawn = ranged?.phases ?? phases.phases, plain = ranged ? phaseBoundaries(phases, row, input.cats, input.xOf, input.y, input.forecast).boundaries : void 0, fills = [], boundaries = [], phaseMarks = [], zeroY = input.y(0), banded = zeroY < input.plot.y - 0.5 || zeroY > input.plot.y + input.plot.h + 0.5;
1796
+ drawn.forEach((phase, index) => {
1797
+ let start = resolved.boundaries[index], end = resolved.boundaries[index + 1];
1798
+ if (banded) {
1799
+ let bandPaint = phasePaint(phase, index, input.paletteRamp, input.palette);
1800
+ fills.push({
1801
+ t: "path",
1802
+ id: `mark:phase:${phase.id}`,
1803
+ d: `M${fmtPathNumber(start.x)} ${fmtPathNumber(input.plot.y)}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.plot.y)}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.plot.y + input.plot.h)}L${fmtPathNumber(start.x)} ${fmtPathNumber(input.plot.y + input.plot.h)}Z`,
1804
+ fill: "tint" in bandPaint ? { ...bandPaint, tint: PHASE_BAND_TINT } : bandPaint,
1805
+ owner: { seriesId: phases.series.id, annotationId: phase.id },
1806
+ part: "phaseFill",
1807
+ display: { value: `${phase.label}: ${input.fmt(start.value)} to ${input.fmt(end.value)}` }
1808
+ });
1809
+ }
1810
+ let span = ranged?.spans[index], top = span ? edgePath(span, linePath) : phases.interpolation === "monotone" ? monotonePathBetween(curvePoints, start, end) : linePath([{ x: start.x, y: start.y }, ...curvePoints.filter((point) => point.x > start.x && point.x < end.x), { x: end.x, y: end.y }]), nodeId = `mark:phase:${phase.id}`;
1811
+ banded || fills.push({ t: "path", id: nodeId, d: `${top}L${fmtPathNumber(end.x)} ${fmtPathNumber(input.baseY)}L${fmtPathNumber(start.x)} ${fmtPathNumber(input.baseY)}Z`, fill: phasePaint(phase, index, input.paletteRamp, input.palette), stroke: { token: "axis" }, width: strokeToken(theme, "hair"), dash: dashToken(theme, "reference"), owner: { seriesId: phases.series.id, annotationId: phase.id }, part: "phaseFill", display: { value: `${phase.label}: ${input.fmt(start.value)} to ${input.fmt(end.value)}` } });
1812
+ let owner = { annotationId: phase.id }, tops = span ? edgePolyline({ ...span, mode: phases.interpolation }) : [start, ...curvePoints.filter((point) => point.x > start.x && point.x < end.x), end];
1813
+ if (!banded)
1814
+ if (!span && phases.interpolation === "monotone" || tops.some((point) => point.y > input.baseY))
1815
+ input.occupied.claim({ x: start.x, y: Math.min(start.y, end.y, input.baseY), w: Math.max(end.x - start.x, 1), h: Math.max(Math.max(start.y, end.y, input.baseY) - Math.min(start.y, end.y, input.baseY), 1) }, "mark", owner);
1816
+ else
1817
+ for (let i = 1; i < tops.length; i++) {
1818
+ let [a, b] = [tops[i - 1], tops[i]], y = Math.min(a.y, b.y);
1819
+ input.occupied.claim(
1820
+ { x: a.x, y, w: Math.max(b.x - a.x, 1), h: Math.max(input.baseY - y, 1) },
1821
+ "mark",
1822
+ owner,
1823
+ void 0,
1824
+ [{ x: a.x, y: a.y }, { x: b.x, y: b.y }, { x: b.x, y: input.baseY }, { x: a.x, y: input.baseY }]
1825
+ );
1826
+ }
1827
+ let labelId = `annotation:phase:${phase.id}`, text = phase.label, measured = input.measure(text, input.tickFont), seatX = (from, to) => Math.max(input.plot.x, Math.min((from + to) / 2 - measured.width / 2, input.plot.x + input.plot.w - measured.width)), x = seatX(start.x, end.x), own = plain ? phases.phases.findIndex((item) => item.id === phase.id) : -1, fallbackXs = own < 0 ? [] : [.../* @__PURE__ */ new Set([
1828
+ seatX(plain[own].x, plain[own + 1].x),
1829
+ seatX(input.xOf(input.cats.findIndex((category) => category.id === phase.to)) - measured.width, input.xOf(input.cats.findIndex((category) => category.id === phase.to))),
1830
+ seatX(input.xOf(input.cats.findIndex((category) => category.id === phase.from)), input.xOf(input.cats.findIndex((category) => category.id === phase.from)) + measured.width)
1831
+ ])].filter((at) => at !== x), headerTop = input.plot.y - input.phaseHeaderHeight;
1832
+ input.labelRequests.push({
1833
+ id: labelId,
1834
+ kind: "annotation",
1835
+ role: "caption",
1836
+ owner: { annotationId: phase.id },
1837
+ text,
1838
+ lines: [text],
1839
+ typeRole: "axis",
1840
+ font: input.tickFont,
1841
+ // A phase with no reading in view yields its name to the phases that have one.
1842
+ fontStep: input.tickFont,
1843
+ priority: ranged?.outside.has(phase.id) ? PRIORITY.extreme - 1 : PRIORITY.extreme,
1844
+ candidates: [
1845
+ { slot: "phaseTop", rect: { x, y: headerTop + 2, w: measured.width, h: measured.height }, penalty: 0 },
1846
+ { slot: "phaseTopLower", rect: { x, y: headerTop + 2 + measured.height, w: measured.width, h: measured.height }, penalty: 1 },
1847
+ ...fallbackXs.map((at, k) => ({ slot: "phaseTop", rect: { x: at, y: headerTop + 2, w: measured.width, h: measured.height }, penalty: 2 + k }))
1848
+ ]
1849
+ });
1850
+ let boundaryNodeId;
1851
+ index < drawn.length - 1 && (boundaryNodeId = `phase-boundary:${phase.id}:${drawn[index + 1].id}`, boundaries.push({ t: "line", id: boundaryNodeId, x1: end.x, y1: input.plot.y, x2: end.x, y2: input.plot.y + input.plot.h, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "reference"), owner: { annotationId: drawn[index + 1].id }, part: "phaseBoundary", display: { value: input.fmt(end.value) } }), input.occupied.claim({ x: end.x - 0.5, y: input.plot.y, w: 1, h: input.plot.h }, "annotation", { annotationId: drawn[index + 1].id })), phaseMarks.push({ id: phase.id, nodeId, fromCategoryId: phase.from, toCategoryId: phase.to, x0: start.x, x1: end.x, y0: start.y, y1: end.y, labelId, ...boundaryNodeId ? { boundaryNodeId } : {} });
1852
+ }), input.marks.phases = phaseMarks;
1853
+ let analytical = input.nodes.splice(input.analyticalSceneStart), areas = analytical.filter((node) => node.part === "area"), baseline = analytical.filter((node) => node.part === "baseline"), foreground = analytical.filter((node) => node.part !== "area" && node.part !== "baseline");
1854
+ return pushAll(input.nodes, fills), pushAll(input.nodes, areas), pushAll(input.nodes, baseline), pushAll(input.nodes, boundaries), pushAll(input.nodes, foreground), resolved.derived;
1855
+ }
1856
+
1857
+ // src/core/charts/line/forecast.ts
1858
+ function forecastBoundaries(series, cats, annotations, phases, stacked) {
1859
+ let turning = series.flatMap((item) => {
1860
+ let start = forecastStart(item, cats);
1861
+ return start > 0 && item.vals.slice(0, start).some((v) => v.v !== null) && item.vals.slice(start).some((v) => v.v !== null) ? [{ start, lastActual: lastActualIndex(item, start, stacked) }] : [];
1862
+ }), transitions = turning.filter((item, index) => turning.findIndex((other) => other.start === item.start && other.lastActual === item.lastActual) === index).sort((a, b) => a.start + a.lastActual - b.start - b.lastActual || a.start - b.start), usedIds = new Set(cats.map((category) => category.id));
1863
+ return transitions.map(({ start: categoryIndex, lastActual }) => {
1864
+ let categoryId = cats[categoryIndex].id, atStart = transitions.filter((item) => item.start === categoryIndex), authored = lastActual === maxOf(atStart.map((item) => item.lastActual)), id = categoryId;
1865
+ if (atStart.length > 1) {
1866
+ for (id = `${categoryId}:from:${lastActual}`; usedIds.has(id); ) id += ":2";
1867
+ usedIds.add(id);
1868
+ }
1869
+ let bands = annotations.filter((ann) => ann.kind === "band" && ann.style === "bracket"), phase = phases?.phases.find((item) => item.from === categoryId);
1870
+ return {
1871
+ categoryIndex,
1872
+ categoryId,
1873
+ id,
1874
+ lastActualIndex: lastActual,
1875
+ labelled: authored && (bands.some((band) => band.from === categoryId && /^(fc|forecast)$/i.test(band.label?.trim() ?? "")) || !!phase && /^(fc|forecast)$/i.test(phase.label.trim())),
1876
+ divided: authored && (!!phase || bands.some((band) => band.from === categoryId && (band.divider === "start" || band.divider === "both") || band.to === cats[categoryIndex - 1].id && (band.divider === "end" || band.divider === "both")))
1877
+ };
1878
+ });
1879
+ }
1880
+ function forecastStroke(paint, theme, crossesBand) {
1881
+ let result = { token: "token" in paint ? paint.token : "neutral", theme: { kind: "line-forecast", base: paint, crossesBand } };
1882
+ return paintColor(theme, result), result;
1883
+ }
1884
+ function forecastDividerAt(domain) {
1885
+ return domain.isArea || domain.fan || domain.phases ? "point" : "band";
1886
+ }
1887
+ function placeForecastHeaders(boundaries, xOf, plot, headerY, font, measure, requests, occupied, header = localeStrings().forecastHeader, boundaryAt = "point", actual) {
1888
+ let measured = measure(header, font), actualSize = actual ? measure(actual, font) : void 0, ordered = [...boundaries].sort((a, b) => forecastBoundaryX(a, xOf, boundaryAt) - forecastBoundaryX(b, xOf, boundaryAt));
1889
+ for (let [index, boundary] of ordered.entries()) {
1890
+ let x = forecastBoundaryX(boundary, xOf, boundaryAt), end = ordered[index + 1] ? forecastBoundaryX(ordered[index + 1], xOf, boundaryAt) : plot.x + plot.w, annotationId = `forecast:${boundary.id}`;
1891
+ if (boundary.divided || occupied.claim({ x: x - 0.5, y: plot.y, w: 1, h: plot.h }, "annotation", { annotationId }, "forecastDivider"), boundary.labelled) continue;
1892
+ let at = (left) => ({ x: Math.max(x, Math.min(left, end - measured.width)), y: headerY + 2, w: measured.width, h: measured.height }), start = index > 0 ? forecastBoundaryX(ordered[index - 1], xOf, boundaryAt) + 4 : plot.x;
1893
+ if (actual && actualSize && ordered.length === 1 && x - 4 - actualSize.width >= start) {
1894
+ let actualId = `forecast:actual:${boundary.id}`;
1895
+ requests.push({
1896
+ id: actualId,
1897
+ kind: "annotation",
1898
+ role: "caption",
1899
+ owner: { annotationId },
1900
+ text: actual,
1901
+ lines: [actual],
1902
+ typeRole: "secondary",
1903
+ font,
1904
+ priority: PRIORITY.valueLine,
1905
+ candidates: [{ slot: "forecastTopActual", rect: { x: x - 4 - actualSize.width, y: headerY + 2, w: actualSize.width, h: actualSize.height }, penalty: 0 }]
1906
+ });
1907
+ }
1908
+ requests.push({
1909
+ id: annotationId,
1910
+ kind: "annotation",
1911
+ role: "caption",
1912
+ owner: { annotationId },
1913
+ text: header,
1914
+ lines: [header],
1915
+ typeRole: "secondary",
1916
+ font,
1917
+ priority: PRIORITY.valueLine,
1918
+ candidates: [
1919
+ { slot: "forecastTop", rect: at(x + 4), penalty: 0 },
1920
+ { slot: "forecastTopStart", rect: at(x), penalty: 1 },
1921
+ { slot: "forecastTopCentre", rect: at((x + end - measured.width) / 2), penalty: 2 },
1922
+ { slot: "forecastTopEnd", rect: at(end - measured.width - 4), penalty: 3 }
1923
+ ]
1924
+ });
1925
+ }
1926
+ }
1927
+ function actualHeader(domain) {
1928
+ if (!domain.isArea) return;
1929
+ let options = domain.options;
1930
+ if (options.strings?.forecastHeader === chartString2({ ...options, strings: void 0 }, "forecastHeader"))
1931
+ return chartString2(options, "actualHeader");
1932
+ }
1933
+ function emitForecastDividers(theme, boundaries, xOf, plot, nodes, at = "point") {
1934
+ for (let boundary of boundaries) {
1935
+ if (boundary.divided) continue;
1936
+ let x = forecastBoundaryX(boundary, xOf, at);
1937
+ nodes.push({
1938
+ t: "line",
1939
+ id: `forecast-divider:${boundary.id}`,
1940
+ x1: x,
1941
+ x2: x,
1942
+ y1: plot.y,
1943
+ y2: plot.y + plot.h,
1944
+ stroke: { token: "leader" },
1945
+ width: strokeToken(theme, "rule"),
1946
+ dash: dashToken(theme, "reference"),
1947
+ owner: { annotationId: `forecast:${boundary.id}` },
1948
+ part: "forecastDivider"
1949
+ });
1950
+ }
1951
+ }
1952
+ function backForecastAreaLabels(labels, series, cats, plot, bandFill, nodes) {
1953
+ for (let label of labels) {
1954
+ if (label.hidden || label.backing || !label.owner.seriesId || !label.owner.categoryId) continue;
1955
+ let dataIdx = series.findIndex((item) => item.id === label.owner.seriesId);
1956
+ if (dataIdx < 0) continue;
1957
+ let owner = series[dataIdx], start = forecastStart(owner, cats), ci = cats.findIndex((cat) => cat.id === label.owner.categoryId), lastActual = ci === start - 1 && label.slot.startsWith("insideBand");
1958
+ if (start < 0 || ci < start && !lastActual) continue;
1959
+ let x = label.rect.x + label.rect.w / 2, y = label.rect.y + label.rect.h / 2;
1960
+ if (!(x < plot.x || x > plot.x + plot.w || y < plot.y || y > plot.y + plot.h)) {
1961
+ if (label.slot.startsWith("insideBand")) {
1962
+ nodes.push({ t: "rect", id: `label-backing:${label.id}`, rect: inflate(label.rect, 1), fill: bandFill(owner, dataIdx, !lastActual), owner: label.owner, part: "labelBacking" });
1963
+ continue;
1964
+ }
1965
+ nodes.push({ t: "rect", id: `plate:${label.id}`, rect: labelPlate(label.rect), fill: { token: "background" }, radius: LABEL_PLATE_RADIUS, owner: label.owner, part: "labelPlate" }), label.halo = !1, "token" in label.ink && (label.ink.token === "ink" || label.ink.token === "inkInverse" || label.ink.theme?.kind === "contrast-ink") && (label.ink = { token: "ink" });
1966
+ }
1967
+ }
1968
+ }
1969
+
1970
+ // src/core/charts/line/means.ts
1971
+ function lineMeans(pv, rowOf, drawnSeries, cats, ownUnits) {
1972
+ let firstVals = pv[rowOf.get(drawnSeries[0])].filter((v) => v !== null), meanValue = firstVals.length > 0 ? firstVals.reduce((a, b) => a + b, 0) / firstVals.length : void 0, catIndex = new Map(cats.map((c, i) => [c.id, i]));
1973
+ return { meanValue, catIndex, meanValueFor: (scope) => {
1974
+ let s = scope.seriesId === void 0 ? drawnSeries[0] : drawnSeries.find((item) => item.id === scope.seriesId);
1975
+ if (!s)
1976
+ return {
1977
+ error: `series '${String(scope.seriesId)}' is not a drawn data series \u2014 the mean must be measured from plotted cells`
1978
+ };
1979
+ let row = pv[rowOf.get(s)], ci0 = 0, ci1 = cats.length - 1;
1980
+ if (scope.from !== void 0 && scope.to !== void 0) {
1981
+ let fi = catIndex.get(scope.from), ti = catIndex.get(scope.to);
1982
+ if (fi === void 0 || ti === void 0)
1983
+ return {
1984
+ error: `category span '${scope.from}'..'${scope.to}' names a category that does not exist`
1985
+ };
1986
+ if (fi > ti)
1987
+ return {
1988
+ error: `category span '${scope.from}'..'${scope.to}' is reversed \u2014 'from' must not come after 'to'`
1989
+ };
1990
+ ci0 = fi, ci1 = ti;
1991
+ }
1992
+ let vals = row.slice(ci0, ci1 + 1).filter((value) => value !== null);
1993
+ return vals.length === 0 ? { error: `series '${s.id}' has no plotted values in the requested span` } : {
1994
+ value: vals.reduce((a, b) => a + b, 0) / vals.length,
1995
+ seriesId: s.id,
1996
+ ...scope.from !== void 0 && scope.to !== void 0 ? { from: scope.from, to: scope.to } : {},
1997
+ ...ownUnits && s.format !== void 0 ? { format: s.format } : {}
1998
+ };
1999
+ } };
2000
+ }
2001
+ function lineValueStats(series, domainEpsilon, population) {
2002
+ return Object.fromEntries(series.map((series2) => {
2003
+ let values = (population?.get(series2.id) ?? series2.vals).flatMap((value) => value.v === null ? [] : [value.v]), range = values.length > 0 ? maxOf(values) - minOf(values) : 0, mean = values.length > 0 ? values.reduce((sum, value) => sum + value, 0) / values.length : 0;
2004
+ return [series2.id, { range, mean, relativeRange: range / Math.max(Math.abs(mean), domainEpsilon) }];
2005
+ }));
2006
+ }
2007
+
2008
+ // src/core/planLineStyle.ts
2009
+ function planLineStyle(scenario, theme) {
2010
+ return scenario === "PL" ? { width: strokeToken(theme, "data"), ink: "ink" } : void 0;
2011
+ }
2012
+
2013
+ // src/core/charts/line/fan.ts
2014
+ function validateDeclaration(input) {
2015
+ let { spec, seriesById, seriesNorm, variant, isArea, rebase100, gapFill } = input, named = [
2016
+ ["fan.of", spec.of],
2017
+ ...spec.bands.flatMap((band, k) => [
2018
+ [`fan.bands[${k}].low`, band.low],
2019
+ [`fan.bands[${k}].high`, band.high]
2020
+ ])
2021
+ ];
2022
+ for (let [path, id] of named)
2023
+ if (!seriesById.has(id)) throw new NormalizeError("fan-series-unknown", path, `fan names unknown series '${id}' \u2014 a band is DECLARED DATA, so every bound must exist in data.series`, `add a series with id '${id}', or point this bound at one of: ${seriesNorm.map((s) => `'${s.id}'`).join(", ")}`);
2024
+ spec.bands.forEach((band, k) => {
2025
+ if (typeof band.label != "string" || band.label.trim() === "") throw new NormalizeError("fan-band-unlabelled", `fan.bands[${k}].label`, `fan.bands[${k}] has no label \u2014 '80% predictive interval' and 'min/max of three scenarios' draw the same band and mean different things`, "add a label that says what the interval means, such as '80% predictive interval'");
2026
+ });
2027
+ let seen = /* @__PURE__ */ new Map([[spec.of, "fan.of"]]);
2028
+ for (let [path, id] of named.slice(1)) {
2029
+ let first = seen.get(id);
2030
+ if (first !== void 0) throw new NormalizeError("fan-series-reused", path, `series '${id}' is used twice by the fan (${first} and ${path}) \u2014 each bound and the centre must be its own series, or the bands drawn are not the bands declared`, "give each band its own low/high series; a shared bound means two intervals claim the same numbers");
2031
+ seen.set(id, path);
2032
+ }
2033
+ if (spec.bands.length > 4) throw new NormalizeError("fan-too-many-bands", "fan.bands", `${spec.bands.length} bands exceed the four the tint ladder can keep apart \u2014 past four the washes are indistinguishable and the exhibit claims a precision the reader cannot see`, "four nested intervals is the legibility limit; drop or merge bands");
2034
+ if (variant === "stacked-area" || variant === "stacked100-area") throw new NormalizeError("fan-composition-conflict", "variant", `variant '${variant}' stacks each series onto the ones below it; a band around one member of a composition bounds nothing the reader can see, because the member's own position depends on its neighbours' values`, "use variant 'line' for a fan, and a separate exhibit for the composition");
2035
+ if (isArea) throw new NormalizeError("fan-area-conflict", "variant", `variant '${variant}' fills from the trajectory down to the baseline with an opaque fill that paints OVER the lower half of every band \u2014 the reader would see only the upper edge of each interval, i.e. a one-sided uncertainty, while the legend key beside it names the whole interval`, "use variant 'line' for a fan \u2014 the fan IS the fill, and a second fill under it hides half of what it declares");
2036
+ if (rebase100) throw new NormalizeError("fan-rebase-conflict", "rebase100", "rebase100 divides EACH series by its OWN value at the base category, so the bounds and the centre are rescaled by different divisors and the bands stop nesting \u2014 the fan would still be drawn, and would be wrong", "rebase the numbers before authoring them, so centre and bounds share one base, or drop rebase100");
2037
+ if (gapFill) throw new NormalizeError("fan-gapfill-conflict", "gapFill", "gapFill and fan are two wash systems in one plot \u2014 a reader cannot tell an uncertainty band from a shaded difference, and the picture would answer neither question", "keep the fan and drop gapFill, or split them into two exhibits");
2038
+ }
2039
+ function buildBands(input) {
2040
+ let { spec, seriesById, cats, pv, rowOf } = input, catLabel = (ci) => cats[ci].label ?? cats[ci].id, bands = spec.bands.map((band) => ({
2041
+ low: seriesById.get(band.low),
2042
+ high: seriesById.get(band.high),
2043
+ label: band.label,
2044
+ widths: cats.map(() => null)
2045
+ }));
2046
+ return bands.forEach((band, k) => {
2047
+ let lowRow = pv[rowOf.get(band.low)], highRow = pv[rowOf.get(band.high)];
2048
+ cats.forEach((_, ci) => {
2049
+ let lo = lowRow[ci], hi = highRow[ci];
2050
+ if (!(lo === null || hi === null)) {
2051
+ if (lo > hi) throw new NormalizeError(
2052
+ "fan-band-inverted",
2053
+ `fan.bands[${k}]`,
2054
+ `band '${band.label}' is inverted at category '${catLabel(ci)}': low '${band.low.id}' = ${lo} is above high '${band.high.id}' = ${hi}`,
2055
+ "swap the low and high series ids for this band \u2014 the engine will not swap them for you, because a silently corrected bound hides which series is actually which"
2056
+ );
2057
+ band.widths[ci] = hi - lo;
2058
+ }
2059
+ });
2060
+ }), bands;
2061
+ }
2062
+ function validateNesting(input) {
2063
+ let { bands, cats, pv, rowOf } = input, row = (series) => pv[rowOf.get(series)];
2064
+ for (let k = 0; k + 1 < bands.length; k++) {
2065
+ let outer = bands[k], inner = bands[k + 1], [oLow, oHigh, iLow, iHigh] = [row(outer.low), row(outer.high), row(inner.low), row(inner.high)];
2066
+ for (let ci = 0; ci < cats.length; ci++) {
2067
+ let [ol, oh, il, ih] = [oLow[ci], oHigh[ci], iLow[ci], iHigh[ci]];
2068
+ if (!(ol === null || oh === null || il === null || ih === null) && (ol > il || oh < ih))
2069
+ throw new NormalizeError(
2070
+ "fan-bands-crossed",
2071
+ `fan.bands[${k + 1}]`,
2072
+ `bands are not nested at category '${cats[ci].label ?? cats[ci].id}': band ${k} '${outer.label}' spans ${ol}..${oh} and does not contain band ${k + 1} '${inner.label}' spanning ${il}..${ih} \u2014 bands must be authored OUTERMOST FIRST`,
2073
+ "reorder the bands outermost-first in the document, or fix the bound values; the engine will not reorder them, because a reordered fan hides an authoring error the reader can never see"
2074
+ );
2075
+ }
2076
+ }
2077
+ }
2078
+ function validateCenter(input) {
2079
+ let { of, ofRow, band, cats, pv, rowOf } = input, low = pv[rowOf.get(band.low)], high = pv[rowOf.get(band.high)];
2080
+ for (let ci = 0; ci < cats.length; ci++) {
2081
+ let [center, lo, hi] = [ofRow[ci], low[ci], high[ci]];
2082
+ if (!(center === null || lo === null || hi === null) && (center < lo || center > hi))
2083
+ throw new NormalizeError(
2084
+ "fan-center-outside-band",
2085
+ "fan.of",
2086
+ `the central series '${of.id}' = ${center} at category '${cats[ci].label ?? cats[ci].id}' lies outside its innermost band '${band.label}' (${lo}..${hi}) \u2014 the centre and the bounds do not describe the same quantity`,
2087
+ "check that fan.of names the central trajectory and that the bound series are aligned to the same categories; a fan whose centre escapes its own interval is drawing two different series as one"
2088
+ );
2089
+ }
2090
+ }
2091
+ function resolveFan(input) {
2092
+ let { spec, seriesById, seriesNorm, cats, variant, isArea, rebase100, gapFill, pv, rowOf, warnings } = input;
2093
+ if (!spec) return null;
2094
+ validateDeclaration({ spec, seriesById, seriesNorm, variant, isArea, rebase100, gapFill });
2095
+ let of = seriesById.get(spec.of), ofRow = pv[rowOf.get(of)];
2096
+ if (ofRow.every((value) => value === null)) throw new NormalizeError("fan-center-empty", "fan.of", `the central series '${of.id}' is null in every category \u2014 a fan with no trajectory is bands around nothing`, "give the central series values, or point fan.of at the series that carries the projection");
2097
+ let bands = buildBands({ spec, seriesById, cats, pv, rowOf });
2098
+ validateNesting({ bands, cats, pv, rowOf }), validateCenter({ of, ofRow, band: bands[bands.length - 1], cats, pv, rowOf });
2099
+ let boundIds = new Set(bands.flatMap((band) => [band.low.id, band.high.id])), origin = null;
2100
+ for (let ci = 0; ci < cats.length && origin === null; ci++)
2101
+ bands.some((band) => (band.widths[ci] ?? 0) > 0) && (origin = cats[ci].id);
2102
+ let row = (series) => pv[rowOf.get(series)], undeclaredAt = cats.filter((_, ci) => bands.some((band) => row(band.low)[ci] === null || row(band.high)[ci] === null)).map((category) => category.id);
2103
+ return origin === null && warnings.push({
2104
+ code: "fan-degenerate",
2105
+ severity: "warn",
2106
+ message: "every fan band has low === high in every category, so there is no interval to wash \u2014 the bounds are drawn as ordinary series instead of as a fan",
2107
+ suggest: "drop options.fan if the bounds are meant to coincide, or supply bounds that differ from each other"
2108
+ }), { of, bands, showBounds: spec.showBounds === !0, origin, boundIds, undeclaredAt };
2109
+ }
2110
+ function outerFanEdge(domain, bands) {
2111
+ let byId = new Map(domain.seriesNorm.map((series) => [series.id, series])), rowOfId = (id) => domain.pv[domain.rowOf.get(byId.get(id))];
2112
+ return bands.flatMap((band, index) => {
2113
+ let low = rowOfId(band.low), high = rowOfId(band.high);
2114
+ for (let ci = low.length - 1; ci >= 0; ci--) if (low[ci] !== null && high[ci] !== null) return [{ index, ci, low: low[ci], high: high[ci] }];
2115
+ return [];
2116
+ }).sort((a, b) => Math.abs(b.high - b.low) - Math.abs(a.high - a.low))[0];
2117
+ }
2118
+ function fanGapNote(fan, cats, strings) {
2119
+ if (!fan || fan.origin === null || fan.undeclaredAt.length === 0) return [];
2120
+ let label = (id) => cats.find((category) => category.id === id)?.label ?? id;
2121
+ return [disclosureNote(stringFields(strings?.fanGap ?? localeStrings().fanGap, { categories: fan.undeclaredAt.map(label).join(", ") }))];
2122
+ }
2123
+ function buildFanPaints(input) {
2124
+ let { fan, drawnSeries, seriesPaint: seriesPaint2, theme, anyHighlight, highlights } = input;
2125
+ if (!fan || fan.origin === null) return { fanLadder: [], fanCentrePaint: null, fanPaints: !1 };
2126
+ let centrePaint = seriesPaint2(fan.of, Math.max(0, drawnSeries.indexOf(fan.of)));
2127
+ return { fanLadder: fanPaintSteps(theme, centrePaint, fan.bands.length, fan.showBounds, fan.of.id, anyHighlight && !highlights.has(fan.of.id)).map((step, index) => ({ ...step, paint: {
2128
+ token: "token" in centrePaint ? centrePaint.token : "highlight",
2129
+ theme: { kind: "fan-step", base: centrePaint, bandCount: fan.bands.length, showBounds: fan.showBounds, index, seriesId: fan.of.id, deEmphasized: anyHighlight && !highlights.has(fan.of.id) }
2130
+ } })), fanCentrePaint: centrePaint, fanPaints: !0 };
2131
+ }
2132
+ function fanBoundText(lo, hi, fmt, spec) {
2133
+ let a = fmt(lo), b = fmt(hi);
2134
+ if (a !== b || !(hi > lo)) return [a, b];
2135
+ let plain = { ...defaultFormatSpec(spec.locale), thousandsSep: spec.thousandsSep };
2136
+ for (let digits = 1; digits <= 15; digits++)
2137
+ if (lo.toFixed(digits) !== hi.toFixed(digits)) return [formatWithSpec(lo, { ...plain, decimals: digits }), formatWithSpec(hi, { ...plain, decimals: digits })];
2138
+ return [formatExactNumber(lo, spec.locale), formatExactNumber(hi, spec.locale)];
2139
+ }
2140
+ function collectRuns(input) {
2141
+ let { lowRow, highRow, cats, compositionInvalidAt, xOf, y, gapCats } = input, runs = [], current = [];
2142
+ return cats.forEach((_, ci) => {
2143
+ let lo = lowRow[ci], hi = highRow[ci];
2144
+ if (lo === null || hi === null || compositionInvalidAt(ci)) {
2145
+ (lo === null || hi === null) && gapCats.add(cats[ci].id), current.length > 0 && runs.push(current), current = [];
2146
+ return;
2147
+ }
2148
+ current.push({ ci, x: xOf(ci), yLow: y(lo), yHigh: y(hi) });
2149
+ }), current.length > 0 && runs.push(current), runs;
2150
+ }
2151
+ function addFanRun(theme, input) {
2152
+ let { run, runIndex, band, bandIndex, lowRow, highRow, cats, interpolation, fanLadder, showBounds, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, occupied, fanNodes, hairNodes, gapCats } = input;
2153
+ if (run.length < 2) {
2154
+ for (let point of run) gapCats.add(cats[point.ci].id);
2155
+ return null;
2156
+ }
2157
+ let upper = input.edges?.[0]?.points ?? run.map((point) => ({ x: point.x, y: point.yHigh })), lower = input.edges?.[1]?.points ?? run.map((point) => ({ x: point.x, y: point.yLow })), upperPath = input.edges ? edgePath(input.edges[0], (points) => pathFor2([...points], interpolation)) : pathFor2(upper, interpolation), lowerCurve = input.edges?.[1]?.curve, reverse = lowerCurve ? [...lowerCurve].reverse().map((c) => `C${fmtPathNumber(c.c2.x)} ${fmtPathNumber(c.c2.y)} ${fmtPathNumber(c.c1.x)} ${fmtPathNumber(c.c1.y)} ${fmtPathNumber(c.from.x)} ${fmtPathNumber(c.from.y)}`).join("") : reversePathTail2(lower, interpolation), nodeId = `mark:fan:${bandIndex}:${runIndex}`, widestAt = run[0].ci;
2158
+ for (let point of run) (band.widths[point.ci] ?? 0) > (band.widths[widestAt] ?? 0) && (widestAt = point.ci);
2159
+ let [loText, hiText] = fanBoundText(lowRow[widestAt], highRow[widestAt], fmt, input.numberSpec);
2160
+ fanNodes.push({
2161
+ t: "path",
2162
+ id: nodeId,
2163
+ d: `${upperPath}L${fmtPathNumber(lower[lower.length - 1].x)} ${fmtPathNumber(lower[lower.length - 1].y)}${reverse}Z`,
2164
+ fill: fanLadder[bandIndex].paint,
2165
+ owner: {},
2166
+ part: "fanBand",
2167
+ display: { value: `${band.label}: ${numberRange(loText, hiText)} at ${cats[widestAt].label ?? cats[widestAt].id}${(band.widths[widestAt] ?? 0) > 0 ? " (widest)" : ""}` }
2168
+ });
2169
+ for (let k = 0; k + 1 < run.length; k++) {
2170
+ let a = run[k], b = run[k + 1], top = Math.min(a.yHigh, b.yHigh), bottom = Math.max(a.yLow, b.yLow);
2171
+ occupied.claim({ x: Math.min(a.x, b.x), y: top, w: Math.max(Math.abs(b.x - a.x), 1), h: Math.max(bottom - top, 1) }, "mark", {}, "fanBand");
2172
+ }
2173
+ if (showBounds) {
2174
+ let hairPaint = fanLadder[bandIndex + 1].paint;
2175
+ for (let [edge, points] of [["high", upper], ["low", lower]]) hairNodes.push({
2176
+ t: "path",
2177
+ id: `mark:fan-bound:${bandIndex}:${edge}:${runIndex}`,
2178
+ d: input.edges ? edgePath(input.edges[edge === "high" ? 0 : 1], (pts) => pathFor2([...pts], interpolation)) : pathFor2(points, interpolation),
2179
+ stroke: hairPaint,
2180
+ width: strokeToken(theme, "rule"),
2181
+ dash: dashToken(theme, "dotted"),
2182
+ lineCap: "round",
2183
+ owner: { seriesId: edge === "high" ? band.high.id : band.low.id },
2184
+ part: "fanBound",
2185
+ display: { value: `${band.label} ${edge}: ${fmt((edge === "high" ? highRow : lowRow)[widestAt])}` }
2186
+ });
2187
+ }
2188
+ return nodeId;
2189
+ }
2190
+ function renderFanWashes(theme, input) {
2191
+ let { fan, fanPaints, fanLadder, interpolationFor, pv, rowOf, cats, compositionInvalidAt, xOf, y, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, numberSpec, occupied, warnings, nodes, marks, analyticalSceneStart } = input;
2192
+ if (!fan || !fanPaints) return;
2193
+ let interpolation = interpolationFor(fan.of), fanNodes = [], hairNodes = [], fanMarks = [], gapCats = /* @__PURE__ */ new Set();
2194
+ if (fan.bands.forEach((band, bandIndex) => {
2195
+ let lowRow = pv[rowOf.get(band.low)], highRow = pv[rowOf.get(band.high)];
2196
+ input.range && cats.forEach((cat, ci) => {
2197
+ (lowRow[ci] === null || highRow[ci] === null) && gapCats.add(cat.id);
2198
+ });
2199
+ let edges = input.range && input.xOfValue ? rangeRuns(input.range, [input.range.plotted[rowOf.get(band.high)], input.range.plotted[rowOf.get(band.low)]], interpolation).map((run) => run.map((edge) => mapEdge(edge, input.xOfValue, y))) : void 0, nodeIds = (edges ? edges.map((run) => run[0].points.map((p, i) => ({ ci: p.ci, x: p.x, yHigh: p.y, yLow: run[1].points[i].y }))) : collectRuns({ lowRow, highRow, cats, compositionInvalidAt, xOf, y, gapCats })).map((run, runIndex) => addFanRun(theme, { ...edges ? { edges: edges[runIndex] } : {}, run, runIndex, band, bandIndex, lowRow, highRow, cats, interpolation, fanLadder, showBounds: fan.showBounds, pathFor: pathFor2, reversePathTail: reversePathTail2, fmt, numberSpec, occupied, fanNodes, hairNodes, gapCats })).filter((id) => id !== null);
2200
+ nodeIds.length > 0 && fanMarks.push({ bandIndex, nodeIds, low: band.low.id, high: band.high.id, label: band.label });
2201
+ }), gapCats.size > 0 && warnings.push({
2202
+ code: "fan-band-gap",
2203
+ severity: "warn",
2204
+ message: `a fan band has no drawable run at ${[...gapCats].map((id) => `'${id}'`).join(", ")} \u2014 a category where either bound is null ends the band there rather than bridging an interval that was never declared`,
2205
+ suggest: "supply both bounds at those categories, or accept the break"
2206
+ }), fanNodes.length === 0) return;
2207
+ marks.fan = fanMarks;
2208
+ let analyticalNodes = nodes.splice(analyticalSceneStart), areas = analyticalNodes.filter((node) => node.part === "area"), baseline = analyticalNodes.filter((node) => node.part === "baseline"), foreground = analyticalNodes.filter((node) => node.part !== "area" && node.part !== "baseline");
2209
+ pushAll(nodes, fanNodes), pushAll(nodes, areas), pushAll(nodes, hairNodes), pushAll(nodes, baseline), pushAll(nodes, foreground);
2210
+ }
2211
+
2212
+ // src/core/charts/line/paints.ts
2213
+ var MARKER_MAX_CATS = 12, BUMP_SHAPES = ["circle", "square", "triangle", "diamond"], BUMP_DASH_ROLES = [void 0, "reference", "dotted"], CONTEXT_LADDER_INK_SHARE = [0, 0.25, 0.45, 0.6, 0.72], LINE_GREY_LADDER_INK_SHARE = [0.65, 0.4, 0.78, 0.52], LINE_GREY_SHAPES = ["square", "diamond", "triangle"], HIGHLIGHT_FADE = 0.5, FADE_PAGE_FLOOR = 1.4, fadedPaint = (paint) => {
2214
+ let mixed = mixedPaint(paint, { token: "background" }, HIGHLIGHT_FADE, "token" in paint ? paint.token : "neutralLight");
2215
+ return "theme" in mixed && mixed.theme?.kind === "mix" ? { ...mixed, theme: { ...mixed.theme, pageFloor: FADE_PAGE_FLOOR } } : mixed;
2216
+ };
2217
+ function lineText(env, domain) {
2218
+ let { options, valueSpec, fmt } = domain, kindSetting = (kind) => {
2219
+ let l = options.labels;
2220
+ if (l === !1) return kind === "category" && labelsOffKeepsNames(options);
2221
+ let v = l?.[kind];
2222
+ return v === void 0 ? !0 : v;
2223
+ }, contentOf = (kind, dflt) => {
2224
+ let s = kindSetting(kind);
2225
+ return s === !1 ? null : Array.isArray(s) ? s : dflt;
2226
+ }, compose = (extra) => (content, abs, pct, catLabel, serLabel, unitSuffix = "", authoredPct = !1, source, categoryId) => {
2227
+ let parts = [], shareText = !authoredPct && source && categoryId !== void 0 ? domain.shareTexts.get(`${categoryId}\0${source.id}`) : void 0, lifted = (value, percent) => {
2228
+ let spec = seriesRasterFormatter(source?.format ?? options.format, domain.seriesNorm.flatMap((s) => s.vals.map((v) => v.v)), options.locale?.language, source?.unit ?? options.unit, options.target).spec;
2229
+ return formatWithSpec(value, {
2230
+ ...spec,
2231
+ decimals: Math.min(20, spec.decimals + extra),
2232
+ wholeFrom: void 0,
2233
+ currencyWhole: void 0,
2234
+ ...percent && !source?.format && !options.format ? { suffix: "%" } : {}
2235
+ });
2236
+ };
2237
+ for (let c of content)
2238
+ c === "absolute" && abs !== null ? parts.push(withUnit(extra ? lifted(abs, authoredPct) : (authoredPct && source && !source.format ? valueSpec.fmtPercent : source ? valueSpec.forSeries(source) : fmt)(abs), unitSuffix, !0)) : c === "percent" && pct !== null ? parts.push(shareText ?? (extra ? formatAutomaticPercent(pct, Math.min(20, (authoredPct ? Math.abs(pct) < 1 && pct !== 0 ? 1 : 0 : shareDecimals(pct)) + extra), !1, options.locale?.language) : authoredPct ? env.authoredPctFmt(pct) : env.pctFmt(pct))) : c === "category" && catLabel ? parts.push(catLabel) : c === "series" && serLabel && parts.push(serLabel);
2239
+ return parts.join(" ");
2240
+ }, composeText = compose(0), endExtra = env.isBump ? 0 : distinctDecimalLift(domain.drawnSeries.flatMap((series) => {
2241
+ let ci = domain.lastIdxOf.get(series.id);
2242
+ if (ci === void 0) return [];
2243
+ if (domain.shareTexts.has(`${domain.cats[ci].id}\0${series.id}`)) return [];
2244
+ let share = domain.variant === "stacked100-area", value = share ? domain.endpoints[series.id]?.value ?? null : domain.rebased ? domain.pv[domain.rowOf.get(series)][ci] : domain.absOf(series, ci);
2245
+ if (value === null) return [];
2246
+ let cell = series.vals[ci], source = domain.rebased ? void 0 : cell.format ? { ...series, format: cell.format } : series;
2247
+ return [{ value, format: (extra) => compose(extra)(share ? ["percent"] : ["absolute"], value, value, "", "", "", cell.isPct, source) }];
2248
+ })), composeEndText = endExtra ? compose(endExtra) : composeText, printsZero = (abs, authoredPct = !1, source) => valueSpec.roundsToZeroAt(abs, authoredPct && source && !source.format ? {} : source), { theme, measure } = env, tickFont = { family: theme.type.family, ...theme.type.axis }, labelFont = { family: theme.type.family, ...theme.type.label }, nameFont = labelFont;
2249
+ return { kindSetting, contentOf, composeText, composeEndText, printsZero, tickFont, secondaryFont: secondaryFont(theme), labelFont, nameFont, labelH: measure("0", labelFont).height };
2250
+ }
2251
+ function heroPlan(env, domain, warnings) {
2252
+ let { drawnSeries, fan, variant, options } = domain, activeFan = fan != null && fan.origin !== null, emphasis = options.emphasis ?? (activeFan ? "first" : "none"), heroEligible = !env.isBump && variant === "line" && // An active fan's centre is the subject even as the only drawn line (the
2253
+ // bounds are not in drawnSeries), so it stays eligible.
2254
+ (drawnSeries.length >= 2 || activeFan) && !env.anyHighlight && !env.paletteRamp && drawnSeries.every((s) => !s.fill && !s.colorRole && !s.scenario), heroMode = emphasis === "first" && heroEligible;
2255
+ options.emphasis === "first" && !heroMode && warnings.push({
2256
+ code: "line-emphasis-ignored",
2257
+ severity: "warn",
2258
+ message: "emphasis 'first' needs two or more plain lines; a single drawn series, a highlight, palette, series fill, colorRole or series-level scenario, or an area or bump variant keeps its own colours",
2259
+ suggest: "remove emphasis, or use highlight to pick the series that leads"
2260
+ });
2261
+ let heroId = heroMode ? fan && fan.origin !== null ? fan.of.id : drawnSeries[0].id : null;
2262
+ return !env.isBump && variant === "line" && !heroMode && !env.anyHighlight && drawnSeries.length > 3 && warnings.push({
2263
+ code: "line-peer-overload",
2264
+ severity: "info",
2265
+ message: `${drawnSeries.length} peer-styled lines are hard to follow \u2014 highlight one series, set emphasis 'first', or facet into small multiples (grid repeat)`
2266
+ }), { heroMode, heroId };
2267
+ }
2268
+ function bumpIdentity(env, domain, warnings) {
2269
+ let bumpRampLen = Math.max(1, (env.paletteRamp ?? env.theme.color.series).length), slot = (dataIdx) => {
2270
+ let shapeWrap = Math.floor(dataIdx / bumpRampLen), dashRole = BUMP_DASH_ROLES[Math.floor(shapeWrap / BUMP_SHAPES.length) % BUMP_DASH_ROLES.length];
2271
+ return {
2272
+ color: dataIdx % bumpRampLen,
2273
+ shape: BUMP_SHAPES[shapeWrap % BUMP_SHAPES.length],
2274
+ dash: dashRole ? dashToken(env.theme, dashRole) : void 0
2275
+ };
2276
+ };
2277
+ if (!env.isBump) return slot;
2278
+ let capacity = bumpRampLen * BUMP_SHAPES.length * BUMP_DASH_ROLES.length, autoIdentity = domain.dataSeries.filter((s) => !s.fill).length;
2279
+ if (autoIdentity > capacity)
2280
+ throw new NormalizeError(
2281
+ "bump-identity-exhausted",
2282
+ "series",
2283
+ `${autoIdentity} entities exceed the ${capacity} distinguishable identities theme '${env.theme.name}' can give a rank line (${bumpRampLen} ramp colours x ${BUMP_SHAPES.length} marker shapes x ${BUMP_DASH_ROLES.length} line styles) \u2014 past that two entities would be drawn identically and a crossing between them could not be read at all`,
2284
+ "rank fewer entities, give the extra series an explicit `fill`, or facet into small multiples with grid repeat"
2285
+ );
2286
+ if (autoIdentity > bumpRampLen) {
2287
+ let channels = autoIdentity > bumpRampLen * BUMP_SHAPES.length ? "the TRIPLE (colour, marker shape, line style)" : "the PAIR (colour, marker shape)";
2288
+ warnings.push({
2289
+ code: "bump-identity-crowded",
2290
+ severity: "info",
2291
+ message: `${autoIdentity} entities exceed the ${bumpRampLen}-colour ramp \u2014 identity is ${channels} from entity ${bumpRampLen + 1} on, so two lines of the same colour are told apart by their markers`
2292
+ });
2293
+ }
2294
+ return slot;
2295
+ }
2296
+ function bumpStoryPaintsOf(env, domain, grey) {
2297
+ if (!env.isBump || !env.anyHighlight || !grey) return;
2298
+ let story = [...env.highlights].filter((id) => domain.drawnSeries.some((s) => s.id === id));
2299
+ if (story.length === 0) return;
2300
+ let paints = bumpStoryPaints(env.theme, Math.min(story.length, 2));
2301
+ return {
2302
+ paintOf: (id) => {
2303
+ let index = story.indexOf(id);
2304
+ if (index < 0) return { token: "neutralLight" };
2305
+ if (index < 2) return paints[index];
2306
+ let paint = { token: "focus", theme: { kind: "bump-story", index, count: story.length } };
2307
+ return paintColor(env.theme, paint), paint;
2308
+ },
2309
+ isContext: (s) => !env.highlights.has(s.id) && !s.colorRole && !s.fill
2310
+ };
2311
+ }
2312
+ function linePaints(env, domain, warnings) {
2313
+ let { theme, highlights, anyHighlight, isBump, paletteRamp } = env, { options, cats, drawnSeries, dataSeries, isStacked, isArea, pv, rowOf } = domain, palette = paletteRamp ? options.palette : void 0, fade = anyHighlight && options.highlightMode === "fade", grey = (anyHighlight || drawnSeries.some((s) => !s.fill && s.colorRole === "highlight")) && !fade, faded = (paint, s) => fade && !highlights.has(s.id) ? fadedPaint(paint) : paint, css = (paint) => paintColor(theme, paint), markersOff = theme.marks?.lineMarkers === "none", paintCategoryIndex = new Map(cats.map((category, index) => [category.id, index])), shadedBandRanges = (options.annotations ?? []).flatMap((annotation) => {
2314
+ if (annotation.kind !== "band" || (annotation.style ?? "shade") !== "shade") return [];
2315
+ if (annotation.from === void 0 || annotation.to === void 0) return [];
2316
+ let from = paintCategoryIndex.get(annotation.from), to = paintCategoryIndex.get(annotation.to);
2317
+ return from === void 0 || to === void 0 ? [] : [[Math.min(from, to), Math.max(from, to)]];
2318
+ }), seriesCrossesShadedBand = (series2) => {
2319
+ if (shadedBandRanges.length === 0) return !1;
2320
+ if (isStacked) return !0;
2321
+ let indices = pv[rowOf.get(series2)].flatMap((value, index) => value === null ? [] : [index]);
2322
+ if (indices.some((index) => shadedBandRanges.some(([from, to]) => index >= from && index <= to))) return !0;
2323
+ for (let position = 1; position < indices.length; position++) {
2324
+ let left = indices[position - 1], right = indices[position];
2325
+ if (!(!series2.interpolateGaps && right !== left + 1) && shadedBandRanges.some(([from, to]) => left <= to && right >= from))
2326
+ return !0;
2327
+ }
2328
+ return !1;
2329
+ }, bandRules = /* @__PURE__ */ new Map(), shadeSafeStroke = (paint, series2, authored = paint) => {
2330
+ if (!seriesCrossesShadedBand(series2)) return paint;
2331
+ let authoredSource = series2.fill ? "fill" : anyHighlight && highlights.has(series2.id) ? "highlight" : null, source = { kind: "line-band", base: paint, seriesId: series2.id }, result = { token: "token" in paint ? paint.token : "inkMuted", theme: source };
2332
+ return css(result), authoredSource && bandRules.set(series2.id, { kind: "line-band-authored-contrast", base: paint, seriesId: series2.id, authoredSource, ...authored !== paint ? { authored } : {} }), result;
2333
+ }, areaLead = isArea && !isStacked && drawnSeries.length > 1 ? drawnSeries.find((s) => highlights.has(s.id) || s.colorRole === "highlight") ?? drawnSeries[0] : void 0;
2334
+ areaLead && warnings.push({
2335
+ code: "line-area-lead",
2336
+ severity: "info",
2337
+ message: `the area variant fills one series when it draws several, so no fill hides another or reads as a stacked band: '${areaLead.label}' is filled and the other ${drawnSeries.length - 1 === 1 ? "series is a line" : `${drawnSeries.length - 1} series are lines`}`,
2338
+ suggest: "highlight the series to fill; use variant 'stacked-area' when the series add up to a total, or 'line' to compare them as peers"
2339
+ });
2340
+ let areaFilled = (s) => isArea && !domain.phases && (areaLead === void 0 || s.id === areaLead.id), { heroMode, heroId } = heroPlan(env, domain, warnings), bumpSlot = bumpIdentity(env, domain, warnings), bumpStory = bumpStoryPaintsOf(env, domain, grey), contextRank = /* @__PURE__ */ new Map();
2341
+ for (let s of drawnSeries)
2342
+ (grey ? !highlights.has(s.id) && !s.colorRole && !s.fill : heroMode && s.id !== heroId) && contextRank.set(s.id, contextRank.size);
2343
+ let plainGrey = grey && !isBump && (domain.variant === "line" || areaLead !== void 0) && drawnSeries.every((s) => highlights.has(s.id) || contextRank.has(s.id) || s.colorRole === "highlight" || areaFilled(s)), contextRungCount = Math.min(CONTEXT_LADDER_INK_SHARE.length, contextRank.size), ladderPaint = (inkShare) => inkShare === 0 ? { token: "neutralLight" } : mixedPaint({ token: "neutralLight" }, { token: "markInk" }, 1 - inkShare, "neutralLight"), linesCross = (a, b) => {
2344
+ let rowA = pv[rowOf.get(a)], rowB = pv[rowOf.get(b)];
2345
+ return new Set(rowA.flatMap((value, index) => {
2346
+ let other = rowB[index];
2347
+ return value === null || other === null || other === void 0 || value === other ? [] : [Math.sign(value - other)];
2348
+ })).size === 2;
2349
+ }, contextSeries = drawnSeries.filter((s) => contextRank.has(s.id)), darkShare = (s) => LINE_GREY_LADDER_INK_SHARE[contextRank.get(s.id) % LINE_GREY_LADDER_INK_SHARE.length], crossingPairs = plainGrey && !isStacked ? contextSeries.flatMap((a, i) => contextSeries.slice(i + 1).filter((b) => linesCross(a, b)).map((b) => [darkShare(a), darkShare(b)])) : [], ladder = plainGrey && crossingPairs.every(([a, b]) => palettePerceptualDistance(css(ladderPaint(a)), css(ladderPaint(b))) >= PALETTE_NORMAL_FLOOR) ? LINE_GREY_LADDER_INK_SHARE : CONTEXT_LADDER_INK_SHARE, top = CONTEXT_LADDER_INK_SHARE[CONTEXT_LADDER_INK_SHARE.length - 1], ladderPaintOf = /* @__PURE__ */ new Map();
2350
+ for (let s of drawnSeries) {
2351
+ let rank = contextRank.get(s.id);
2352
+ if (rank === void 0) continue;
2353
+ let apartFrom = isStacked ? [] : drawnSeries.flatMap((other) => {
2354
+ let paint = ladderPaintOf.get(other.id);
2355
+ return paint && linesCross(s, other) ? [paint] : [];
2356
+ });
2357
+ if (crossingPairs.length > 0) {
2358
+ let result = { token: "neutralLight", theme: { kind: "line-apart", share: CONTEXT_LADDER_INK_SHARE[rank % CONTEXT_LADDER_INK_SHARE.length], top, apartFrom, darker: { share: darkShare(s), pairs: crossingPairs } } };
2359
+ css(result), ladderPaintOf.set(s.id, result);
2360
+ continue;
2361
+ }
2362
+ let share = ladder[rank % ladder.length];
2363
+ ladderPaintOf.set(s.id, apartFrom.length === 0 ? ladderPaint(share) : {
2364
+ token: "neutralLight",
2365
+ theme: { kind: "line-apart", share, top, apartFrom }
2366
+ });
2367
+ }
2368
+ let contextPaint = (s) => {
2369
+ let rank = (contextRank.get(s.id) ?? 0) % CONTEXT_LADDER_INK_SHARE.length;
2370
+ if (seriesCrossesShadedBand(s)) {
2371
+ let result = { token: "neutralLight", theme: { kind: "line-context", rank, rungCount: contextRungCount, seriesId: s.id } };
2372
+ return css(result), result;
2373
+ }
2374
+ return ladderPaintOf.get(s.id) ?? ladderPaint(ladder[rank % ladder.length]);
2375
+ }, planStyleOf = (s) => !areaFilled(s) && !isBump ? planLineStyle(s.scenario, theme) : void 0, lineHollowOf = (s) => planStyleOf(s) !== void 0, scenarioStyleOf = (s) => s.scenario === void 0 ? void 0 : {
2376
+ ...planStyleOf(s),
2377
+ ...options.scenarioStyle?.[s.scenario]
2378
+ }, areaTint = theme.marks?.areaTint, themedArea = (s) => areaTint !== void 0 && isArea && !isStacked && drawnSeries.length === 1 && !palette && !s.fill && !s.colorRole && !scenarioStyleOf(s)?.ink && s.scenario !== "PY" && s.scenario !== "PL", slots = rampSlots(theme, dataSeries.map((s) => {
2379
+ let ink = scenarioStyleOf(s)?.ink;
2380
+ return s.fill ? { css: s.fill } : isArea && grey && highlights.has(s.id) ? { token: "focus" } : s.colorRole ? markRolePaint(s.colorRole, isArea) : ink ? { token: ink } : void 0;
2381
+ }), palette, !grey && !heroMode && !isBump && options.emphasis !== "ordered" && dataSeries.length > 1 ? { labels: dataSeries.map((s) => s.label), warnings } : void 0), quietRest = options.emphasis === "ordered" && (options.othersShade ?? DEFAULT_OTHERS_SHADE) === "quietest" && dataSeries.some((s) => s.colorRole === "others" && !s.fill);
2382
+ quietRest && pushAll(warnings, othersShadeUnavailableWarnings(theme, { token: "markInk" }));
2383
+ let ordered = (s) => options.emphasis === "ordered" && !s.colorRole && !(grey && highlights.has(s.id)), series = (s, dataIdx) => {
2384
+ let paint, scenarioInk = scenarioStyleOf(s)?.ink;
2385
+ return themedArea(s) ? paint = { token: "markInk" } : s.fill ? paint = { css: s.fill } : ordered(s) ? paint = orderedRampPaint(dataIdx, dataSeries.length, quietRest) : bumpStory && !s.colorRole ? paint = bumpStory.paintOf(s.id) : grey ? paint = highlights.has(s.id) ? { token: "focus" } : s.colorRole ? markRolePaint(s.colorRole) : contextPaint(s) : heroMode ? paint = s.id === heroId ? { token: "markInk" } : contextPaint(s) : s.colorRole ? paint = markRolePaint(s.colorRole) : scenarioInk ? paint = { token: scenarioInk } : dataSeries.length === 1 ? paint = seriesPaint(dataIdx, palette, s.scenario) : paint = seriesPaint(isBump ? bumpSlot(dataIdx).color : slots[dataIdx] ?? dataIdx, palette), shadeSafeStroke(faded(paint, s), s, paint);
2386
+ }, areaFillOwn = (s, dataIdx, forecast = !1) => {
2387
+ if (themedArea(s)) return forecast ? { token: "focus" } : { token: "focus", tint: areaTint };
2388
+ if (s.fill) return { css: s.fill };
2389
+ if (ordered(s)) return orderedRampPaint(dataIdx, dataSeries.length, quietRest);
2390
+ if (grey && highlights.has(s.id)) return { token: "focus" };
2391
+ if (s.colorRole) return markRolePaint(s.colorRole, !0);
2392
+ let scenarioInk = scenarioStyleOf(s)?.ink;
2393
+ return scenarioInk ? { token: scenarioInk } : dataSeries.length === 1 ? seriesPaint(dataIdx, palette, s.scenario) : seriesPaint(slots[dataIdx] ?? dataIdx, palette);
2394
+ }, areaFill = (s, dataIdx, forecast = !1) => faded(areaFillOwn(s, dataIdx, forecast), s), keyPaint = (s, dataIdx) => areaFilled(s) && !themedArea(s) ? areaFill(s, dataIdx) : !isArea && s.scenario === "FC" && domain.variant !== "line" ? forecastStroke(series(s, dataIdx), theme, seriesCrossesShadedBand(s)) : series(s, dataIdx), { fanLadder, fanCentrePaint, fanPaints } = buildFanPaints({
2395
+ fan: domain.fan,
2396
+ drawnSeries,
2397
+ seriesPaint: series,
2398
+ paintCss: css,
2399
+ theme,
2400
+ anyHighlight,
2401
+ highlights
2402
+ }), dashOf = (s, dataIdx) => s.lineStyle === "dashed" ? dashToken(theme, "reference") : s.lineStyle === "dotted" ? dashToken(theme, "dotted") : isBump ? bumpSlot(dataIdx).dash : void 0, pointScenario = (s, ci) => s.vals[ci].scenario ?? s.scenario;
2403
+ return {
2404
+ css,
2405
+ bandRules: () => [...bandRules.values()],
2406
+ seriesCrossesShadedBand,
2407
+ series,
2408
+ areaFill,
2409
+ areaFilled,
2410
+ keyPaint,
2411
+ lineHollowOf,
2412
+ lineWidthOf: (s) => themedArea(s) ? strokeToken(theme, "data") : anyHighlight && highlights.has(s.id) ? strokeToken(theme, "focus") : heroId ? s.id === heroId ? strokeToken(theme, "focus") : strokeToken(theme, "data") : bumpStory?.isContext(s) ? strokeToken(theme, "mark") : scenarioStyleOf(s)?.width ?? strokeToken(theme, "data"),
2413
+ ref: (s) => s.fill ? { css: s.fill } : s.colorRole ? { token: markRoleToken(s.colorRole) } : { token: "ink" },
2414
+ dashOf,
2415
+ legendDashOf: (s, dataIdx) => s.scenario === "FC" ? dashToken(theme, "reference") : dashOf(s, dataIdx),
2416
+ // Bump ignores the density cutoff: the marker is what makes a crossing
2417
+ // readable. A partial period keeps a (hollow) marker where density drops
2418
+ // the rest. A theme without default markers drops them as the cutoff does.
2419
+ markerOf: (s, dataIdx, ci) => s.marker ?? (bumpStory ? bumpStory.isContext(s) ? "none" : "circle" : isBump ? bumpSlot(dataIdx).shape : isArea || (markersOff || cats.length > MARKER_MAX_CATS) && cats[ci].partial !== !0 ? "none" : contextRank.has(s.id) ? plainGrey ? LINE_GREY_SHAPES[contextRank.get(s.id) % LINE_GREY_SHAPES.length] : BUMP_SHAPES[contextRank.get(s.id) % BUMP_SHAPES.length] : "circle"),
2420
+ hollowAt: (s, ci) => {
2421
+ let sc = pointScenario(s, ci);
2422
+ return sc === "PY" || sc === "PL" || sc === "FC" || cats[ci].partial === !0;
2423
+ },
2424
+ pointScenario,
2425
+ // A bump point carries BOTH quantities: `display.value` stays the metric
2426
+ // and `display.state` names the rank the y position encodes.
2427
+ bumpPointState: (row, ci) => isBump && row[ci] !== null ? { state: `rank ${row[ci]}` } : {},
2428
+ heroMode,
2429
+ heroId,
2430
+ fanLadder,
2431
+ fanCentrePaint,
2432
+ fanPaints
2433
+ };
2434
+ }
2435
+
2436
+ // src/core/charts/line/referenceBands.ts
2437
+ var REFERENCE_BAND_MIN_PX = 4, COLUMN_WIDTH_FRACTION = 0.18, LANE_START = 4, LANE_STEP = 3, RUN_IN = 8, ENTRY_GAP = 4, EDGE_AIR = 4, LEVEL_TOLERANCE = 1.5;
2438
+ function wrapEntry(label, description, nameFont, textFont, maxWidth, measure) {
2439
+ let nameW = measure(label, nameFont).width, rows = [[]], widthOf = (row, words) => (row === 0 ? nameW : 0) + (words.length === 0 ? 0 : measure(`${row === 0 ? " " : ""}${words.join(" ")}`, textFont).width);
2440
+ for (let word of description?.split(/\s+/u) ?? []) {
2441
+ let row = rows.length - 1, next = [...rows[row], word];
2442
+ widthOf(row, next) <= maxWidth || row > 0 && rows[row].length === 0 ? rows[row] = next : rows.push([word]);
2443
+ }
2444
+ return { lines: rows.map((words, row) => {
2445
+ if (row > 0) return { text: words.join(" "), nameOnly: !1 };
2446
+ if (words.length === 0) return { text: label, nameOnly: !0 };
2447
+ let rest = ` ${words.join(" ")}`;
2448
+ return { text: `${label}${rest}`, runs: [{ text: label, weight: nameFont.weight }, { text: rest, weight: textFont.weight }], nameOnly: !1 };
2449
+ }), width: Math.max(...rows.map((words, row) => widthOf(row, words))) };
2450
+ }
2451
+ function planReferenceBandColumn(bands, canvasWidth, font, measure) {
2452
+ if (!bands?.length) return;
2453
+ let textFont = font, nameFont = font, widestName = maxOf(bands.map((band) => measure(band.label, nameFont).width)), maxWidth = Math.max(COLUMN_WIDTH_FRACTION * canvasWidth, widestName), taken = new Set(bands.flatMap((band) => band.id === void 0 ? [] : [band.id])), idOf = (index) => {
2454
+ let n = index + 1;
2455
+ for (; taken.has(`band-${n}`); ) n++;
2456
+ return taken.add(`band-${n}`), `band-${n}`;
2457
+ }, entries = bands.map((band, index) => {
2458
+ let low = band.value ?? band.low, high = band.value ?? band.high;
2459
+ return { id: band.id ?? idOf(index), low, high, label: band.label, description: band.description, ...wrapEntry(band.label, band.description, nameFont, textFont, maxWidth, measure) };
2460
+ }), gutter = LANE_START + LANE_STEP * (bands.length - 1) + RUN_IN, width = maxOf(entries.map((entry) => entry.width)), lineH = font.size * (font.lineHeight ?? 1.2);
2461
+ return {
2462
+ entries,
2463
+ gutter,
2464
+ reserve: gutter + width + EDGE_AIR,
2465
+ nameFont,
2466
+ textFont,
2467
+ lineH,
2468
+ minHeight: entries.reduce((sum, entry) => sum + entry.lines.length * lineH, 0) + Math.max(0, entries.length - 1) * ENTRY_GAP
2469
+ };
2470
+ }
2471
+ function overlapWarnings(entries, warnings) {
2472
+ entries.forEach((a, i) => {
2473
+ for (let b of entries.slice(i + 1))
2474
+ a.low > b.high || b.low > a.high || warnings.push({
2475
+ code: "reference-band-overlap",
2476
+ severity: "warn",
2477
+ message: `reference bands '${a.id}' and '${b.id}' overlap (${a.low}\u2013${a.high} and ${b.low}\u2013${b.high}), so the reader cannot tell which name a value in the shared span belongs to`,
2478
+ suggest: "give each band its own span, or merge the two into one band"
2479
+ });
2480
+ });
2481
+ }
2482
+ function unexplainedWarnings(entries, warnings) {
2483
+ for (let entry of entries)
2484
+ /\p{L}/u.test(`${entry.label} ${entry.description ?? ""}`) || warnings.push({
2485
+ code: "reference-band-unexplained",
2486
+ severity: "warn",
2487
+ message: `reference band '${entry.id}' is named '${entry.label}' only, which repeats the value axis without saying what the level means`,
2488
+ suggest: "add a description, such as 'typical cycle'"
2489
+ });
2490
+ }
2491
+ function layoutReferenceBands(theme, input) {
2492
+ let { column, plot, y, claims, warnings } = input, { entries, lineH } = column;
2493
+ overlapWarnings(entries, warnings), unexplainedWarnings(entries, warnings);
2494
+ let bands = [], nodes = [], bottom = plot.y + plot.h, levels = entries.map((entry) => {
2495
+ let a = y(entry.low), b = y(entry.high), h = Math.max(Math.abs(a - b), REFERENCE_BAND_MIN_PX), top = Math.min(Math.max((a + b) / 2 - h / 2, plot.y), bottom - h), owner = { annotationId: `referenceBand:${entry.id}` };
2496
+ return bands.push({ t: "rect", id: `referenceBand:${entry.id}`, rect: { x: plot.x, y: top, w: plot.w, h }, fill: { token: "neutralLight" }, owner, part: "referenceBand" }), top + h / 2;
2497
+ }), heights = entries.map((entry) => entry.lines.length * lineH), spread = spread1DResult(entries.map((_, i) => ({ desired: levels[i] - lineH / 2 + heights[i] / 2, size: heights[i] })), [plot.y, bottom], ENTRY_GAP);
2498
+ warnSpreadOverflow(warnings, spread.fits, `reference bands: the ${entries.length} names need more height than the plot has, so some touch; shorten the descriptions or drop a band`);
2499
+ let edge = plot.x + plot.w, nameX = edge + column.gutter, tops = spread.positions.map((centre, i) => centre - heights[i] / 2), shift = entries.map((_, i) => tops[i] + lineH / 2 - levels[i]), lane = /* @__PURE__ */ new Map(), byLevel = entries.map((_, i) => i).sort((a, b) => levels[a] - levels[b] || a - b);
2500
+ return byLevel.filter((i) => shift[i] < -LEVEL_TOLERANCE).forEach((i, k) => lane.set(i, k)), byLevel.reverse().filter((i) => shift[i] > LEVEL_TOLERANCE).forEach((i, k) => lane.set(i, k)), entries.forEach((entry, i) => {
2501
+ let owner = { annotationId: `referenceBand:${entry.id}` }, top = tops[i], k = lane.get(i);
2502
+ if (k !== void 0) {
2503
+ let from = levels[i], to = top + lineH / 2, elbow = edge + LANE_START + LANE_STEP * k;
2504
+ nodes.push({ t: "path", id: `referenceBand:${entry.id}:leader`, d: `M${edge} ${from}H${elbow}V${to}H${nameX - 2}`, stroke: { token: "leader" }, width: strokeToken(theme, "rule"), owner, part: "leader" }), claims.claim({ x: edge, y: from - 0.5, w: elbow - edge, h: 1 }, "annotation", owner, "referenceBandLeader"), claims.claim({ x: elbow - 0.5, y: Math.min(from, to), w: 1, h: Math.abs(to - from) }, "annotation", owner, "referenceBandLeader"), claims.claim({ x: elbow, y: to - 0.5, w: nameX - elbow, h: 1 }, "annotation", owner, "referenceBandLeader");
2505
+ }
2506
+ entry.lines.forEach((line, row) => {
2507
+ nodes.push({
2508
+ t: "text",
2509
+ id: `referenceBand:${entry.id}:line${row + 1}`,
2510
+ x: nameX,
2511
+ y: top + row * lineH,
2512
+ lines: [line.text],
2513
+ ...line.runs ? { runs: line.runs } : {},
2514
+ align: "start",
2515
+ typeRole: "label",
2516
+ font: line.nameOnly ? column.nameFont : column.textFont,
2517
+ ink: { token: "ink" },
2518
+ owner,
2519
+ part: "referenceBandLabel",
2520
+ role: "note"
2521
+ });
2522
+ }), claims.claim({ x: nameX, y: top, w: entry.width, h: heights[i] }, "annotation", owner, "referenceBandLabel");
2523
+ }), { bands, column: nodes };
2524
+ }
2525
+ function referenceBandsA11y(column, fmt, options) {
2526
+ if (!column) return "";
2527
+ let span = (entry) => entry.low === entry.high ? fmt(entry.low) : chartString2(options, "spanText", { v1: fmt(entry.low), v2: fmt(entry.high) });
2528
+ return chartString2(options, "referenceBandsSentence", { v1: column.entries.map((entry) => `${span(entry)} (${[entry.label, entry.description].filter(Boolean).join(" ")})`).join(", ") });
2529
+ }
2530
+
2531
+ // src/core/charts/line/adjacent.ts
2532
+ function lineSeriesAdjacentWarnings(input) {
2533
+ let byId = new Map(input.nodes.map((node) => [node.id, node])), categoryIndexes = new Map(input.cats.map((category, index) => [category.id, index])), samples = [];
2534
+ for (let mark of input.marks.series) {
2535
+ let index = input.drawnSeries.findIndex((series2) => series2.id === mark.seriesId);
2536
+ if (index < 0) continue;
2537
+ let filled = input.isArea && mark.areaNodeId !== void 0, nodeId = filled ? mark.areaNodeId : mark.pathNodeId ?? mark.fcPathNodeId ?? mark.points.find((point) => point.nodeId)?.nodeId, node = nodeId ? byId.get(nodeId) : void 0, paint = node && ("fill" in node && filled ? node.fill : "stroke" in node ? node.stroke : "fill" in node ? node.fill : void 0);
2538
+ if (!paint) continue;
2539
+ let css = input.paintCss(paint), series = input.drawnSeries[index], forecastStart2 = series.scenario === "FC" ? 0 : series.vals.findIndex((value) => value.scenario === "FC"), highlighted = input.highlights.has(mark.seriesId) || "token" in paint && (paint.token === "highlight" || paint.token === "focus");
2540
+ for (let point of mark.points) {
2541
+ let categoryIndex = categoryIndexes.get(point.categoryId);
2542
+ if (filled && !input.paintedAreaCats.get(mark.seriesId)?.has(categoryIndex)) continue;
2543
+ let hatched = filled && forecastStart2 >= 0 && categoryIndex >= forecastStart2;
2544
+ samples.push({
2545
+ seriesId: mark.seriesId,
2546
+ categoryId: point.categoryId,
2547
+ // A hatch in the series' own colour is read by its stripes, as adjacentSeries.ts reads bars;
2548
+ // only an ink hatch, one stripe colour for all, differs by its wash.
2549
+ css: hatched && input.theme.pattern.hatchColor === "ink" ? effectiveFill(css, "hatch45", input.theme) : css,
2550
+ highlighted,
2551
+ paint,
2552
+ ...hatched ? { pattern: "hatch45", byStripe: !0 } : {},
2553
+ from: input.isStacked ? input.cumBot[index][categoryIndex] : point.y,
2554
+ to: input.isStacked ? input.cumTop[index][categoryIndex] : point.y
2555
+ });
2556
+ }
2557
+ }
2558
+ return retainAdjacentWarningRule(samples, input.isStacked, input.capture), adjacentSeriesWarnings(samples, input.isStacked, input.theme);
2559
+ }
2560
+
2561
+ // src/core/charts/line/difference.ts
2562
+ function resolveGapFillSeries(input) {
2563
+ let { gapFill, seriesById, warnings } = input;
2564
+ if (!gapFill) return null;
2565
+ let [aId, bId] = gapFill.between, a = seriesById.get(aId), b = seriesById.get(bId);
2566
+ for (let missingId of [a ? null : aId, b ? null : bId])
2567
+ missingId !== null && warnings.push({
2568
+ code: "gapfill-unknown-series",
2569
+ severity: "error",
2570
+ message: `gapFill names unknown series '${missingId}'`,
2571
+ owner: { seriesId: missingId }
2572
+ });
2573
+ return a && b && a.id !== b.id ? [a, b] : (a && b && warnings.push({
2574
+ code: "gapfill-unknown-series",
2575
+ severity: "error",
2576
+ message: `gapFill requires two distinct series ids; received '${a.id}' twice`,
2577
+ owner: { seriesId: a.id }
2578
+ }), null);
2579
+ }
2580
+ function resolveInterpolation(input) {
2581
+ let { gapFillSeries, interpolationFor, warnings } = input, a = interpolationFor(gapFillSeries[0]), b = interpolationFor(gapFillSeries[1]);
2582
+ return a !== b ? (warnings.push({
2583
+ code: "gapfill-interpolation-conflict",
2584
+ severity: "warn",
2585
+ message: `gapFill boundaries use different interpolation (${a} vs ${b}) \u2014 fill suppressed rather than drawing a wash that follows neither curve`,
2586
+ suggest: "give both boundary series the same smooth setting"
2587
+ }), null) : a === "monotone" ? (warnings.push({
2588
+ code: "gapfill-monotone-unsupported",
2589
+ severity: "warn",
2590
+ message: "gapFill crossing partitions are linear/step exact but do not yet solve cubic intersections \u2014 fill suppressed while both monotone lines remain visible",
2591
+ suggest: "use interpolate:'linear' for this gapFill exhibit"
2592
+ }), null) : a;
2593
+ }
2594
+ function collectGapRegions(input) {
2595
+ let { cats, seriesA, seriesB, rowA, rowB, interpolation, compositionInvalidAt, xOf, y } = input, regions = [], active = null, samePoint = (a, b) => a.x === b.x && a.yA === b.yA && a.yB === b.yB, appendPiece = (sign, start, end) => {
2596
+ if (samePoint(start, end)) return;
2597
+ let tail = active?.points.at(-1);
2598
+ if (active?.sign === sign && tail?.x === start.x) {
2599
+ samePoint(tail, start) || active.points.push(start), samePoint(active.points.at(-1), end) || active.points.push(end);
2600
+ return;
2601
+ }
2602
+ active = { sign, points: [start, end] }, regions.push(active);
2603
+ }, connectsAcross = (series, fromCi, toCi) => series.interpolateGaps && (!input.range || fromCi >= input.range.indexes[0] && toCi <= input.range.indexes[input.range.indexes.length - 1]) || (input.range?.values.get(series.id) ?? series.vals).slice(fromCi + 1, toCi).every((value) => value.v !== null), previousCi = null;
2604
+ for (let ci of input.range ? rangeIndexes(input.range) : cats.keys()) {
2605
+ if (compositionInvalidAt(ci)) {
2606
+ active = null, previousCi = null;
2607
+ continue;
2608
+ }
2609
+ let a1 = rowA[ci], b1 = rowB[ci];
2610
+ if (!(a1 === null || b1 === null)) {
2611
+ if (previousCi !== null) {
2612
+ let a0 = rowA[previousCi], b0 = rowB[previousCi];
2613
+ if (!(a0 !== null && b0 !== null && connectsAcross(seriesA, previousCi, ci) && connectsAcross(seriesB, previousCi, ci))) active = null;
2614
+ else if (interpolation === "linear") {
2615
+ let start = { ci: previousCi, x: xOf(previousCi), yA: y(a0), yB: y(b0) }, end = { ci, x: xOf(ci), yA: y(a1), yB: y(b1) }, d0 = a0 - b0, d1 = a1 - b1;
2616
+ if (d0 * d1 < 0) {
2617
+ let fraction = d0 / (d0 - d1), crossingValue = a0 + (a1 - a0) * fraction, crossing = { ci, x: start.x + (end.x - start.x) * fraction, yA: y(crossingValue), yB: y(crossingValue) };
2618
+ appendPiece(d0 > 0 ? "positive" : "negative", start, crossing), active = null, appendPiece(d1 > 0 ? "positive" : "negative", crossing, end);
2619
+ } else {
2620
+ let nonzero = d0 !== 0 ? d0 : d1;
2621
+ nonzero !== 0 ? appendPiece(nonzero > 0 ? "positive" : "negative", start, end) : active = null;
2622
+ }
2623
+ } else {
2624
+ let heldCi = interpolation === "step-after" ? previousCi : ci, heldA = rowA[heldCi], heldB = rowB[heldCi], diff = heldA - heldB;
2625
+ diff === 0 ? active = null : appendPiece(diff > 0 ? "positive" : "negative", { ci: previousCi, x: xOf(previousCi), yA: y(heldA), yB: y(heldB) }, { ci, x: xOf(ci), yA: y(heldA), yB: y(heldB) });
2626
+ }
2627
+ }
2628
+ previousCi = ci;
2629
+ }
2630
+ }
2631
+ return regions;
2632
+ }
2633
+ function gapFillPaint(tone) {
2634
+ return separatedWashPaint(tone === "good" ? "goodFill" : tone === "bad" ? "badFill" : tone, "surface-gap");
2635
+ }
2636
+ function addGapRegion(input) {
2637
+ let { region, regionIndex, seriesA, seriesB, gapFill, cats, occupied, nodes, marks } = input;
2638
+ if (region.points.length < 2) return;
2639
+ let upper = region.points.map((point) => ({ x: point.x, y: point.yA })), lower = [...region.points].reverse().map((point) => ({ x: point.x, y: point.yB })), tone = region.sign === "positive" ? gapFill.positiveTone ?? "good" : gapFill.negativeTone ?? "bad", nodeId = `mark:gapfill:${seriesA.id}:${seriesB.id}:${regionIndex}`;
2640
+ nodes.push({
2641
+ t: "path",
2642
+ id: nodeId,
2643
+ d: `${linePath(upper)}${lower.map((point) => `L${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join("")}Z`,
2644
+ fill: gapFillPaint(tone),
2645
+ owner: {},
2646
+ part: "gapFill"
2647
+ });
2648
+ for (let pointIndex = 0; pointIndex + 1 < region.points.length; pointIndex++) {
2649
+ let a = region.points[pointIndex], b = region.points[pointIndex + 1];
2650
+ occupied.claim({
2651
+ x: Math.min(a.x, b.x),
2652
+ y: Math.min(a.yA, a.yB, b.yA, b.yB),
2653
+ w: Math.max(Math.abs(b.x - a.x), 1),
2654
+ h: Math.max(Math.max(a.yA, a.yB, b.yA, b.yB) - Math.min(a.yA, a.yB, b.yA, b.yB), 1)
2655
+ }, "mark", {}, "gapFill");
2656
+ }
2657
+ marks.push({
2658
+ nodeId,
2659
+ sign: region.sign,
2660
+ fromCategoryId: cats[region.points[0].ci].id,
2661
+ toCategoryId: cats[region.points.at(-1).ci].id
2662
+ });
2663
+ }
2664
+ function renderGapFill(input) {
2665
+ let { gapFillSeries, gapFill, interpolationFor, pv, rowOf, cats, compositionInvalidAt, xOf, y, warnings, occupied, nodes, marks, analyticalSceneStart } = input;
2666
+ if (!gapFillSeries || !gapFill) return;
2667
+ let interpolation = resolveInterpolation({ gapFillSeries, interpolationFor, warnings });
2668
+ if (!interpolation) return;
2669
+ let [seriesA, seriesB] = gapFillSeries, range = input.range, regions = collectGapRegions({
2670
+ cats,
2671
+ seriesA,
2672
+ seriesB,
2673
+ rowA: pv[rowOf.get(seriesA)],
2674
+ rowB: pv[rowOf.get(seriesB)],
2675
+ interpolation,
2676
+ compositionInvalidAt,
2677
+ xOf,
2678
+ y,
2679
+ ...range && input.xOfValue ? {
2680
+ range,
2681
+ cats: range.categories,
2682
+ rowA: range.plotted[rowOf.get(seriesA)],
2683
+ rowB: range.plotted[rowOf.get(seriesB)],
2684
+ compositionInvalidAt: (ci) => range.invalid.has(ci),
2685
+ xOf: (ci) => input.xOfValue(range.xs[ci])
2686
+ } : {}
2687
+ });
2688
+ if (range && input.xOfValue) {
2689
+ let visible = new Map(range.indexes.map((source, ci) => [source, ci]));
2690
+ regions = regions.flatMap((region) => {
2691
+ let clipped = ["yA", "yB"].map((key) => cutEdge(
2692
+ { points: region.points.map((p) => ({ x: p.x, y: p[key], ci: visible.get(p.ci) ?? (p.ci < range.indexes[0] ? 0 : cats.length - 1) })) },
2693
+ "linear",
2694
+ input.xOfValue(range.lo),
2695
+ input.xOfValue(range.hi)
2696
+ ).points);
2697
+ return clipped[0].length < 2 ? [] : [{ sign: region.sign, points: clipped[0].map((p, i) => ({ ci: p.ci, x: p.x, yA: p.y, yB: clipped[1][i].y })) }];
2698
+ });
2699
+ }
2700
+ let gapFillNodes = [], gapFillMarks = [];
2701
+ if (regions.forEach((region, regionIndex) => addGapRegion({ region, regionIndex, seriesA, seriesB, gapFill, cats, occupied, nodes: gapFillNodes, marks: gapFillMarks })), gapFillNodes.length === 0) {
2702
+ warnings.push({ code: "gapfill-no-area", severity: "info", message: `gapFill '${seriesA.id}' vs '${seriesB.id}' has no non-zero shared region` });
2703
+ return;
2704
+ }
2705
+ marks.gapFills = gapFillMarks;
2706
+ let analyticalNodes = nodes.splice(analyticalSceneStart), areas = analyticalNodes.filter((node) => node.part === "area"), baseline = analyticalNodes.filter((node) => node.part === "baseline"), foreground = analyticalNodes.filter((node) => node.part !== "area" && node.part !== "baseline");
2707
+ pushAll(nodes, areas), pushAll(nodes, gapFillNodes), pushAll(nodes, baseline), pushAll(nodes, foreground);
2708
+ }
2709
+ function targetCandidates(cx, cy, measured) {
2710
+ return [
2711
+ { slot: "above", rect: { x: cx - measured.width / 2, y: cy - measured.height - 8, w: measured.width, h: measured.height }, penalty: 0 },
2712
+ { slot: "below", rect: { x: cx - measured.width / 2, y: cy + 8, w: measured.width, h: measured.height }, penalty: 1 },
2713
+ { slot: "right", rect: { x: cx + 9, y: cy - measured.height / 2, w: measured.width, h: measured.height }, penalty: 2 },
2714
+ { slot: "left", rect: { x: cx - measured.width - 9, y: cy - measured.height / 2, w: measured.width, h: measured.height }, penalty: 3 },
2715
+ // The quadrants a dashed goal path leaves free where it runs through the goal.
2716
+ { slot: "aboveRight", rect: { x: cx + 6, y: cy - measured.height - 6, w: measured.width, h: measured.height }, penalty: 4 },
2717
+ { slot: "belowLeft", rect: { x: cx - measured.width - 6, y: cy + 6, w: measured.width, h: measured.height }, penalty: 5 },
2718
+ { slot: "aboveLeft", rect: { x: cx - measured.width - 6, y: cy - measured.height - 6, w: measured.width, h: measured.height }, penalty: 6 },
2719
+ { slot: "belowRight", rect: { x: cx + 6, y: cy + 6, w: measured.width, h: measured.height }, penalty: 7 }
2720
+ ];
2721
+ }
2722
+ function namesValue(name, value) {
2723
+ let escaped = value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2724
+ return new RegExp(`(^|(?<!\\d)\\s)${escaped}[%).]*$`, "u").test(name.trim());
2725
+ }
2726
+ function addTarget(theme, input) {
2727
+ let { target, categoryOrder, xOf, y, nodes, occupied, fmt, labelFont, measure, labelRequests, plot, targetLabelIds } = input, right = Math.max(plot.x + plot.w, input.rightEdge ?? 0), cx = xOf(categoryOrder.get(target.at)), cy = y(target.value);
2728
+ nodes.push({ t: "circle", id: target.id, cx, cy, r: 4.5, fill: { token: "background" }, stroke: { token: "markInk" }, strokeWidth: strokeToken(theme, "mark"), owner: { seriesId: target.seriesId, categoryId: target.at, pointId: target.id }, part: "targetMarker", display: { value: fmt(target.value) } }), occupied.claim({ x: cx - 5, y: cy - 5, w: 10, h: 10 }, "mark", { seriesId: target.seriesId, categoryId: target.at, pointId: target.id }, "targetMarker");
2729
+ let labelId;
2730
+ if (target.label) {
2731
+ labelId = `target-label:${target.id}`, targetLabelIds.add(labelId);
2732
+ let targetFont = { ...labelFont, weight: emphasisWeight(theme) }, value = fmt(target.value), lines = namesValue(target.label, value) ? [target.label] : [target.label, value], text = lines.join(" "), measured = { width: Math.max(...lines.map((line) => measure(line, targetFont).width)), height: lines.length * measure(lines[0], targetFont).height };
2733
+ labelRequests.push({
2734
+ id: labelId,
2735
+ kind: "annotation",
2736
+ owner: { seriesId: target.seriesId, categoryId: target.at, pointId: target.id },
2737
+ text,
2738
+ lines,
2739
+ align: "middle",
2740
+ typeRole: "label",
2741
+ font: targetFont,
2742
+ priority: PRIORITY.extreme,
2743
+ candidates: targetCandidates(cx, cy, measured).filter((candidate) => candidate.rect.x >= plot.x && candidate.rect.y >= plot.y && candidate.rect.x + candidate.rect.w <= right && candidate.rect.y + candidate.rect.h <= plot.y + plot.h && // The label shares its series' owner, so the solver would let it sit on that series' line
2744
+ // and point markers; a goal's name there hides the point it is compared with. An area's
2745
+ // fill claims the same way, and a label may sit on that fill, so an area keeps every seat.
2746
+ (input.areaSeries || !occupied.hits(candidate.rect, 0, (claim) => !(claim.kind === "mark" && claim.part === void 0 && claim.owner.seriesId === target.seriesId))))
2747
+ });
2748
+ }
2749
+ return { seriesId: target.seriesId, categoryId: target.at, value: target.value, nodeId: target.id, ...labelId ? { labelId } : {} };
2750
+ }
2751
+ function renderTargets(theme, input) {
2752
+ let targetLabelIds = /* @__PURE__ */ new Set();
2753
+ if (input.targets.length === 0) return targetLabelIds;
2754
+ for (let seriesId of new Set(input.targets.map((target) => target.seriesId))) {
2755
+ let targets = input.targets.filter((target) => target.seriesId === seriesId), last = input.marks.series.find((mark) => mark.seriesId === seriesId)?.points.at(-1), lastIndex = last ? input.categoryOrder.get(last.categoryId) : void 0;
2756
+ if (!last || lastIndex === void 0) continue;
2757
+ let ahead = targets.filter((target) => input.categoryOrder.get(target.at) > lastIndex).sort((a, b) => input.categoryOrder.get(a.at) - input.categoryOrder.get(b.at));
2758
+ if (ahead.length === 0) continue;
2759
+ let path = [{ x: last.x, y: last.y }, ...ahead.map((target) => ({ x: input.xOf(input.categoryOrder.get(target.at)), y: input.y(target.value) }))];
2760
+ input.nodes.push({ t: "path", id: `target-path:${seriesId}`, d: path.map((point, i) => `${i === 0 ? "M" : "L"}${fmtPathNumber(point.x)} ${fmtPathNumber(point.y)}`).join(""), stroke: { token: "markInk" }, width: strokeToken(theme, "rule"), dash: dashToken(theme, "reference"), owner: { seriesId }, part: "targetPath" }), path.slice(1).forEach((point, i) => {
2761
+ let from = path[i];
2762
+ for (let k = 0; k < 8; k++) {
2763
+ let [x0, y0] = [from.x + (point.x - from.x) * k / 8, from.y + (point.y - from.y) * k / 8], [x1, y1] = [from.x + (point.x - from.x) * (k + 1) / 8, from.y + (point.y - from.y) * (k + 1) / 8];
2764
+ input.occupied.claim({ x: Math.min(x0, x1) - 1, y: Math.min(y0, y1) - 1, w: Math.abs(x1 - x0) + 2, h: Math.abs(y1 - y0) + 2 }, "mark", {}, "targetPath");
2765
+ }
2766
+ });
2767
+ }
2768
+ let targetMarks = input.targets.map((target) => addTarget(theme, { ...input, target, targetLabelIds, areaSeries: input.marks.series.some((mark) => mark.seriesId === target.seriesId && mark.areaNodeId !== void 0) }));
2769
+ return input.marks.targets = targetMarks, targetLabelIds;
2770
+ }
2771
+
2772
+ // src/core/charts/line/scene.ts
2773
+ var INTERVAL_TICK = 4, MIN_TICK_GAP = 2, BAND_HATCH_PITCH = Math.SQRT1_2, BAND_HATCH_SHARE = 0.45;
2774
+ function bandHatch(theme, hatchStrength) {
2775
+ return {
2776
+ gap: theme.pattern.hatchGap * hatchGapFactor({ strength: hatchStrength ?? HATCH_STRENGTH_DEFAULT.second, cue: "second" }) * BAND_HATCH_PITCH,
2777
+ width: strokeToken(theme, "hair"),
2778
+ share: BAND_HATCH_SHARE * (0.5 + 0.5 * (hatchStrength ?? HATCH_STRENGTH_DEFAULT.second) / 100) / (0.5 + 0.5 * HATCH_STRENGTH_DEFAULT.second / 100)
2779
+ };
2780
+ }
2781
+ function layoutLineMarks(env, domain, area, paints, text, reserves, warnings) {
2782
+ let { theme, measure, highlights } = env, { options, drawnSeries, pv, rowOf, cats, isStacked, isArea, compositionInvalidAt, cumTop, cumBot, interpolationFor, dLo, dHi } = domain, { plot, y, xOf } = area, { tickFont, labelFont } = text, nodes = [...area.frame.nodes], latestPointSeries = options.latestPoint === void 0 || options.latestPoint === "none" ? void 0 : typeof options.latestPoint == "object" ? options.latestPoint.series : (drawnSeries.find((s) => s.id === paints.heroId) ?? domain.dataSeries.find((s) => s.scenario === void 0 || s.scenario === "AC") ?? domain.dataSeries[0])?.id, claims = createOccupiedIndex({ x: 0, y: 0, w: env.size.width, h: env.size.height }), axes = [];
2783
+ if (area.axisShown || area.disclosedTicks) {
2784
+ let axisResult = layoutValueAxis(
2785
+ {
2786
+ scale: y,
2787
+ plot,
2788
+ orient: "y",
2789
+ // A plain line with a shown value axis draws light gridlines by default;
2790
+ // a panel that shares its scale with other panels keeps their (gridless) look.
2791
+ gridlines: options.valueAxis?.gridlines ?? ((domain.variant === "line" || domain.variant === "area" && domain.drawnSeries.length === 1) && options.valueAxis?.show === !0 && options.scaleGroup === void 0),
2792
+ format: area.axisFmt,
2793
+ ...area.axisTickSpec ? { formatSpec: area.axisTickSpec } : {},
2794
+ theme,
2795
+ measure,
2796
+ ...area.bumpTicks ? { ticks: area.bumpTicks, keepEndTicks: !0 } : {},
2797
+ ...!area.bumpTicks && area.disclosedTicks ? { ticks: area.disclosedTicks } : {},
2798
+ ...!area.bumpTicks && !area.disclosedTicks && area.stepTicks ? { ticks: area.stepTicks } : {}
2799
+ },
2800
+ claims
2801
+ );
2802
+ if (area.discloseNonzeroBaseline) {
2803
+ let glyph = straightBreakGlyph(theme, { x: plot.x, y: plot.y + plot.h - 7 }, "axis:y:baseline-disclosure", {}, { token: "axis" }, "baselineDisclosure");
2804
+ axisResult.nodes.push(...glyph.nodes), claims.claim(glyph.rect, "axis", {}, "baselineDisclosure"), axisResult.axis.baselineDisclosure = { value: area.baselineValue, rect: glyph.rect, nodeIds: glyph.nodeIds };
2805
+ }
2806
+ pushAll(nodes, axisResult.nodes), axes.push(axisResult.axis);
2807
+ }
2808
+ let tickXs = domain.autoSampled ? area.intervalTicks?.flatMap((tick, ci) => tick ? [xOf(ci)] : []) : void 0, crowded = tickXs?.some((x, k) => k > 0 && x - tickXs[k - 1] < MIN_TICK_GAP) === !0;
2809
+ if (area.intervalTicks?.forEach((tick, ci) => {
2810
+ if (!tick || crowded && !area.catPlan.keep[ci]) return;
2811
+ let x = xOf(ci), top = plot.y + plot.h;
2812
+ nodes.push({ t: "line", id: `axis:x:tick:${cats[ci].id}`, x1: x, y1: top, x2: x, y2: top + INTERVAL_TICK, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: { categoryId: cats[ci].id }, part: "tick" }), claims.claim({ x: x - 0.5, y: top, w: 1, h: INTERVAL_TICK }, "axis", { categoryId: cats[ci].id }, "tick");
2813
+ }), area.xTicks && area.xOfValue && area.showCategoryTickRow) {
2814
+ let top = plot.y + plot.h;
2815
+ area.xTicks.values.forEach((value, i) => {
2816
+ let x = round2(area.xOfValue(value));
2817
+ nodes.push({ t: "line", id: `axis:x:scale-tick:${i}`, x1: x, y1: top, x2: x, y2: top + INTERVAL_TICK, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner: {}, part: "tick" }), claims.claim({ x: x - 0.5, y: top, w: 1, h: INTERVAL_TICK }, "axis", {}, "tick");
2818
+ });
2819
+ }
2820
+ let referenceBands = reserves.referenceBands ? layoutReferenceBands(theme, { column: reserves.referenceBands, plot: area.forecastPlot, y, claims, warnings }) : void 0;
2821
+ referenceBands && pushAll(nodes, referenceBands.bands);
2822
+ let headerRequests = area.axisTitle && area.axisShown ? [valueAxisTitleRequest(area.axisTitle, { x: area.frame.plot.x, y: area.axisTitleY }, "start", "axis:y:title")] : [];
2823
+ placeForecastHeaders(area.forecast, xOf, area.forecastPlot, area.forecastHeaderInPlot ? area.forecastPlot.y + 2 : area.forecastPlot.y - area.phaseHeaderHeight - area.forecastHeaderHeight, text.secondaryFont, measure, headerRequests, claims, options.strings.forecastHeader, forecastDividerAt(domain), actualHeader(domain));
2824
+ let baseY = dLo <= 0 && dHi >= 0 ? y(0) : plot.y + plot.h, rendered = renderLineMarks({
2825
+ theme,
2826
+ highlights: env.highlights,
2827
+ drawnSeries,
2828
+ refSeries: domain.refSeries,
2829
+ pv,
2830
+ rowOf,
2831
+ cats,
2832
+ isStacked,
2833
+ isArea,
2834
+ compositionInvalidAt,
2835
+ y,
2836
+ cumTop,
2837
+ cumBot,
2838
+ xOf,
2839
+ hasSuppressed100: domain.nmCats100.size > 0 || domain.naCats100.size > 0,
2840
+ baseY,
2841
+ plot,
2842
+ range: domain.x?.range,
2843
+ xOfValue: area.xOfValue,
2844
+ // A stacked band's forecast overlay is a second cue (hatchStrength). Its
2845
+ // stripes are the page colour at 45% over the band's own fill (one solid colour, not an opacity), hair
2846
+ // weight, 9.6 px apart along x at the default strength; lower strengths spread and fade them.
2847
+ hatch: bandHatch(theme, options.hatchStrength),
2848
+ seriesPaint: paints.series,
2849
+ areaFillPaint: paints.areaFill,
2850
+ areaFilled: paints.areaFilled,
2851
+ // A plain line's forecast keeps its colour; the dashes, open markers and divider mark it.
2852
+ forecastLinePaint: (series, index) => isArea || domain.variant === "line" ? paints.series(series, index) : forecastStroke(
2853
+ paints.series(series, index),
2854
+ theme,
2855
+ paints.seriesCrossesShadedBand(series)
2856
+ ),
2857
+ lineWidthOf: paints.lineWidthOf,
2858
+ lineHollowOf: paints.lineHollowOf,
2859
+ interpolationFor,
2860
+ dashOf: paints.dashOf,
2861
+ markerOf: paints.markerOf,
2862
+ hollowAt: paints.hollowAt,
2863
+ rebased: domain.rebased,
2864
+ variant: domain.variant,
2865
+ pctFmt: env.pctFmt,
2866
+ shareTexts: domain.shareTexts,
2867
+ authoredPctFmt: env.authoredPctFmt,
2868
+ fmt: domain.fmt,
2869
+ seriesFmt: domain.valueSpec.forSeries,
2870
+ absOf: domain.absOf,
2871
+ bumpPointState: paints.bumpPointState,
2872
+ inlineNamesEnabled: reserves.endpoint.inlineNamesEnabled,
2873
+ ...latestPointSeries === void 0 ? {} : { latestPointSeries },
2874
+ ...domain.bumpDerived ? { bump: domain.bumpDerived, bumpOmitted: domain.bumpOmitted } : {},
2875
+ nmCats100: domain.nmCats100,
2876
+ naCats100: domain.naCats100,
2877
+ naGlyph: notApplicableGlyph(options.strings),
2878
+ labelFont,
2879
+ measure,
2880
+ refPaintOf: paints.ref,
2881
+ nodes,
2882
+ occupied: claims
2883
+ }), { marks, analyticalSceneStart, paintedAreaCats } = rendered, paintWarningRules = [], before = warnings.filter((warning) => !["pie-ramp-crowded", "likert-ramp-invisible", "band-lightness-insufficient", "series-adjacent-similar", "highlight-reads-as-loss", "line-band-authored-contrast"].includes(warning.code)).length;
2884
+ pushAll(warnings, lineSeriesAdjacentWarnings({ marks, nodes, cats, drawnSeries, cumBot, cumTop, paintedAreaCats, isStacked, isArea, highlights, paintCss: paints.css, theme, capture: { rules: paintWarningRules, before } }));
2885
+ for (let rule of paints.bandRules())
2886
+ paintWarningRules.push({ ...rule, before }), pushAll(warnings, resolvePaintWarnings(theme, [{ ...rule, before }]));
2887
+ renderGapFill({
2888
+ range: domain.x?.range,
2889
+ xOfValue: area.xOfValue,
2890
+ gapFillSeries: domain.gapFillSeries,
2891
+ gapFill: options.gapFill,
2892
+ interpolationFor,
2893
+ pv,
2894
+ rowOf,
2895
+ cats,
2896
+ compositionInvalidAt,
2897
+ xOf,
2898
+ y,
2899
+ warnings,
2900
+ occupied: claims,
2901
+ nodes,
2902
+ marks,
2903
+ analyticalSceneStart
2904
+ }), renderFanWashes(theme, {
2905
+ range: domain.x?.range,
2906
+ xOfValue: area.xOfValue,
2907
+ fan: domain.fan,
2908
+ fanPaints: paints.fanPaints,
2909
+ fanLadder: paints.fanLadder,
2910
+ interpolationFor,
2911
+ pv,
2912
+ rowOf,
2913
+ cats,
2914
+ compositionInvalidAt,
2915
+ xOf,
2916
+ y,
2917
+ pathFor,
2918
+ reversePathTail,
2919
+ fmt: domain.fmt,
2920
+ numberSpec: domain.valueSpec.spec,
2921
+ occupied: claims,
2922
+ warnings,
2923
+ nodes,
2924
+ marks,
2925
+ analyticalSceneStart
2926
+ });
2927
+ let phaseRequests = [], phaseDerived = renderPhaseFills(theme, {
2928
+ range: domain.x?.range,
2929
+ xOfValue: area.xOfValue,
2930
+ phases: domain.phases,
2931
+ pv,
2932
+ rowOf,
2933
+ cats,
2934
+ xOf,
2935
+ y,
2936
+ baseY,
2937
+ plot: area.forecastPlot,
2938
+ phaseHeaderHeight: area.phaseHeaderHeight,
2939
+ paletteRamp: env.paletteRamp,
2940
+ palette: options.palette,
2941
+ fmt: domain.fmt,
2942
+ measure,
2943
+ tickFont,
2944
+ labelRequests: phaseRequests,
2945
+ occupied: claims,
2946
+ nodes,
2947
+ marks,
2948
+ analyticalSceneStart,
2949
+ forecast: area.forecast
2950
+ });
2951
+ drawLineTrends(theme, domain, area, paints, nodes, claims);
2952
+ let targetRequests = [], targetLabelIds = renderTargets(env.theme, {
2953
+ targets: domain.targets,
2954
+ categoryOrder: area.categoryOrder,
2955
+ xOf,
2956
+ y,
2957
+ nodes,
2958
+ occupied: claims,
2959
+ fmt: domain.fmt,
2960
+ labelFont,
2961
+ measure,
2962
+ labelRequests: targetRequests,
2963
+ plot,
2964
+ marks,
2965
+ rightEdge: env.size.width - 4
2966
+ }), { meanValue, meanValueFor } = lineMeans(domain.population?.plotted ?? pv, rowOf, drawnSeries, domain.population?.categories ?? cats, !domain.rebased && domain.variant !== "stacked100-area");
2967
+ return claimValueLines(reserves.annList, meanValue, meanValueFor, cats, area, claims), referenceBands && pushAll(nodes, referenceBands.column), {
2968
+ nodes,
2969
+ claims,
2970
+ axes,
2971
+ rendered,
2972
+ marks,
2973
+ paintWarningRules,
2974
+ headerRequests,
2975
+ phaseRequests,
2976
+ targetRequests,
2977
+ phaseDerived,
2978
+ targetLabelIds,
2979
+ baseY,
2980
+ meanValue,
2981
+ meanValueFor
2982
+ };
2983
+ }
2984
+ function claimValueLines(annList, meanValue, meanValueFor, cats, area, claims) {
2985
+ let { plot, y, xOf } = area, resolveBand = annList.some((ann) => ann.kind === "band" && ann.from !== void 0 && ann.to !== void 0 && !!ann.label) ? categoryBandFromCenters(cats.map((c) => c.id), plot, xOf, "x") : void 0;
2986
+ annList.forEach((ann, k) => {
2987
+ if (ann.kind !== "valueLine") return;
2988
+ let scoped = ann.seriesId !== void 0 || ann.from !== void 0 || ann.to !== void 0, v;
2989
+ if (!scoped) v = ann.value === "mean" || ann.value === void 0 ? meanValue : ann.value;
2990
+ else if ((ann.value === "mean" || ann.value === void 0) && ann.from === void 0 == (ann.to === void 0)) {
2991
+ let resolved = meanValueFor({ seriesId: ann.seriesId, from: ann.from, to: ann.to });
2992
+ v = "error" in resolved ? void 0 : resolved.value;
2993
+ }
2994
+ if (v === void 0) return;
2995
+ let fromBand = ann.from !== void 0 ? resolveBand?.(ann.from) : null, toBand = ann.to !== void 0 ? resolveBand?.(ann.to) : null, x0 = fromBand && toBand && "x" in fromBand && "x" in toBand ? Math.min(fromBand.x, toBand.x) : plot.x, x1 = fromBand && toBand && "x" in fromBand && "x" in toBand ? Math.max(fromBand.x + fromBand.w, toBand.x + toBand.w) : plot.x + plot.w;
2996
+ claims.claim({ x: x0, y: y(v) - 1, w: Math.max(x1 - x0, 0), h: 2 }, "annotation", { annotationId: ann.id ?? `valueLine-${k + 1}` });
2997
+ });
2998
+ }
2999
+
3000
+ export {
3001
+ trendTimeline,
3002
+ fitLineTrends,
3003
+ lineTrendLabel,
3004
+ lineTrendKeys,
3005
+ screenEdges,
3006
+ seatValuesOnGround,
3007
+ rangeCut,
3008
+ rangeRuns,
3009
+ pathFor,
3010
+ forecastBoundaryX,
3011
+ withoutEvents,
3012
+ fillShadingKinds,
3013
+ shadesFills,
3014
+ fillShadings,
3015
+ regroundOnShadings,
3016
+ markerPath,
3017
+ latestRingReach,
3018
+ END_LABEL_KEY,
3019
+ END_LABEL_WIDE,
3020
+ INLINE_FALLBACK,
3021
+ usesInlineFallback,
3022
+ usesEndLabelKey,
3023
+ fanEdgeInKey,
3024
+ usesWideEndLabels,
3025
+ lineFocusFont,
3026
+ endUnitSuffix,
3027
+ valueUnit,
3028
+ prepareEndpointLabels,
3029
+ placeInlineSeriesLabels,
3030
+ placeEndpointLabels,
3031
+ lineToDateIds,
3032
+ pointLabelSelection,
3033
+ defaultValueContent,
3034
+ PLOT_END_AIR,
3035
+ pointLabelEndRoom,
3036
+ pointValueWidths,
3037
+ placePointValueLabels,
3038
+ placeCategoryLabels,
3039
+ flaggedPoints,
3040
+ lineLabelModes,
3041
+ BUMP_FOLDED,
3042
+ prepareBump,
3043
+ deriveBumpRanks,
3044
+ bumpMethodNote,
3045
+ buildBumpStartLabels,
3046
+ placeBumpTieLabels,
3047
+ joinTieValues,
3048
+ placeBumpStartLabels,
3049
+ resolveGapFillSeries,
3050
+ gapFillPaint,
3051
+ resolveFan,
3052
+ outerFanEdge,
3053
+ fanGapNote,
3054
+ forecastBoundaries,
3055
+ forecastDividerAt,
3056
+ placeForecastHeaders,
3057
+ actualHeader,
3058
+ emitForecastDividers,
3059
+ backForecastAreaLabels,
3060
+ lineValueStats,
3061
+ planLineStyle,
3062
+ MARKER_MAX_CATS,
3063
+ lineText,
3064
+ linePaints,
3065
+ planReferenceBandColumn,
3066
+ referenceBandsA11y,
3067
+ bandHatch,
3068
+ layoutLineMarks
3069
+ };