boardplot 0.0.0-stage → 0.52.5

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 (817) hide show
  1. package/CHANGELOG.md +18 -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-VUNSFKZY.js +137 -0
  8. package/dist/annotateEngine-H7OW4H3W.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24WB3HMB.js +621 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QQEWNV.js +18 -0
  13. package/dist/chunk-2AKWCMS4.js +24 -0
  14. package/dist/chunk-2DHJJ2EN.js +24 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2GELJH37.js +88 -0
  17. package/dist/chunk-2JAWQ7VV.js +3874 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2MTWKMEG.js +841 -0
  20. package/dist/chunk-2SGIHKKU.js +33 -0
  21. package/dist/chunk-2UVTHU7A.js +1146 -0
  22. package/dist/chunk-33CBPK5Q.js +2800 -0
  23. package/dist/chunk-33PLBIMA.js +176 -0
  24. package/dist/chunk-35DZP2R2.js +22 -0
  25. package/dist/chunk-3D3D3D23.js +25 -0
  26. package/dist/chunk-3EZRM4YM.js +92 -0
  27. package/dist/chunk-3GZECHOK.js +802 -0
  28. package/dist/chunk-3HHNQPAH.js +68 -0
  29. package/dist/chunk-3I6RANBJ.js +1058 -0
  30. package/dist/chunk-3SIRPKMP.js +12 -0
  31. package/dist/chunk-3W23F7EY.js +185 -0
  32. package/dist/chunk-3XQ635KD.js +24 -0
  33. package/dist/chunk-3ZCKEANJ.js +24 -0
  34. package/dist/chunk-4DNOEV3Q.js +25857 -0
  35. package/dist/chunk-4GB7TBY7.js +373 -0
  36. package/dist/chunk-4SM2ONUC.js +18 -0
  37. package/dist/chunk-5C7TWNYZ.js +79 -0
  38. package/dist/chunk-5DJXJXDE.js +58 -0
  39. package/dist/chunk-5ENRZX6I.js +687 -0
  40. package/dist/chunk-5KWXRYAT.js +294 -0
  41. package/dist/chunk-5T5YW52S.js +47 -0
  42. package/dist/chunk-627P6T25.js +936 -0
  43. package/dist/chunk-62FR4FYJ.js +23 -0
  44. package/dist/chunk-6JUJ2DU3.js +67 -0
  45. package/dist/chunk-6KWIQ5KF.js +18 -0
  46. package/dist/chunk-6UBEGKIQ.js +25 -0
  47. package/dist/chunk-6XE3GVGU.js +116 -0
  48. package/dist/chunk-76ANFJOI.js +227 -0
  49. package/dist/chunk-7IFLQMJL.js +160 -0
  50. package/dist/chunk-7JVAQX6C.js +28 -0
  51. package/dist/chunk-7QDAHY5M.js +63 -0
  52. package/dist/chunk-7VXZDB45.js +149 -0
  53. package/dist/chunk-7X65ZQN4.js +38 -0
  54. package/dist/chunk-A2FHZH7E.js +1410 -0
  55. package/dist/chunk-A372DLQX.js +54 -0
  56. package/dist/chunk-A3ULWR5N.js +76 -0
  57. package/dist/chunk-A4QZXLXF.js +7 -0
  58. package/dist/chunk-A5JWFZVU.js +1467 -0
  59. package/dist/chunk-A5LZUYK4.js +59 -0
  60. package/dist/chunk-A6XCAQ52.js +89 -0
  61. package/dist/chunk-A7A4PDG5.js +24 -0
  62. package/dist/chunk-A7IEVBYI.js +35 -0
  63. package/dist/chunk-ACXX2JNL.js +6 -0
  64. package/dist/chunk-AFK47A6O.js +25 -0
  65. package/dist/chunk-ALKTNXMR.js +3650 -0
  66. package/dist/chunk-AOQ6VF5H.js +6 -0
  67. package/dist/chunk-ASAON7G4.js +648 -0
  68. package/dist/chunk-ATTE3FYC.js +24 -0
  69. package/dist/chunk-AZOUSKZD.js +728 -0
  70. package/dist/chunk-B2EBEXIS.js +113 -0
  71. package/dist/chunk-B67K5X4M.js +58 -0
  72. package/dist/chunk-BBL3R5YZ.js +186 -0
  73. package/dist/chunk-BIDIGDGH.js +6 -0
  74. package/dist/chunk-BKYMLFUG.js +69 -0
  75. package/dist/chunk-BLFWUMTD.js +12 -0
  76. package/dist/chunk-BM6SFFWF.js +6 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BVWU6GOB.js +47 -0
  79. package/dist/chunk-BW5VLBSZ.js +15 -0
  80. package/dist/chunk-C64FBRJO.js +290 -0
  81. package/dist/chunk-CAE2HK2G.js +295 -0
  82. package/dist/chunk-CCQNL33L.js +446 -0
  83. package/dist/chunk-CDZHNLO6.js +42 -0
  84. package/dist/chunk-COKHNEJP.js +24 -0
  85. package/dist/chunk-COYPDRJK.js +21 -0
  86. package/dist/chunk-CRZKGHZ6.js +1810 -0
  87. package/dist/chunk-CS4DHFNG.js +128 -0
  88. package/dist/chunk-CYDZP5W6.js +1589 -0
  89. package/dist/chunk-D4BIV6WG.js +1072 -0
  90. package/dist/chunk-D4SOADBD.js +19 -0
  91. package/dist/chunk-DCCJRLAJ.js +422 -0
  92. package/dist/chunk-DFKTS6XJ.js +75 -0
  93. package/dist/chunk-DGDOGOTQ.js +25 -0
  94. package/dist/chunk-DLC23CKC.js +53 -0
  95. package/dist/chunk-DRTA6JG5.js +160 -0
  96. package/dist/chunk-DVKBU23L.js +97 -0
  97. package/dist/chunk-E2HEVF23.js +692 -0
  98. package/dist/chunk-EC2NAYPQ.js +24 -0
  99. package/dist/chunk-EKQK5D6G.js +14 -0
  100. package/dist/chunk-EKQMYG2B.js +2353 -0
  101. package/dist/chunk-ELYU6TRQ.js +98 -0
  102. package/dist/chunk-EQT3EPTB.js +203 -0
  103. package/dist/chunk-ERAIVAK5.js +1359 -0
  104. package/dist/chunk-ETHWK2RZ.js +16 -0
  105. package/dist/chunk-EWVKBRLV.js +72 -0
  106. package/dist/chunk-F77BNDAT.js +43 -0
  107. package/dist/chunk-FGAGGPFF.js +566 -0
  108. package/dist/chunk-FIANWJXX.js +19 -0
  109. package/dist/chunk-FIWNDOMO.js +6 -0
  110. package/dist/chunk-FOKEGVPB.js +24 -0
  111. package/dist/chunk-FT3F72C3.js +30 -0
  112. package/dist/chunk-FT47HQ5U.js +47 -0
  113. package/dist/chunk-GDOW2KNP.js +19 -0
  114. package/dist/chunk-GDQ3NGDZ.js +17 -0
  115. package/dist/chunk-GH3ZMBFX.js +563 -0
  116. package/dist/chunk-GQPESFAF.js +3378 -0
  117. package/dist/chunk-GQS46LC3.js +50 -0
  118. package/dist/chunk-GULJ6KVT.js +587 -0
  119. package/dist/chunk-GWQIXU37.js +2774 -0
  120. package/dist/chunk-GZ2VNM4L.js +24 -0
  121. package/dist/chunk-GZ4RHGIW.js +836 -0
  122. package/dist/chunk-H4H4O62O.js +46 -0
  123. package/dist/chunk-H57TJD3B.js +72 -0
  124. package/dist/chunk-H7UZZ7KP.js +24 -0
  125. package/dist/chunk-HAAUJDGB.js +83 -0
  126. package/dist/chunk-HFG76JTS.js +296 -0
  127. package/dist/chunk-HJXXFPOL.js +211 -0
  128. package/dist/chunk-HTYFQHRC.js +24 -0
  129. package/dist/chunk-HUF6TQ2J.js +24 -0
  130. package/dist/chunk-HUFCSX2Y.js +89 -0
  131. package/dist/chunk-HX3MQ3H4.js +26 -0
  132. package/dist/chunk-HZQEQ34U.js +296 -0
  133. package/dist/chunk-I322G5UG.js +888 -0
  134. package/dist/chunk-IDDA5INB.js +60 -0
  135. package/dist/chunk-IDTLHPTK.js +60 -0
  136. package/dist/chunk-II7652VA.js +2918 -0
  137. package/dist/chunk-IN4QT33I.js +38 -0
  138. package/dist/chunk-IV2UXZXX.js +16 -0
  139. package/dist/chunk-IXSZ7OKR.js +133 -0
  140. package/dist/chunk-IYEFEBRN.js +41 -0
  141. package/dist/chunk-IZ35GMGB.js +2543 -0
  142. package/dist/chunk-IZCOG3FS.js +28 -0
  143. package/dist/chunk-JA755JHN.js +379 -0
  144. package/dist/chunk-JETXFF3M.js +33 -0
  145. package/dist/chunk-JFBEAUJ6.js +24 -0
  146. package/dist/chunk-JFG4DHKQ.js +48 -0
  147. package/dist/chunk-JL5BRMDT.js +179 -0
  148. package/dist/chunk-JLCAWQ3H.js +195 -0
  149. package/dist/chunk-JLZM7XMZ.js +525 -0
  150. package/dist/chunk-JMH5MD5A.js +19 -0
  151. package/dist/chunk-JRPI64AQ.js +3066 -0
  152. package/dist/chunk-JSX3C6LL.js +344 -0
  153. package/dist/chunk-JY4R3GML.js +83 -0
  154. package/dist/chunk-JYBT2JNY.js +61 -0
  155. package/dist/chunk-K2HNV4LE.js +2008 -0
  156. package/dist/chunk-KAXJFL7N.js +43 -0
  157. package/dist/chunk-KDMKHR5A.js +32 -0
  158. package/dist/chunk-KFFNCDX6.js +19 -0
  159. package/dist/chunk-KKWZWP67.js +24 -0
  160. package/dist/chunk-KOJ5QETJ.js +8 -0
  161. package/dist/chunk-KPMGGE4W.js +51 -0
  162. package/dist/chunk-KS7DXCXH.js +27 -0
  163. package/dist/chunk-KSYVTEKR.js +24 -0
  164. package/dist/chunk-KU4YS6HN.js +61 -0
  165. package/dist/chunk-KYELSLDJ.js +40 -0
  166. package/dist/chunk-LC3PSQJJ.js +383 -0
  167. package/dist/chunk-LC6DYCTG.js +85 -0
  168. package/dist/chunk-LNKY5Z2X.js +23 -0
  169. package/dist/chunk-LO2DANS6.js +302 -0
  170. package/dist/chunk-M4SPKUZE.js +7 -0
  171. package/dist/chunk-M4YLED7M.js +17 -0
  172. package/dist/chunk-M6KTNAND.js +746 -0
  173. package/dist/chunk-MCOIEWW6.js +54 -0
  174. package/dist/chunk-MDYLOIS2.js +48 -0
  175. package/dist/chunk-MEISCROL.js +24 -0
  176. package/dist/chunk-MFLH5ZDQ.js +69 -0
  177. package/dist/chunk-MIXKQJ64.js +935 -0
  178. package/dist/chunk-MJMJEURO.js +359 -0
  179. package/dist/chunk-MNJ2DHU6.js +526 -0
  180. package/dist/chunk-NEVSQGOI.js +63 -0
  181. package/dist/chunk-NG5IGZXC.js +1179 -0
  182. package/dist/chunk-NLOMCLKI.js +3303 -0
  183. package/dist/chunk-NMCOUVN5.js +24 -0
  184. package/dist/chunk-NT3HAZYT.js +51 -0
  185. package/dist/chunk-NXNQQ3DS.js +382 -0
  186. package/dist/chunk-NYEY6W5R.js +569 -0
  187. package/dist/chunk-OAPCJO6W.js +23 -0
  188. package/dist/chunk-OH7FA4TF.js +251 -0
  189. package/dist/chunk-OLNORNCT.js +331 -0
  190. package/dist/chunk-OQEBOVUO.js +30 -0
  191. package/dist/chunk-ORUJI3VB.js +83 -0
  192. package/dist/chunk-PEN2DK7T.js +49 -0
  193. package/dist/chunk-PGIQMQRU.js +1650 -0
  194. package/dist/chunk-PTVOXB5T.js +39 -0
  195. package/dist/chunk-PUVGWJQ5.js +24 -0
  196. package/dist/chunk-PWROWDZS.js +137 -0
  197. package/dist/chunk-Q6XJOJTY.js +29 -0
  198. package/dist/chunk-QBR6IKIX.js +50 -0
  199. package/dist/chunk-QETGGFH2.js +30 -0
  200. package/dist/chunk-QG6MOQLI.js +2934 -0
  201. package/dist/chunk-QGCEHR6S.js +13 -0
  202. package/dist/chunk-QHFQHQDC.js +43 -0
  203. package/dist/chunk-QHRE2M6V.js +26 -0
  204. package/dist/chunk-QKL7IY42.js +38 -0
  205. package/dist/chunk-QN6JHMGU.js +44 -0
  206. package/dist/chunk-QNHZXFRA.js +347 -0
  207. package/dist/chunk-QPWRHDLZ.js +17 -0
  208. package/dist/chunk-QVABTUDS.js +80 -0
  209. package/dist/chunk-QXILAMAU.js +28 -0
  210. package/dist/chunk-QZAT46PP.js +95 -0
  211. package/dist/chunk-R3WI7ZLE.js +545 -0
  212. package/dist/chunk-R5SWC3EW.js +30 -0
  213. package/dist/chunk-RJQ5YS3Q.js +40 -0
  214. package/dist/chunk-RNOD2UWF.js +613 -0
  215. package/dist/chunk-RNXITK5M.js +24 -0
  216. package/dist/chunk-ROXO4R3J.js +16 -0
  217. package/dist/chunk-RQ5DNYLG.js +10 -0
  218. package/dist/chunk-RSWVH7DB.js +24 -0
  219. package/dist/chunk-RTJXOIIQ.js +12 -0
  220. package/dist/chunk-RZNYW7UP.js +133 -0
  221. package/dist/chunk-S4F27M7N.js +37 -0
  222. package/dist/chunk-S4ONWRJE.js +28 -0
  223. package/dist/chunk-S53OGZL6.js +168 -0
  224. package/dist/chunk-S5ADHIZK.js +2508 -0
  225. package/dist/chunk-S62M63LU.js +19 -0
  226. package/dist/chunk-S7VDRUED.js +62 -0
  227. package/dist/chunk-SGD3ZHID.js +250 -0
  228. package/dist/chunk-SGSPYHFE.js +40 -0
  229. package/dist/chunk-SLTMRTXV.js +597 -0
  230. package/dist/chunk-SXGTRZFN.js +26 -0
  231. package/dist/chunk-SZPTTNW7.js +16 -0
  232. package/dist/chunk-T3IGJARD.js +22 -0
  233. package/dist/chunk-TA3TFKYZ.js +86 -0
  234. package/dist/chunk-TNEHPP3H.js +18 -0
  235. package/dist/chunk-TPYV2FTV.js +25 -0
  236. package/dist/chunk-TPZB2YWR.js +25 -0
  237. package/dist/chunk-TSR5YDPS.js +1266 -0
  238. package/dist/chunk-TTR7EWNH.js +170 -0
  239. package/dist/chunk-TVHLKVUO.js +24 -0
  240. package/dist/chunk-TXINIAFL.js +198 -0
  241. package/dist/chunk-TXZBBZOG.js +58 -0
  242. package/dist/chunk-UEU46Q3D.js +300 -0
  243. package/dist/chunk-UMDEWWXT.js +33 -0
  244. package/dist/chunk-UQSVWO7Z.js +334 -0
  245. package/dist/chunk-UZF3G2FN.js +942 -0
  246. package/dist/chunk-V422EKLW.js +24 -0
  247. package/dist/chunk-V4DYVLOO.js +433 -0
  248. package/dist/chunk-V4VC25UL.js +128 -0
  249. package/dist/chunk-V667FCIJ.js +12 -0
  250. package/dist/chunk-VABRPZVC.js +43 -0
  251. package/dist/chunk-VB2MJLET.js +19 -0
  252. package/dist/chunk-VDAKTZQP.js +18 -0
  253. package/dist/chunk-VDAZPGR2.js +79 -0
  254. package/dist/chunk-VXZFQKBJ.js +21 -0
  255. package/dist/chunk-VYMGZ27S.js +133 -0
  256. package/dist/chunk-W2RGSGRR.js +131 -0
  257. package/dist/chunk-W7UZXD5D.js +1109 -0
  258. package/dist/chunk-WDUNR2VI.js +2718 -0
  259. package/dist/chunk-WHSTEAVP.js +229 -0
  260. package/dist/chunk-WJMUMN3I.js +127 -0
  261. package/dist/chunk-WLZ54FWG.js +120 -0
  262. package/dist/chunk-WMJPFLF3.js +2980 -0
  263. package/dist/chunk-WRHFBCVY.js +24 -0
  264. package/dist/chunk-WVSNSWBJ.js +47 -0
  265. package/dist/chunk-WYJEOMNY.js +31 -0
  266. package/dist/chunk-WYJMV62X.js +24 -0
  267. package/dist/chunk-WZGJSQKN.js +29 -0
  268. package/dist/chunk-WZL4EEBS.js +11 -0
  269. package/dist/chunk-X7TXGKRX.js +272 -0
  270. package/dist/chunk-XB4KZ6WO.js +81 -0
  271. package/dist/chunk-XDLQRSSH.js +266 -0
  272. package/dist/chunk-XDS4UZGR.js +113 -0
  273. package/dist/chunk-XEGRWWNO.js +30 -0
  274. package/dist/chunk-XO5ONLVM.js +420 -0
  275. package/dist/chunk-XPWRD424.js +24 -0
  276. package/dist/chunk-XTNV2YMB.js +50 -0
  277. package/dist/chunk-XW5J5JAX.js +42 -0
  278. package/dist/chunk-XY5O74BH.js +33 -0
  279. package/dist/chunk-XYONCO5Q.js +984 -0
  280. package/dist/chunk-Y4PXIJMD.js +829 -0
  281. package/dist/chunk-YAYRRKC7.js +24 -0
  282. package/dist/chunk-YEDYBMCW.js +210 -0
  283. package/dist/chunk-YFG4E3N2.js +1161 -0
  284. package/dist/chunk-YHTO46W2.js +2670 -0
  285. package/dist/chunk-YI2ZVTCB.js +38 -0
  286. package/dist/chunk-YKO3VCTF.js +24 -0
  287. package/dist/chunk-YP3I6W7T.js +24 -0
  288. package/dist/chunk-YQ2B3YVF.js +687 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YTSSXSZR.js +197 -0
  291. package/dist/chunk-Z256ACGC.js +27 -0
  292. package/dist/chunk-Z2MGTKDR.js +20 -0
  293. package/dist/chunk-Z5VSLLNY.js +23 -0
  294. package/dist/chunk-Z7X3RGGA.js +22 -0
  295. package/dist/chunk-ZF43WRG3.js +29 -0
  296. package/dist/chunk-ZJKOLOVF.js +1754 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZSLGN6CO.js +89 -0
  299. package/dist/chunk-ZVTFZF4V.js +542 -0
  300. package/dist/cli/index.js +9 -0
  301. package/dist/core-5Z6UW5DS.js +31 -0
  302. package/dist/core-6ANZ2OWO.js +40 -0
  303. package/dist/core-6LLJNZ4O.js +37 -0
  304. package/dist/core-CPN2HF75.js +33 -0
  305. package/dist/core-CS7AKNME.js +37 -0
  306. package/dist/core-DBRILYNB.js +38 -0
  307. package/dist/core-DU77ZYPR.js +34 -0
  308. package/dist/core-E6YD7VU4.js +32 -0
  309. package/dist/core-EE55P6XK.js +56 -0
  310. package/dist/core-FFLPH5XK.js +41 -0
  311. package/dist/core-IV26EL5C.js +32 -0
  312. package/dist/core-IZVZ2B7Y.js +34 -0
  313. package/dist/core-JQV7STNF.js +34 -0
  314. package/dist/core-KBH3EJZV.js +32 -0
  315. package/dist/core-KFBW5PRT.js +36 -0
  316. package/dist/core-KWGXHBJE.js +37 -0
  317. package/dist/core-MZMR2DF4.js +32 -0
  318. package/dist/core-OK2ZY5OJ.js +29 -0
  319. package/dist/core-OV5MPTZP.js +43 -0
  320. package/dist/core-OW5V74Q4.js +40 -0
  321. package/dist/core-PL64QPOH.js +57 -0
  322. package/dist/core-PVINU5JJ.js +33 -0
  323. package/dist/core-QUYSNTC7.js +34 -0
  324. package/dist/core-RE3L6YCM.js +29 -0
  325. package/dist/core-RUA3EWW3.js +39 -0
  326. package/dist/core-RY6IFRKM.js +35 -0
  327. package/dist/core-SCWEVNUY.js +34 -0
  328. package/dist/core-SE67HHFG.js +55 -0
  329. package/dist/core-T5Q4DSH2.js +32 -0
  330. package/dist/core-TJX3I7KH.js +37 -0
  331. package/dist/core-ULUA5ZB2.js +55 -0
  332. package/dist/core-WLVU2HWX.js +46 -0
  333. package/dist/core-WQPHNVNY.js +51 -0
  334. package/dist/core-XXIOJY2X.js +52 -0
  335. package/dist/core-ZH7XTJTD.js +39 -0
  336. package/dist/core-ZHE7N4NS.js +50 -0
  337. package/dist/core-ZJYLJWZQ.js +38 -0
  338. package/dist/dataTable-IL7HVDHL.js +58 -0
  339. package/dist/engine-MYLZI5VH.js +961 -0
  340. package/dist/fixtures.d.ts +1 -0
  341. package/dist/fixtures.js +40 -0
  342. package/dist/fontTables-ZYBUCJ5N.js +18 -0
  343. package/dist/fonts.d.ts +1 -0
  344. package/dist/fonts.js +19 -0
  345. package/dist/geo/dach.d.ts +1 -0
  346. package/dist/geo/dach.js +14 -0
  347. package/dist/geo/de-states.d.ts +1 -0
  348. package/dist/geo/de-states.js +14 -0
  349. package/dist/geo/eu27.d.ts +1 -0
  350. package/dist/geo/eu27.js +14 -0
  351. package/dist/geo/europe.d.ts +1 -0
  352. package/dist/geo/europe.js +14 -0
  353. package/dist/geo/index.d.ts +1 -0
  354. package/dist/geo/index.js +41 -0
  355. package/dist/geo/us-states.d.ts +1 -0
  356. package/dist/geo/us-states.js +14 -0
  357. package/dist/geo/world.d.ts +1 -0
  358. package/dist/geo/world.js +14 -0
  359. package/dist/index.d.ts +1 -0
  360. package/dist/index.js +363 -0
  361. package/dist/main-ISJ53IS5.js +568 -0
  362. package/dist/mcp/server.js +1023 -0
  363. package/dist/module-SVEW5ZUE.js +137233 -0
  364. package/dist/react/bar.d.ts +1 -0
  365. package/dist/react/bar.js +80 -0
  366. package/dist/react/bartable.d.ts +1 -0
  367. package/dist/react/bartable.js +70 -0
  368. package/dist/react/box.d.ts +1 -0
  369. package/dist/react/box.js +64 -0
  370. package/dist/react/bullet.d.ts +1 -0
  371. package/dist/react/bullet.js +71 -0
  372. package/dist/react/butterfly.d.ts +1 -0
  373. package/dist/react/butterfly.js +65 -0
  374. package/dist/react/choropleth.d.ts +1 -0
  375. package/dist/react/choropleth.js +67 -0
  376. package/dist/react/cohort.d.ts +1 -0
  377. package/dist/react/cohort.js +69 -0
  378. package/dist/react/column.d.ts +1 -0
  379. package/dist/react/column.js +85 -0
  380. package/dist/react/combo.d.ts +1 -0
  381. package/dist/react/combo.js +85 -0
  382. package/dist/react/creative.d.ts +1 -0
  383. package/dist/react/creative.js +61 -0
  384. package/dist/react/diagram.d.ts +1 -0
  385. package/dist/react/diagram.js +60 -0
  386. package/dist/react/dimswitch.d.ts +1 -0
  387. package/dist/react/dimswitch.js +71 -0
  388. package/dist/react/dot.d.ts +1 -0
  389. package/dist/react/dot.js +69 -0
  390. package/dist/react/export.d.ts +1 -0
  391. package/dist/react/export.js +657 -0
  392. package/dist/react/funnel.d.ts +1 -0
  393. package/dist/react/funnel.js +62 -0
  394. package/dist/react/gantt.d.ts +1 -0
  395. package/dist/react/gantt.js +62 -0
  396. package/dist/react/grid.d.ts +1 -0
  397. package/dist/react/grid.js +66 -0
  398. package/dist/react/heatmap.d.ts +1 -0
  399. package/dist/react/heatmap.js +67 -0
  400. package/dist/react/histogram.d.ts +1 -0
  401. package/dist/react/histogram.js +85 -0
  402. package/dist/react/index.d.ts +1 -0
  403. package/dist/react/index.js +503 -0
  404. package/dist/react/kpi.d.ts +1 -0
  405. package/dist/react/kpi.js +67 -0
  406. package/dist/react/likert.d.ts +1 -0
  407. package/dist/react/likert.js +82 -0
  408. package/dist/react/line.d.ts +1 -0
  409. package/dist/react/line.js +80 -0
  410. package/dist/react/mekko.d.ts +1 -0
  411. package/dist/react/mekko.js +70 -0
  412. package/dist/react/pareto.d.ts +1 -0
  413. package/dist/react/pareto.js +89 -0
  414. package/dist/react/pie.d.ts +1 -0
  415. package/dist/react/pie.js +63 -0
  416. package/dist/react/prepare.d.ts +1 -0
  417. package/dist/react/prepare.js +277 -0
  418. package/dist/react/pvm.d.ts +1 -0
  419. package/dist/react/pvm.js +67 -0
  420. package/dist/react/pyramid.d.ts +1 -0
  421. package/dist/react/pyramid.js +66 -0
  422. package/dist/react/sankey.d.ts +1 -0
  423. package/dist/react/sankey.js +59 -0
  424. package/dist/react/scatter.d.ts +1 -0
  425. package/dist/react/scatter.js +62 -0
  426. package/dist/react/slope.d.ts +1 -0
  427. package/dist/react/slope.js +63 -0
  428. package/dist/react/sparkline.d.ts +1 -0
  429. package/dist/react/sparkline.js +59 -0
  430. package/dist/react/spec.d.ts +1 -0
  431. package/dist/react/spec.js +370 -0
  432. package/dist/react/status.d.ts +1 -0
  433. package/dist/react/status.js +64 -0
  434. package/dist/react/story.d.ts +1 -0
  435. package/dist/react/story.js +140 -0
  436. package/dist/react/table.d.ts +1 -0
  437. package/dist/react/table.js +68 -0
  438. package/dist/react/theme.d.ts +1 -0
  439. package/dist/react/theme.js +53 -0
  440. package/dist/react/tilemap.d.ts +1 -0
  441. package/dist/react/tilemap.js +66 -0
  442. package/dist/react/treemap.d.ts +1 -0
  443. package/dist/react/treemap.js +61 -0
  444. package/dist/react/variance.d.ts +1 -0
  445. package/dist/react/variance.js +64 -0
  446. package/dist/react/waffle.d.ts +1 -0
  447. package/dist/react/waffle.js +62 -0
  448. package/dist/react/waterfall.d.ts +1 -0
  449. package/dist/react/waterfall.js +67 -0
  450. package/dist/resvg-ZOVDIZTV.js +23 -0
  451. package/dist/rows.d.ts +1 -0
  452. package/dist/rows.js +23 -0
  453. package/dist/rowsModule-3Y4I3M3E.js +27 -0
  454. package/dist/schema-2BMZOHXI.js +22 -0
  455. package/dist/schema-2GUBWOBC.js +26 -0
  456. package/dist/schema-34ZELWRQ.js +25 -0
  457. package/dist/schema-3BHL2B76.js +22 -0
  458. package/dist/schema-4735XAZX.js +29 -0
  459. package/dist/schema-5YTNQ6JY.js +22 -0
  460. package/dist/schema-7J3NAIN2.js +27 -0
  461. package/dist/schema-AOJJ7JZB.js +22 -0
  462. package/dist/schema-CVMV4LRA.js +22 -0
  463. package/dist/schema-D3RCMN3T.js +22 -0
  464. package/dist/schema-E2ISJ65D.js +23 -0
  465. package/dist/schema-E6YOSOWB.js +28 -0
  466. package/dist/schema-EQQB43AY.js +22 -0
  467. package/dist/schema-EVLLL5UF.js +22 -0
  468. package/dist/schema-EYQ5IBLF.js +23 -0
  469. package/dist/schema-EYZVD73N.js +22 -0
  470. package/dist/schema-G4KFMQBL.js +22 -0
  471. package/dist/schema-GH7IKSOU.js +23 -0
  472. package/dist/schema-IF5N3J56.js +42 -0
  473. package/dist/schema-IG7JIR4H.js +23 -0
  474. package/dist/schema-JJYJOQTT.js +23 -0
  475. package/dist/schema-KFC4WYH4.js +32 -0
  476. package/dist/schema-L7263JMT.js +25 -0
  477. package/dist/schema-MEAFRXVH.js +53 -0
  478. package/dist/schema-P63S63GE.js +23 -0
  479. package/dist/schema-P7LJFJAJ.js +22 -0
  480. package/dist/schema-PA2MXYY4.js +23 -0
  481. package/dist/schema-PDZ6256H.js +23 -0
  482. package/dist/schema-PNC3Z7AH.js +25 -0
  483. package/dist/schema-QEVSIMGO.js +22 -0
  484. package/dist/schema-QJJPRRE7.js +22 -0
  485. package/dist/schema-S3EQKVOT.js +23 -0
  486. package/dist/schema-STGL44TL.js +22 -0
  487. package/dist/schema-T4NE2EAO.js +22 -0
  488. package/dist/schema-TQYTESG3.js +22 -0
  489. package/dist/schema-W376PAJG.js +22 -0
  490. package/dist/schema-XYYDUUHS.js +26 -0
  491. package/dist/specValidation-NVBIZMEE.js +48 -0
  492. package/dist/theme.d.ts +1 -0
  493. package/dist/theme.js +24 -0
  494. package/dist/themeShapeRules-5C2463YH.js +11 -0
  495. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  496. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  497. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  498. package/dist/types/core/a11y/types.d.ts +116 -0
  499. package/dist/types/core/annotate.d.ts +300 -0
  500. package/dist/types/core/annotateArms.d.ts +37 -0
  501. package/dist/types/core/annotateFields.d.ts +30 -0
  502. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  503. package/dist/types/core/annotateLinks.d.ts +47 -0
  504. package/dist/types/core/annotateTargets.d.ts +90 -0
  505. package/dist/types/core/axis.d.ts +179 -0
  506. package/dist/types/core/bandSelect.d.ts +10 -0
  507. package/dist/types/core/bands.d.ts +14 -0
  508. package/dist/types/core/calendarLabels.d.ts +101 -0
  509. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  510. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  511. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  512. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  513. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  514. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  515. package/dist/types/core/charts/box/types.d.ts +110 -0
  516. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  517. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  518. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  519. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  520. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  521. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  522. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  523. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  524. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  525. package/dist/types/core/charts/column/layout.d.ts +116 -0
  526. package/dist/types/core/charts/column/model.d.ts +295 -0
  527. package/dist/types/core/charts/column/types.d.ts +56 -0
  528. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  529. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  530. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  531. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  532. package/dist/types/core/charts/creative/types.d.ts +73 -0
  533. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  534. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  535. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  536. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  537. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  538. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  540. package/dist/types/core/charts/gantt/layout.d.ts +56 -0
  541. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  542. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  543. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  544. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  545. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  546. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  547. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  548. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  549. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  550. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  551. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  552. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  553. package/dist/types/core/charts/line/types.d.ts +6 -0
  554. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  555. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  556. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  557. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  558. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  559. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  560. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  561. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  562. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  563. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  564. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  565. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  566. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  567. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  568. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  569. package/dist/types/core/charts/status/layout.d.ts +71 -0
  570. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  571. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  572. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  573. package/dist/types/core/charts/table/view.d.ts +156 -0
  574. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  575. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  576. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  577. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  578. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  579. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  580. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  581. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  582. package/dist/types/core/claims/browser.d.ts +49 -0
  583. package/dist/types/core/claims/manifest.d.ts +22 -0
  584. package/dist/types/core/dateFormat.d.ts +39 -0
  585. package/dist/types/core/deferred.d.ts +121 -0
  586. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  587. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  588. package/dist/types/core/doc/bareChart.d.ts +2 -0
  589. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  590. package/dist/types/core/doc/docExpand.d.ts +39 -0
  591. package/dist/types/core/doc/document.d.ts +43 -0
  592. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  593. package/dist/types/core/doc/specError.d.ts +6 -0
  594. package/dist/types/core/emptyData.d.ts +27 -0
  595. package/dist/types/core/eventLane.d.ts +208 -0
  596. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  597. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  598. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  599. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  600. package/dist/types/core/footer.d.ts +59 -0
  601. package/dist/types/core/format.d.ts +149 -0
  602. package/dist/types/core/formatPrecision.d.ts +136 -0
  603. package/dist/types/core/formatSpec.d.ts +302 -0
  604. package/dist/types/core/frame.d.ts +583 -0
  605. package/dist/types/core/geo/packs/all.d.ts +7 -0
  606. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  607. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  608. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  609. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  610. package/dist/types/core/geo/packs/index.d.ts +22 -0
  611. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  612. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  613. package/dist/types/core/geo/packs/world.d.ts +16 -0
  614. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  615. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  616. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  617. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  618. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  619. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  620. package/dist/types/core/geo/types.d.ts +146 -0
  621. package/dist/types/core/geometry.d.ts +102 -0
  622. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  623. package/dist/types/core/icons.d.ts +227 -0
  624. package/dist/types/core/inputError.d.ts +14 -0
  625. package/dist/types/core/isoDate.d.ts +2 -0
  626. package/dist/types/core/isoTime.d.ts +7 -0
  627. package/dist/types/core/label/categoryRow.d.ts +332 -0
  628. package/dist/types/core/label/occupied.d.ts +41 -0
  629. package/dist/types/core/label/ownership.d.ts +83 -0
  630. package/dist/types/core/label/solver.d.ts +380 -0
  631. package/dist/types/core/label/tickRow.d.ts +78 -0
  632. package/dist/types/core/live/types.d.ts +50 -0
  633. package/dist/types/core/normalize/shared.d.ts +56 -0
  634. package/dist/types/core/notes.d.ts +174 -0
  635. package/dist/types/core/othersShade.d.ts +9 -0
  636. package/dist/types/core/periodYears.d.ts +9 -0
  637. package/dist/types/core/polyline.d.ts +11 -0
  638. package/dist/types/core/rangeRules.d.ts +19 -0
  639. package/dist/types/core/ratioTier.d.ts +120 -0
  640. package/dist/types/core/readerStrings.d.ts +13 -0
  641. package/dist/types/core/reading.d.ts +120 -0
  642. package/dist/types/core/registry.d.ts +178 -0
  643. package/dist/types/core/repaintGeometry.d.ts +19 -0
  644. package/dist/types/core/request.d.ts +124 -0
  645. package/dist/types/core/rows.d.ts +45 -0
  646. package/dist/types/core/scale.d.ts +106 -0
  647. package/dist/types/core/schema/capability.d.ts +229 -0
  648. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  649. package/dist/types/core/schema/reference.d.ts +31 -0
  650. package/dist/types/core/schema/refusals.d.ts +45 -0
  651. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  652. package/dist/types/core/seriesIdentity.d.ts +120 -0
  653. package/dist/types/core/shareRounding.d.ts +49 -0
  654. package/dist/types/core/sizing.d.ts +330 -0
  655. package/dist/types/core/staticFooter.d.ts +6 -0
  656. package/dist/types/core/story.d.ts +41 -0
  657. package/dist/types/core/structureCounts.d.ts +10 -0
  658. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  659. package/dist/types/core/target.d.ts +89 -0
  660. package/dist/types/core/text.d.ts +113 -0
  661. package/dist/types/core/theme.d.ts +478 -0
  662. package/dist/types/core/themeFields.d.ts +11 -0
  663. package/dist/types/core/themeRules.d.ts +111 -0
  664. package/dist/types/core/themeShape.d.ts +87 -0
  665. package/dist/types/core/themeValidate.d.ts +15 -0
  666. package/dist/types/core/timeAxis.d.ts +106 -0
  667. package/dist/types/core/types/annotations.d.ts +223 -0
  668. package/dist/types/core/types/cell.d.ts +82 -0
  669. package/dist/types/core/types/data.d.ts +309 -0
  670. package/dist/types/core/types/diagram.d.ts +234 -0
  671. package/dist/types/core/types/index.d.ts +8 -0
  672. package/dist/types/core/types/options.d.ts +1583 -0
  673. package/dist/types/core/types/scene.d.ts +990 -0
  674. package/dist/types/core/types/sizing.d.ts +51 -0
  675. package/dist/types/core/types/table.d.ts +873 -0
  676. package/dist/types/core/types/theme.d.ts +806 -0
  677. package/dist/types/core/zoom.d.ts +106 -0
  678. package/dist/types/fixtures/index.d.ts +40 -0
  679. package/dist/types/fixtures/registry.d.ts +15 -0
  680. package/dist/types/fonts.d.ts +10 -0
  681. package/dist/types/index.d.ts +70 -0
  682. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  683. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  684. package/dist/types/react/ScaleGroup.d.ts +31 -0
  685. package/dist/types/react/SceneRenderer.d.ts +23 -0
  686. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  687. package/dist/types/react/StoryFrame.d.ts +42 -0
  688. package/dist/types/react/TableChart.d.ts +220 -0
  689. package/dist/types/react/a11ySurface.d.ts +20 -0
  690. package/dist/types/react/barrelCharts.d.ts +1023 -0
  691. package/dist/types/react/charts/bar.d.ts +28 -0
  692. package/dist/types/react/charts/bartable.d.ts +27 -0
  693. package/dist/types/react/charts/box.d.ts +27 -0
  694. package/dist/types/react/charts/bullet.d.ts +28 -0
  695. package/dist/types/react/charts/butterfly.d.ts +28 -0
  696. package/dist/types/react/charts/choropleth.d.ts +27 -0
  697. package/dist/types/react/charts/cohort.d.ts +52 -0
  698. package/dist/types/react/charts/column.d.ts +27 -0
  699. package/dist/types/react/charts/combo.d.ts +7 -0
  700. package/dist/types/react/charts/creative.d.ts +27 -0
  701. package/dist/types/react/charts/diagram.d.ts +162 -0
  702. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  703. package/dist/types/react/charts/dot.d.ts +28 -0
  704. package/dist/types/react/charts/funnel.d.ts +28 -0
  705. package/dist/types/react/charts/gantt.d.ts +28 -0
  706. package/dist/types/react/charts/grid.d.ts +29 -0
  707. package/dist/types/react/charts/heatmap.d.ts +28 -0
  708. package/dist/types/react/charts/histogram.d.ts +27 -0
  709. package/dist/types/react/charts/kpi.d.ts +28 -0
  710. package/dist/types/react/charts/likert.d.ts +27 -0
  711. package/dist/types/react/charts/line.d.ts +28 -0
  712. package/dist/types/react/charts/mekko.d.ts +28 -0
  713. package/dist/types/react/charts/pareto.d.ts +28 -0
  714. package/dist/types/react/charts/pie.d.ts +28 -0
  715. package/dist/types/react/charts/pvm.d.ts +27 -0
  716. package/dist/types/react/charts/pyramid.d.ts +27 -0
  717. package/dist/types/react/charts/sankey.d.ts +27 -0
  718. package/dist/types/react/charts/scatter.d.ts +28 -0
  719. package/dist/types/react/charts/slope.d.ts +28 -0
  720. package/dist/types/react/charts/sparkline.d.ts +28 -0
  721. package/dist/types/react/charts/status.d.ts +27 -0
  722. package/dist/types/react/charts/table.d.ts +6 -0
  723. package/dist/types/react/charts/tilemap.d.ts +27 -0
  724. package/dist/types/react/charts/treemap.d.ts +27 -0
  725. package/dist/types/react/charts/variance.d.ts +28 -0
  726. package/dist/types/react/charts/waffle.d.ts +28 -0
  727. package/dist/types/react/charts/waterfall.d.ts +28 -0
  728. package/dist/types/react/createChartComponent.d.ts +135 -0
  729. package/dist/types/react/export/clipboard.d.ts +8 -0
  730. package/dist/types/react/export/csv.d.ts +2 -0
  731. package/dist/types/react/export/frame.d.ts +35 -0
  732. package/dist/types/react/export/index.d.ts +7 -0
  733. package/dist/types/react/export/png.d.ts +14 -0
  734. package/dist/types/react/export/svg.d.ts +5 -0
  735. package/dist/types/react/export/types.d.ts +69 -0
  736. package/dist/types/react/export/useExport.d.ts +17 -0
  737. package/dist/types/react/exportLink.d.ts +49 -0
  738. package/dist/types/react/footerFrame.d.ts +25 -0
  739. package/dist/types/react/hover/dataTable.d.ts +13 -0
  740. package/dist/types/react/hover/engine.d.ts +210 -0
  741. package/dist/types/react/hover/keyboard.d.ts +44 -0
  742. package/dist/types/react/hover/labelCard.d.ts +170 -0
  743. package/dist/types/react/hover/placement.d.ts +49 -0
  744. package/dist/types/react/index.d.ts +16 -0
  745. package/dist/types/react/parseChartSpec.d.ts +16 -0
  746. package/dist/types/react/prepare.d.ts +32 -0
  747. package/dist/types/react/prepared.d.ts +53 -0
  748. package/dist/types/react/preparedTable.d.ts +15 -0
  749. package/dist/types/react/rowsInput.d.ts +55 -0
  750. package/dist/types/react/rowsModule.d.ts +18 -0
  751. package/dist/types/react/rowsStore.d.ts +50 -0
  752. package/dist/types/react/scale-group.d.ts +2 -0
  753. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  754. package/dist/types/react/scenePaint.d.ts +10 -0
  755. package/dist/types/react/scrollState.d.ts +26 -0
  756. package/dist/types/react/spec.d.ts +65 -0
  757. package/dist/types/react/specValidation.d.ts +45 -0
  758. package/dist/types/react/story.d.ts +15 -0
  759. package/dist/types/react/theme.d.ts +9 -0
  760. package/dist/types/react/themeContext.d.ts +44 -0
  761. package/dist/types/react/useChartLayout.d.ts +22 -0
  762. package/dist/types/react/useContainerSize.d.ts +57 -0
  763. package/dist/types/react/useHover.d.ts +100 -0
  764. package/dist/types/react/useZoom.d.ts +50 -0
  765. package/dist/types/rows.d.ts +58 -0
  766. package/dist/types/tableLooks.d.ts +6 -0
  767. package/dist/types/theme.d.ts +3 -0
  768. package/dist/types/validate.d.ts +3 -0
  769. package/dist/validate.d.ts +1 -0
  770. package/dist/validate.js +222 -0
  771. package/docs/FONTS.md +68 -0
  772. package/docs/TELEMETRY.md +94 -0
  773. package/docs/manual.md +838 -0
  774. package/docs/reference/bar.md +222 -0
  775. package/docs/reference/bartable.md +143 -0
  776. package/docs/reference/box.md +93 -0
  777. package/docs/reference/bullet.md +118 -0
  778. package/docs/reference/butterfly.md +117 -0
  779. package/docs/reference/choropleth.md +148 -0
  780. package/docs/reference/cohort.md +149 -0
  781. package/docs/reference/column.md +275 -0
  782. package/docs/reference/combo.md +219 -0
  783. package/docs/reference/creative.md +147 -0
  784. package/docs/reference/diagram.md +191 -0
  785. package/docs/reference/dimswitch.md +1395 -0
  786. package/docs/reference/dot.md +117 -0
  787. package/docs/reference/fixtures.md +1088 -0
  788. package/docs/reference/funnel.md +121 -0
  789. package/docs/reference/gantt.md +132 -0
  790. package/docs/reference/grid.md +302 -0
  791. package/docs/reference/heatmap.md +127 -0
  792. package/docs/reference/histogram.md +77 -0
  793. package/docs/reference/kpi.md +115 -0
  794. package/docs/reference/likert.md +113 -0
  795. package/docs/reference/line.md +436 -0
  796. package/docs/reference/mekko.md +114 -0
  797. package/docs/reference/options.md +313 -0
  798. package/docs/reference/pareto.md +102 -0
  799. package/docs/reference/pie.md +114 -0
  800. package/docs/reference/pvm.md +114 -0
  801. package/docs/reference/pyramid.md +99 -0
  802. package/docs/reference/react.md +703 -0
  803. package/docs/reference/reading.md +28 -0
  804. package/docs/reference/sankey.md +110 -0
  805. package/docs/reference/scatter.md +211 -0
  806. package/docs/reference/slope.md +126 -0
  807. package/docs/reference/sparkline.md +74 -0
  808. package/docs/reference/status.md +107 -0
  809. package/docs/reference/table.md +673 -0
  810. package/docs/reference/theme.md +361 -0
  811. package/docs/reference/tilemap.md +121 -0
  812. package/docs/reference/treemap.md +86 -0
  813. package/docs/reference/variance.md +126 -0
  814. package/docs/reference/waffle.md +106 -0
  815. package/docs/reference/waterfall.md +164 -0
  816. package/llms.txt +57 -0
  817. package/package.json +437 -4
@@ -0,0 +1,2543 @@
1
+ import {
2
+ BADGE_SECTION_ONLY,
3
+ BADGE_TEXT_EMPTY,
4
+ STATUS_VALUES
5
+ } from "./chunk-KOJ5QETJ.js";
6
+ import {
7
+ tableCellKey
8
+ } from "./chunk-M4SPKUZE.js";
9
+ import {
10
+ calcPreservesScale
11
+ } from "./chunk-T3IGJARD.js";
12
+ import {
13
+ DEFAULT_TRACK_GROWTH,
14
+ DENSE_COLUMNS,
15
+ INLINE_LABEL_INDENT,
16
+ LABEL_WRAP_FLOOR,
17
+ SOFT_LABEL_CAP,
18
+ SORT_CHEVRON_RESERVE,
19
+ authoredTrackWidth,
20
+ authoredWidthWarnings,
21
+ cellPadX,
22
+ changeLineFont,
23
+ collapsedHintWidth,
24
+ columnTracks,
25
+ encodingReserve,
26
+ frameFillExtras,
27
+ groupHeadingFaces,
28
+ groupHeadingFloors,
29
+ headerContentWidth,
30
+ headsFit,
31
+ inlineFont,
32
+ intrinsicColumnWidth,
33
+ kindFont,
34
+ labelIndents,
35
+ rowFont,
36
+ sectionChipFloor,
37
+ tableFonts,
38
+ wrapFloorWidth
39
+ } from "./chunk-QNHZXFRA.js";
40
+ import {
41
+ toneTextPaint
42
+ } from "./chunk-A3ULWR5N.js";
43
+ import {
44
+ operatorWidth,
45
+ qualifierFont
46
+ } from "./chunk-Z2MGTKDR.js";
47
+ import {
48
+ bandFor
49
+ } from "./chunk-263SZKIL.js";
50
+ import {
51
+ chartSizing,
52
+ fitsSize,
53
+ resolveSizing
54
+ } from "./chunk-GQPESFAF.js";
55
+ import {
56
+ clamp,
57
+ datePatternFromExample,
58
+ formatDate,
59
+ isNumberAlone,
60
+ numericVariant,
61
+ unitPrinted
62
+ } from "./chunk-2JAWQ7VV.js";
63
+ import {
64
+ disclosureNote,
65
+ disclosuresShown,
66
+ footerType
67
+ } from "./chunk-YTSSXSZR.js";
68
+ import {
69
+ AUTOMATIC_FORMAT,
70
+ MAGNITUDE_DIVISOR,
71
+ MAGNITUDE_GROUP,
72
+ differenceExample,
73
+ effectiveScale,
74
+ formatWithSpec,
75
+ magnitudeLabel,
76
+ parseFormatExample,
77
+ parseISODate,
78
+ roundedNumber,
79
+ specUnitKind,
80
+ unitOfSpec,
81
+ withChartMarks
82
+ } from "./chunk-ASAON7G4.js";
83
+ import {
84
+ MINUS,
85
+ chartNumberMarks,
86
+ currencyWholeNumbers,
87
+ formatExactNumber,
88
+ intervalText,
89
+ localeStrings,
90
+ nonzeroDecimals,
91
+ typicalDecimals,
92
+ withSmallValues,
93
+ zeroLifts
94
+ } from "./chunk-YQ2B3YVF.js";
95
+ import {
96
+ canvasMargin,
97
+ contrastInkPaint,
98
+ groundTextPaint,
99
+ markRolePaint,
100
+ microType,
101
+ mixedPaint,
102
+ readerFloorPx,
103
+ resolveTheme,
104
+ semanticPalettePaint,
105
+ sequentialShare,
106
+ signedFillPaint,
107
+ tableEmphasis,
108
+ tableHeadFloorPx,
109
+ textScaleOf
110
+ } from "./chunk-II7652VA.js";
111
+ import {
112
+ DEFAULT_TARGET,
113
+ NormalizeError,
114
+ TARGET_SIZE,
115
+ resolveCanvasOptions,
116
+ resolveHighlight,
117
+ resolveSize,
118
+ resolveSubtitle,
119
+ scaleTextPx,
120
+ targetFloorsPx
121
+ } from "./chunk-SGD3ZHID.js";
122
+ import {
123
+ maxOf,
124
+ minOf,
125
+ pushAll
126
+ } from "./chunk-WYJEOMNY.js";
127
+ import {
128
+ twoLineWidth
129
+ } from "./chunk-TXINIAFL.js";
130
+
131
+ // src/core/charts/table/ladder.ts
132
+ var COHORT_GRID = {
133
+ cohort: { rowHeight: 26, sizeStep: -0.5 },
134
+ "cohort-small": { rowHeight: 20, sizeStep: -1 }
135
+ };
136
+ function isCohortDensity(density) {
137
+ return density === "cohort" || density === "cohort-small";
138
+ }
139
+ var LINE_RATIO = 1.33, INLINE_LINE_RATIO = 1.3, INLINE_GAP = 2, CLOSER_STANDOFF = 8, LINE_BOX_EPSILON = 1e-6;
140
+ function lineBoxAt(size, ratio) {
141
+ return Math.ceil(size * ratio - LINE_BOX_EPSILON);
142
+ }
143
+ function levelLadder(theme, density = "regular", target = DEFAULT_TARGET, textScale = 1) {
144
+ let d = (px) => scaleTextPx(px, textScale), grid = isCohortDensity(density) ? COHORT_GRID[density] : void 0, table = theme.table, sizeStep = d(grid ? grid.sizeStep : 0), labelFloor = Math.min(theme.type.label.size, readerFloorPx(target, "label", textScale)), headFace = table?.head?.size ?? theme.type.axis.size, ownHead = textScale < 1 && headFace >= (table?.head?.size !== void 0 ? tableHeadFloorPx(target) : targetFloorsPx(target).axis) ? 1 / 0 : headFace, axisFloor = Math.min(ownHead, tableHeadFloorPx(target, textScale)), padStep = density === "compact" ? -1 : density === "relaxed" ? 2 : 0, label = Math.max(labelFloor, theme.type.label.size + sizeStep), total = grid && table?.fixedType === !0 ? theme.type.label.size : label, body = Math.max(labelFloor, grid || table?.rows ? label : label - d(1)), headStep = table?.head?.size ?? Math.max(axisFloor, theme.type.axis.size + (grid ? 0 : sizeStep)), axis = Math.max(axisFloor, Math.min(headStep, body - d(2))), headRatio = table?.head?.lineHeight ?? LINE_RATIO, headBox = (value) => lineBoxAt(value, headRatio), sectionRatio = table?.section?.lineHeight, micro = microType(theme).size, rows = grid ? void 0 : table?.rows, size = (level) => Math.max(labelFloor, grid || rows || level <= 0 ? label : label - d(1)), lineBox = (value) => rows?.lineHeight === void 0 ? Math.ceil(value * LINE_RATIO) : lineBoxAt(value, rows.lineHeight), sectionBox = (value) => sectionRatio === void 0 ? lineBox(value) : lineBoxAt(value, sectionRatio);
145
+ if (grid) {
146
+ let rowHeight = Math.max(grid.rowHeight, lineBox(label) + 2), air = Math.max(1, (rowHeight - lineBox(label)) / 2);
147
+ return {
148
+ target,
149
+ textScale,
150
+ label,
151
+ total,
152
+ axis,
153
+ headBox,
154
+ sectionBox,
155
+ micro,
156
+ rowHeight,
157
+ group: Math.max(axisFloor, axis - d(0.5), micro),
158
+ // The closing row stands 4 px off the matrix and carries a rule on
159
+ // each side: one pitch of air plus that standoff, minus the rules.
160
+ totalPad: Math.max(1, (rowHeight + CLOSER_STANDOFF - lineBox(total) - 2) / 2),
161
+ lineBox,
162
+ inlineSize: () => Math.max(labelFloor, micro, label - d(2)),
163
+ inlineBox: (value) => Math.ceil(value * INLINE_LINE_RATIO),
164
+ inlineGap: INLINE_GAP,
165
+ size,
166
+ weight: () => theme.type.label.weight,
167
+ pad: () => air
168
+ };
169
+ }
170
+ return {
171
+ target,
172
+ textScale,
173
+ label,
174
+ total,
175
+ axis,
176
+ headBox,
177
+ sectionBox,
178
+ micro,
179
+ group: Math.max(axisFloor, axis - d(0.5), micro),
180
+ totalPad: Math.max(1, 8 + padStep),
181
+ lineBox,
182
+ inlineSize: () => Math.max(labelFloor, micro, label - d(2)),
183
+ inlineBox: (size2) => Math.ceil(size2 * INLINE_LINE_RATIO),
184
+ inlineGap: INLINE_GAP,
185
+ size,
186
+ weight: (_level, hasChildren) => hasChildren ? tableEmphasis(theme) : theme.type.label.weight,
187
+ pad: (level, hasChildren) => Math.max(rows?.pad === void 0 ? 1 : 0, (rows?.pad ?? (level <= 0 || level === 1 && hasChildren ? 7 : level <= 2 ? 4 : 3)) + padStep)
188
+ };
189
+ }
190
+
191
+ // src/core/charts/table/presets.ts
192
+ var PLAIN = {
193
+ totalPosition: "bottom",
194
+ groupBand: !0,
195
+ squareChips: !1,
196
+ datesRight: !1
197
+ }, LANGUAGE = {
198
+ hierarchy: PLAIN,
199
+ steering: { ...PLAIN, totalPosition: "top", groupBand: !1 },
200
+ benchmark: { ...PLAIN, labelEmphasis: "strong", groupBand: !1 },
201
+ status: { ...PLAIN, squareChips: !0 },
202
+ receipts: { ...PLAIN, datesRight: !0 }
203
+ };
204
+ function presetLanguage(variant) {
205
+ return LANGUAGE[variant ?? "hierarchy"];
206
+ }
207
+
208
+ // src/core/charts/table/calcRef.ts
209
+ function previousColumnInGroup(groups, colId) {
210
+ for (let group of groups) {
211
+ let index = group.columns.indexOf(colId);
212
+ if (index > 0) return group.columns[index - 1];
213
+ if (index === 0) return null;
214
+ }
215
+ return null;
216
+ }
217
+ function resolveCalcRef(ref, currentRow, currentCol, previousCol, noPrevious = "na") {
218
+ if (typeof ref == "string") return { rowId: currentRow, colId: ref };
219
+ if (ref.previous) {
220
+ if (!currentCol || !previousCol) return "na";
221
+ let colId2 = previousCol(currentCol);
222
+ return colId2 === null ? noPrevious : { rowId: ref.row, colId: colId2 };
223
+ }
224
+ let colId = ref.col ?? currentCol;
225
+ return colId ? { rowId: ref.row, colId } : "missing";
226
+ }
227
+ function readCalcInput(ref, args) {
228
+ let resolved = resolveCalcRef(ref, args.currentRow, args.currentCol, args.previousCol, args.noPrevious);
229
+ if (typeof resolved == "string")
230
+ return args.emit(`<${resolved}>`), resolved;
231
+ let { rowId, colId } = resolved, s = rowId === args.currentRow ? args.states.get(colId) : args.rawState?.get(rowId)?.get(colId);
232
+ return s ? s.state !== "value" || typeof s.raw != "number" ? (args.emit(`<${s.state}>`), s.state) : (args.inputs.push({ rowId, colId, value: s.raw }), args.emit(`$${args.inputs.length - 1}`), s.raw) : (args.emit("?"), "missing");
233
+ }
234
+
235
+ // src/core/charts/table/rank.ts
236
+ function assertTableRankOptions(options) {
237
+ let segments = options.sort?.segments;
238
+ if (segments !== void 0 && segments !== "sheet")
239
+ throw new NormalizeError(
240
+ "table-sort-segments-unsupported",
241
+ "options.sort.segments",
242
+ `table has no segments; sort.segments '${segments}' cannot reorder columns without breaking groups and accounting`,
243
+ "drop sort.segments, or sort rows with sort.categories ('sheet', 'reverse', 'asc', 'desc')"
244
+ );
245
+ }
246
+ function ranksAsData(row) {
247
+ return (row?.role ?? "data") === "data" && row?.kind !== "result" && row?.kind !== "driver";
248
+ }
249
+ function additiveRankKey(row, columns) {
250
+ let sum = 0, counted = !1;
251
+ for (let column of columns) {
252
+ if (column.kind !== "value" || column.aggregate === "none" || column.aggregate === "source") continue;
253
+ let cell = row.cells[column.id];
254
+ cell?.state === "value" && typeof cell.raw == "number" && (sum += cell.raw, counted = !0);
255
+ }
256
+ return counted ? sum : null;
257
+ }
258
+ function requireAdditiveRanking(columns, rows, path, action) {
259
+ if (!rows.some((row) => ranksAsData(row) && additiveRankKey(row, columns) !== null))
260
+ throw new NormalizeError(
261
+ "table-rank-unranked",
262
+ path,
263
+ `${action} needs at least one additive value column with a numeric cell; text, status and non-aggregating columns are not ranking keys`,
264
+ "add a value column with aggregate 'sum', or drop the ranking option"
265
+ );
266
+ }
267
+ function authoredById(rows) {
268
+ let out = /* @__PURE__ */ new Map(), walk = (list) => {
269
+ for (let row of list)
270
+ out.set(row.id, row), row.children && walk(row.children);
271
+ };
272
+ return walk(rows), out;
273
+ }
274
+ function usedIds(rows) {
275
+ return new Set(authoredById(rows).keys());
276
+ }
277
+ function othersIdFor(parentId, used) {
278
+ let id = parentId ? `others:${parentId}` : "others";
279
+ for (; used.has(id); ) id = `_${id}`;
280
+ return used.add(id), id;
281
+ }
282
+ function siblingGroups(table) {
283
+ let groups = /* @__PURE__ */ new Map();
284
+ for (let row of table.rows) {
285
+ let parentId = row.parentId, list = groups.get(parentId) ?? [];
286
+ list.push(row), groups.set(parentId, list);
287
+ }
288
+ return groups;
289
+ }
290
+ function toAuthored(row, original, children) {
291
+ return {
292
+ ...original,
293
+ id: row.id,
294
+ label: original?.label ?? row.label,
295
+ role: original?.role ?? row.role,
296
+ relation: original?.relation ?? row.relation,
297
+ // The fold rebuilds a nested tree, including rows authored with parentId.
298
+ parentId: void 0,
299
+ children: children.length > 0 ? children : void 0
300
+ };
301
+ }
302
+ function foldSiblings(parentId, groups, original, table, topN, used, generatedOthers) {
303
+ let rebuilt = (groups.get(parentId) ?? []).map(
304
+ (row) => toAuthored(row, original.get(row.id), foldSiblings(row.id, groups, original, table, topN, used, generatedOthers))
305
+ ), dataIdx = rebuilt.map((_, index) => index).filter((index) => ranksAsData(original.get(rebuilt[index].id)));
306
+ if (dataIdx.length <= topN.n) return rebuilt;
307
+ let dataRows = dataIdx.map((index) => rebuilt[index]);
308
+ if (dataRows.some((row) => (original.get(row.id)?.relation ?? "additive") !== "additive"))
309
+ throw new NormalizeError(
310
+ "table-topn-relation-unsupported",
311
+ "options.topN",
312
+ "topN cannot regroup ofWhich or displayOnly rows; nesting them under Others would change whose total they annotate",
313
+ "keep those rows as authored siblings, or drop options.topN"
314
+ );
315
+ let keys = dataRows.map((row) => {
316
+ let resolved = table.rows.find((candidate) => candidate.id === row.id);
317
+ return Math.abs(additiveRankKey(resolved, table.columns) ?? 0);
318
+ }), ranked = dataRows.map((_, index) => index).sort((a, b) => keys[b] - keys[a] || a - b), keep = new Set(ranked.slice(0, Math.max(1, topN.n)));
319
+ if (topN.threshold !== void 0) {
320
+ for (let index of [...keep])
321
+ keys[index] < topN.threshold && keep.delete(index);
322
+ keep.size === 0 && ranked.length > 0 && keep.add(ranked[0]);
323
+ }
324
+ let dropped = dataRows.filter((_, index) => !keep.has(index));
325
+ if (dropped.length === 0) return rebuilt;
326
+ if (topN.rest === !1) {
327
+ if (parentId !== void 0)
328
+ throw new NormalizeError(
329
+ "table-topn-rest-required",
330
+ "options.topN.rest",
331
+ "topN.rest false would drop sibling summands and change the parent total; tables keep accounting by nesting the rest under Others",
332
+ "omit topN.rest (defaults to true), or flatten the hierarchy before omitting rows"
333
+ );
334
+ let keptIds2 = new Set(dataRows.filter((_, index) => keep.has(index)).map((row) => row.id));
335
+ return rebuilt.filter((row, index) => dataIdx.includes(index) ? keptIds2.has(row.id) : !0);
336
+ }
337
+ let keptIds = new Set(dataRows.filter((_, index) => keep.has(index)).map((row) => row.id)), lastData = dataIdx[dataIdx.length - 1], before = rebuilt.slice(0, lastData + 1).filter((row, index) => !dataIdx.includes(index) || keptIds.has(row.id)), after = rebuilt.slice(lastData + 1), label = (topN.restLabel ?? "Others") + (topN.showRestCount ? ` (${dropped.length})` : ""), id = othersIdFor(parentId, used);
338
+ return generatedOthers.add(id), [...before, {
339
+ id,
340
+ label,
341
+ role: "data",
342
+ relation: "additive",
343
+ totalPolicy: "derive",
344
+ children: dropped
345
+ }, ...after];
346
+ }
347
+ function foldTableTopN(data, ranked, options) {
348
+ let topN = options.topN, generatedOthers = /* @__PURE__ */ new Set();
349
+ if (!topN || topN.n <= 0) return { data, generatedOthers };
350
+ requireAdditiveRanking(ranked.columns, ranked.rows, "options.topN", "topN");
351
+ let original = authoredById(data.rows), folded = foldSiblings(
352
+ void 0,
353
+ siblingGroups(ranked),
354
+ original,
355
+ ranked,
356
+ topN,
357
+ usedIds(data.rows),
358
+ generatedOthers
359
+ );
360
+ return { data: { ...data, rows: folded }, generatedOthers };
361
+ }
362
+
363
+ // src/core/charts/table/encodings/arrow.ts
364
+ var ARROW_GAP = 4;
365
+ function arrowGlyph(value, maxAbs, scale) {
366
+ let share = scale === "absolute" ? value / 100 : maxAbs > 0 ? value / maxAbs : 0;
367
+ return share > 0.1 ? "\u2191" : share > 0.02 ? "\u2197" : share >= -0.02 ? "\u2192" : share >= -0.1 ? "\u2198" : "\u2193";
368
+ }
369
+ var ARROW_KEY = [
370
+ ["\u2191", "rise over 10%", "rise over 10% of the largest change"],
371
+ ["\u2197", "rise over 2%, up to 10%", "rise over 2%, up to 10% of the largest change"],
372
+ ["\u2192", "within 2%", "within 2% of the largest change"],
373
+ ["\u2198", "fall over 2%, up to 10%", "fall over 2%, up to 10% of the largest change"],
374
+ ["\u2193", "fall over 10%", "fall over 10% of the largest change"]
375
+ ], ARROW_FOOTNOTE = "An arrow's angle on a relative scale compares the change with the largest change in its column.";
376
+ function arrowKey(columns, rows) {
377
+ let drawn = { absolute: /* @__PURE__ */ new Set(), relative: /* @__PURE__ */ new Set() };
378
+ for (let column of columns) {
379
+ if (column.cellEncoding?.type !== "arrow" || column.kind !== "computed" || !column.polarity) continue;
380
+ let scale = column.cellEncoding.scale, values = rows.flatMap((row) => {
381
+ let cell = row.cells[column.id];
382
+ return cell?.state === "value" && typeof cell.raw == "number" ? [cell.raw] : [];
383
+ }), maxAbs = Math.max(0, maxOf(values.map(Math.abs)));
384
+ for (let value of values) drawn[scale].add(arrowGlyph(value, maxAbs, scale));
385
+ }
386
+ return ["absolute", "relative"].flatMap((scale) => ARROW_KEY.filter(([glyph]) => drawn[scale].has(glyph)).map(([glyph, absolute, relative]) => ({ id: scale === "absolute" ? `arrowKey:${glyph}` : `arrowKey:relative:${glyph}`, label: scale === "absolute" ? absolute : relative, glyph })));
387
+ }
388
+ function emitArrow(context, metrics) {
389
+ let value = context.cell.raw;
390
+ if (context.cell.state !== "value" || typeof value != "number") return [];
391
+ let glyph = arrowGlyph(value, metrics.maxAbs, metrics.scale), font = metrics.font, glyphWidth = context.measure(glyph, font).width, valueWidth = context.measure(context.cell.displayed, metrics.font).width, valueLeft = metrics.valueX - valueWidth, available = valueLeft - context.box.x - ARROW_GAP;
392
+ if (available <= 0) return [];
393
+ if (glyphWidth > available) {
394
+ let floor = Math.min(font.size, readerFloorPx(metrics.target ?? DEFAULT_TARGET, "label", metrics.textScale));
395
+ if (font = { ...font, size: Math.max(floor, font.size * available / glyphWidth) }, glyphWidth = context.measure(glyph, font).width, glyphWidth > available) return [];
396
+ }
397
+ return [
398
+ {
399
+ t: "text",
400
+ typeRole: "label",
401
+ id: context.nodeId("arrow"),
402
+ x: valueLeft - ARROW_GAP - glyphWidth,
403
+ y: context.box.y + (context.box.h - context.measure(glyph, font).height) / 2,
404
+ lines: [glyph],
405
+ align: "start",
406
+ font,
407
+ // The glyph prints in its figure's text colour, as the grid's arrow inherits it.
408
+ ink: context.cell.tone === "neutral" ? { token: "neutral" } : context.toneInk ?? toneTextPaint(context.theme, context.cell.tone, context.palette),
409
+ owner: context.owner,
410
+ part: "tableArrow"
411
+ }
412
+ ];
413
+ }
414
+
415
+ // src/core/charts/table/encodings/heat.ts
416
+ function heatRanges(columns, rows) {
417
+ let ranges = /* @__PURE__ */ new Map();
418
+ for (let column of columns) {
419
+ if (column.cellEncoding?.type !== "heat" || column.kind !== "value" && column.kind !== "computed") continue;
420
+ let spec = column.format === void 0 ? void 0 : parseFormatExample(column.format), status = column.cellEncoding.scale === "status", dataOnly = column.cellEncoding.steps !== void 0 || status, values = [], total;
421
+ for (let row of rows) {
422
+ let raw = row.cells[column.id];
423
+ if (row.role === "total" && raw?.state === "value" && typeof raw.raw == "number" && (total ??= raw.raw), dataOnly && row.role === "total") continue;
424
+ let cell = row.cells[column.id];
425
+ cell?.heat !== !1 && cell?.state === "value" && typeof cell.raw == "number" && values.push(cell.raw);
426
+ }
427
+ ranges.set(column.id, {
428
+ min: values.length > 0 ? minOf(values) : 0,
429
+ max: values.length > 0 ? maxOf(values) : 0,
430
+ signed: column.kind === "computed" && !!column.polarity || (spec?.signed ?? !1),
431
+ percent: spec !== void 0 && specUnitKind(spec) !== "number",
432
+ // Under `center: 'total'` a band is the distance from the figure the
433
+ // closing row prints, which the reader can check.
434
+ ...column.cellEncoding.center === "total" && total !== void 0 ? { mean: total, totalCentre: !0 } : values.length > 0 ? { mean: values.reduce((sum, value) => sum + value, 0) / values.length } : {},
435
+ ...status && column.polarity === "lowerIsBetter" ? { lowerIsBetter: !0 } : {}
436
+ });
437
+ }
438
+ return ranges;
439
+ }
440
+ var DEFAULT_ALPHA = 0.18, AUTO_INK_THRESHOLD = 0.35, DEFAULT_HEAT_STEPS = [0.06, 0.14, 0.26, 0.42], FILL_SEPARATION_FLOOR = 1.1, DIVERGING_ALPHAS = [0.12, 0.26], DIVERGING_BINS = [1, 4];
441
+ function stepAlphas(theme, steps) {
442
+ let ladder = theme.surface?.heatSteps ?? DEFAULT_HEAT_STEPS, count = Math.max(1, steps - 1);
443
+ if (count === ladder.length) return ladder;
444
+ let last = ladder.length - 1;
445
+ return Array.from({ length: count }, (_, index) => ladder[count === 1 ? last : Math.round(index * last / (count - 1))]);
446
+ }
447
+ function bandOf(value, range, options, steps) {
448
+ let scale = options.scale ?? "column";
449
+ if (scale === "absolute") {
450
+ let bins = options.bins ?? [];
451
+ return Math.min(steps - 1, bins.filter((edge) => value >= edge).length);
452
+ }
453
+ if (scale === "diverging") {
454
+ let edges = options.bins ?? DIVERGING_BINS, distance = Math.abs(value - (range.mean ?? 0)), reached = edges.filter((edge) => distance >= edge).length;
455
+ return reached === 0 ? null : reached;
456
+ }
457
+ let { min, max } = range, spread = Math.max(max - min, options.span ?? 0);
458
+ return spread <= 0 ? Math.floor((steps - 1) / 2) : Math.min(steps - 1, Math.floor((value - min) / spread * steps));
459
+ }
460
+ function bandPaint(theme, options, steps, band, bad) {
461
+ if (options.scale === "diverging") {
462
+ let tone = signedFillPaint(bad ? "bad" : "good"), alpha = DIVERGING_ALPHAS[Math.min(band, DIVERGING_ALPHAS.length) - 1];
463
+ return { fill: { ...tone, tint: 1 - alpha }, ink: { token: "ink" } };
464
+ }
465
+ if (band >= steps - 1)
466
+ return { fill: { token: "heatTop" }, ink: { token: "heatTopInk" }, weight: theme.type.label.weight };
467
+ let bands = STEP_BANDS.get(theme);
468
+ bands || STEP_BANDS.set(theme, bands = /* @__PURE__ */ new Map());
469
+ let paint = bands.get(`${steps}:${band}`);
470
+ if (paint === void 0) {
471
+ let fill = { token: "markInk", tint: 1 - stepAlphas(theme, steps)[band] };
472
+ bands.set(`${steps}:${band}`, paint = { fill, ink: groundTextPaint({ token: "ink" }, fill) });
473
+ }
474
+ return paint;
475
+ }
476
+ var STEP_BANDS = /* @__PURE__ */ new WeakMap();
477
+ function steppedPaint(context, range, options, steps, value) {
478
+ let band = bandOf(value, range, options, steps);
479
+ return band === null ? { ink: { token: "ink" } } : bandPaint(context.theme, options, steps, band, badSide(value < (range.mean ?? 0), context.cell.polarity));
480
+ }
481
+ function badSide(low, polarity) {
482
+ return low !== (polarity === "lowerIsBetter");
483
+ }
484
+ function heatKey(columns, ranges, theme, strings, language) {
485
+ let groups = /* @__PURE__ */ new Map(), statusEntries;
486
+ for (let column of columns) {
487
+ let encoding = column.cellEncoding;
488
+ if (encoding?.type !== "heat") continue;
489
+ let entries = encoding.scale === "status" ? statusEntries ??= statusKey(columns, ranges, encoding, strings) : laneHeatKey([column], ranges, theme, strings, language);
490
+ if (entries.length === 0) continue;
491
+ let format = column.format === void 0 ? void 0 : parseFormatExample(column.format), identity = JSON.stringify(encoding.scale === "status" ? entries : [
492
+ encoding.scale,
493
+ encoding.bins ?? (encoding.scale === "diverging" ? DIVERGING_BINS : null),
494
+ entries.map((entry) => entry.fill),
495
+ format && [format.prefix, format.suffix, format.magnitude]
496
+ ]), group = groups.get(identity);
497
+ group ? group.columns.push(column.label) : groups.set(identity, { columns: [column.label], entries });
498
+ }
499
+ return groups.size === 1 ? groups.values().next().value.entries : [...groups.values()].flatMap((group, index) => group.entries.map((entry) => ({
500
+ ...entry,
501
+ id: `${entry.id}:scale${index}`,
502
+ label: `${group.columns.join(", ")}: ${entry.label}`
503
+ })));
504
+ }
505
+ function laneHeatKey(columns, ranges, theme, strings, language) {
506
+ for (let column of columns) {
507
+ let encoding = column.cellEncoding;
508
+ if (encoding?.type === "heat" && encoding.scale === "status") return statusKey(columns, ranges, encoding, strings);
509
+ if (encoding?.type !== "heat" || encoding.scale !== "absolute" && encoding.scale !== "diverging") continue;
510
+ let diverging = encoding.scale === "diverging", edges = encoding.bins ?? (diverging ? DIVERGING_BINS : []);
511
+ if (edges.length === 0) continue;
512
+ let steps = encoding.steps ?? edges.length + 1, spec = column.format === void 0 ? void 0 : withChartMarks(diverging ? { ...parseFormatExample(differenceExample(column.format)), signed: !1 } : parseFormatExample(column.format), language), text = spec === void 0 ? (value) => formatExactNumber(value, language) : (value) => formatWithSpec(value, spec), band = (index, last) => last ? `${text(edges[index - 1])} and more` : index === 0 ? `under ${text(edges[0])}` : intervalText(text(edges[index - 1]), text(edges[index])), swatch = (id, label, fill) => ({ id: `heatKey:${id}`, label, fill });
513
+ if (diverging) {
514
+ let sides = edges.map((_, index) => ({ index: index + 1, label: band(index + 1, index === edges.length - 1) }));
515
+ return [
516
+ ...[...sides].reverse().map(({ index, label }) => swatch(`below${index}`, `${label} below`, bandPaint(theme, encoding, steps, index, badSide(!0, column.polarity)).fill)),
517
+ swatch("none", `under ${text(edges[0])} either way`, { token: "background" }),
518
+ ...sides.map(({ index, label }) => swatch(`above${index}`, `${label} above`, bandPaint(theme, encoding, steps, index, badSide(!1, column.polarity)).fill))
519
+ ];
520
+ }
521
+ let count = Math.min(steps, edges.length + 1);
522
+ return Array.from({ length: count }, (_, index) => swatch(`band${index}`, band(index, index === count - 1), bandPaint(theme, encoding, steps, index, !1).fill));
523
+ }
524
+ return [];
525
+ }
526
+ var STATUS_TOLERANCE = { pct: 5 };
527
+ function statusBand(value, range, tolerance = STATUS_TOLERANCE, polarity) {
528
+ let centre = range.mean;
529
+ if (centre === void 0) return null;
530
+ let lower = polarity === void 0 ? range.lowerIsBetter === !0 : polarity === "lowerIsBetter", distance = (value - centre) * (lower ? -1 : 1), limit = tolerance.abs ?? Math.abs(centre) * (tolerance.pct ?? 0) / 100;
531
+ return Math.abs(distance) - limit <= 1e-9 * Math.max(1, Math.abs(centre)) ? "warn" : distance > 0 ? "good" : "bad";
532
+ }
533
+ function statusFill(band, alpha) {
534
+ let base = markRolePaint(band, !0);
535
+ return { token: "token" in base ? base.token : "neutral", theme: { kind: "visible-tint", base, amount: 1 - alpha, floor: 1, darkMatchLight: !0 } };
536
+ }
537
+ function statusLanes(columns) {
538
+ return columns.filter((column) => column.cellEncoding?.type === "heat" && column.cellEncoding.scale === "status");
539
+ }
540
+ function centreNoun(range) {
541
+ return range?.totalCentre === !0 ? "total" : "average";
542
+ }
543
+ function statusKey(columns, ranges, encoding, strings) {
544
+ let lanes = statusLanes(columns), lower = lanes.length > 0 && lanes.every((column) => column.polarity === "lowerIsBetter"), noun = centreNoun(ranges.get(lanes[0].id)), swatch = (id, label, band) => ({ id: `heatKey:${id}`, label, fill: statusFill(band, encoding.alpha) });
545
+ return [
546
+ swatch("below", strings?.heatBelow ?? `Below ${noun}`, lower ? "good" : "bad"),
547
+ swatch("around", strings?.heatAround ?? `Around ${noun}`, "warn"),
548
+ swatch("above", strings?.heatAbove ?? `Above ${noun}`, lower ? "bad" : "good")
549
+ ];
550
+ }
551
+ function statusDirectionNote(columns, ranges, colorblindSafe = !1) {
552
+ let lanes = statusLanes(columns), lower = lanes.filter((column) => column.polarity === "lowerIsBetter");
553
+ if (lower.length === 0 || lower.length === lanes.length) return;
554
+ let byNoun = /* @__PURE__ */ new Map();
555
+ for (let column of lower) {
556
+ let noun = centreNoun(ranges.get(column.id));
557
+ byNoun.set(noun, [...byNoun.get(noun) ?? [], column.label]);
558
+ }
559
+ let where = byNoun.size === 1 ? `below the ${[...byNoun.keys()][0]}` : [...byNoun].map(([noun, labels]) => `below the ${noun} for ${labels.join(", ")}`).join(" and ");
560
+ return `Lower is better for ${lower.map((column) => column.label).join(", ")}: there, ${colorblindSafe ? "the good tone" : "green"} marks ${where}.`;
561
+ }
562
+ function heatPaint(context, range, options = {}) {
563
+ let value = context.cell.raw, alpha = options.alpha ?? DEFAULT_ALPHA, excludeTotals = options.excludeTotals ?? !0;
564
+ if (context.cell.state !== "value" || typeof value != "number")
565
+ return { ink: { token: "ink" } };
566
+ if (context.cell.heat === !1) return { ink: { token: "inkMeta" }, weight: context.theme.type.label.weight };
567
+ if (excludeTotals && context.cell.role === "total")
568
+ return { ink: { token: "ink" } };
569
+ if (options.scale === "status") {
570
+ let band = statusBand(value, range, options.tolerance, context.cell.polarity);
571
+ if (band === null) return { ink: { token: "ink" } };
572
+ let fill2 = statusFill(band, alpha);
573
+ return { fill: fill2, ink: alpha > AUTO_INK_THRESHOLD ? contrastInkPaint(fill2) : { token: "ink" } };
574
+ }
575
+ let steps = options.steps ?? (options.bins === void 0 ? void 0 : options.bins.length + 1);
576
+ if (steps !== void 0 && steps >= 2) return steppedPaint(context, range, options, steps, value);
577
+ let diverging = range.min < 0 && range.max > 0 || range.signed === !0, extreme = Math.max(Math.abs(range.min), Math.abs(range.max)), authoredCap = range.percent === !0 ? options.cap?.pct : options.cap?.abs, capValue = Math.max(authoredCap ?? Math.abs(extreme), 1e-9), normalized = clamp(!diverging && authoredCap === void 0 ? sequentialShare(value, range.min, range.max) : Math.abs(value) / capValue, 0, 1), tone;
578
+ diverging ? tone = value === 0 ? semanticPalettePaint(context.theme, context.palette, "neutral") : signedFillPaint(badSide(value < 0, context.cell.polarity) ? "bad" : "good") : tone = mixedPaint(
579
+ semanticPalettePaint(context.theme, context.palette, "sequential"),
580
+ semanticPalettePaint(context.theme, context.palette, "neutral"),
581
+ normalized,
582
+ "series-1"
583
+ );
584
+ let tintWeight = alpha * normalized;
585
+ if (tintWeight <= 0) return { ink: { token: "ink" } };
586
+ let fill = {
587
+ token: "token" in tone ? tone.token : "neutral",
588
+ theme: { kind: "visible-tint", base: tone, amount: 1 - tintWeight, floor: FILL_SEPARATION_FLOOR }
589
+ }, ink = { token: "ink" };
590
+ return tintWeight > AUTO_INK_THRESHOLD && (ink = contrastInkPaint(fill)), { fill, ink };
591
+ }
592
+ function emitHeat(context, range, options = {}) {
593
+ let { fill, ink, weight } = heatPaint(context, range, options);
594
+ return {
595
+ nodes: fill === void 0 ? [] : [
596
+ {
597
+ t: "rect",
598
+ id: context.nodeId("heat"),
599
+ rect: { ...context.box },
600
+ fill,
601
+ owner: context.owner,
602
+ part: "tableHeat"
603
+ }
604
+ ],
605
+ ink,
606
+ ...weight === void 0 ? {} : { weight }
607
+ };
608
+ }
609
+
610
+ // src/core/charts/table/resolve.ts
611
+ var ZERO_LIFT = /* @__PURE__ */ Symbol("tableZeroLift"), SUPPRESSED_MARKER = "*", STATE_GLYPHS = {
612
+ missing: "\u2014",
613
+ na: "n/a",
614
+ nm: "n.m.",
615
+ suppressed: `\u2014${SUPPRESSED_MARKER}`,
616
+ // An open period prints nothing: the band ground under the cell
617
+ // says the period has not happened, and no theme glyph replaces that.
618
+ open: ""
619
+ };
620
+ function stateGlyphs(theme, notApplicable = STATE_GLYPHS.na) {
621
+ let own = theme?.table?.glyphs;
622
+ return own === void 0 ? { ...STATE_GLYPHS, na: notApplicable } : {
623
+ missing: own.missing ?? STATE_GLYPHS.missing,
624
+ na: own.na ?? notApplicable,
625
+ nm: own.nm ?? STATE_GLYPHS.nm,
626
+ suppressed: own.suppressed === void 0 ? STATE_GLYPHS.suppressed : `${own.suppressed}${SUPPRESSED_MARKER}`,
627
+ open: STATE_GLYPHS.open
628
+ };
629
+ }
630
+ var PERCENT_DELTA_CAP = 999, ROUNDING_FOOTNOTE = "Figures may not add due to rounding.", HEAT_COLUMN_FOOTNOTE = "Shading compares values within each column, not across columns.", PARTIAL_MARKER = "\u2020", PARTIAL_FOOTNOTE = `${PARTIAL_MARKER} Partial aggregate: missing values skipped.`, SUPPRESSED_FOOTNOTE = `${SUPPRESSED_MARKER} Suppressed: value withheld, not missing.`, STATE_PRECEDENCE = ["suppressed", "open", "nm", "na", "missing"], STATE_REASON = {
631
+ missing: "missing",
632
+ na: "not applicable (n/a)",
633
+ nm: "not meaningful (n.m.)",
634
+ suppressed: "suppressed",
635
+ open: "an open period"
636
+ };
637
+ function dominantState(states) {
638
+ for (let candidate of STATE_PRECEDENCE)
639
+ if (states.includes(candidate)) return candidate;
640
+ return "missing";
641
+ }
642
+ function scalesWithMagnitude(spec) {
643
+ return spec.magnitude !== "none" || unitOfSpec(spec) !== null;
644
+ }
645
+ function holdAuthoredScale(spec, thousands) {
646
+ spec.magnitude === "none" || spec.lockMagnitude || (spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = spec.decimals > 0 && thousands === spec.decimalSep ? spec.decimalSep === "," ? "." : "," : thousands));
647
+ }
648
+ function forceScale(spec, magnitude, thousands) {
649
+ spec.magnitude === "none" && magnitude === "m" && (spec.decimals = Math.max(spec.decimals, 1)), spec.magnitude = magnitude, spec.lockMagnitude = !0, spec.thousandsSep === "" && (spec.thousandsSep = thousands);
650
+ }
651
+ function sameUnit(a, b) {
652
+ return a.prefix === b.prefix && a.suffix === b.suffix && a.magnitude === b.magnitude && a.signed === b.signed && a.negative === b.negative && a.thousandsSep === b.thousandsSep && a.decimalSep === b.decimalSep;
653
+ }
654
+ function stripMagnitude(text, spec) {
655
+ let label = magnitudeLabel(spec, spec.magnitude);
656
+ return label ? text.endsWith(")") ? text.replace(`${label})`, ")") : text.endsWith(label) ? text.slice(0, -label.length) : text : text;
657
+ }
658
+ var floatNoise = (a, b) => 1e-9 * Math.max(1, Math.abs(a), Math.abs(b));
659
+ function columnHeadLabel(label, theme) {
660
+ return theme.table?.head?.case === "asis" ? label : label.toUpperCase();
661
+ }
662
+ function columnHeaderAffix(column) {
663
+ let affix = [column.scenario, column.unitLabel].filter(Boolean).join(", ");
664
+ return `${affix ? ` (${affix})` : ""}${column.partial ? ` ${PARTIAL_MARKER}` : ""}`;
665
+ }
666
+ function resolveTable(data, options = {}, magnitudeSource = data) {
667
+ return withSmallValues(options.smallValues, () => resolveTableIn(data, options, magnitudeSource));
668
+ }
669
+ function resolveTableIn(data, options, magnitudeSource) {
670
+ let liftsBefore = zeroLifts.count, liftMode = options[ZERO_LIFT], automaticAs = (on) => on && liftMode !== "none" ? liftMode ?? !0 : !1, formats = /* @__PURE__ */ new Map(), markedLanguage = options.locale?.language, parseFormatExample2 = (example) => {
671
+ let spec = formats.get(example);
672
+ return spec === void 0 && (spec = parseFormatExample(example), spec.locale = markedLanguage, formats.set(example, spec)), { ...spec };
673
+ }, warnings = [];
674
+ data.columns.forEach((column, index) => {
675
+ if (column.kind === "status")
676
+ for (let [key, label] of Object.entries(column.labels ?? {}))
677
+ typeof label != "string" || label.trim() !== "" || warnings.push({
678
+ code: "status-label-blank",
679
+ severity: "warn",
680
+ message: `status label '${key}' in column '${column.id}' contains only whitespace and draws blank. A later release refuses this label.`,
681
+ owner: { colId: column.id },
682
+ field: ["data", "columns", index, "labels", key],
683
+ suggest: "Give the status a visible label, or remove this label so the status key prints.",
684
+ fix: [{ op: "remove", path: `/data/columns/${index}/labels/${key}` }]
685
+ });
686
+ });
687
+ let records = [], autoFootnotes = /* @__PURE__ */ new Set(), lowerJudged = /* @__PURE__ */ new Set(), higherJudged = /* @__PURE__ */ new Set(), partialColumnIds = /* @__PURE__ */ new Set(), highlightedRows = new Set(resolveHighlight(options.highlight));
688
+ assertTableRankOptions(options);
689
+ let folded = applyTableTopN(data, options);
690
+ data = folded.data;
691
+ let generatedOthers = folded.generatedOthers, language = presetLanguage(options.variant), theme = resolveTheme(options.theme), glyphs = stateGlyphs(theme, options.strings?.notApplicable ?? localeStrings(options.locale?.language).notApplicable), previousPlaceholders = theme?.table?.noPrevious === void 0, noPrevious = theme?.table?.noPrevious ?? "na", cohortDash = isCohortDensity(options.density ?? "regular") && theme?.table?.glyphs?.missing === void 0 ? "\u2013" : glyphs.missing, tableMissingGlyph = options.nulls === "blank" ? "" : cohortDash, dataGap = theme?.table?.dataGap ?? (theme?.table?.glyphs?.missing === void 0 ? "word" : "glyph"), gapWord = options.nulls !== "blank" && !isCohortDensity(options.density ?? "regular") && dataGap === "word", columns = data.columns, colById = /* @__PURE__ */ new Map();
692
+ for (let c of columns) {
693
+ if (colById.has(c.id))
694
+ throw new NormalizeError("duplicate-column-id", `columns[${c.id}]`, `duplicate column id '${c.id}'`);
695
+ colById.set(c.id, c);
696
+ }
697
+ let rowLabelCols = columns.filter((c) => c.kind === "rowLabel");
698
+ if (rowLabelCols.length !== 1)
699
+ throw new NormalizeError(
700
+ "row-label-count",
701
+ "columns",
702
+ `exactly one rowLabel column required, found ${rowLabelCols.length}`
703
+ );
704
+ validateGroups(data, colById), validateCalcRefs(columns, colById);
705
+ let toggleResolution = resolveColumnToggles(data, options, colById, warnings), flat = flattenRows(data.rows), flatById = new Map(flat.map((row) => [row.id, row])), calcRunIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed" && calcPreservesScale(c.calc)).map((c) => c.id)), predecessorIds = new Set(columns.filter((c) => c.kind === "value" || c.kind === "computed").map((c) => c.id));
706
+ if (![...calcRunIds].some((id) => predecessorIds.has(previousColumnInGroup(data.columnGroups ?? [], id) ?? "")))
707
+ for (let row of flat)
708
+ row.calc === void 0 || !calcRefs(row.calc).some((ref) => typeof ref != "string" && ref.previous === !0) || warnings.push({
709
+ code: "calc-previous-ungrouped",
710
+ severity: "warn",
711
+ message: `row '${row.id}' reads the previous period ({ row, previous: true }), but no value column has a value column before it in its columnGroup, so every cell of the row prints the missing dash`,
712
+ owner: { rowId: row.id },
713
+ suggest: 'Add a columnGroups entry that lists the period value columns in order, e.g. { id: "months", columns: ["jan", "feb", "mar"] }.'
714
+ });
715
+ let levelOffset = Math.trunc(options.levelOffset ?? 0), childrenOf = /* @__PURE__ */ new Map();
716
+ for (let r of flat) {
717
+ let list = childrenOf.get(r.parentId) ?? [];
718
+ list.push(r), childrenOf.set(r.parentId, list);
719
+ }
720
+ let treeChildrenOf = /* @__PURE__ */ new Map();
721
+ for (let [parentId, list] of childrenOf) {
722
+ let kept = list.filter((child) => child.inline !== !0);
723
+ kept.length > 0 && treeChildrenOf.set(parentId, kept);
724
+ }
725
+ let expansion = resolveExpansion(flat, treeChildrenOf, options, warnings, generatedOthers), signTo = (row, stop) => contributionSignOf(row, (id) => flatById.get(id), stop), summandCache = /* @__PURE__ */ new Map(), summandsOf = (parentId) => {
726
+ let cached = summandCache.get(parentId);
727
+ if (cached) return cached;
728
+ let hoisted = [], dissolveSections = (pid) => {
729
+ for (let k of childrenOf.get(pid) ?? [])
730
+ k.relation === "additive" && (k.role === "section" ? dissolveSections(k.id) : hoisted.push(k));
731
+ };
732
+ dissolveSections(parentId);
733
+ let out = hoisted.some((k) => k.role !== "total") ? hoisted.filter((k) => k.role !== "total") : hoisted;
734
+ return summandCache.set(parentId, out), out;
735
+ }, nonAdditiveFormat = (format) => {
736
+ if (!format) return !1;
737
+ let spec = parseFormatExample2(format);
738
+ return specUnitKind(spec) !== "number" || /^[x\u00d7]$/i.test(spec.suffix.trim());
739
+ }, formatAt = (row, colId) => cellFormat(row.cells[colId]) ?? row.format, nonAdditiveSum = (col, row, kids) => nonAdditiveFormat(col.format) || [row, ...kids].some((k) => nonAdditiveFormat(formatAt(k, col.id))) || new Set(kids.map((k) => formatAt(k, col.id) ?? col.format ?? "")).size > 1, aggregateFor = (col, row) => col.aggregate ?? (nonAdditiveSum(col, row, summandsOf(row.id)) ? "none" : "sum"), warnedNonAdditive = /* @__PURE__ */ new Set(), rawState = /* @__PURE__ */ new Map();
740
+ for (let r of flat) rawState.set(r.id, /* @__PURE__ */ new Map());
741
+ for (let [id, row] of folded.hidden) rawState.set(id, new Map(row.states));
742
+ let valueCols = columns.filter((c) => c.kind === "value"), postOrder = orderPostfix(childrenOf);
743
+ for (let row of postOrder) {
744
+ if (row.role === "section") continue;
745
+ let states = rawState.get(row.id);
746
+ for (let col of valueCols)
747
+ states.set(col.id, evalValueCell(row, col));
748
+ }
749
+ for (let row of flat) {
750
+ if (row.role !== "total" || row.totalPolicy === "source" || summandsOf(row.id).length > 0) continue;
751
+ let siblings = summandsOf(row.parentId);
752
+ if (!(siblings.includes(row) || siblings.length === 0))
753
+ for (let col of valueCols) {
754
+ let own = rawState.get(row.id).get(col.id);
755
+ if (own.state !== "value" || typeof own.raw != "number" || own.partial || aggregateFor(col, row) !== "sum") continue;
756
+ let sum = 0, skipped = [];
757
+ for (let sibling of siblings) {
758
+ let state = rawState.get(sibling.id).get(col.id);
759
+ state?.state === "value" && typeof state.raw == "number" ? (sum += signTo(sibling, row.parentId) * state.raw, state.partial && pushAll(skipped, skippedRows(state))) : skipped.push(sibling.id);
760
+ }
761
+ skipped.length > 0 && Math.abs(sum - own.raw) <= floatNoise(own.raw, sum) && rawState.get(row.id).set(col.id, { ...own, partial: !0, skipped: skippedKey(skipped) });
762
+ }
763
+ }
764
+ function evalValueCell(row, col) {
765
+ let authored = readNumeric(row.cells[col.id]);
766
+ authored.nonNumeric !== void 0 && warnings.push({
767
+ code: "value-cell-not-numeric",
768
+ severity: "warn",
769
+ message: `'${row.id}'.'${col.id}': ${JSON.stringify(authored.nonNumeric)} is a string in a value column \u2014 it is treated as MISSING (it drops out of aggregates and share denominators); author the number unquoted`,
770
+ owner: { rowId: row.id, colId: col.id }
771
+ });
772
+ let kids = summandsOf(row.id), aggregate = aggregateFor(col, row), isParent = kids.length > 0;
773
+ if (isParent && col.aggregate === "sum" && !warnedNonAdditive.has(col.id) && nonAdditiveSum(col, row, kids) && (warnedNonAdditive.add(col.id), warnings.push({
774
+ code: "aggregate-non-additive",
775
+ severity: "warn",
776
+ message: `column '${col.id}' sums rows that do not add (a percentage, percentage points, a multiple, or rows in different formats): the parent '${row.id}' prints a sum that is no total`,
777
+ owner: { rowId: row.id, colId: col.id },
778
+ suggest: "drop aggregate: 'sum' so the parent shows its authored value, or author a weighted figure on the parent row"
779
+ })), authored.state === "na" || authored.state === "nm" || authored.state === "suppressed" || authored.state === "open")
780
+ return { raw: null, state: authored.state };
781
+ if (!isParent || aggregate === "none" || aggregate === "source")
782
+ return authored.raw === null ? { raw: null, state: "missing" } : { raw: authored.raw, state: "value" };
783
+ let inputs = [], blockers = [], sum = 0, partialKid = !1, skippedKids = [];
784
+ for (let kid of kids) {
785
+ let ks = rawState.get(kid.id).get(col.id);
786
+ if (ks.state === "value" && typeof ks.raw == "number") {
787
+ let contribution = signTo(kid, row.id) * ks.raw;
788
+ sum += contribution, ks.partial && (partialKid = !0, pushAll(skippedKids, skippedRows(ks))), inputs.push({ rowId: kid.id, colId: col.id, value: contribution });
789
+ } else
790
+ blockers.push({ id: kid.id, state: ks.state });
791
+ }
792
+ let nulls = col.nulls ?? "propagate", derived, noSummands = inputs.length === 0, unauditedRecord = () => {
793
+ records.push({
794
+ rowId: row.id,
795
+ colId: col.id,
796
+ op: "no-measured-summands",
797
+ inputs: blockers.map((b) => ({
798
+ rowId: b.id,
799
+ colId: col.id,
800
+ value: null,
801
+ state: b.state
802
+ })),
803
+ raw: null,
804
+ state: dominantState(blockers.map((b) => b.state)),
805
+ displayed: "",
806
+ kind: "unaudited"
807
+ });
808
+ };
809
+ if (noSummands && blockers.every((b) => b.state === "open"))
810
+ derived = { raw: null, state: "open" };
811
+ else if (noSummands) {
812
+ let inherited = dominantState(blockers.map((b) => b.state));
813
+ warnings.push({
814
+ code: "aggregate-no-summands",
815
+ // INFO reports a data state without asking the author to change it.
816
+ // Lints for generated documents split in two: 'warn'/'error' is for
817
+ // cases a generator chooses DELIBERATELY (and must then declare, for
818
+ // example in the title), 'info' is an honesty disclosure about a state
819
+ // the data happened to reach. This is the second kind — it appears
820
+ // when sibling leaves happen to be sparse in the same column, and no
821
+ // title could announce it because nothing chose it.
822
+ // It is also not actionable: there is no nulls policy under which an
823
+ // empty set of summands honestly yields a number, so there is nothing
824
+ // for the author to change. The reader is not left guessing either —
825
+ // the cell prints the state glyph and this message names every child.
826
+ // The twin below stays 'warn' on purpose: under 'propagate', values
827
+ // that EXIST are being discarded, and switching the policy is a real
828
+ // action the author can take.
829
+ severity: "info",
830
+ message: `'${row.id}'.'${col.id}' is '${glyphs[inherited]}': not one of its ${kids.length} additive children carries a value (${blockers.map((b) => `'${b.id}' is ${STATE_REASON[b.state]}`).join(", ")}) \u2014 an empty sum is not a total`
831
+ }), derived = { raw: null, state: inherited };
832
+ } else if (blockers.length > 0 && nulls === "propagate") {
833
+ let inherited = dominantState(blockers.map((b) => b.state));
834
+ warnings.push({
835
+ code: "aggregate-null-child",
836
+ severity: "warn",
837
+ message: `'${row.id}'.'${col.id}' is '${glyphs[inherited]}' because ${blockers.map((b) => `child '${b.id}' is ${STATE_REASON[b.state]}`).join(", ")} (column nulls policy 'propagate')`
838
+ }), derived = { raw: null, state: inherited };
839
+ } else
840
+ blockers.length > 0 && (autoFootnotes.add(PARTIAL_FOOTNOTE), partialColumnIds.add(col.id)), derived = { raw: sum, state: "value", ...blockers.length > 0 || partialKid ? { partial: !0, skipped: skippedKey([...blockers.map((b) => b.id), ...skippedKids]) } : {} };
841
+ let policy = row.totalPolicy ?? (authored.raw !== null ? "validate" : "derive");
842
+ return policy === "source" ? authored.raw === null ? derived : { raw: authored.raw, state: "value" } : policy === "validate" && authored.raw !== null ? (noSummands ? unauditedRecord() : records.push({
843
+ rowId: row.id,
844
+ colId: col.id,
845
+ op: "sum",
846
+ inputs,
847
+ raw: derived.raw,
848
+ state: derived.state,
849
+ displayed: "",
850
+ // filled after formatting
851
+ kind: "reconciliation"
852
+ }), derived.raw !== null && Math.abs(derived.raw - authored.raw) > floatNoise(derived.raw, authored.raw) ? (warnings.push({
853
+ code: "total-reconciliation",
854
+ severity: "warn",
855
+ message: `'${row.id}'.'${col.id}': authored total ${authored.raw} differs from the sum of additive children ${derived.raw} (\u0394 ${authored.raw - derived.raw}); authored value displays (policy 'validate')`
856
+ }), { raw: authored.raw, state: "value" }) : { raw: authored.raw, state: "value", ...derived.partial ? { partial: !0, skipped: derived.skipped } : {} }) : (authored.raw !== null && policy === "derive" && warnings.push({
857
+ code: "computed-overridden",
858
+ severity: "warn",
859
+ message: `'${row.id}'.'${col.id}': authored value ${authored.raw} ignored \u2014 totals derive from children (policy 'derive'); use totalPolicy 'validate' or 'source' to keep it`
860
+ }), derived.raw !== null ? records.push({
861
+ rowId: row.id,
862
+ colId: col.id,
863
+ op: "sum",
864
+ inputs,
865
+ raw: derived.raw,
866
+ state: "value",
867
+ displayed: "",
868
+ kind: "aggregate"
869
+ }) : noSummands && unauditedRecord(), derived);
870
+ }
871
+ let leafRows = [], collectLeafSummands = (parentId) => {
872
+ for (let r of summandsOf(parentId))
873
+ summandsOf(r.id).length === 0 ? leafRows.push(r) : collectLeafSummands(r.id);
874
+ };
875
+ collectLeafSummands(null);
876
+ let leafTotal = (colId) => {
877
+ let t = 0;
878
+ for (let r of leafRows) {
879
+ let s = rawState.get(r.id).get(colId);
880
+ if (!s || s.state !== "value" || typeof s.raw != "number") return null;
881
+ t += signTo(r, null) * s.raw;
882
+ }
883
+ return t;
884
+ }, computedCols = columns.filter((c) => c.kind === "computed"), calcNotes = evaluateTableCalcs(flat, valueCols, computedCols, rawState, records, leafTotal, data.columnGroups ?? [], colById, noPrevious, (id) => {
885
+ let row = flatById.get(id);
886
+ return row ? signTo(row, null) : folded.hidden.get(id)?.sign ?? 1;
887
+ });
888
+ calcNotes.nearZero && autoFootnotes.add(options.strings?.nearZeroChange ?? localeStrings(options.locale?.language).nearZeroChange), calcNotes.mixedCoverage && autoFootnotes.add(options.strings?.mixedCoverage ?? localeStrings(options.locale?.language).mixedCoverage);
889
+ let locale = localeDefaults(options.locale), sourceRows = magnitudeSource === data ? flatById : new Map(flattenRows(magnitudeSource.rows).map((row) => [row.id, row])), sourceColumns = new Map(magnitudeSource.columns.map((col) => [col.id, col])), scales = (example) => scalesWithMagnitude(parseFormatExample2(example)), specs = /* @__PURE__ */ new Map(), formatExamples = /* @__PURE__ */ new Map(), localeDerivedColumns = /* @__PURE__ */ new Set();
890
+ for (let col of [...valueCols, ...computedCols]) {
891
+ let inherited = col.kind === "computed" && !calcPreservesScale(col.calc) ? void 0 : options.format, authoredExample = col.format ?? inherited, example = authoredExample ?? defaultExample(col);
892
+ authoredExample === void 0 && localeDerivedColumns.add(col.id), formatExamples.set(col.id, example);
893
+ let spec = parseFormatExample2(example), sourceExample = sourceColumns.get(col.id)?.format ?? inherited;
894
+ spec.automatic = automaticAs(sourceExample === void 0 && options.unit === void 0 && options.magnitude !== "million" && options.magnitude !== "thousand"), authoredExample === void 0 && currencyWholeNumbers(options.unit, options.target) && (col.kind !== "computed" || calcPreservesScale(col.calc)) && (spec.currencyWhole = !0), scales(sourceColumns.get(col.id)?.format ?? inherited ?? defaultExample(col)) && (options.magnitude === "million" || options.magnitude === "thousand") && forceScale(spec, options.magnitude === "million" ? "m" : "k", locale.thousands), sourceExample !== void 0 && holdAuthoredScale(spec, locale.thousands), specs.set(col.id, spec);
895
+ }
896
+ let rowSpecs = /* @__PURE__ */ new Map(), rowById = /* @__PURE__ */ new Map(), forcedMagnitude = options.magnitude === "million" ? "m" : options.magnitude === "thousand" ? "k" : void 0, authoredSpec = (example, sourceExample = example) => {
897
+ let spec = parseFormatExample2(example);
898
+ return forcedMagnitude !== void 0 && scales(sourceExample) && forceScale(spec, forcedMagnitude, locale.thousands), spec;
899
+ }, valuesOfRow = /* @__PURE__ */ new Map(), rowValues = (row) => {
900
+ let values = valuesOfRow.get(row.id);
901
+ return values === void 0 && valuesOfRow.set(row.id, values = rowValuesUncached(row)), values;
902
+ }, rowValuesUncached = (row) => valueCols.filter((col) => col.format === void 0 && cellFormat(row.cells[col.id]) === void 0 && !(data.columnToggles ?? []).some((toggle) => toggle.columns.includes(col.id) && (options.columnVisibility?.[toggle.id] ?? toggle.defaultVisible ?? !1) === !1)).map((col) => rawState.get(row.id)?.get(col.id)?.raw).filter((v) => typeof v == "number"), largest = (values) => values.reduce((n, v) => Math.max(n, Math.abs(v)), 0), groupOf = (row) => sourceRows.get(row.id)?.[MAGNITUDE_GROUP], groupMax = /* @__PURE__ */ new Map(), groupValues = /* @__PURE__ */ new Map();
903
+ for (let row of flat) {
904
+ let group = groupOf(row);
905
+ if (group === void 0) continue;
906
+ let values = rowValues(row);
907
+ groupMax.set(group, Math.max(groupMax.get(group) ?? 0, largest(values)));
908
+ let shared = groupValues.get(group);
909
+ shared === void 0 ? groupValues.set(group, [...values]) : pushAll(shared, values);
910
+ }
911
+ for (let row of flat) {
912
+ rowById.set(row.id, row);
913
+ let example = row.format ?? (row.scale ? row.scale === "percent" ? "1.2%" : "1,234" : void 0) ?? (row.calc && calcYieldsPoints(row.calc) ? `1${locale.decimal}2%` : void 0);
914
+ if (example) {
915
+ let spec = authoredSpec(example, sourceRows.get(row.id)?.format ?? example), authoredRow = sourceRows.get(row.id);
916
+ authoredRow?.format !== void 0 && authoredRow[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands);
917
+ let group = groupOf(row), rowScale = row.scale === "money" || row.scale === "perUnit";
918
+ if (rowScale || specUnitKind(spec) === "number") {
919
+ let values = rowValues(row), max = group === void 0 ? largest(values) : groupMax.get(group), climb = (from) => max >= 1e9 ? "bn" : max >= 1e6 ? "m" : max >= from ? "k" : "none", authoredFormat = sourceRows.get(row.id)?.format !== void 0;
920
+ if (rowScale) {
921
+ let heldMoney = row.scale === "money" && forcedMagnitude !== void 0;
922
+ if (spec.magnitude = heldMoney ? forcedMagnitude : row.scale === "money" ? climb(1e3) : "none", row.scale === "money")
923
+ spec.decimals = max >= 1e3 && !(heldMoney && forcedMagnitude === "k" && max >= 1e5) ? 1 : 0;
924
+ else if ((!authoredFormat || values.every(Number.isInteger)) && (spec.decimals = max >= 10 ? 0 : 1, !authoredFormat))
925
+ for (let value of values)
926
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
927
+ spec.prefix = "", spec.suffix = "", spec.lockMagnitude = heldMoney, spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = locale.thousands);
928
+ } else row.scale === "count" && !authoredFormat && max >= 1e6 && spec.magnitude === "none" && !spec.signed && (spec.magnitude = climb(1 / 0), spec.decimals = 1, spec.lockMagnitude = !1, spec.rollMagnitude = !1);
929
+ let smallMoney = !rowScale && forcedMagnitude && scales(example) && values.every((v) => Math.abs(v) < 1e3), changeLine = row.inline === !0 || spec.signed;
930
+ if (smallMoney || !changeLine && group === void 0 && values.some((v) => v !== 0 && roundedNumber(v, spec) === 0)) {
931
+ if (smallMoney || !rowScale && spec.lockMagnitude && spec.magnitude === "k" || row.scale === "money" && spec.magnitude === "k") {
932
+ let authored = parseFormatExample2(example);
933
+ spec.decimals = !rowScale && authored.magnitude === "none" ? authored.decimals : 0, spec.magnitude = "none";
934
+ }
935
+ spec.decimals = values.reduce((decimals, value) => nonzeroDecimals(value / MAGNITUDE_DIVISOR[spec.magnitude], decimals), spec.decimals);
936
+ }
937
+ if (!changeLine && (spec.magnitude !== "none" || group !== void 0 && row.scale === "money") && !(spec.lockMagnitude && spec.magnitude === "k") && (row.scale === "money" || row.scale === "count" && !authoredFormat))
938
+ for (let value of group === void 0 ? values : groupValues.get(group))
939
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > (group === void 0 ? Math.abs(value) : max) * 0.01; ) spec.decimals++;
940
+ }
941
+ let sourceRow = sourceRows.get(row.id);
942
+ spec.automatic = automaticAs(group !== void 0 || (sourceRow?.format === void 0 || sourceRow[AUTOMATIC_FORMAT] === !0) && options.format === void 0 && options.unit === void 0 && forcedMagnitude === void 0), rowSpecs.set(row.id, spec);
943
+ }
944
+ }
945
+ let cellSpecs = /* @__PURE__ */ new Map();
946
+ for (let row of flat)
947
+ for (let col of valueCols) {
948
+ let example = cellFormat(row.cells[col.id]);
949
+ if (example !== void 0) {
950
+ let sourceRow = sourceRows.get(row.id), sourceColumn = sourceColumns.get(col.id), sourceExample = cellFormat(sourceRow?.cells[col.id]) ?? sourceColumn?.format ?? sourceRow?.format ?? options.format ?? defaultExample(col), inRow = cellSpecs.get(row.id);
951
+ inRow || cellSpecs.set(row.id, inRow = /* @__PURE__ */ new Map());
952
+ let spec = authoredSpec(example, sourceExample), sourceCell = sourceRow?.cells[col.id];
953
+ cellFormat(sourceRow?.cells[col.id]) !== void 0 && sourceCell?.[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands), sourceCell?.[AUTOMATIC_FORMAT] === !0 && (spec.automatic = automaticAs(!0)), inRow.set(col.id, spec);
954
+ }
955
+ }
956
+ let hoistedRowUnits = /* @__PURE__ */ new Map();
957
+ if (forcedMagnitude !== void 0)
958
+ for (let [rowId, spec] of rowSpecs) {
959
+ if (rowById.get(rowId)?.scale === "money" || rowById.get(rowId)?.scale === "perUnit" || rowById.get(rowId)?.calc !== void 0 || !scales(sourceRows.get(rowId)?.format ?? "1,234")) continue;
960
+ let unit = unitOfSpec(spec);
961
+ unit !== null && hoistedRowUnits.set(rowId, unit);
962
+ }
963
+ let authoredColumnFormat = new Set([...valueCols, ...computedCols].filter((col) => col.format !== void 0).map((col) => col.id)), rowFormattedColumns = /* @__PURE__ */ new Set();
964
+ for (let row of flat)
965
+ if (!(row.calc || !rowSpecs.has(row.id)))
966
+ for (let col of valueCols)
967
+ !authoredColumnFormat.has(col.id) && typeof rawState.get(row.id)?.get(col.id)?.raw == "number" && rowFormattedColumns.add(col.id);
968
+ let hoistedUnitSet = new Set(hoistedRowUnits.values()), figureRows = flat.filter((row) => !row.calc && valueCols.some((col) => typeof rawState.get(row.id)?.get(col.id)?.raw == "number")), headUnit = figureRows.length > 1 && hoistedUnitSet.size === 1 && figureRows.every((row) => hoistedRowUnits.has(row.id)) ? [...hoistedUnitSet][0] : void 0;
969
+ function defaultExample(col) {
970
+ if (col.kind === "computed" && calcYieldsPoints(col.calc)) return `1${locale.decimal}2%`;
971
+ if (options.magnitude === "million") return `1${locale.thousands}234${locale.decimal}2m`;
972
+ if (options.magnitude === "thousand") return `1${locale.thousands}234k`;
973
+ let colId = col.id, maxAbs = 0, values = [];
974
+ for (let r of flat) {
975
+ let s = rawState.get(r.id).get(colId);
976
+ s && typeof s.raw == "number" && (maxAbs = Math.max(maxAbs, Math.abs(s.raw)), values.push(s.raw));
977
+ }
978
+ if (maxAbs >= 1e9) return `1${locale.decimal}2bn`;
979
+ if (maxAbs >= 1e6) return `1${locale.decimal}2m`;
980
+ if (maxAbs >= 100) return `1${locale.thousands}234`;
981
+ let decimals = typicalDecimals(values);
982
+ return decimals > 1 ? `0${locale.decimal}${"1234".slice(0, decimals)}` : `1${locale.decimal}2`;
983
+ }
984
+ let unitByCol = /* @__PURE__ */ new Map(), rollsOff = (colId, spec) => spec.magnitude !== "none" && flat.some((row) => {
985
+ if (rowSpecs.has(row.id) && (row.calc !== void 0 || row.inline === !0 || !authoredColumnFormat.has(colId)) || cellSpecs.get(row.id)?.has(colId)) return !1;
986
+ let raw = rawState.get(row.id)?.get(colId)?.raw;
987
+ return typeof raw == "number" && raw !== 0 && effectiveScale(Math.abs(raw), spec).magnitude !== spec.magnitude;
988
+ }), lettersInCells = /* @__PURE__ */ new Set();
989
+ for (let col of [...valueCols, ...computedCols]) {
990
+ let spec = specs.get(col.id);
991
+ !rowFormattedColumns.has(col.id) && rollsOff(col.id, spec) && lettersInCells.add(col.id), unitByCol.set(col.id, rowFormattedColumns.has(col.id) || lettersInCells.has(col.id) ? null : unitOfSpec(spec));
992
+ }
993
+ let headerUnitFor = (id) => unitByCol.get(id) ?? (rowFormattedColumns.has(id) ? headUnit ?? null : null), headerScaledFor = (id) => unitByCol.get(id) != null ? specs.get(id).magnitude !== "none" : rowFormattedColumns.has(id) && headUnit !== void 0 && figureRows.some((row) => (rowSpecs.get(row.id)?.magnitude ?? "none") !== "none"), distinctUnits = [...new Set([...unitByCol.keys()].map(headerUnitFor).filter((u) => u !== null))], candidateUnit = distinctUnits.length === 1 && [...valueCols, ...computedCols].every((col) => {
994
+ let kind = specUnitKind(specs.get(col.id));
995
+ return kind === "percent" || kind === "pp" || headerUnitFor(col.id) === distinctUnits[0];
996
+ }) ? distinctUnits[0] : void 0, frameCarriesUnit = unitPrinted({
997
+ subtitle: resolveSubtitle(options.subtitle),
998
+ unit: candidateUnit,
999
+ unitShown: options.unitShown
1000
+ }), uniformUnit = candidateUnit && frameCarriesUnit ? candidateUnit : null;
1001
+ uniformUnit !== null && options.unit !== void 0 && options.unit !== uniformUnit && warnings.push({
1002
+ code: "table-unit-overridden",
1003
+ severity: "warn",
1004
+ field: ["options", "unit"],
1005
+ message: `options.unit '${options.unit}' is not printed. The table prints '${uniformUnit}' because its column formats resolve that shared unit.`,
1006
+ suggest: "Remove options.unit so the column formats supply the unit.",
1007
+ fix: [{ op: "remove", path: "/options/unit" }]
1008
+ });
1009
+ let rowOverridesColumn = (rowId) => {
1010
+ let row = rowById.get(rowId);
1011
+ return row?.calc !== void 0 || row?.inline === !0;
1012
+ }, specFor = (colId, rowId) => {
1013
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0;
1014
+ if (cellSpec) return cellSpec;
1015
+ let rowSpec = rowId ? rowSpecs.get(rowId) : void 0;
1016
+ return rowSpec && (rowOverridesColumn(rowId) || !authoredColumnFormat.has(colId)) ? rowSpec : specs.get(colId);
1017
+ }, formatNumber = (raw, colId, rowId, lift = !0) => {
1018
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0, rowSpec = rowId ? rowSpecs.get(rowId) : void 0, rowPath = rowSpec !== void 0 && (rowOverridesColumn(rowId) || !authoredColumnFormat.has(colId)), base = rowPath ? rowSpec : specs.get(colId);
1019
+ if (cellSpec && !sameUnit(cellSpec, base)) return formatWithSpec(raw, lift ? cellSpec : { ...cellSpec, automatic: !1 });
1020
+ let decimals = cellSpec?.decimals ?? base.decimals;
1021
+ if (rowPath) {
1022
+ if (raw === 0 && lift && !cellSpec && groupOf(rowById.get(rowId)) !== void 0) return "0";
1023
+ let hoisted = rowId !== void 0 && hoistedRowUnits.has(rowId), automatic = lift && (cellSpec ? cellSpec.automatic : rowSpec.automatic);
1024
+ return hoisted ? stripMagnitude(formatWithSpec(raw, { ...rowSpec, decimals, automatic, prefix: "", suffix: "" }), rowSpec) : formatWithSpec(raw, { ...rowSpec, decimals, automatic });
1025
+ }
1026
+ let spec = { ...specs.get(colId), decimals, ...cellSpec ? { currencyWhole: void 0, automatic: cellSpec.automatic } : {}, ...lift ? {} : { automatic: !1 } }, rendered = unitByCol.get(colId) == null ? formatWithSpec(raw, spec) : formatWithSpec(raw, { ...spec, prefix: "", suffix: "" }), localized = localeDerivedColumns.has(colId) && locale.minusGlyph === "-" && rendered.startsWith(MINUS) ? `-${rendered.slice(MINUS.length)}` : rendered;
1027
+ return unitByCol.get(colId) == null ? localized : stripMagnitude(localized, spec);
1028
+ }, madeNm = /* @__PURE__ */ new Set();
1029
+ for (let record of records) {
1030
+ if (record.kind !== "calc" || record.state !== "value") continue;
1031
+ let baseInput = record.op === "percentDelta($0,$1)" ? record.inputs[1] : void 0, nearZeroBase = baseInput !== void 0 && baseInput.value !== null && !/[1-9]/.test(formatNumber(baseInput.value, baseInput.colId, baseInput.rowId, !1));
1032
+ !nearZeroBase && (madeNm.size === 0 || !record.inputs.some((input) => madeNm.has(JSON.stringify([input.rowId, input.colId])))) || (record.raw = null, record.state = "nm", rawState.get(record.rowId)?.set(record.colId, { raw: null, state: "nm" }), madeNm.add(JSON.stringify([record.rowId, record.colId])), nearZeroBase && autoFootnotes.add(options.strings?.nearZeroChange ?? localeStrings(options.locale?.language).nearZeroChange));
1033
+ }
1034
+ let displayOverride = /* @__PURE__ */ new Map(), overrideAmount = /* @__PURE__ */ new Map();
1035
+ for (let col of computedCols) {
1036
+ if (!("op" in col.calc) || col.calc.op !== "share") continue;
1037
+ let spec = specs.get(col.id);
1038
+ reconcileShares(col.id, spec);
1039
+ }
1040
+ function reconcileShares(colId, spec) {
1041
+ let entries = leafRows.map((r) => ({ r, s: rawState.get(r.id).get(colId) })).filter((e) => e.s.state === "value" && typeof e.s.raw == "number");
1042
+ if (entries.length !== leafRows.length || entries.length === 0) return;
1043
+ let decimals = spec.decimals ?? 1, unit = Math.pow(10, -decimals), floors = entries.map((e) => Math.floor(e.s.raw / unit) * unit), remainders = entries.map((e, i) => e.s.raw - floors[i]), deficit = Math.round((100 - floors.reduce((a, b) => a + b, 0)) / unit), order = entries.map((_, i) => i).sort((a, b) => remainders[b] - remainders[a] || a - b), adjusted = /* @__PURE__ */ new Set();
1044
+ for (let i of order) {
1045
+ if (deficit <= 0) break;
1046
+ adjusted.add(i), deficit--;
1047
+ }
1048
+ entries.forEach((e, i) => {
1049
+ let shown = floors[i] + (adjusted.has(i) ? unit : 0);
1050
+ displayOverride.set(tableCellKey(e.r.id, colId), shown === 0 && e.s.raw > 0 && spec.automatic ? `<${formatNumber(unit, colId)}` : formatNumber(shown, colId)), overrideAmount.set(tableCellKey(e.r.id, colId), shown), adjusted.has(i) && Math.abs(shown - e.s.raw) > 1e-9 && records.push({
1051
+ rowId: e.r.id,
1052
+ colId,
1053
+ op: "share-reconcile",
1054
+ // The display UNIT is half the calculation: this record says "the
1055
+ // exact share, rounded up by one unit". With only the exact share in
1056
+ // the receipt, the adjustment could not be checked against anything.
1057
+ inputs: [
1058
+ { rowId: e.r.id, colId, value: e.s.raw },
1059
+ { rowId: SHARE_UNIT_ROW_ID, colId, value: unit }
1060
+ ],
1061
+ raw: shown,
1062
+ state: "value",
1063
+ displayed: formatNumber(shown, colId),
1064
+ kind: "rounding-adjustment"
1065
+ });
1066
+ });
1067
+ }
1068
+ for (let col of [...valueCols, ...computedCols]) {
1069
+ if (col.kind === "computed" ? calcYieldsPoints(col.calc) : col.percentScale === "points") continue;
1070
+ let spec = col.kind === "computed" || col.format ? specs.get(col.id) : void 0;
1071
+ if (!spec || !(spec.suffix ?? "").includes("%")) continue;
1072
+ let vals = flat.map((r) => rawState.get(r.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1073
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1074
+ code: "percent-scale-suspect",
1075
+ severity: "warn",
1076
+ message: col.kind === "computed" ? `column '${col.id}': the format is percent but every computed value is within \xB11.5 \u2014 percent columns carry POINTS, and a ratio calc yields a FRACTION (0.42 renders "0.4%"); multiply by 100 (mul(div(a,b), lit 100)) or drop the '%'` : `column '${col.id}': every value is within \xB11.5 but the format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`,
1077
+ ...col.kind === "value" ? { suggest: "values already in points: set percentScale: 'points' on the column" } : {}
1078
+ });
1079
+ }
1080
+ for (let row of flat) {
1081
+ let rowSpec = rowSpecs.get(row.id);
1082
+ if (!rowSpec || row.calc || !(rowSpec.suffix ?? "").includes("%")) continue;
1083
+ let vals = valueCols.filter((col) => !authoredColumnFormat.has(col.id) && col.percentScale !== "points").map((col) => rawState.get(row.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1084
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1085
+ code: "percent-scale-suspect",
1086
+ severity: "warn",
1087
+ message: `row '${row.id}': every value is within \xB11.5 but the row format is percent \u2014 percent values are authored in POINTS (6.2 \u2192 "6.2%"); these look like fractions`
1088
+ });
1089
+ }
1090
+ for (let row of flat) {
1091
+ if (row.role === "section") continue;
1092
+ let kids = summandsOf(row.id);
1093
+ if (kids.length !== 0)
1094
+ for (let col of valueCols) {
1095
+ if (aggregateFor(col, row) !== "sum") continue;
1096
+ let spec = specFor(col.id, row.id), p = rawState.get(row.id).get(col.id);
1097
+ if (p.state !== "value" || typeof p.raw != "number") continue;
1098
+ let childRaw = kids.map((k) => rawState.get(k.id).get(col.id)).filter((s) => s.state === "value" && typeof s.raw == "number").map((s, i) => s.raw * signTo(kids[i], row.id));
1099
+ if (childRaw.length !== kids.length) continue;
1100
+ let rawSum = childRaw.reduce((a, b) => a + b, 0), rawGap = p.raw - rawSum, noise = floatNoise(p.raw, rawSum), parentShown = roundedNumber(p.raw, spec), childShown = childRaw.map((value, i) => roundedNumber(value, specFor(col.id, kids[i].id))), displayGap = parentShown - childShown.reduce((a, b) => a + b, 0), roundingGap = Math.abs(rawGap) > noise ? displayGap - rawGap : displayGap, inputs = [
1101
+ { rowId: row.id, colId: col.id, value: p.raw, role: "raw" },
1102
+ { rowId: row.id, colId: col.id, value: parentShown, role: "displayed" },
1103
+ ...kids.flatMap((k, i) => [
1104
+ { rowId: k.id, colId: col.id, value: childRaw[i], role: "raw" },
1105
+ { rowId: k.id, colId: col.id, value: childShown[i], role: "displayed" }
1106
+ ])
1107
+ ], unitOf = (candidate) => Math.pow(10, -candidate.decimals) * MAGNITUDE_DIVISOR[candidate.magnitude], displayUnit = Math.min(unitOf(spec), minOf(kids.map((k) => unitOf(specFor(col.id, k.id)))));
1108
+ Math.abs(roundingGap) > displayUnit * 0.5 && (autoFootnotes.add(ROUNDING_FOOTNOTE), records.push({
1109
+ rowId: row.id,
1110
+ colId: col.id,
1111
+ op: "rounding-gap",
1112
+ inputs,
1113
+ raw: roundingGap,
1114
+ state: "value",
1115
+ displayed: "",
1116
+ kind: "rounding-adjustment"
1117
+ }));
1118
+ }
1119
+ }
1120
+ for (let column of columns)
1121
+ (column.kind === "value" || column.kind === "computed") && column.align === "left" && warnings.push({
1122
+ code: "align-override-suspect",
1123
+ severity: "warn",
1124
+ message: `column '${column.id}' forces a numeric column left \u2014 right alignment is the comparison-safe default`,
1125
+ owner: { colId: column.id }
1126
+ });
1127
+ let resolvedColumns = columns.map((c) => ({
1128
+ id: c.id,
1129
+ kind: c.kind,
1130
+ label: c.label ?? (c.kind === "rowLabel" ? "" : c.id),
1131
+ ...c.subLabel === void 0 ? {} : { subLabel: c.subLabel },
1132
+ format: c.kind === "value" || c.kind === "computed" ? formatExamples.get(c.id) : c.kind === "date" ? c.format : void 0,
1133
+ scenario: c.kind === "value" ? c.scenario : void 0,
1134
+ polarity: c.kind === "value" || c.kind === "computed" ? c.polarity : void 0,
1135
+ aggregate: c.kind === "value" ? c.aggregate ?? (nonAdditiveFormat(c.format) ? "none" : "sum") : "none",
1136
+ groupId: data.columnGroups?.find((g) => g.columns.includes(c.id))?.id,
1137
+ toggleGroup: toggleResolution.membership.get(c.id),
1138
+ width: c.width,
1139
+ maxWidth: c.kind === "rowLabel" ? c.maxWidth : void 0,
1140
+ maxTextWidth: c.kind === "rowLabel" ? c.maxTextWidth : void 0,
1141
+ wrap: c.kind === "text" ? c.wrap : void 0,
1142
+ statusMark: c.kind === "status" && c.mark === "square" ? "square" : void 0,
1143
+ unitLabel: uniformUnit === null && (c.kind === "value" || c.kind === "computed") ? headerUnitFor(c.id) ?? void 0 : void 0,
1144
+ ...uniformUnit === null && (c.kind === "value" || c.kind === "computed") && headerUnitFor(c.id) !== null && headerScaledFor(c.id) ? { unitScaled: !0 } : {},
1145
+ ...lettersInCells.has(c.id) ? { magnitudeInCells: !0 } : {},
1146
+ encoding: c.kind === "encoding" ? c.encoding : void 0,
1147
+ cellEncoding: resolveCellEncoding(encodingFor(options.encodings, c.id), specs.get(c.id)?.suffix.includes("%") === !0),
1148
+ // The preset's own two column decisions: a benchmark's first
1149
+ // column is the subject and carries the header's weight, a receipts
1150
+ // table's dates sit under each other on the right.
1151
+ emphasis: c.emphasis ?? (c.kind === "rowLabel" ? language.labelEmphasis : void 0),
1152
+ ...c.band === void 0 ? {} : { band: c.band },
1153
+ ...c.noteLine === void 0 ? {} : { noteLine: c.noteLine },
1154
+ // A cohort grid centres its figures: every cell in a period column is
1155
+ // the same two or three digits, and a right edge would draw a ragged
1156
+ // column of gaps. A column that names its own alignment, the
1157
+ // cohort size beside the label, keeps it.
1158
+ align: c.align ?? (c.kind === "value" || c.kind === "computed" ? isCohortDensity(options.density ?? "regular") ? "center" : "right" : c.kind === "status" ? "center" : c.kind === "date" && language.datesRight ? "right" : "left")
1159
+ })), driverToneMode = options.driverTones ?? "grouped";
1160
+ function driverToneOf(row) {
1161
+ return driverToneMode !== "grouped" ? driverToneMode === "always" : row.parentId !== null && flatById.get(row.parentId)?.role !== "section";
1162
+ }
1163
+ let resolvedRows = flat.map((row) => {
1164
+ let cells = {};
1165
+ for (let col of columns)
1166
+ cells[col.id] = resolveCell(row, col);
1167
+ let hasChildren = (treeChildrenOf.get(row.id) ?? []).length > 0;
1168
+ return {
1169
+ id: row.id,
1170
+ label: row.label,
1171
+ ...row.parentId === null ? {} : { parentId: row.parentId },
1172
+ hasChildren,
1173
+ ...hasChildren ? { defaultExpanded: expansion.get(row.id) } : {},
1174
+ level: row.level,
1175
+ step: ladderStep(row, flatById, levelOffset),
1176
+ ...row.kind === void 0 ? {} : { kind: row.kind },
1177
+ ...row.kind === "driver" && driverToneOf(row) ? { driverTone: !0 } : {},
1178
+ ...row.sign === void 0 ? {} : { sign: row.sign },
1179
+ ...row.final === void 0 ? {} : { final: row.final },
1180
+ ...options.signs === "operators" ? { operator: row.sign === -1 ? "\u2212" : row.kind === "result" ? "=" : row.operator } : {},
1181
+ ...row.divider === !0 ? { divider: !0 } : {},
1182
+ role: row.role,
1183
+ relation: row.relation,
1184
+ order: row.order,
1185
+ ...row.polarity === void 0 ? {} : { polarity: row.polarity },
1186
+ ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1187
+ highlightTone: highlightedRows.has(row.id) ? rowHighlightTone(cells) : void 0,
1188
+ // A forced magnitude wins: it is a claim about the whole table, and
1189
+ // the letter it hoists out of the cells has to be the one the label
1190
+ // prints. Without one the author's own affix stands.
1191
+ ...hoistedRowUnits.has(row.id) ? headUnit === void 0 ? { unitAffix: row.kind === "member" && row.unitAffix ? `${row.unitAffix.split(",")[0]}, ${hoistedRowUnits.get(row.id)}` : hoistedRowUnits.get(row.id) } : {} : row.unitAffix === void 0 ? {} : { unitAffix: row.unitAffix },
1192
+ ...row.spacer === void 0 ? {} : { spacer: row.spacer },
1193
+ ...hasChildren && row.foldable === !1 ? { foldable: !1 } : {},
1194
+ ...row.badge === void 0 ? {} : { badge: { text: row.badge.text, tone: row.badge.tone ?? "neutral" } },
1195
+ cells
1196
+ };
1197
+ });
1198
+ {
1199
+ let resolvedById = new Map(resolvedRows.map((row) => [row.id, row]));
1200
+ for (let [parentId, list] of childrenOf) {
1201
+ if (parentId === null) continue;
1202
+ let lines = list.filter((child) => child.inline === !0).map((child) => resolvedById.get(child.id));
1203
+ lines.length > 0 && (resolvedById.get(parentId).inlineRows = lines);
1204
+ }
1205
+ }
1206
+ function judgementTone(tone, strong) {
1207
+ return options.judgements === "exceptions" && (tone === "warn" || tone === "good" && !strong) ? "neutral" : tone;
1208
+ }
1209
+ function blankInputs(row, col) {
1210
+ let calc = row.calc ?? (col.kind === "computed" ? col.calc : void 0);
1211
+ if (calc === void 0) return !1;
1212
+ let gaps = calcRefs(calc).flatMap((ref) => {
1213
+ let rowId = typeof ref == "string" ? row.id : ref.row, colId = typeof ref == "string" ? ref : ref.col ?? (ref.previous ? previousColumnInGroup(data.columnGroups ?? [], col.id) : col.id);
1214
+ if (colId === null) return [];
1215
+ let state = rawState.get(rowId)?.get(colId);
1216
+ return state !== void 0 && state.state === "missing" ? [{ rowId, colId }] : [];
1217
+ });
1218
+ return gaps.length > 0 && gaps.every(({ rowId, colId }) => {
1219
+ let input = flatById.get(rowId), cell = input?.cells[colId];
1220
+ return ((isCellObject(cell) ? cell.missing : void 0) ?? input?.missing) === "blank";
1221
+ });
1222
+ }
1223
+ function resolveCell(row, col) {
1224
+ let authored = row.cells[col.id], obj = isCellObject(authored) ? authored : void 0, missing = obj?.missing ?? row.missing, missingGlyph = missing === void 0 ? tableMissingGlyph : missing === "blank" ? "" : glyphs.missing, base = {
1225
+ rowId: row.id,
1226
+ colId: col.id,
1227
+ kind: col.kind,
1228
+ raw: null,
1229
+ state: "missing",
1230
+ displayed: "",
1231
+ tone: judgementTone(obj?.tone ?? "neutral", obj?.strong),
1232
+ note: obj?.note,
1233
+ href: obj?.href,
1234
+ ...obj?.heat === !1 ? { heat: !1 } : {},
1235
+ ...obj?.strong === !0 && obj.tone !== void 0 && obj.tone !== "neutral" ? { strong: !0 } : {},
1236
+ ...typeof obj?.bar == "number" && Number.isFinite(obj.bar) ? { bar: Math.min(1, Math.max(0, obj.bar)) } : {},
1237
+ ...col.kind === "value" && obj?.format !== void 0 ? { format: obj.format } : {},
1238
+ scenario: col.kind === "value" ? col.scenario : void 0,
1239
+ role: row.role,
1240
+ relation: row.relation,
1241
+ level: row.level
1242
+ };
1243
+ if (row.role === "section" && col.kind !== "rowLabel")
1244
+ return { ...base, state: "na", displayed: "" };
1245
+ if (obj?.state && col.kind !== "rowLabel" && col.kind !== "encoding")
1246
+ return { ...base, raw: null, state: obj.state, displayed: glyphs[obj.state], tone: "neutral", ...obj.muted === !0 ? { deEmphasized: !0 } : {} };
1247
+ switch (col.kind) {
1248
+ case "rowLabel":
1249
+ return { ...base, raw: row.label, state: "value", displayed: row.label };
1250
+ case "value":
1251
+ case "computed": {
1252
+ let evaluated = rawState.get(row.id).get(col.id), s = evaluated ?? { raw: null, state: "missing" }, displayed;
1253
+ if (s.state !== "value" || typeof s.raw != "number") {
1254
+ let state = s.state === "value" ? "missing" : s.state, noPreviousColumn = row.calc !== void 0 && JSON.stringify(row.calc).includes('"previous":true') && previousColumnInGroup(data.columnGroups ?? [], col.id) === null, noPreviousValue = state === "na" && previousPlaceholders && noPreviousColumn;
1255
+ displayed = state === "missing" && gapWord && missing === void 0 && evaluated !== void 0 && !(noPreviousColumn && noPrevious === "missing") && !blankInputs(row, col) ? glyphs.na : state === "missing" || noPreviousValue ? missingGlyph : glyphs[state];
1256
+ } else {
1257
+ let relativeChange = (row.inline === !0 || row.calc !== void 0 || col.kind === "computed") && (specUnitKind(specFor(col.id, row.id)) !== "number" || row.calc !== void 0 && calcYieldsPoints(row.calc) || col.kind === "computed" && calcYieldsPoints(col.calc)), negate = (options.signs ?? "signed") === "signed" && row.kind !== "driver" && row.kind !== "result" && !relativeChange && signTo(row, null) === -1;
1258
+ displayed = (negate ? void 0 : displayOverride.get(tableCellKey(row.id, col.id))) ?? formatNumber(negate && s.raw !== 0 ? -s.raw : s.raw, col.id, row.id), negate && locale.minusGlyph === "-" && (displayed = displayed.replace(MINUS, "-")), s.partial && !(disclosuresShown(options) && partialColumnIds.has(col.id)) && (displayed = `${displayed} ${options.strings?.incomplete ?? localeStrings(options.locale?.language).incomplete}`);
1259
+ }
1260
+ let band = obj?.bands !== void 0 && s.state === "value" && typeof s.raw == "number" ? bandFor(s.raw, obj.bands) : void 0, bandIndex = band === void 0 ? -1 : obj.bands.indexOf(band), tone = obj?.tone ?? band?.tone ?? "neutral", deEmphasized, judgmentRow = row.relation === "additive" || row.calc !== void 0 || row.inline === !0 && row.polarity !== void 0, polarity = col.polarity !== void 0 ? row.polarity ?? col.polarity : row.calc !== void 0 || row.inline === !0 || specFor(col.id, row.id).signed ? row.polarity : void 0;
1261
+ if (s.state === "value" && typeof s.raw == "number" && judgmentRow) {
1262
+ if (polarity && !obj?.tone && band === void 0 && roundedNumber(s.raw, specFor(col.id, row.id)) !== 0) {
1263
+ let goodSign = polarity === "higherIsBetter" ? 1 : -1;
1264
+ tone = Math.sign(s.raw) === goodSign ? "good" : "bad";
1265
+ let measure = row.polarity === void 0 ? col.label ?? col.id : row.inline === !0 && row.parentId !== null ? flatById.get(row.parentId)?.label ?? row.label : row.label;
1266
+ (polarity === "lowerIsBetter" ? lowerJudged : higherJudged).add(measure);
1267
+ }
1268
+ let mat = col.materiality, threshold = specs.get(col.id).suffix.includes("%") ? mat?.pct : mat?.abs;
1269
+ threshold !== void 0 && Math.abs(s.raw) < threshold && (deEmphasized = !0, tone = "neutral");
1270
+ }
1271
+ obj?.muted === !0 && (deEmphasized = !0, tone = "neutral"), tone = judgementTone(tone, obj?.strong);
1272
+ let reconciled = overrideAmount.get(tableCellKey(row.id, col.id)), zero = tone === "neutral" && !deEmphasized && s.state === "value" && typeof s.raw == "number" && (reconciled !== void 0 ? Math.abs(reconciled) < 1e-9 : roundedNumber(s.raw, specFor(col.id, row.id)) === 0);
1273
+ return {
1274
+ ...base,
1275
+ raw: s.raw,
1276
+ state: s.state,
1277
+ displayed,
1278
+ tone,
1279
+ deEmphasized,
1280
+ polarity,
1281
+ ...zero ? { zero: !0 } : {},
1282
+ ...band === void 0 ? {} : { band: { to: band.to, ...bandIndex > 0 ? { from: obj.bands[bandIndex - 1].to } : {}, ...band.label === void 0 ? {} : { label: band.label } } }
1283
+ };
1284
+ }
1285
+ case "status": {
1286
+ let given = typeof authored == "number" ? authored : obj?.v, v = typeof authored == "string" ? authored : typeof given == "string" ? given : null;
1287
+ if (typeof given == "number")
1288
+ return warnings.push({
1289
+ code: "status-value-number",
1290
+ severity: "warn",
1291
+ message: `status cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write one of: ${STATUS_VALUES.join(" \xB7 ")}, or use a text column with a cell tone. A later release refuses a number here.`,
1292
+ owner: { rowId: row.id, colId: col.id }
1293
+ }), { ...base, displayed: missingGlyph };
1294
+ if (v !== null && !STATUS_VALUES.includes(v))
1295
+ throw new NormalizeError(
1296
+ "status-value-invalid",
1297
+ `rows[${row.id}].cells[${col.id}]`,
1298
+ `status '${v}' is not one of: ${STATUS_VALUES.join(" \xB7 ")}; for free status text use a text column with a cell tone`
1299
+ );
1300
+ if (v === null) return { ...base, displayed: missingGlyph };
1301
+ let tone = v === "off-track" ? "bad" : v === "at-risk" ? "warn" : v === "done" || v === "on-track" ? "good" : "neutral", labels = col.kind === "status" ? col.labels : void 0;
1302
+ return { ...base, raw: v, state: "value", displayed: labels?.[v] ?? v, tone: judgementTone(tone, obj?.strong) };
1303
+ }
1304
+ case "date": {
1305
+ let v = typeof authored == "string" ? authored : typeof obj?.v == "string" ? obj.v : null;
1306
+ if (v === null) return { ...base, displayed: missingGlyph };
1307
+ let d = parseISODate(v);
1308
+ if (!d)
1309
+ throw new NormalizeError(
1310
+ "date-invalid",
1311
+ `rows[${row.id}].cells[${col.id}]`,
1312
+ `'${v}' is not an ISO date (YYYY-MM-DD)`
1313
+ );
1314
+ let pattern = datePatternFromExample(col.kind === "date" ? col.format : void 0);
1315
+ return { ...base, raw: v, state: "value", displayed: formatDate(d, pattern, options.locale?.language) };
1316
+ }
1317
+ case "text": {
1318
+ let v = typeof authored == "string" ? authored : typeof authored == "number" ? String(authored) : obj?.v !== void 0 ? String(obj.v) : null;
1319
+ return v === null && !obj?.note ? { ...base, displayed: "" } : { ...base, raw: v, state: "value", displayed: v ?? "" };
1320
+ }
1321
+ case "encoding":
1322
+ return { ...base, state: "value", displayed: "" };
1323
+ }
1324
+ }
1325
+ stampRecordDisplay(records, resolvedRows, formatNumber), sortSiblingGroups(childrenOf, resolvedRows, resolvedColumns, options, generatedOthers);
1326
+ let totalPos = options.totalPosition ?? language.totalPosition, ordered = orderRows(resolvedRows, childrenOf, totalPos);
1327
+ ordered.forEach((r, i) => r.order = i);
1328
+ for (let row of ordered) {
1329
+ if (!generatedOthers.has(row.id) || !row.hasChildren) continue;
1330
+ let members = (treeChildrenOf.get(row.id) ?? []).map((child) => child.label);
1331
+ autoFootnotes.add(`${row.label} groups ${members.join(", ")}.`);
1332
+ }
1333
+ resolvedColumns.filter((column) => (column.kind === "value" || column.kind === "computed") && column.cellEncoding?.type === "heat" && (column.cellEncoding.scale ?? "column") === "column" && column.cellEncoding.cap === void 0).length > 1 && autoFootnotes.add(HEAT_COLUMN_FOOTNOTE);
1334
+ let statusNote = statusDirectionNote(resolvedColumns, heatRanges(resolvedColumns, ordered), options.colorblindSafe === !0);
1335
+ if (statusNote !== void 0 && autoFootnotes.add(statusNote), resolvedColumns.some((column) => column.cellEncoding?.type === "arrow" && column.cellEncoding.scale === "relative" && column.kind === "computed" && column.polarity) && autoFootnotes.add(ARROW_FOOTNOTE), lowerJudged.size && higherJudged.size) {
1336
+ let [fewer, word] = lowerJudged.size <= higherJudged.size ? [lowerJudged, "Lower"] : [higherJudged, "Higher"];
1337
+ autoFootnotes.add(`${options.colorblindSafe === !0 ? "The good tone" : "Green"} marks a favourable change. ${word} is better for ${[...fewer].join(", ")}.`);
1338
+ }
1339
+ let footnotes = [...autoFootnotes];
1340
+ if (disclosuresShown(options)) for (let column of resolvedColumns) partialColumnIds.has(column.id) && (column.partial = !0);
1341
+ let result = {
1342
+ ...zeroLifts.count === liftsBefore ? {} : { lifted: !0 },
1343
+ table: {
1344
+ columns: resolvedColumns,
1345
+ columnGroups: (data.columnGroups ?? []).map((g) => ({
1346
+ id: g.id,
1347
+ label: g.label,
1348
+ columnIds: g.columns,
1349
+ ...g.band === void 0 ? {} : { band: g.band },
1350
+ ...g.note === void 0 ? {} : { note: g.note },
1351
+ ...g.spacer === void 0 ? {} : { spacer: g.spacer },
1352
+ ...g.heading === void 0 ? {} : { heading: g.heading },
1353
+ ...g.hoverSeries === void 0 ? {} : { hoverSeries: g.hoverSeries }
1354
+ })),
1355
+ columnToggles: toggleResolution.toggles,
1356
+ rows: ordered,
1357
+ unit: uniformUnit ?? void 0,
1358
+ ...data.levelNouns === void 0 ? {} : { levelNouns: data.levelNouns },
1359
+ footnotes,
1360
+ ...partialColumnIds.size > 0 ? { partialColumnIds: [...partialColumnIds] } : {},
1361
+ ...options.colorblindSafe === !0 ? { colorblindSafe: !0 } : {},
1362
+ provenance: {}
1363
+ },
1364
+ computedCells: records,
1365
+ warnings
1366
+ };
1367
+ return evaluatedStates.set(result, rawState), result;
1368
+ }
1369
+ var HEAT_DEFAULT_ALPHA = 0.18, HEAT_STATUS_ALPHA = 0.26;
1370
+ function encodingFor(encodings, columnId) {
1371
+ let own = encodings?.[columnId];
1372
+ if (own !== void 0) return own;
1373
+ for (let entry of Object.values(encodings ?? {}))
1374
+ if (typeof entry != "string" && entry.type === "heat" && entry.columns?.includes(columnId) === !0) return entry;
1375
+ }
1376
+ function resolveCellEncoding(encoding, percent) {
1377
+ if (encoding !== void 0)
1378
+ return encoding === "arrow" || typeof encoding == "object" && encoding.type === "arrow" ? { type: "arrow", scale: (typeof encoding == "object" ? encoding.scale : void 0) ?? (percent ? "absolute" : "relative") } : typeof encoding == "string" ? encoding === "heat" ? { type: "heat", alpha: HEAT_DEFAULT_ALPHA, excludeTotals: !0 } : { type: encoding } : {
1379
+ type: "heat",
1380
+ ...encoding.cap === void 0 ? {} : { cap: encoding.cap },
1381
+ alpha: encoding.alpha ?? (encoding.scale === "status" ? HEAT_STATUS_ALPHA : HEAT_DEFAULT_ALPHA),
1382
+ excludeTotals: encoding.excludeTotals ?? !0,
1383
+ ...encoding.steps === void 0 ? {} : { steps: encoding.steps },
1384
+ ...encoding.scale === void 0 ? {} : { scale: encoding.scale },
1385
+ ...encoding.bins === void 0 ? {} : { bins: encoding.bins },
1386
+ ...encoding.span === void 0 ? {} : { span: encoding.span },
1387
+ ...encoding.center === void 0 ? {} : { center: encoding.center },
1388
+ ...encoding.tolerance === void 0 ? {} : { tolerance: encoding.tolerance }
1389
+ };
1390
+ }
1391
+ var evaluatedStates = /* @__PURE__ */ new WeakMap();
1392
+ function applyTableTopN(data, options) {
1393
+ let topN = options.topN;
1394
+ if (!topN || topN.n <= 0) return { data, generatedOthers: /* @__PURE__ */ new Set(), hidden: /* @__PURE__ */ new Map() };
1395
+ let inner = resolveTable(data, { ...options, topN: void 0 }), folded = foldTableTopN(data, inner.table, options), kept = new Set(flattenRows(folded.data.rows).map((row) => row.id)), innerById = new Map(inner.table.rows.map((row) => [row.id, row])), hidden = /* @__PURE__ */ new Map();
1396
+ for (let row of inner.table.rows) {
1397
+ if (kept.has(row.id)) continue;
1398
+ let evaluated = evaluatedStates.get(inner)?.get(row.id), states = /* @__PURE__ */ new Map();
1399
+ for (let [colId, cell] of Object.entries(row.cells)) {
1400
+ let own = evaluated?.get(colId);
1401
+ states.set(colId, { raw: cell.raw, state: cell.state, ...own?.partial ? { partial: !0, skipped: own.skipped } : {} });
1402
+ }
1403
+ hidden.set(row.id, { sign: contributionSignOf(row, (id) => innerById.get(id), null), states });
1404
+ }
1405
+ return { ...folded, hidden };
1406
+ }
1407
+ function stampRecordDisplay(records, resolvedRows, formatNumber) {
1408
+ let cellIndex = /* @__PURE__ */ new Map();
1409
+ for (let r of resolvedRows) for (let c of Object.values(r.cells)) cellIndex.set(tableCellKey(c.rowId, c.colId), c);
1410
+ for (let rec of records) {
1411
+ if (rec.kind === "reconciliation" || rec.kind === "rounding-adjustment") {
1412
+ rec.displayed = typeof rec.raw == "number" ? formatNumber(rec.raw, rec.colId) : "";
1413
+ continue;
1414
+ }
1415
+ rec.displayed = cellIndex.get(tableCellKey(rec.rowId, rec.colId))?.displayed ?? rec.displayed;
1416
+ }
1417
+ }
1418
+ function sortSiblingGroups(childrenOf, resolvedRows, columns, options, generatedOthers) {
1419
+ let catSort = options.sort?.categories ?? "sheet";
1420
+ if ((catSort === "asc" || catSort === "desc") && requireAdditiveRanking(columns, resolvedRows, "options.sort.categories", "sort.categories"), catSort === "sheet") {
1421
+ pinOthersLast(childrenOf, resolvedRows, generatedOthers);
1422
+ return;
1423
+ }
1424
+ let byId = new Map(resolvedRows.map((row) => [row.id, row]));
1425
+ for (let sibs of childrenOf.values()) {
1426
+ let dataIdx = sibs.map((_, index) => index).filter((index) => ranksAsData(byId.get(sibs[index].id)));
1427
+ if (dataIdx.length < 2) continue;
1428
+ let data = dataIdx.map((index) => sibs[index]), rest = data.filter((row) => !generatedOthers.has(row.id)), others = data.filter((row) => generatedOthers.has(row.id));
1429
+ if (catSort === "reverse") rest.reverse();
1430
+ else {
1431
+ let dir = catSort === "asc" ? 1 : -1;
1432
+ rest.sort((a, b) => {
1433
+ let ka = additiveRankKey(byId.get(a.id), columns) ?? 0, kb = additiveRankKey(byId.get(b.id), columns) ?? 0;
1434
+ return (ka - kb) * dir || a.order - b.order;
1435
+ });
1436
+ }
1437
+ let ordered = [...rest, ...others];
1438
+ dataIdx.forEach((index, j) => {
1439
+ sibs[index] = ordered[j];
1440
+ });
1441
+ }
1442
+ }
1443
+ function pinOthersLast(childrenOf, resolvedRows, generatedOthers) {
1444
+ let byId = new Map(resolvedRows.map((row) => [row.id, row]));
1445
+ for (let sibs of childrenOf.values()) {
1446
+ let dataIdx = sibs.map((_, index) => index).filter((index) => ranksAsData(byId.get(sibs[index].id))), data = dataIdx.map((index) => sibs[index]), rest = data.filter((row) => !generatedOthers.has(row.id)), others = data.filter((row) => generatedOthers.has(row.id));
1447
+ if (others.length === 0) continue;
1448
+ let ordered = [...rest, ...others];
1449
+ dataIdx.forEach((index, j) => {
1450
+ sibs[index] = ordered[j];
1451
+ });
1452
+ }
1453
+ }
1454
+ function rowHighlightTone(cells) {
1455
+ let tones = new Set(Object.values(cells).map((cell) => cell.tone));
1456
+ return tones.has("bad") ? "bad" : tones.has("warn") ? "warn" : tones.has("good") ? "good" : "highlight";
1457
+ }
1458
+ function isCellObject(c) {
1459
+ return typeof c == "object" && c !== null;
1460
+ }
1461
+ function cellFormat(c) {
1462
+ return isCellObject(c) ? c.format : void 0;
1463
+ }
1464
+ function readNumeric(c) {
1465
+ return c == null ? { raw: null, state: "missing" } : typeof c == "number" ? { raw: c, state: "value" } : typeof c == "string" ? { raw: null, state: "missing", nonNumeric: c } : c.state ? { raw: typeof c.v == "number" ? c.v : null, state: c.state } : typeof c.v == "number" ? { raw: c.v, state: "value" } : typeof c.v == "string" ? { raw: null, state: "missing", nonNumeric: c.v } : { raw: null, state: "missing" };
1466
+ }
1467
+ function ladderStep(row, byId, offset) {
1468
+ if (row.rung !== void 0) return Math.max(0, row.rung + offset);
1469
+ let depth = 0, parentId = row.parentId;
1470
+ for (; parentId != null; ) {
1471
+ let parent = byId.get(parentId);
1472
+ if (parent === void 0) break;
1473
+ parent.role !== "section" && (depth += 1), parentId = parent.parentId;
1474
+ }
1475
+ return Math.max(0, depth + (row.role === "total" ? 0 : offset));
1476
+ }
1477
+ function flattenRows(rows) {
1478
+ let out = [], seen = /* @__PURE__ */ new Set(), order = 0, walk = (row, parentId, level) => {
1479
+ if (seen.has(row.id))
1480
+ throw new NormalizeError(
1481
+ "duplicate-row-id",
1482
+ `rows[${row.id}]`,
1483
+ `row id '${row.id}' appears more than once \u2014 row ids are globally unique (a fact shown in two groupings needs two rows referencing it)`
1484
+ );
1485
+ if (seen.add(row.id), row.badge !== void 0 && row.role !== "section")
1486
+ throw new NormalizeError("invalid-data", `rows[${row.id}].badge`, BADGE_SECTION_ONLY);
1487
+ let badgeText = row.badge?.text.trim();
1488
+ if (badgeText === "") throw new NormalizeError("invalid-data", `rows[${row.id}].badge.text`, BADGE_TEXT_EMPTY);
1489
+ let displayOnly = row.kind === "result" || row.kind === "driver";
1490
+ if (displayOnly && row.relation !== void 0 && row.relation !== "displayOnly") throw new NormalizeError("invalid-data", `rows[${row.id}].relation`, row.kind === "result" ? "a result is computed from rows above; adding it to a parent counts it twice" : "a driver explains a row; adding it to a parent counts a different measure");
1491
+ if (row.sign !== void 0 && (displayOnly || (row.relation ?? "additive") !== "additive")) throw new NormalizeError("invalid-data", `rows[${row.id}].sign`, "sign requires relation additive");
1492
+ if (row.final && row.kind !== "result") throw new NormalizeError("invalid-data", `rows[${row.id}].final`, "final requires kind result");
1493
+ let declaredParent = row.parentId ?? parentId;
1494
+ if (row.parentId && parentId && row.parentId !== parentId)
1495
+ throw new NormalizeError(
1496
+ "parent-conflict",
1497
+ `rows[${row.id}]`,
1498
+ `nested under '${parentId}' but declares parentId '${row.parentId}'`
1499
+ );
1500
+ out.push({
1501
+ id: row.id,
1502
+ label: row.label ?? row.id,
1503
+ parentId: declaredParent ?? null,
1504
+ kind: row.kind,
1505
+ sign: row.sign,
1506
+ operator: row.operator,
1507
+ final: row.final,
1508
+ ...row.divider === !0 ? { divider: !0 } : {},
1509
+ scale: row.scale,
1510
+ rung: row.rung,
1511
+ role: row.role ?? (row.kind === "section" ? "section" : "data"),
1512
+ relation: displayOnly ? "displayOnly" : row.relation ?? "additive",
1513
+ totalPolicy: row.totalPolicy,
1514
+ calc: row.calc,
1515
+ format: row.format,
1516
+ polarity: row.polarity,
1517
+ ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1518
+ ...row.unitAffix === void 0 ? {} : { unitAffix: row.unitAffix },
1519
+ ...row.missing === void 0 ? {} : { missing: row.missing },
1520
+ ...row.spacer === void 0 || row.spacer <= 0 ? {} : { spacer: row.spacer },
1521
+ ...row.foldable === !1 ? { foldable: !1 } : {},
1522
+ ...row.badge === void 0 ? {} : { badge: { ...row.badge, text: badgeText } },
1523
+ cells: row.cells ?? {},
1524
+ level,
1525
+ order: order++,
1526
+ ...row[MAGNITUDE_GROUP] === void 0 ? {} : { [MAGNITUDE_GROUP]: row[MAGNITUDE_GROUP] },
1527
+ ...row[AUTOMATIC_FORMAT] === !0 ? { [AUTOMATIC_FORMAT]: !0 } : {}
1528
+ });
1529
+ for (let child of row.children ?? []) walk(child, row.id, level + 1);
1530
+ };
1531
+ for (let row of rows) walk(row, null, 0);
1532
+ let byId = new Map(out.map((r) => [r.id, r]));
1533
+ for (let r of out) {
1534
+ if (r.parentId && !byId.has(r.parentId))
1535
+ throw new NormalizeError("parent-missing", `rows[${r.id}]`, `parentId '${r.parentId}' does not exist`);
1536
+ let level = 0, p = r.parentId, guard = /* @__PURE__ */ new Set([r.id]);
1537
+ for (; p; ) {
1538
+ if (guard.has(p))
1539
+ throw new NormalizeError("parent-cycle", `rows[${r.id}]`, `row hierarchy contains a cycle at '${p}'`);
1540
+ guard.add(p), level++, p = byId.get(p).parentId;
1541
+ }
1542
+ r.level = level;
1543
+ }
1544
+ return out;
1545
+ }
1546
+ function orderPostfix(childrenOf) {
1547
+ let out = [], visit = (rows) => {
1548
+ for (let r of rows)
1549
+ visit(childrenOf.get(r.id) ?? []), out.push(r);
1550
+ };
1551
+ return visit(childrenOf.get(null) ?? []), out;
1552
+ }
1553
+ function orderRows(rows, childrenOf, totalPos) {
1554
+ let byId = new Map(rows.map((r) => [r.id, r])), out = [], emit = (ids) => {
1555
+ let relocates = (r) => byId.get(r.id).role === "total" && r.kind !== "result" && r.kind !== "driver", totals = ids.filter(relocates), rest = ids.filter((r) => !relocates(r)), sequence = totalPos === "top" ? [...totals, ...rest] : [...rest, ...totals];
1556
+ for (let f of sequence)
1557
+ out.push(byId.get(f.id)), emit(childrenOf.get(f.id) ?? []);
1558
+ };
1559
+ return emit(childrenOf.get(null) ?? []), out;
1560
+ }
1561
+ function localeDefaults(locale) {
1562
+ let { decimal, thousands } = chartNumberMarks(locale);
1563
+ return { decimal, thousands, minusGlyph: locale?.minusGlyph ?? MINUS };
1564
+ }
1565
+ function resolveExpansion(rows, childrenOf, options, warnings, generatedOthers) {
1566
+ let byId = new Map(rows.map((row) => [row.id, row])), parents = rows.filter((row) => (childrenOf.get(row.id) ?? []).length > 0), depth = options.expansion?.depth ?? "all", expanded = new Map(
1567
+ parents.map((row) => [row.id, row.foldable === !1 || depth === "all" || (depth === "totals" ? row.role === "section" : row.level < depth)])
1568
+ );
1569
+ for (let id of generatedOthers)
1570
+ expanded.has(id) && expanded.set(id, !1);
1571
+ let apply = (ids, value) => {
1572
+ for (let id of ids ?? []) {
1573
+ let row = byId.get(id);
1574
+ row ? expanded.has(id) ? row.foldable === !1 ? warnings.push({
1575
+ code: "expansion-ref-unfoldable",
1576
+ severity: "info",
1577
+ message: `expansion references row '${id}', which is foldable: false \u2014 its children stay drawn`,
1578
+ owner: { rowId: id }
1579
+ }) : expanded.set(id, value) : warnings.push({
1580
+ code: "expansion-ref-leaf",
1581
+ severity: "info",
1582
+ message: `expansion references leaf row '${id}' \u2014 leaves have no expansion state`,
1583
+ owner: { rowId: id }
1584
+ }) : warnings.push({
1585
+ code: "expansion-ref-unknown",
1586
+ severity: "warn",
1587
+ message: `expansion references unknown row '${id}' \u2014 no view state was changed`,
1588
+ owner: { rowId: id }
1589
+ });
1590
+ }
1591
+ };
1592
+ return apply(options.expansion?.collapsed, !1), apply(options.expansion?.expanded, !0), expanded;
1593
+ }
1594
+ function resolveColumnToggles(data, options, colById, warnings) {
1595
+ let membership = /* @__PURE__ */ new Map(), toggleIds = /* @__PURE__ */ new Set(), groupByColumn = /* @__PURE__ */ new Map();
1596
+ for (let group of data.columnGroups ?? [])
1597
+ for (let columnId of group.columns) groupByColumn.set(columnId, group.id);
1598
+ for (let toggle of data.columnToggles ?? []) {
1599
+ if (toggleIds.has(toggle.id))
1600
+ throw new NormalizeError(
1601
+ "duplicate-toggle-id",
1602
+ `columnToggles[${toggle.id}]`,
1603
+ `duplicate toggle id '${toggle.id}'`
1604
+ );
1605
+ toggleIds.add(toggle.id);
1606
+ for (let columnId of toggle.columns) {
1607
+ if (!colById.has(columnId))
1608
+ throw new NormalizeError(
1609
+ "toggle-ref-invalid",
1610
+ `columnToggles[${toggle.id}]`,
1611
+ `toggle '${toggle.id}' references unknown column '${columnId}'`
1612
+ );
1613
+ let owner = membership.get(columnId);
1614
+ if (owner !== void 0)
1615
+ throw new NormalizeError(
1616
+ "toggle-ref-invalid",
1617
+ `columnToggles[${toggle.id}]`,
1618
+ `column '${columnId}' already belongs to toggle '${owner}' \u2014 a column may belong to at most one toggle group`
1619
+ );
1620
+ membership.set(columnId, toggle.id);
1621
+ }
1622
+ if (new Set(toggle.columns.map((columnId) => groupByColumn.get(columnId))).size !== 1)
1623
+ throw new NormalizeError(
1624
+ "toggle-group-span",
1625
+ `columnToggles[${toggle.id}]`,
1626
+ `every member of toggle '${toggle.id}' must belong to one columnGroup, or none of them to any`
1627
+ );
1628
+ }
1629
+ for (let toggleId of Object.keys(options.columnVisibility ?? {}))
1630
+ toggleIds.has(toggleId) || warnings.push({
1631
+ code: "column-visibility-ref-unknown",
1632
+ severity: "warn",
1633
+ message: `columnVisibility references unknown toggle '${toggleId}' \u2014 no columns were changed`
1634
+ });
1635
+ return {
1636
+ membership,
1637
+ toggles: (data.columnToggles ?? []).map((toggle) => {
1638
+ let defaultVisible = toggle.defaultVisible ?? !1;
1639
+ return {
1640
+ id: toggle.id,
1641
+ label: toggle.label,
1642
+ columnIds: toggle.columns,
1643
+ defaultVisible,
1644
+ visible: options.columnVisibility?.[toggle.id] ?? defaultVisible
1645
+ };
1646
+ })
1647
+ };
1648
+ }
1649
+ function validateGroups(data, colById) {
1650
+ let groups = data.columnGroups ?? [], claimed = /* @__PURE__ */ new Map(), columnIndex = new Map(data.columns.map((column, index) => [column.id, index]));
1651
+ for (let g of groups) {
1652
+ for (let cid of g.columns) {
1653
+ if (!colById.has(cid))
1654
+ throw new NormalizeError("group-ref-invalid", `columnGroups[${g.id}]`, `references unknown column '${cid}'`);
1655
+ if (claimed.has(cid))
1656
+ throw new NormalizeError(
1657
+ "group-ref-invalid",
1658
+ `columnGroups[${g.id}]`,
1659
+ `column '${cid}' already belongs to group '${claimed.get(cid)}'`
1660
+ );
1661
+ claimed.set(cid, g.id);
1662
+ }
1663
+ let idx = g.columns.map((cid) => columnIndex.get(cid)).sort((a, b) => a - b);
1664
+ for (let i = 1; i < idx.length; i++)
1665
+ if (idx[i] !== idx[i - 1] + 1)
1666
+ throw new NormalizeError(
1667
+ "group-not-contiguous",
1668
+ `columnGroups[${g.id}]`,
1669
+ "group members must be contiguous in columns[] order"
1670
+ );
1671
+ }
1672
+ }
1673
+ function validateCalcRefs(columns, colById) {
1674
+ let checkRef = (rid, owner) => {
1675
+ let target = colById.get(rid);
1676
+ if (!target)
1677
+ throw new NormalizeError("calc-ref-missing", `columns[${owner}].calc`, `references unknown column '${rid}'`);
1678
+ if (target.kind !== "value")
1679
+ throw new NormalizeError(
1680
+ "compute-ref-computed",
1681
+ `columns[${owner}].calc`,
1682
+ `references '${rid}' (kind '${target.kind}') \u2014 calcs may reference value columns only in v1`
1683
+ );
1684
+ }, checkCell = (ref, owner) => {
1685
+ if (typeof ref != "string")
1686
+ throw new NormalizeError(
1687
+ "row-ref-in-column-calc",
1688
+ `columns[${owner}].calc`,
1689
+ "column calculations still refer to the current row \u2014 use a column id, or put a cross-row calc on the row"
1690
+ );
1691
+ checkRef(ref, owner);
1692
+ }, check = (calc, owner) => {
1693
+ if (!("lit" in calc)) {
1694
+ if ("ref" in calc) return checkCell(calc.ref, owner);
1695
+ switch (calc.op) {
1696
+ case "abs":
1697
+ return check(calc.of, owner);
1698
+ case "add":
1699
+ case "sub":
1700
+ case "mul":
1701
+ case "div":
1702
+ check(calc.a, owner), check(calc.b, owner);
1703
+ return;
1704
+ case "share":
1705
+ return checkCell(calc.of, owner);
1706
+ case "delta":
1707
+ case "percentDelta":
1708
+ checkCell(calc.a, owner), checkCell(calc.b, owner);
1709
+ return;
1710
+ }
1711
+ }
1712
+ };
1713
+ for (let c of columns)
1714
+ c.kind === "computed" && check(c.calc, c.id);
1715
+ }
1716
+ function calcYieldsPoints(calc) {
1717
+ return "op" in calc && (calc.op === "share" || calc.op === "percentDelta");
1718
+ }
1719
+ var LEAF_TOTAL_ROW_ID = "__leafTotal", SHARE_UNIT_ROW_ID = "__displayUnit";
1720
+ function pushCalcRecord(records, rowId, colId, res) {
1721
+ records.push({
1722
+ rowId,
1723
+ colId,
1724
+ op: res.op,
1725
+ inputs: res.inputs,
1726
+ raw: res.raw,
1727
+ state: res.state,
1728
+ displayed: "",
1729
+ kind: "calc"
1730
+ });
1731
+ }
1732
+ function contributionSignOf(row, byId, stop) {
1733
+ let sign = 1, current = row;
1734
+ for (; current && current.id !== stop && !(current !== row && (current.kind === "driver" || current.kind === "result")); )
1735
+ current.relation === "additive" && (sign *= current.sign ?? 1), current = current.parentId == null ? void 0 : byId(current.parentId);
1736
+ return sign;
1737
+ }
1738
+ function numericColKind(kind) {
1739
+ return kind === "value" || kind === "computed";
1740
+ }
1741
+ function validateRowCalcRef(ref, owner, rowIds, calcRows, colById, reads) {
1742
+ if (typeof ref == "string") {
1743
+ let target = colById.get(ref);
1744
+ if (!target || !numericColKind(target.kind))
1745
+ throw new NormalizeError(
1746
+ "calc-ref-missing",
1747
+ `rows[${owner}].calc`,
1748
+ `references unknown numeric column '${typeof ref == "string" ? ref : ""}'`
1749
+ );
1750
+ return;
1751
+ }
1752
+ if (!rowIds.has(ref.row))
1753
+ throw new NormalizeError("calc-ref-missing", `rows[${owner}].calc`, `references unknown row '${ref.row}'`);
1754
+ if (calcRows.has(ref.row) && reads?.push(ref.row), ref.col) {
1755
+ let target = colById.get(ref.col);
1756
+ if (!target || !numericColKind(target.kind))
1757
+ throw new NormalizeError(
1758
+ "calc-ref-missing",
1759
+ `rows[${owner}].calc`,
1760
+ `references unknown numeric column '${ref.col}'`
1761
+ );
1762
+ }
1763
+ }
1764
+ function calcRefs(calc, refs = []) {
1765
+ if ("lit" in calc) return refs;
1766
+ if ("ref" in calc)
1767
+ return refs.push(calc.ref), refs;
1768
+ switch (calc.op) {
1769
+ case "abs":
1770
+ return calcRefs(calc.of, refs);
1771
+ case "add":
1772
+ case "sub":
1773
+ case "mul":
1774
+ case "div":
1775
+ return calcRefs(calc.a, refs), calcRefs(calc.b, refs);
1776
+ case "share":
1777
+ return refs.push(calc.of), refs;
1778
+ case "delta":
1779
+ case "percentDelta":
1780
+ refs.push(calc.a, calc.b);
1781
+ }
1782
+ return refs;
1783
+ }
1784
+ function walkRowCalc(calc, owner, rowIds, calcRows, colById, reads = []) {
1785
+ let ref = (r) => validateRowCalcRef(r, owner, rowIds, calcRows, colById, reads);
1786
+ if ("lit" in calc) return reads;
1787
+ if ("ref" in calc)
1788
+ return ref(calc.ref), reads;
1789
+ switch (calc.op) {
1790
+ case "abs":
1791
+ return walkRowCalc(calc.of, owner, rowIds, calcRows, colById, reads);
1792
+ case "add":
1793
+ case "sub":
1794
+ case "mul":
1795
+ case "div":
1796
+ return walkRowCalc(calc.a, owner, rowIds, calcRows, colById, reads), walkRowCalc(calc.b, owner, rowIds, calcRows, colById, reads), reads;
1797
+ case "share":
1798
+ return ref(calc.of), reads;
1799
+ case "delta":
1800
+ case "percentDelta":
1801
+ ref(calc.a), ref(calc.b);
1802
+ }
1803
+ return reads;
1804
+ }
1805
+ function evaluateTableCalcs(flat, valueCols, computedCols, rawState, records, leafTotal, columnGroups, colById, noPrevious = "na", contributionSign = () => 1) {
1806
+ let nearZero = !1, mixedCoverage = !1, rowIds = new Set(rawState.keys()), calcRows = new Set(flat.filter((row) => row.calc).map((row) => row.id)), previousCol = (colId) => previousColumnInGroup(columnGroups, colId), numericCols = [...valueCols, ...computedCols], partialFrom = (res, rowId, states) => {
1807
+ if (res.state !== "value") return {};
1808
+ let partials = res.inputs.map((input) => (input.rowId === rowId ? states : rawState.get(input.rowId))?.get(input.colId)).filter((state) => state?.partial);
1809
+ return partials.length > 0 ? { partial: !0, skipped: skippedKey(partials.flatMap((state) => skippedRows(state))) } : {};
1810
+ }, coverageOf = (rowId, states, currentCol) => (ref) => {
1811
+ let cell = resolveCalcRef(ref, rowId, currentCol, previousCol);
1812
+ if (typeof cell != "string")
1813
+ return (cell.rowId === rowId ? states.get(cell.colId) : rawState.get(cell.rowId)?.get(cell.colId))?.skipped ?? "";
1814
+ };
1815
+ for (let row of flat) {
1816
+ if (row.role === "section" || row.calc) continue;
1817
+ let states = rawState.get(row.id);
1818
+ for (let col of computedCols) {
1819
+ let res = evalCalc(col.calc, row, states, leafTotal, void 0, contributionSign);
1820
+ res.state === "value" && comparesMixedRows(col.calc, coverageOf(row.id, states, col.id)) && (res = { ...res, raw: null, state: "nm" }, mixedCoverage = !0), states.set(col.id, { raw: res.raw, state: res.state, ...partialFrom(res, row.id, states) }), res.nearZero && (nearZero = !0), pushCalcRecord(records, row.id, col.id, res);
1821
+ }
1822
+ }
1823
+ let calcFlat = flat.filter((row) => row.role !== "section" && row.calc), byId = new Map(calcFlat.map((row) => [row.id, row])), ordered = [], visit = /* @__PURE__ */ new Map(), place = (row) => {
1824
+ if (visit.get(row.id) !== "done") {
1825
+ if (visit.get(row.id) === "open") throw new NormalizeError("compute-ref-cycle", `rows[${row.id}].calc`, `row calcs form a cycle through '${row.id}'`);
1826
+ if (row.relation === "additive")
1827
+ throw new NormalizeError(
1828
+ "row-calc-relation",
1829
+ `rows[${row.id}]`,
1830
+ `row '${row.id}' has calc but relation '${row.relation}' \u2014 row calculations must be ofWhich or displayOnly so they are not summed`
1831
+ );
1832
+ visit.set(row.id, "open");
1833
+ for (let id of walkRowCalc(row.calc, row.id, rowIds, calcRows, colById)) place(byId.get(id));
1834
+ visit.set(row.id, "done"), ordered.push(row);
1835
+ }
1836
+ };
1837
+ calcFlat.forEach(place);
1838
+ for (let row of ordered) {
1839
+ let states = rawState.get(row.id), sourceStates = new Map(states);
1840
+ for (let col of numericCols) {
1841
+ if (col.kind === "computed" && !calcPreservesScale(col.calc)) continue;
1842
+ let res = evalCalc(row.calc, row, sourceStates, leafTotal, {
1843
+ currentCol: col.id,
1844
+ rawState,
1845
+ previousCol,
1846
+ noPrevious
1847
+ }, contributionSign);
1848
+ res.state === "value" && comparesMixedRows(row.calc, coverageOf(row.id, sourceStates, col.id)) && (res = { ...res, raw: null, state: "nm" }, mixedCoverage = !0), states.set(col.id, { raw: res.raw, state: res.state, ...partialFrom(res, row.id, sourceStates) }), res.nearZero && (nearZero = !0), pushCalcRecord(records, row.id, col.id, res);
1849
+ }
1850
+ }
1851
+ return { nearZero, mixedCoverage };
1852
+ }
1853
+ function comparesMixedRows(calc, skippedOf) {
1854
+ let side = (node) => {
1855
+ let keys = (typeof node == "string" || !("op" in node || "ref" in node || "lit" in node) ? [node] : calcRefs(node)).map(skippedOf).filter((key) => key !== void 0);
1856
+ return keys.length === 0 ? void 0 : skippedKey(keys.flatMap((key) => skippedRows({ skipped: key })));
1857
+ }, differ = (a, b) => {
1858
+ let left = side(a), right = side(b);
1859
+ return left !== void 0 && right !== void 0 && left !== right;
1860
+ }, visit = (node) => {
1861
+ if ("lit" in node || "ref" in node) return !1;
1862
+ switch (node.op) {
1863
+ case "abs":
1864
+ return visit(node.of);
1865
+ case "add":
1866
+ return visit(node.a) || visit(node.b);
1867
+ case "sub":
1868
+ case "mul":
1869
+ case "div":
1870
+ return visit(node.a) || visit(node.b) || differ(node.a, node.b);
1871
+ case "delta":
1872
+ case "percentDelta":
1873
+ return differ(node.a, node.b);
1874
+ case "share":
1875
+ return !1;
1876
+ }
1877
+ return !1;
1878
+ };
1879
+ return visit(calc);
1880
+ }
1881
+ function skippedKey(ids) {
1882
+ return [...new Set(ids)].sort().join("");
1883
+ }
1884
+ function skippedRows(state) {
1885
+ return state.skipped ? state.skipped.split("") : [];
1886
+ }
1887
+ function evalCalc(calc, row, states, leafTotal, scope, contributionSign = () => 1) {
1888
+ let inputs = [], isState = (v) => typeof v != "number", expr = "", nearZero = !1, emit = (text) => {
1889
+ expr = text;
1890
+ }, read = (ref) => readCalcInput(ref, {
1891
+ currentRow: row.id,
1892
+ currentCol: scope?.currentCol,
1893
+ states,
1894
+ rawState: scope?.rawState,
1895
+ previousCol: scope?.previousCol,
1896
+ noPrevious: scope?.noPrevious,
1897
+ inputs,
1898
+ emit
1899
+ }), worse = (a, b) => dominantState([a, b]), child = (node) => [evalNode(node), expr], evalNode = (node) => {
1900
+ if ("ref" in node) return read(node.ref);
1901
+ if ("lit" in node)
1902
+ return emit(String(node.lit)), node.lit;
1903
+ switch (node.op) {
1904
+ case "abs": {
1905
+ let [v, vExpr] = child(node.of);
1906
+ return emit(`abs(${vExpr})`), typeof v == "number" ? Math.abs(v) : v;
1907
+ }
1908
+ case "add":
1909
+ case "sub":
1910
+ case "mul":
1911
+ case "div": {
1912
+ let [a, aExpr] = child(node.a), [b, bExpr] = child(node.b);
1913
+ return emit(`${node.op}(${aExpr},${bExpr})`), isState(a) && isState(b) ? worse(a, b) : isState(a) ? a : isState(b) ? b : node.op === "add" ? a + b : node.op === "sub" ? a - b : node.op === "mul" ? a * b : b === 0 ? a === 0 ? "na" : "nm" : a / b;
1914
+ }
1915
+ case "delta": {
1916
+ let a = read(node.a), aExpr = expr, b = read(node.b);
1917
+ return emit(`delta(${aExpr},${expr})`), isState(a) && isState(b) ? worse(a, b) : isState(a) ? a : isState(b) ? b : a - b;
1918
+ }
1919
+ case "percentDelta": {
1920
+ let a = read(node.a), aExpr = expr, b = read(node.b);
1921
+ if (emit(`percentDelta(${aExpr},${expr})`), isState(a) && isState(b)) return worse(a, b);
1922
+ if (isState(a)) return a;
1923
+ if (isState(b)) return b;
1924
+ if (b === 0)
1925
+ return a === 0 ? "na" : (nearZero = !0, "nm");
1926
+ if (b < 0) return "nm";
1927
+ let change = 100 * (a - b) / b;
1928
+ return Math.abs(change) <= PERCENT_DELTA_CAP ? change : (nearZero = !0, "nm");
1929
+ }
1930
+ case "share": {
1931
+ let sign = contributionSign(typeof node.of == "string" ? row.id : node.of.row), authored = read(node.of), v = typeof authored == "number" ? sign * authored : authored, vExpr = sign === -1 ? `mul(${expr},-1)` : expr;
1932
+ if (isState(v))
1933
+ return emit(`share(${vExpr},?)`), v;
1934
+ let ofCol = typeof node.of == "string" ? node.of : node.of.col ?? scope?.currentCol, total = ofCol ? leafTotal(ofCol) : null;
1935
+ return !ofCol || total === null ? (emit(`share(${vExpr},?)`), "missing") : (inputs.push({ rowId: LEAF_TOTAL_ROW_ID, colId: ofCol, value: total }), emit(`share(${vExpr},$${inputs.length - 1})`), total === 0 ? v === 0 ? "na" : "nm" : 100 * v / total);
1936
+ }
1937
+ }
1938
+ }, result = evalNode(calc), op = "ref" in calc ? `ref(${expr})` : "lit" in calc ? `lit(${expr})` : expr;
1939
+ return isState(result) ? { raw: null, state: result, op, inputs, ...nearZero && result === "nm" ? { nearZero: !0 } : {} } : { raw: result, state: "value", op, inputs };
1940
+ }
1941
+
1942
+ // src/core/charts/table/view.ts
1943
+ var NUMERIC_COLUMNS = /* @__PURE__ */ new Set(["value", "computed", "date", "encoding"]);
1944
+ function cellHoldsNumber(kind, displayed) {
1945
+ if (!NUMERIC_COLUMNS.has(kind)) return !1;
1946
+ let alone = numberAlone.get(displayed);
1947
+ return alone === void 0 && (numberAlone.size >= 32768 && numberAlone.clear(), numberAlone.set(displayed, alone = isNumberAlone(displayed))), alone;
1948
+ }
1949
+ var numberAlone = /* @__PURE__ */ new Map();
1950
+ function numericCell(cell) {
1951
+ return cellHoldsNumber(cell.kind, cell.displayed);
1952
+ }
1953
+ function cellDrawsTabular(theme, kind, displayed) {
1954
+ return numericVariant("value", theme) === "tabular-nums" && cellHoldsNumber(kind, displayed);
1955
+ }
1956
+ function tableFootnotes(table, rows, columns) {
1957
+ let emitted = new Set(columns.map((column) => column.id)), marked = rows.some(
1958
+ (row) => Object.values(row.cells).some(
1959
+ (cell) => cell.state === "suppressed" && emitted.has(cell.colId)
1960
+ )
1961
+ ), partialShown = table.partialColumnIds === void 0 || table.partialColumnIds.some((id) => emitted.has(id)), statusNote = statusDirectionNote(table.columns, heatRanges(table.columns, table.rows), table.colorblindSafe), shownStatusNote = statusNote === void 0 ? void 0 : statusDirectionNote(columns, heatRanges(columns, rows), table.colorblindSafe), footnotes = table.footnotes.flatMap((note) => note === PARTIAL_FOOTNOTE && !partialShown ? [] : note === statusNote ? shownStatusNote === void 0 ? [] : [shownStatusNote] : [note]);
1962
+ return (marked ? [...footnotes, SUPPRESSED_FOOTNOTE] : footnotes).map(disclosureNote);
1963
+ }
1964
+ function treeChildCounts(table) {
1965
+ let counts = /* @__PURE__ */ new Map();
1966
+ for (let row of table.rows)
1967
+ row.parentId === void 0 || row.inline === !0 || counts.set(row.parentId, (counts.get(row.parentId) ?? 0) + 1);
1968
+ return counts;
1969
+ }
1970
+ function collapsedByDefault(table) {
1971
+ return new Set(
1972
+ table.rows.filter((row) => row.hasChildren && row.defaultExpanded === !1).map((row) => row.id)
1973
+ );
1974
+ }
1975
+ function collapsedForDepth(table, depth) {
1976
+ return table.rows.filter((row) => row.inline !== !0 && row.hasChildren && row.foldable !== !1 && row.step >= depth - 1).map((row) => row.id);
1977
+ }
1978
+ function depthToExpansion(table, depth) {
1979
+ return {
1980
+ collapsed: collapsedForDepth(table, Math.max(1, depth)),
1981
+ rootsHidden: depth <= 0
1982
+ };
1983
+ }
1984
+ function expansionForFolds(table, authored, folds) {
1985
+ let base = collapsedByDefault(table), collapsed = new Set(authored?.collapsed ?? []), expanded = new Set(authored?.expanded ?? []);
1986
+ for (let row of table.rows)
1987
+ !row.hasChildren || row.foldable === !1 || folds.has(row.id) === base.has(row.id) || (folds.has(row.id) ? (expanded.delete(row.id), collapsed.add(row.id)) : (collapsed.delete(row.id), expanded.add(row.id)));
1988
+ let { collapsed: _collapsed, expanded: _expanded, ...rest } = authored ?? {};
1989
+ return {
1990
+ ...rest,
1991
+ ...collapsed.size > 0 ? { collapsed: [...collapsed] } : {},
1992
+ ...expanded.size > 0 ? { expanded: [...expanded] } : {}
1993
+ };
1994
+ }
1995
+ function expansionRootsHidden(table, expansion) {
1996
+ return expansion?.rootsHidden ?? (expansion?.depth === "totals" && table.rows.some((row) => row.role === "total"));
1997
+ }
1998
+ function emptyMessageRow(table, message) {
1999
+ let id = "boardplot:empty", labelId = table.columns.find((column) => column.kind === "rowLabel")?.id;
2000
+ return {
2001
+ id,
2002
+ label: message,
2003
+ hasChildren: !1,
2004
+ level: 0,
2005
+ step: 0,
2006
+ role: "data",
2007
+ relation: "displayOnly",
2008
+ kind: "detail",
2009
+ order: table.rows.length,
2010
+ cells: Object.fromEntries(table.columns.map((column) => [column.id, {
2011
+ rowId: id,
2012
+ colId: column.id,
2013
+ kind: column.kind,
2014
+ raw: column.id === labelId ? message : null,
2015
+ state: column.id === labelId ? "value" : "missing",
2016
+ displayed: column.id === labelId ? message : "",
2017
+ tone: "neutral",
2018
+ role: "data",
2019
+ relation: "displayOnly",
2020
+ level: 0
2021
+ }]))
2022
+ };
2023
+ }
2024
+ function visibleRows(table, collapsed, rootsHidden = !1) {
2025
+ let collapsedIds = collapsed ?? collapsedByDefault(table), rowById = new Map(table.rows.map((row) => [row.id, row]));
2026
+ return table.rows.filter((row) => {
2027
+ if (row.inline === !0 || rootsHidden && underARoot(row, rowById)) return !1;
2028
+ let parentId = row.parentId;
2029
+ for (; parentId !== void 0; ) {
2030
+ let parent = rowById.get(parentId);
2031
+ if (collapsedIds.has(parentId) && parent?.foldable !== !1) return !1;
2032
+ parentId = parent?.parentId;
2033
+ }
2034
+ return !0;
2035
+ });
2036
+ }
2037
+ function underARoot(row, rowById) {
2038
+ let current = row;
2039
+ for (; current !== void 0; ) {
2040
+ if (current.role !== "data") return !1;
2041
+ if (current.parentId === void 0) return current.foldable !== !1;
2042
+ let parent = rowById.get(current.parentId);
2043
+ if (parent === void 0 || parent.role === "section") return current.foldable !== !1 && parent?.foldable !== !1;
2044
+ current = parent;
2045
+ }
2046
+ return !1;
2047
+ }
2048
+ function finalClosers(rows) {
2049
+ let parent = new Map(rows.map((row) => [row.id, row.parentId])), inside = (id, root) => {
2050
+ for (let p = id; p !== void 0; p = parent.get(p)) if (p === root) return !0;
2051
+ return !1;
2052
+ }, closers = /* @__PURE__ */ new Set();
2053
+ return rows.forEach((row, i) => {
2054
+ if (!row.final) return;
2055
+ let j = i;
2056
+ for (; j + 1 < rows.length && inside(rows[j + 1].parentId, row.id); ) j++;
2057
+ closers.add(rows[j].id);
2058
+ }), closers;
2059
+ }
2060
+ function rowGrounds(table) {
2061
+ let grounds = /* @__PURE__ */ new Map(), rung = (row) => JSON.stringify([row.parentId ?? null, row.step]), rungsWithParents = new Set(table.rows.filter((row) => row.role === "data" && row.inline !== !0 && row.hasChildren).map(rung));
2062
+ for (let row of table.rows)
2063
+ row.role !== "data" || row.inline === !0 || !rungsWithParents.has(rung(row)) || (row.step === 0 ? grounds.set(row.id, "emphasis") : row.step === 1 && grounds.set(row.id, "band"));
2064
+ return grounds;
2065
+ }
2066
+ var SORTABLE_COLUMNS = /* @__PURE__ */ new Set(["value", "computed", "date", "text"]);
2067
+ function sortableColumnIds(table, sortable) {
2068
+ if (sortable === void 0 || sortable === !1) return /* @__PURE__ */ new Set();
2069
+ let authored = sortable === !0 ? void 0 : new Set(sortable);
2070
+ return new Set(
2071
+ table.columns.filter(
2072
+ (column) => authored === void 0 ? SORTABLE_COLUMNS.has(column.kind) : authored.has(column.id)
2073
+ ).map((column) => column.id)
2074
+ );
2075
+ }
2076
+ function sortKey(row, colId) {
2077
+ let cell = row.cells[colId];
2078
+ if (cell === void 0 || cell.state !== "value") return { missing: !0 };
2079
+ if (typeof cell.raw == "number") return { missing: !1, number: cell.raw };
2080
+ let text = typeof cell.raw == "string" && cell.raw !== "" ? cell.raw : cell.displayed;
2081
+ return text === "" ? { missing: !0 } : { missing: !1, text };
2082
+ }
2083
+ function textCollator(locale) {
2084
+ try {
2085
+ return new Intl.Collator(locale, { numeric: !0 });
2086
+ } catch {
2087
+ return new Intl.Collator(void 0, { numeric: !0 });
2088
+ }
2089
+ }
2090
+ function sortRows(table, sort, locale) {
2091
+ if (!sort || !table.columns.some((column) => column.id === sort.column)) return table.rows;
2092
+ let sign = sort.direction === "asc" ? 1 : -1, collator = textCollator(locale), childrenOf = /* @__PURE__ */ new Map();
2093
+ for (let row of table.rows) {
2094
+ let list = childrenOf.get(row.parentId) ?? [];
2095
+ list.push(row), childrenOf.set(row.parentId, list);
2096
+ }
2097
+ let movable = (row) => row.role === "data" && row.inline !== !0, compare = (a, b) => {
2098
+ let ka = sortKey(a, sort.column), kb = sortKey(b, sort.column);
2099
+ if (ka.missing || kb.missing)
2100
+ return ka.missing === kb.missing ? a.order - b.order : ka.missing ? 1 : -1;
2101
+ let step = ka.number !== void 0 && kb.number !== void 0 ? ka.number - kb.number : collator.compare(String(ka.text ?? ka.number), String(kb.text ?? kb.number));
2102
+ return sign * step || a.order - b.order;
2103
+ }, ordered = (parentId) => {
2104
+ let sibs = [...childrenOf.get(parentId) ?? []], start = 0;
2105
+ for (let index = 0; index <= sibs.length; index++)
2106
+ if (!(index < sibs.length && movable(sibs[index]))) {
2107
+ if (index - start > 1) {
2108
+ let run = sibs.slice(start, index).sort(compare);
2109
+ for (let offset = 0; offset < run.length; offset++) sibs[start + offset] = run[offset];
2110
+ }
2111
+ start = index + 1;
2112
+ }
2113
+ return sibs;
2114
+ }, out = [], walk = (parentId) => {
2115
+ for (let row of ordered(parentId))
2116
+ out.push(row), walk(row.id);
2117
+ };
2118
+ return walk(void 0), out.length === table.rows.length ? out : table.rows;
2119
+ }
2120
+ function visibleInlineRows(row, visibility) {
2121
+ return row.role !== "data" || row.inlineRows === void 0 ? [] : row.inlineRows.filter((line) => visibility?.[line.inlineGroup ?? line.id] !== !1);
2122
+ }
2123
+ var heatColumn = (column) => column.cellEncoding?.type === "heat";
2124
+ function printsFigures(figures, columns) {
2125
+ return figures !== !1 || !columns.some(heatColumn);
2126
+ }
2127
+ function visibleColumns(table, visibility) {
2128
+ let groupVisible = new Map(
2129
+ table.columnToggles.map((toggle) => [
2130
+ toggle.id,
2131
+ visibility?.[toggle.id] ?? toggle.visible
2132
+ ])
2133
+ );
2134
+ return table.columns.filter(
2135
+ (column) => column.toggleGroup === void 0 || groupVisible.get(column.toggleGroup) !== !1
2136
+ );
2137
+ }
2138
+ function groupSpans(table, visibleCols) {
2139
+ let visibleIds = new Set(visibleCols.map((column) => column.id));
2140
+ return table.columnGroups.map((group) => ({
2141
+ id: group.id,
2142
+ label: group.label,
2143
+ span: group.columnIds.filter((columnId) => visibleIds.has(columnId)).length,
2144
+ fullSpan: group.columnIds.length
2145
+ }));
2146
+ }
2147
+ function inCellBarMaxima(rows, columns) {
2148
+ let maxima = /* @__PURE__ */ new Map();
2149
+ for (let column of columns) {
2150
+ if (column.cellEncoding?.type !== "inCellBar" && column.cellEncoding?.type !== "arrow") continue;
2151
+ let maximum = 0;
2152
+ for (let row of rows) {
2153
+ let cell = row.cells[column.id];
2154
+ cell?.state === "value" && typeof cell.raw == "number" && (maximum = Math.max(maximum, Math.abs(cell.raw)));
2155
+ }
2156
+ maxima.set(column.id, maximum);
2157
+ }
2158
+ return maxima;
2159
+ }
2160
+
2161
+ // src/core/charts/table/widths.ts
2162
+ var FLEX_MIN = 80, HEAT_ONLY_CELL_W = 22;
2163
+ function tableWidths(table, theme, measure, options = {}, view = {}) {
2164
+ let regular = tableWidthsOnce(table, theme, measure, options, view), count = (view.columns ?? visibleColumns(table)).length, densePad = count >= 25 ? 3 : count >= DENSE_COLUMNS ? 5 : regular.cellPadX;
2165
+ if (options.cellPadX !== void 0 || densePad >= regular.cellPadX || Math.max(regular.minimumW, regular.totalW) <= (view.available ?? 1 / 0)) return regular;
2166
+ let dense = tableWidthsOnce(table, theme, measure, { ...options, cellPadX: densePad }, view), regularOverflow = regular.warnings.find((warning) => warning.code === "table-overflow");
2167
+ return regularOverflow && (dense.warnings = dense.warnings.map((warning) => warning.code === "table-overflow" ? regularOverflow : warning)), dense;
2168
+ }
2169
+ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2170
+ let cols = view.columns ?? visibleColumns(table), rows = view.rows ?? visibleRows(table), fullRows = view.fullRows ?? table.rows, widthRows = view.widthRows ?? table.rows, available = view.available ?? 1 / 0, spacerBefore = /* @__PURE__ */ new Map();
2171
+ for (let group of table.columnGroups) {
2172
+ if (group.spacer === void 0 || group.spacer <= 0) continue;
2173
+ let ordered = view.allColumns ?? cols, first = ordered.find((col) => group.columnIds.includes(col.id));
2174
+ first && first.id !== ordered[0]?.id && spacerBefore.set(first.id, cols.some((col) => group.columnIds.includes(col.id)) ? group.spacer : 0);
2175
+ }
2176
+ let spacerTotal = view.spacerTotal ?? [...spacerBefore.values()].reduce((sum, width) => sum + width, 0), figures = printsFigures(options.figures, cols), wideTable = cols.length >= DENSE_COLUMNS, cellPadX2 = options.cellPadX ?? cellPadX(cols.length), labelColumn = cols.find((col) => col.kind === "rowLabel"), labelLead = labelColumn?.width === void 0 ? Math.ceil(view.leadWidth ?? 0) : 0, groupCell = {
2177
+ padX: cellPadX2,
2178
+ trailingTracking: view.trailingTracking,
2179
+ startRule: view.groupStart === void 0 ? void 0 : (groupId) => {
2180
+ let first = cols.find((col) => col.groupId === groupId);
2181
+ return first && view.groupStart.has(first.id) ? 1 : 0;
2182
+ }
2183
+ }, headingFaces = (faces) => groupHeadingFaces(view.trailingTracking ? { ...faces.group, letterSpacing: Math.round((faces.group.letterSpacing ?? 0) * 1e3) / 1e3 } : faces.group), warnings = [], ladder = levelLadder(theme, options.density ?? "regular", options.target, textScaleOf(options)), regularFonts = tableFonts(theme, ladder), rowById = new Map([...widthRows, ...rows].map((row) => [row.id, row])), hasChanges = new Set(table.rows.filter((row) => visibleInlineRows(row, options.inlineVisibility).length > 0).map((row) => row.id)), cellStep = (cell) => rowById.get(cell.rowId)?.step ?? cell.level, childCount = treeChildCounts(table), isTree = fullRows.some((row) => row.hasChildren), indents = labelIndents(cellPadX2, options.labelIndent, view.withMarks ?? options.outlineMarks === !0), operatorSlot = operatorWidth(rows, theme), rowIndent = (level) => (isTree ? indents.base + level * indents.step : 0) + operatorSlot, inlineFont2 = (level, signed) => inlineFont(theme, ladder, level, signed);
2184
+ function cellFont(cell) {
2185
+ let row = rowById.get(cell.rowId), kind = row?.kind, totalFace = kind === void 0 || kind !== "subtotal" && kind !== "result" && kind !== "driver" && (kind !== "member" && kind !== "measure" || theme.table?.weights?.figures?.[kind] === void 0);
2186
+ return cell.role === "total" && cell.kind !== "rowLabel" && totalFace ? regularFonts.totalValue : kindFont(rowFont(theme, ladder, regularFonts, cell.role, cellStep(cell), row?.hasChildren === !0, hasChanges.has(cell.rowId)), kind, cell.kind === "rowLabel", theme);
2187
+ }
2188
+ function affixRoom(row, font) {
2189
+ return row.unitAffix === void 0 ? 0 : theme.table?.qualifier === void 0 ? measure(` ${row.unitAffix}`, inlineFont2(row.step, !1)).width : measure(row.unitAffix, qualifierFont(font, theme)).width + (theme.table.qualifier.gap ?? 4);
2190
+ }
2191
+ let columnHeaderText = (col) => columnHeadLabel(col.label, theme) + columnHeaderAffix(col);
2192
+ function trackWidths(faces) {
2193
+ let widths2 = /* @__PURE__ */ new Map(), minimumWidths2 = /* @__PURE__ */ new Map(), wrappedOneLines = /* @__PURE__ */ new Map(), context = {
2194
+ theme,
2195
+ measure,
2196
+ fonts: faces,
2197
+ cellFont,
2198
+ inlineFont: inlineFont2,
2199
+ changeFont: (level) => changeLineFont(theme, ladder, level),
2200
+ rowIndent,
2201
+ inlineIndent: INLINE_LABEL_INDENT,
2202
+ padX: cellPadX2,
2203
+ headerText: columnHeaderText,
2204
+ headerReserve: (col) => view.sortable?.has(col.id) ? SORT_CHEVRON_RESERVE : 0,
2205
+ headerTrailingTracking: view.trailingTracking,
2206
+ slack: view.slack,
2207
+ reserve: (col) => encodingReserve(col, measure, faces),
2208
+ // The face the sparkline cells draw their end value in (`emitSparkline`).
2209
+ sparkFont: { family: theme.type.family, ...theme.type.label },
2210
+ // A cell and each line in it take figures by their own string, as the
2211
+ // text nodes below take their role.
2212
+ figures: (col, cellText, lineText) => cellDrawsTabular(theme, col.kind, lineText ?? cellText),
2213
+ // the collapsed hint shares the label's line, as a unit affix does, so the track pays for it.
2214
+ hint: (row) => collapsedHintWidth(row, table.levelNouns, childCount.get(row.id) ?? 0, measure, faces.hint),
2215
+ ...view.headLines === void 0 ? {} : { headLines: view.headLines }
2216
+ };
2217
+ for (let col of cols) {
2218
+ let heatOnlyWidth = Math.max(HEAT_ONLY_CELL_W, Math.ceil((view.scroll ? headerContentWidth(col, context) : measure(columnHeaderText(col), faces.header).width) + 2 * cellPadX2)), intrinsicWidth = figures || !heatColumn(col) ? intrinsicColumnWidth(col, widthRows, context) : heatOnlyWidth, endRule = col.width === void 0 && (figures || !heatColumn(col)) && view.groupEnd?.has(col.id) ? 1 : 0;
2219
+ if (col.kind === "encoding") {
2220
+ let track = (authoredTrackWidth(col, widthRows, context) ?? intrinsicWidth) + endRule;
2221
+ widths2.set(col.id, track), minimumWidths2.set(col.id, track);
2222
+ continue;
2223
+ }
2224
+ let headerW = view.scroll ? headerContentWidth(col, context) : measure(columnHeaderText(col), faces.header).width + (context.headerReserve?.(col) ?? 0), minimumWidth = col.wrap ? wrapFloorWidth(col, widthRows, headerW, context) : col.kind === "rowLabel" ? intrinsicColumnWidth(col, widthRows, { ...context, hint: void 0 }) : intrinsicWidth;
2225
+ minimumWidths2.set(col.id, minimumWidth);
2226
+ let wrapped = view.scroll && col.wrap && col.width === void 0 && (figures || !heatColumn(col)), authoredContext = col.kind === "rowLabel" ? { ...context, twoLineLabels: options.rowLabelLines !== 1 } : context, authored = col.kind === "rowLabel" && col.width !== void 0 && intrinsicWidth <= col.width ? col.width : authoredTrackWidth(col, widthRows, authoredContext);
2227
+ widths2.set(col.id, figures || !heatColumn(col) ? authored ?? (wrapped ? minimumWidth : intrinsicWidth) : heatOnlyWidth), wrapped && wrappedOneLines.set(col.id, intrinsicWidth);
2228
+ let extra = (col.kind === "rowLabel" ? labelLead : 0) + endRule;
2229
+ if (extra > 0) for (let target of [widths2, minimumWidths2]) target.set(col.id, target.get(col.id) + extra);
2230
+ }
2231
+ {
2232
+ let groupFaces = headingFaces(faces), drawn = cols.map((col) => col.id), isFixed = (id) => {
2233
+ let col = cols.find((candidate) => candidate.id === id);
2234
+ return col !== void 0 && (col.width !== void 0 || !figures && heatColumn(col));
2235
+ };
2236
+ for (let target of [widths2, minimumWidths2]) {
2237
+ let floors = groupHeadingFloors(table.columnGroups, drawn, (id) => target.get(id) ?? 0, isFixed, groupFaces, measure, groupCell);
2238
+ for (let [id, extra] of floors) target.set(id, target.get(id) + extra);
2239
+ }
2240
+ }
2241
+ let chipFloor = sectionChipFloor(widthRows, { ...context, hint: void 0 });
2242
+ if (labelColumn !== void 0)
2243
+ for (let [target, floor] of [[widths2, sectionChipFloor(widthRows, context)], [minimumWidths2, chipFloor]]) {
2244
+ let span = chipSpan(target);
2245
+ span < floor && target.set(labelColumn.id, target.get(labelColumn.id) + floor - span);
2246
+ }
2247
+ let labelFloor = options[LABEL_WRAP_FLOOR] === !0 && labelColumn !== void 0 ? labelWrapFloor(labelColumn, faces) + labelLead : 0;
2248
+ if (labelFloor > 0) for (let target of [widths2, minimumWidths2]) target.set(labelColumn.id, Math.max(target.get(labelColumn.id), labelFloor));
2249
+ view.scroll && labelColumn?.width === void 0 && labelColumn !== void 0 && (labelFloor = Math.max(labelFloor, intrinsicColumnWidth(labelColumn, widthRows, {
2250
+ ...context,
2251
+ hint: void 0,
2252
+ twoLineLabels: options.rowLabelLines !== 1
2253
+ }) + labelLead + (view.groupEnd?.has(labelColumn.id) ? 1 : 0)));
2254
+ let wrapFloors = /* @__PURE__ */ new Map(), wouldWrap = cols.filter((col) => {
2255
+ if (col.kind !== "text" || col.wrap || col.width !== void 0) return !1;
2256
+ let floor = wrapFloorWidth(col, widthRows, measure(columnHeaderText(col), faces.header).width, context);
2257
+ return floor >= minimumWidths2.get(col.id) ? !1 : (wrapFloors.set(col.id, floor), !0);
2258
+ });
2259
+ return { widths: widths2, minimumWidths: minimumWidths2, context, wouldWrap, wrapFloors, chipFloor, labelFloor, wrappedOneLines };
2260
+ }
2261
+ function labelWrapFloor(col, faces) {
2262
+ let text = rowIndent(0) + Math.max(0, ...columnHeaderText(col).split(/\s+/).map((word) => measure(word, faces.header).width)), unit = 0, open = new Set(rows.map((row) => row.parentId));
2263
+ for (let row of rows) {
2264
+ let cell = row.cells[col.id];
2265
+ if (row.role === "section" || row.inline === !0 || !cell?.displayed) continue;
2266
+ let font = cellFont(cell), indent = rowIndent(cellStep(cell));
2267
+ if (text = Math.max(text, indent + (options.rowLabelLines === 1 ? measure(cell.displayed, font).width : twoLineWidth(cell.displayed, font, measure, !0))), row.unitAffix !== void 0 && !(row.kind === "member" && open.has(row.id))) {
2268
+ let unitFont = theme.table?.qualifier === void 0 ? { ...inlineFont2(row.step, !1), ...font.style ? { style: font.style } : {} } : qualifierFont(font, theme);
2269
+ unit = Math.max(unit, indent + measure(row.unitAffix, unitFont).width);
2270
+ }
2271
+ for (let line of visibleInlineRows(row, options.inlineVisibility))
2272
+ line.label && (text = Math.max(text, indent + INLINE_LABEL_INDENT + measure(line.label, changeLineFont(theme, ladder, row.step)).width));
2273
+ }
2274
+ return Math.ceil(Math.max(text + 2 * cellPadX2, unit + cellPadX2));
2275
+ }
2276
+ function chipSpan(target) {
2277
+ return cols.slice(cols.indexOf(labelColumn)).reduce((sum, col) => sum + (target.get(col.id) ?? 0), 0);
2278
+ }
2279
+ let sumOf = (map) => [...map.values()].reduce((a, b) => a + b, spacerTotal), regular = trackWidths(regularFonts), dense = cols.length >= DENSE_COLUMNS ? trackWidths(tableFonts(theme, ladder, cols.length)) : void 0, wrapMinimumWidth = dense === void 0 && table.columnGroups.length === 0 && regular.chipFloor === 0 ? cols.reduce((sum, col) => sum + (regular.wrapFloors.get(col.id) ?? regular.minimumWidths.get(col.id)), spacerTotal) : void 0, regularHeadsFit = dense === void 0 || headsFit(
2280
+ cols,
2281
+ table.columnGroups,
2282
+ (id) => regular.widths.get(id) ?? 0,
2283
+ figures,
2284
+ regular.context,
2285
+ headingFaces(regularFonts),
2286
+ groupCell
2287
+ ), chosen = dense !== void 0 && (!regularHeadsFit || !view.scroll && sumOf(regular.widths) > available) ? dense : regular, fonts = chosen.context.fonts, widths = chosen.widths, minimumWidths = chosen.minimumWidths, sizingMinimums = (dense ?? regular).minimumWidths, sizingTracks = new Map((dense ?? regular).widths);
2288
+ if (view.scroll && view.fit === void 0 && Number.isFinite(available) && chosen.wrappedOneLines.size > 0) {
2289
+ let want = [...chosen.wrappedOneLines].reduce((sum, [id, oneLine]) => sum + Math.max(0, oneLine - widths.get(id)), 0), share = Math.max(0, Math.min(want, available - sumOf(widths)));
2290
+ if (share > 0) for (let [id, oneLine] of chosen.wrappedOneLines) {
2291
+ let natural = widths.get(id);
2292
+ widths.set(id, Math.floor(natural + share * Math.max(0, oneLine - natural) / want));
2293
+ }
2294
+ }
2295
+ let canShrink = (col) => !view.scroll || col.width === void 0 && col.kind === "rowLabel", flexIds = cols.filter((c) => canShrink(c) && (c.kind === "rowLabel" || c.kind === "text")).map((c) => c.id), totalW = sumOf(widths), floorFlexIds = cols.filter((col) => col.kind === "rowLabel" || col.kind === "text").map((col) => col.id), minimumW = Math.max(sumOf(sizingMinimums), sumOf(shrinkReach(cols, floorFlexIds, wideTable, sizingTracks, sizingMinimums, (dense ?? regular).labelFloor)));
2296
+ if (totalW > available && flexIds.length > 0) {
2297
+ let deficit = totalW - available;
2298
+ for (let col of cols.filter((c) => canShrink(c) && c.kind === "rowLabel")) {
2299
+ let take = Math.min(deficit, Math.max(0, widths.get(col.id) - minimumWidths.get(col.id)));
2300
+ take > 0 && (widths.set(col.id, widths.get(col.id) - take), deficit -= take);
2301
+ }
2302
+ for (let kind of ["text", "rowLabel"]) {
2303
+ if (deficit <= 0) break;
2304
+ let shrinkable = cols.filter((c) => canShrink(c) && c.kind === kind).map((col) => ({
2305
+ id: col.id,
2306
+ room: Math.max(0, widths.get(col.id) - (view.scroll ? chosen.labelFloor : shrinkFloorWidth(col, wideTable, minimumWidths, chosen.labelFloor)))
2307
+ })).filter((f) => f.room > 0), totalRoom = shrinkable.reduce((a, f) => a + f.room, 0);
2308
+ if (totalRoom <= 0) continue;
2309
+ let take = Math.min(deficit, totalRoom);
2310
+ for (let f of shrinkable) {
2311
+ let cut = take * f.room / totalRoom;
2312
+ widths.set(f.id, Math.round(widths.get(f.id) - cut));
2313
+ }
2314
+ deficit -= take;
2315
+ }
2316
+ let remaining = Math.ceil(sumOf(widths) - available);
2317
+ if (remaining > 0 && wideTable) {
2318
+ let compactable = cols.filter((col) => canShrink(col) && col.kind !== "rowLabel" && col.kind !== "text").map((col) => col.id);
2319
+ for (; remaining > 0; ) {
2320
+ let changed = !1;
2321
+ for (let id of compactable) {
2322
+ if (remaining <= 0) break;
2323
+ let current = widths.get(id), minimum = minimumWidths.get(id);
2324
+ current <= minimum || (widths.set(id, current - 1), remaining--, changed = !0);
2325
+ }
2326
+ if (!changed) break;
2327
+ }
2328
+ }
2329
+ labelColumn !== void 0 && chipSpan(widths) < chosen.chipFloor && widths.set(labelColumn.id, widths.get(labelColumn.id) + chosen.chipFloor - chipSpan(widths));
2330
+ }
2331
+ let narrowed = cols.some((col) => col.width !== void 0 && (figures || !heatColumn(col)) && widths.get(col.id) < col.width);
2332
+ if (narrowed || sumOf(widths) > available) {
2333
+ let margin = resolveCanvasOptions(options).margin, frameWidth = Math.ceil(totalW);
2334
+ for (let pass = 0; pass < 4; pass++) {
2335
+ let sides = { ...canvasMargin(theme, frameWidth), ...margin }, next = Math.ceil(totalW + sides.left + sides.right);
2336
+ if (next === frameWidth) break;
2337
+ frameWidth = next;
2338
+ }
2339
+ let size = options.size === void 0 ? void 0 : resolveSize(options.size), height = options[TARGET_SIZE]?.fixed.height === !1 || typeof options.size == "object" && options.size.height === void 0 ? void 0 : size?.height;
2340
+ warnings.push({
2341
+ code: "table-overflow",
2342
+ severity: "warn",
2343
+ message: narrowed ? `authored column widths were narrowed to fit the frame; use a frame at least ${frameWidth} px wide to keep them` : `table wider than the plot area; use a frame at least ${frameWidth} px wide to show all columns`,
2344
+ field: ["options", "size"],
2345
+ detail: { naturalWidth: frameWidth },
2346
+ suggest: `Set the frame width to ${frameWidth} px or more.`,
2347
+ fix: [{ op: "add", path: "/options/size", value: { width: frameWidth, ...height === void 0 ? {} : { height } } }]
2348
+ });
2349
+ }
2350
+ let grownFrom = /* @__PURE__ */ new Map(), grow = (id, add) => {
2351
+ grownFrom.has(id) || grownFrom.set(id, widths.get(id)), widths.set(id, widths.get(id) + add);
2352
+ }, room = Number.isFinite(available) ? Math.floor(available - sumOf(widths)) : 1 / 0;
2353
+ if (Number.isFinite(available) && options.frameFill !== "none")
2354
+ for (let col of cols) {
2355
+ if (room < 1) break;
2356
+ if (col.width === void 0 || col.kind !== "value" && col.kind !== "computed" || !figures && heatColumn(col)) continue;
2357
+ let add = Math.min(room, Math.ceil(minimumWidths.get(col.id) - widths.get(col.id)));
2358
+ add < 1 || (grow(col.id, add), room -= add);
2359
+ }
2360
+ for (let [id, short] of groupHeadingFloors(table.columnGroups, cols.map((col) => col.id), (member) => widths.get(member) ?? 0, () => !1, headingFaces(fonts), measure, groupCell)) {
2361
+ let add = options.frameFill === "none" ? 0 : Math.max(0, Math.min(room, Math.ceil(short)));
2362
+ if (add >= 1 && (grow(id, add), room -= add), short - add > 0.5) {
2363
+ let group = table.columnGroups.find((candidate) => candidate.columnIds.includes(id));
2364
+ warnings.push({
2365
+ code: "table-group-heading-overflow",
2366
+ severity: "warn",
2367
+ message: `column group '${group.id}' heading needs ${Math.ceil(short - add)} px more than its columns' authored widths; it runs past the block`,
2368
+ suggest: "Shorten the heading or its note, widen a column of the group, or give the table a wider frame."
2369
+ });
2370
+ }
2371
+ }
2372
+ for (let col of cols) if (figures || !heatColumn(col)) {
2373
+ let grown = grownFrom.get(col.id), track = grown ?? widths.get(col.id), minimum = col.kind === "rowLabel" && col.width !== void 0 && minimumWidths.get(col.id) > track ? intrinsicColumnWidth(col, widthRows, { ...chosen.context, twoLineLabels: options.rowLabelLines !== 1 }) : minimumWidths.get(col.id), found = authoredWidthWarnings(col, table.columns.findIndex((authored) => authored.id === col.id), track, minimum, chosen.context);
2374
+ warnings.push(...grown === void 0 ? found : found.filter((warning) => warning.code === "table-column-widened" || widths.get(col.id) < minimumWidths.get(col.id)));
2375
+ }
2376
+ let rowToFrame = (options.rowExtent ?? "frame") === "frame";
2377
+ if (Number.isFinite(available) && options.lastTrackFlex === !0 && !rowToFrame && cols.length > 0) {
2378
+ let slack = available - sumOf(widths), lastCol = cols[cols.length - 1];
2379
+ slack > 0 && lastCol.width === void 0 && widths.set(lastCol.id, widths.get(lastCol.id) + slack);
2380
+ }
2381
+ let beforeFill = new Map(widths);
2382
+ if (Number.isFinite(available) && rowToFrame && options.frameFill !== "none") {
2383
+ let growing = cols.filter((col) => col.width === void 0 && (col.kind === "value" || col.kind === "computed") && (figures || !heatColumn(col))), extras = frameFillExtras(
2384
+ growing.map((col) => ({ id: col.id, width: widths.get(col.id) })),
2385
+ available - sumOf(widths),
2386
+ options.maxGrowth,
2387
+ labelColumn?.width === void 0 ? labelColumn?.id : void 0
2388
+ ), labelCap = labelColumn?.maxWidth;
2389
+ labelColumn !== void 0 && labelCap !== void 0 && extras.has(labelColumn.id) && extras.set(labelColumn.id, Math.max(0, Math.min(extras.get(labelColumn.id), labelCap - widths.get(labelColumn.id))));
2390
+ for (let [id, extra] of extras) widths.set(id, widths.get(id) + extra);
2391
+ }
2392
+ let labelNeed;
2393
+ if (labelColumn !== void 0 && labelColumn.width === void 0) {
2394
+ let labelId = labelColumn.id, need = view.scroll ? intrinsicColumnWidth(
2395
+ { ...labelColumn, maxWidth: void 0, maxTextWidth: void 0 },
2396
+ widthRows,
2397
+ { ...chosen.context, hint: void 0 }
2398
+ ) + labelLead : Math.ceil(Math.max(0, maxOf(rows.map((row) => {
2399
+ let cell = row.cells[labelId];
2400
+ if (row.role === "section" || !cell?.displayed) return 0;
2401
+ let font = cellFont(cell);
2402
+ return measure(cell.displayed, font).width + affixRoom(row, font) + rowIndent(cellStep(cell)) + 2 * cellPadX2;
2403
+ })))), cap = labelColumn.maxWidth !== void 0 && options[SOFT_LABEL_CAP] !== !0 ? labelColumn.maxWidth : 1 / 0;
2404
+ labelNeed = Math.min(need, cap);
2405
+ let short = labelNeed - widths.get(labelId);
2406
+ if (short > 0) {
2407
+ let outside = Number.isFinite(available) ? Math.min(short, Math.max(0, Math.floor(available - sumOf(widths)))) : 0;
2408
+ widths.set(labelId, widths.get(labelId) + outside), short -= outside;
2409
+ let grown = cols.filter((col) => col.id !== labelId && widths.get(col.id) > beforeFill.get(col.id)), total = grown.reduce((sum, col) => sum + widths.get(col.id) - beforeFill.get(col.id), 0), take = Math.min(short, Math.floor(total)), left = take;
2410
+ for (let [index, col] of grown.entries()) {
2411
+ let extra = widths.get(col.id) - beforeFill.get(col.id), back = index === grown.length - 1 ? Math.min(left, Math.floor(extra)) : Math.min(left, Math.floor(take * extra / total));
2412
+ widths.set(col.id, widths.get(col.id) - back), left -= back;
2413
+ }
2414
+ widths.set(labelId, widths.get(labelId) + take - left);
2415
+ }
2416
+ }
2417
+ let tracks = columnTracks((view.allColumns ?? cols).map((col) => ({ id: col.id, natural: widths.get(col.id) ?? 0 })), {
2418
+ fit: rowToFrame ? "content" : view.fit,
2419
+ available: Number.isFinite(available) && (!view.scroll || view.fit !== void 0) ? Math.max(0, available - spacerTotal) : void 0,
2420
+ anchorId: (view.allColumns ?? cols)[0]?.id,
2421
+ hidden: view.allColumns === void 0 ? void 0 : new Set(view.allColumns.filter((col) => !widths.has(col.id)).map((col) => col.id)),
2422
+ fixed: new Set(cols.filter((col) => col.width !== void 0 || !figures && heatColumn(col)).map((col) => col.id)),
2423
+ ...options.maxGrowth === !1 ? {} : { maxGrowth: options.maxGrowth ?? DEFAULT_TRACK_GROWTH }
2424
+ }), labelsWrap = labelColumn !== void 0 && labelNeed !== void 0 && widths.get(labelColumn.id) < labelNeed, gridTracks = tracks.flatMap((track, index) => {
2425
+ let spacer = spacerBefore.get(track.id), drawn = index === 0 && (view.frameStart ?? 0) > 0 ? { ...track, width: track.width + view.frameStart } : track;
2426
+ return spacer === void 0 ? [drawn] : [{ id: `bp-spacer:${track.id}`, natural: spacer, width: spacer }, drawn];
2427
+ });
2428
+ return {
2429
+ tracks,
2430
+ gridTracks,
2431
+ spacerBefore,
2432
+ spacerTotal,
2433
+ labelNeed,
2434
+ labelsWrap,
2435
+ widths,
2436
+ minimumWidths,
2437
+ sizingMinimums,
2438
+ totalW,
2439
+ minimumW,
2440
+ fonts,
2441
+ regularFonts,
2442
+ context: chosen.context,
2443
+ wouldWrap: (dense ?? regular).wouldWrap,
2444
+ wrapMinimumWidth,
2445
+ warnings,
2446
+ cellPadX: cellPadX2,
2447
+ rowIndent,
2448
+ cellFont,
2449
+ cellStep,
2450
+ columnHeaderText,
2451
+ indents,
2452
+ operatorSlot,
2453
+ childCount,
2454
+ hasChanges
2455
+ };
2456
+ }
2457
+ function shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor = 0) {
2458
+ return col.kind === "rowLabel" ? Math.min(col.width ?? 1 / 0, Math.max(wideTable ? 180 : FLEX_MIN, labelFloor)) : col.kind === "text" && col.wrap ? Math.max(FLEX_MIN, minimumWidths.get(col.id) ?? FLEX_MIN) : FLEX_MIN;
2459
+ }
2460
+ function shrinkReach(cols, flexIds, wideTable, drawn, minimumWidths, labelFloor = 0) {
2461
+ return new Map(cols.map((col) => {
2462
+ let width = drawn.get(col.id) ?? 0, minimum = minimumWidths.get(col.id) ?? width;
2463
+ if (!flexIds.includes(col.id)) return [col.id, wideTable ? Math.min(width, minimum) : width];
2464
+ let floor = shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor);
2465
+ return [col.id, Math.min(width, floor, col.kind === "rowLabel" ? minimum : width)];
2466
+ }));
2467
+ }
2468
+ function tableDisplayFloor(table, theme, options, target, width, frame) {
2469
+ let ladder = levelLadder(theme, options.density ?? "regular", target, textScaleOf(options)), fonts = tableFonts(theme, ladder), floors = targetFloorsPx(target), scale = 0.9, include = (size, role) => {
2470
+ scale = Math.max(scale, floors[role] / size);
2471
+ };
2472
+ frame.title && include(theme.type.title.size, "title"), frame.subtitle && include(theme.type.subtitle.size, "subtitle"), (frame.source || frame.footnotes.length) && include(footerType(theme.type.footnote, target, textScaleOf(options)).size, "footnote");
2473
+ let includeHead = (size) => {
2474
+ scale = Math.max(scale, tableHeadFloorPx(target) / size);
2475
+ };
2476
+ table.columns.length && includeHead(fonts.header.size), table.columns.some((column) => column.subLabel) && includeHead(fonts.sub.size), table.columnGroups.some((group) => group.heading !== !1) && includeHead(fonts.group.size);
2477
+ for (let row of table.rows) {
2478
+ if (row.inline) continue;
2479
+ let hasChanges = visibleInlineRows(row, options.inlineVisibility).length > 0;
2480
+ include(rowFont(theme, ladder, fonts, row.role, row.step, row.hasChildren, hasChanges).size, "label"), hasChanges && include(changeLineFont(theme, ladder, row.step).size, "label"), row.badge && include(fonts.chip.size, "label"), row.unitAffix && include(ladder.inlineSize(), "label");
2481
+ for (let cell of Object.values(row.cells))
2482
+ cell.kind === "status" && include(fonts.chip.size, "label"), cell.note && include(ladder.inlineSize(), "footnote");
2483
+ }
2484
+ return { target, minDisplayWidth: width * scale };
2485
+ }
2486
+ function belowTableViewportFloor(authoredSize) {
2487
+ if (authoredSize === void 0) return !1;
2488
+ let size = resolveSize(authoredSize), sizing = resolveSizing(chartSizing("table"), size), heightAuthored = typeof authoredSize != "object" || authoredSize.height !== void 0;
2489
+ return !fitsSize({ width: size.width, height: heightAuthored ? size.height : 1 / 0 }, sizing);
2490
+ }
2491
+ function tableFrameMode(options) {
2492
+ if (options.mode) return options.mode;
2493
+ if (options.size === void 0) return "full";
2494
+ let size = resolveSize(options.size), sizing = resolveSizing(chartSizing("table"), size);
2495
+ return fitsSize(size, sizing) ? "full" : "compact";
2496
+ }
2497
+
2498
+ export {
2499
+ isCohortDensity,
2500
+ LINE_RATIO,
2501
+ INLINE_LINE_RATIO,
2502
+ LINE_BOX_EPSILON,
2503
+ levelLadder,
2504
+ presetLanguage,
2505
+ arrowGlyph,
2506
+ arrowKey,
2507
+ emitArrow,
2508
+ heatRanges,
2509
+ badSide,
2510
+ heatKey,
2511
+ heatPaint,
2512
+ emitHeat,
2513
+ ZERO_LIFT,
2514
+ columnHeadLabel,
2515
+ columnHeaderAffix,
2516
+ resolveTable,
2517
+ cellHoldsNumber,
2518
+ numericCell,
2519
+ cellDrawsTabular,
2520
+ tableFootnotes,
2521
+ treeChildCounts,
2522
+ collapsedByDefault,
2523
+ collapsedForDepth,
2524
+ depthToExpansion,
2525
+ expansionForFolds,
2526
+ expansionRootsHidden,
2527
+ emptyMessageRow,
2528
+ visibleRows,
2529
+ finalClosers,
2530
+ rowGrounds,
2531
+ sortableColumnIds,
2532
+ sortRows,
2533
+ visibleInlineRows,
2534
+ heatColumn,
2535
+ printsFigures,
2536
+ visibleColumns,
2537
+ groupSpans,
2538
+ inCellBarMaxima,
2539
+ tableWidths,
2540
+ tableDisplayFloor,
2541
+ belowTableViewportFloor,
2542
+ tableFrameMode
2543
+ };