boardplot 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. package/CHANGELOG.md +153 -0
  2. package/README.md +3 -3
  3. package/dist/{ReaderBox-3FFPHWSI.js → ReaderBox-GCIITQCX.js} +5 -5
  4. package/dist/{annotateEngine-ET4DM2OK.js → annotateEngine-JMZI6QEG.js} +1 -1
  5. package/dist/build-identity.json +3 -3
  6. package/dist/{chunk-RO2PSSAI.js → chunk-26WNBTWB.js} +21 -5
  7. package/dist/{chunk-3AJY353W.js → chunk-2AJWRVZ2.js} +4 -3
  8. package/dist/{chunk-NVGAEQ6M.js → chunk-2BHLRHF2.js} +2 -2
  9. package/dist/{chunk-CZ3WCG55.js → chunk-2HD5RY2U.js} +11 -3
  10. package/dist/{chunk-HR2BKLS3.js → chunk-2I76VFMZ.js} +186 -241
  11. package/dist/{chunk-3B3CFJ2H.js → chunk-2KCK63DD.js} +2 -2
  12. package/dist/{chunk-GDZI5ZJ7.js → chunk-2WTD3GCR.js} +11 -3
  13. package/dist/{chunk-EBC5TMI2.js → chunk-2X6XY4K4.js} +27 -10
  14. package/dist/{chunk-MJMOKPTF.js → chunk-3DUGZ7ML.js} +196 -138
  15. package/dist/{chunk-N5TZL74Y.js → chunk-3LNVEE5Z.js} +1 -1
  16. package/dist/{chunk-DB2JKPOX.js → chunk-43PCSBVQ.js} +567 -14
  17. package/dist/{chunk-WEMUCDPK.js → chunk-4JGBCBDZ.js} +1 -1
  18. package/dist/{chunk-7UPZPFHQ.js → chunk-4JNHF6JW.js} +12 -12
  19. package/dist/{chunk-4X3HNETE.js → chunk-4RN4OM6I.js} +3 -3
  20. package/dist/{chunk-Z7NHFNH3.js → chunk-4U2WSW6F.js} +107 -26
  21. package/dist/{chunk-6D4EO3S7.js → chunk-53OEKS4L.js} +5 -3
  22. package/dist/{chunk-E44W4EEG.js → chunk-54HEIM2A.js} +2 -2
  23. package/dist/{chunk-CLGUFVHM.js → chunk-5H4HFRDO.js} +6 -6
  24. package/dist/{chunk-SFG7NG23.js → chunk-5HTGSB6Y.js} +3 -3
  25. package/dist/{chunk-WXJ5MHLH.js → chunk-5JTRCSBN.js} +1 -1
  26. package/dist/{chunk-4Y7BA2NW.js → chunk-5P4MXWKP.js} +4 -4
  27. package/dist/{chunk-MLW72KWN.js → chunk-5RHP7YTL.js} +5 -5
  28. package/dist/{chunk-AB35GVPG.js → chunk-5TUDYKNL.js} +41 -31
  29. package/dist/{chunk-HZUAEMN5.js → chunk-5WSIH4SR.js} +1 -1
  30. package/dist/{chunk-YTCIGJUU.js → chunk-62JZL6FW.js} +45 -37
  31. package/dist/{chunk-S7NRL66K.js → chunk-6EE6XEMA.js} +4 -4
  32. package/dist/chunk-6JXBLQJ2.js +32 -0
  33. package/dist/{chunk-BGJRCG7N.js → chunk-6KHRMK3I.js} +46 -26
  34. package/dist/{chunk-3OZRODC4.js → chunk-6LQKU6YN.js} +4 -4
  35. package/dist/chunk-6VU2XI3W.js +89 -0
  36. package/dist/{chunk-E6HDUEGK.js → chunk-6WJOHZPW.js} +5 -5
  37. package/dist/{chunk-XJQXFVXY.js → chunk-6XU5XGYV.js} +7 -8
  38. package/dist/{chunk-QOWE55RR.js → chunk-6ZN2XJFI.js} +11 -6
  39. package/dist/{chunk-4WT3T5SH.js → chunk-72OJBDRB.js} +205 -60
  40. package/dist/{chunk-GFIT3FRE.js → chunk-73O6AOAA.js} +63 -47
  41. package/dist/{chunk-DEYAI662.js → chunk-76UL4CT4.js} +60 -24
  42. package/dist/chunk-7BQK2UDV.js +13 -0
  43. package/dist/{chunk-NHYKSPL4.js → chunk-7EQU2TUN.js} +304 -119
  44. package/dist/{chunk-FS6ZE5TG.js → chunk-7FAO4ICF.js} +2 -2
  45. package/dist/{chunk-LSF76AS3.js → chunk-7MYJUJZV.js} +6 -2
  46. package/dist/{chunk-D2QMNHCC.js → chunk-7P7D6WXR.js} +11 -2
  47. package/dist/{chunk-GCSCHK5Y.js → chunk-A33MFWHW.js} +3 -3
  48. package/dist/{chunk-3C24WWUQ.js → chunk-A6XCVOC5.js} +1 -1
  49. package/dist/{chunk-O7DVW3IE.js → chunk-AFA32LHN.js} +134 -37
  50. package/dist/{chunk-WALYNKBN.js → chunk-AFGQXMKT.js} +264 -88
  51. package/dist/{chunk-ZTMZOKVC.js → chunk-AKJO6N4K.js} +3 -3
  52. package/dist/{chunk-P6TA7M3G.js → chunk-ANNQJWDX.js} +11 -11
  53. package/dist/{chunk-KFGZMHIB.js → chunk-AOIZJ7GR.js} +7 -7
  54. package/dist/chunk-B5A7X2BA.js +44 -0
  55. package/dist/{chunk-HGT3UKDW.js → chunk-BDCKHLUB.js} +16 -16
  56. package/dist/{chunk-NUCYUKVH.js → chunk-BFDPY7JM.js} +10 -3
  57. package/dist/{chunk-BK6P6KMW.js → chunk-BM2A3IGQ.js} +1 -1
  58. package/dist/{chunk-H3AEYPRP.js → chunk-BO5EJBLH.js} +249 -129
  59. package/dist/chunk-BQIADGJB.js +23 -0
  60. package/dist/{chunk-F6CVYNDY.js → chunk-BY5JGQFZ.js} +24 -7
  61. package/dist/{chunk-WDIVAU5U.js → chunk-C5SQEYTQ.js} +78 -57
  62. package/dist/{chunk-NCZWLV7T.js → chunk-CEMXGMQN.js} +2 -2
  63. package/dist/{chunk-6H3OSHEY.js → chunk-CIDOL4FO.js} +5 -5
  64. package/dist/{chunk-WAPCCJUB.js → chunk-CT4RFZO4.js} +6 -6
  65. package/dist/{chunk-7Q37C6GZ.js → chunk-CV3NC75L.js} +1 -1
  66. package/dist/{chunk-GDVR3XHT.js → chunk-D3PQAVFW.js} +23 -13
  67. package/dist/{chunk-GMJFCBR6.js → chunk-D5G67OER.js} +1 -1
  68. package/dist/{chunk-BFFPYT3Y.js → chunk-D5RAVZ5C.js} +6 -7
  69. package/dist/{chunk-FQF7GSJK.js → chunk-DJBMA4FW.js} +4 -4
  70. package/dist/{chunk-4DZFR52I.js → chunk-DPUCT567.js} +2 -2
  71. package/dist/{chunk-ZHFUMVW7.js → chunk-DYSEZVIJ.js} +18 -2
  72. package/dist/{chunk-SA46CNMS.js → chunk-ED7GLWTF.js} +4 -1
  73. package/dist/{chunk-YXM4W3TN.js → chunk-EDBUVDRI.js} +118 -68
  74. package/dist/{chunk-JBMWRXDS.js → chunk-EEBMK6T6.js} +6 -6
  75. package/dist/{chunk-CYKIX3IQ.js → chunk-EEL2N4Y6.js} +7 -8
  76. package/dist/{chunk-PYV6ZIR6.js → chunk-EFKFZNQC.js} +24 -18
  77. package/dist/{chunk-IOKWBUQP.js → chunk-EHNGPUTO.js} +6 -6
  78. package/dist/{chunk-ZBSNF5F7.js → chunk-EHQLLZCQ.js} +49 -22
  79. package/dist/{chunk-ONKSGT2M.js → chunk-EWR6WVOV.js} +6 -6
  80. package/dist/{chunk-MTRV3BJL.js → chunk-EY4OA4OF.js} +1005 -666
  81. package/dist/{chunk-Y3L655X6.js → chunk-F4JAGDPD.js} +6 -6
  82. package/dist/{chunk-LRCO4G7C.js → chunk-FAFUMSPR.js} +35 -26
  83. package/dist/{chunk-63L35UCI.js → chunk-FERP4WS3.js} +19 -9
  84. package/dist/{chunk-N5HN5QGH.js → chunk-FF7MV4D4.js} +1 -1
  85. package/dist/{chunk-G63WXSQP.js → chunk-FJKFYQ5I.js} +23 -18
  86. package/dist/chunk-FL3FQ2YA.js +27 -0
  87. package/dist/{chunk-YOOHNQ3L.js → chunk-FX5VZK5F.js} +4 -0
  88. package/dist/{chunk-37A6CLR5.js → chunk-G5BUGYIL.js} +70 -18
  89. package/dist/{chunk-JU7S52HI.js → chunk-G5CELEUR.js} +6 -6
  90. package/dist/{chunk-EW47LNWH.js → chunk-GADI2DU7.js} +11 -10
  91. package/dist/{chunk-F6OLHND5.js → chunk-GAFEN3H7.js} +2 -2
  92. package/dist/{chunk-EXDMYV5W.js → chunk-GC4WOLV3.js} +1 -1
  93. package/dist/{chunk-WFSOKGGA.js → chunk-GHFTKVJN.js} +1 -1
  94. package/dist/chunk-GKDUIDU6.js +138 -0
  95. package/dist/{chunk-LA5OYJ5P.js → chunk-GKQLKUMF.js} +188 -84
  96. package/dist/{chunk-LLDKKEUD.js → chunk-GS5UG6QD.js} +1 -1
  97. package/dist/{chunk-BWVNCLUS.js → chunk-H2POQ4LB.js} +5 -5
  98. package/dist/{chunk-WSJDLZSZ.js → chunk-H3EWFSWI.js} +97 -53
  99. package/dist/{chunk-XPOMQWXY.js → chunk-H6EJ63QN.js} +20 -18
  100. package/dist/{chunk-Q3E74U2W.js → chunk-HB3TH7GY.js} +3 -3
  101. package/dist/{chunk-MLGEBFEX.js → chunk-HC6WHTBX.js} +2 -2
  102. package/dist/{chunk-X7XTIM6U.js → chunk-HDSHS2QZ.js} +47 -32
  103. package/dist/{chunk-QBJDHFJJ.js → chunk-HFFKN7PA.js} +11 -6
  104. package/dist/{chunk-K5S3K6QK.js → chunk-HGPFEG2L.js} +7 -8
  105. package/dist/{chunk-7Z73MM35.js → chunk-HVX2E26J.js} +46 -26
  106. package/dist/{chunk-KAYBRD4F.js → chunk-I3DLERI7.js} +2 -2
  107. package/dist/{chunk-SPSGUFTI.js → chunk-I4NUYVP5.js} +1 -1
  108. package/dist/{chunk-OHGEDG46.js → chunk-I5ZADE2U.js} +1 -1
  109. package/dist/{chunk-CPGASWNN.js → chunk-I65OLJ2X.js} +1 -1
  110. package/dist/{chunk-LAVVML3X.js → chunk-I6QGYRY4.js} +3 -3
  111. package/dist/{chunk-N7N5NIAU.js → chunk-I7KDPCC7.js} +3 -3
  112. package/dist/{chunk-UF3HSFAE.js → chunk-IFURKTOL.js} +3 -3
  113. package/dist/{chunk-Y54LU4CU.js → chunk-IPWUBZ4P.js} +1 -1
  114. package/dist/{chunk-IQDMZ33D.js → chunk-IRXTNSZL.js} +10 -10
  115. package/dist/{chunk-GD5TYS5R.js → chunk-IUVJVMKS.js} +13 -13
  116. package/dist/{chunk-E5OEWMNX.js → chunk-IVQT2E3Y.js} +66 -36
  117. package/dist/{chunk-7DAH2E4T.js → chunk-IW3YUMPI.js} +2 -2
  118. package/dist/chunk-IXM6BAM4.js +53 -0
  119. package/dist/{chunk-XVUQMZWV.js → chunk-IZRTNCJQ.js} +5 -5
  120. package/dist/{chunk-KZH2QI6S.js → chunk-J22ETKDJ.js} +2 -2
  121. package/dist/{chunk-HJRNBKIT.js → chunk-JARJP576.js} +3 -3
  122. package/dist/{chunk-4YHZSPAJ.js → chunk-JHWDTV4K.js} +5 -1
  123. package/dist/{chunk-PQYJZMCR.js → chunk-JIH52I36.js} +79 -79
  124. package/dist/{chunk-LFUJTEJO.js → chunk-JKXJWCJ5.js} +71 -36
  125. package/dist/{chunk-2BP6X5GX.js → chunk-JMOBA5ES.js} +2 -2
  126. package/dist/{chunk-2TAK2ELB.js → chunk-JMXNXLAC.js} +5 -1
  127. package/dist/{chunk-Z5V6ZM76.js → chunk-JRRSKCGG.js} +3 -3
  128. package/dist/{chunk-IVRYF7QA.js → chunk-JSA3ESEJ.js} +1 -1
  129. package/dist/{chunk-NOCIN2EM.js → chunk-K6Y4HBK7.js} +32 -32
  130. package/dist/{chunk-WQT6HIIY.js → chunk-KAAB2DIV.js} +23 -13
  131. package/dist/{chunk-GM2HIU6C.js → chunk-KF3ZHLHQ.js} +7 -8
  132. package/dist/{chunk-3XOWXLLQ.js → chunk-KGS5Z7SL.js} +3 -3
  133. package/dist/{chunk-AIU4GZV5.js → chunk-KIXNHDXS.js} +7 -8
  134. package/dist/{chunk-ILFQ75N4.js → chunk-KJLH5EHD.js} +29 -29
  135. package/dist/{chunk-UIYXMPDW.js → chunk-KLQKHA3T.js} +6 -6
  136. package/dist/chunk-KQ2WZ6BY.js +11 -0
  137. package/dist/{chunk-5SLJGRUO.js → chunk-KUMJI5B6.js} +32 -18
  138. package/dist/{chunk-XYYRHGQI.js → chunk-L2XRUG4P.js} +7 -8
  139. package/dist/{chunk-JYBT2JNY.js → chunk-LE3LSEUL.js} +27 -2
  140. package/dist/{chunk-RTXRIZYU.js → chunk-LFX5BERN.js} +167 -70
  141. package/dist/{chunk-D7G27EYZ.js → chunk-LGMV7ZV4.js} +4 -4
  142. package/dist/{chunk-H4VDQ7OE.js → chunk-LO3AGGE3.js} +7 -8
  143. package/dist/{chunk-UNMIUILK.js → chunk-LSKCKGCF.js} +5 -1
  144. package/dist/{chunk-CVIW2MV4.js → chunk-LSR3SBJ4.js} +78 -37
  145. package/dist/{chunk-V634AXDM.js → chunk-LUZ7HXBT.js} +1 -1
  146. package/dist/{chunk-B3AXM3MT.js → chunk-LW4ZQGVL.js} +2 -2
  147. package/dist/{chunk-H3IBJQ5A.js → chunk-M2OQK2FO.js} +1 -1
  148. package/dist/{chunk-AZM4YNRE.js → chunk-M74H7QYD.js} +2 -2
  149. package/dist/{chunk-M427S3G7.js → chunk-MOQFYJ3F.js} +6 -6
  150. package/dist/{chunk-QRVIS2QB.js → chunk-MQ5EKWIG.js} +51 -9
  151. package/dist/{chunk-LHKDZAWN.js → chunk-MSYTF3DZ.js} +10 -3
  152. package/dist/{chunk-LD4LML5P.js → chunk-MTCDGSYW.js} +9 -1
  153. package/dist/{chunk-KHRAJDBM.js → chunk-NCCDEUHD.js} +1 -1
  154. package/dist/{chunk-IGVAWAOK.js → chunk-NIDH22DI.js} +31 -7
  155. package/dist/{chunk-IF2ZABAM.js → chunk-NINK4G7U.js} +2 -2
  156. package/dist/{chunk-F5V7YFKS.js → chunk-NO7GRVUU.js} +10 -8
  157. package/dist/{chunk-EBVJCVXL.js → chunk-NRYERHEI.js} +6 -6
  158. package/dist/{chunk-OJ2BPQGQ.js → chunk-O4D27FKH.js} +1 -1
  159. package/dist/{chunk-RYPJB3RO.js → chunk-O7Y6RJ4D.js} +23 -11
  160. package/dist/{chunk-2C4SYWZ3.js → chunk-OAT6FWKL.js} +7 -8
  161. package/dist/{chunk-VL7WLE4H.js → chunk-OF7FMGH5.js} +6 -6
  162. package/dist/{chunk-V3MSLNSD.js → chunk-OKM5LYYP.js} +7 -8
  163. package/dist/{chunk-YV5KYGE5.js → chunk-OQQMDSCC.js} +1 -1
  164. package/dist/{chunk-QKWBDH2L.js → chunk-OTGNVAI4.js} +2 -2
  165. package/dist/{chunk-HFRQLMKK.js → chunk-PSYPB22T.js} +3 -3
  166. package/dist/{chunk-JXBZIJCG.js → chunk-PYGEIPPH.js} +1 -1
  167. package/dist/{chunk-KZJ5VM6E.js → chunk-PZ3TQFSY.js} +15 -1
  168. package/dist/{chunk-MQYIBGZE.js → chunk-Q7VPTN5X.js} +4 -4
  169. package/dist/{chunk-XZLU3G23.js → chunk-QFIRPOXR.js} +6 -2
  170. package/dist/{chunk-QBRRJ5OR.js → chunk-QHPJ5ZKS.js} +6 -6
  171. package/dist/{chunk-R27IDIJI.js → chunk-QLWUFEKR.js} +6 -6
  172. package/dist/{chunk-COQEHO7B.js → chunk-QNLESRH6.js} +3 -1
  173. package/dist/{chunk-5UVJKB7L.js → chunk-QRZESG66.js} +40 -29
  174. package/dist/{chunk-KND4OM4B.js → chunk-QYOZ46ZQ.js} +70 -23
  175. package/dist/{chunk-HLOXWM2O.js → chunk-QZMLSK43.js} +244 -74
  176. package/dist/{chunk-NGA7ICG4.js → chunk-RDJ3ZU6O.js} +16 -13
  177. package/dist/{chunk-AF7EB6N6.js → chunk-RHBQ2Q5H.js} +104 -47
  178. package/dist/{chunk-Y2CAIAUI.js → chunk-RHVP62HI.js} +6 -6
  179. package/dist/{chunk-EAR43REB.js → chunk-RMVCKO6N.js} +16 -14
  180. package/dist/chunk-RRPTQGRU.js +47 -0
  181. package/dist/{chunk-IF76JRXT.js → chunk-S2TSXUYP.js} +6 -6
  182. package/dist/{chunk-O2KKQNGW.js → chunk-SD6ENKTO.js} +7 -2
  183. package/dist/{chunk-J5PL6JLL.js → chunk-SGDWLXUC.js} +1 -1
  184. package/dist/{chunk-75TWO5B2.js → chunk-SHAAMKN7.js} +45 -24
  185. package/dist/{chunk-NB7M4KX4.js → chunk-SHCW2TCA.js} +11 -11
  186. package/dist/{chunk-3ZAH24P6.js → chunk-SSZB3VXG.js} +19 -19
  187. package/dist/chunk-SXAZDIGM.js +84 -0
  188. package/dist/{chunk-QHRE2M6V.js → chunk-T2L5H2WW.js} +4 -3
  189. package/dist/{chunk-ODZJ4LW7.js → chunk-T3WCDDIL.js} +7 -2
  190. package/dist/{chunk-OOFSQ5AS.js → chunk-T5MBORBK.js} +1 -1
  191. package/dist/{chunk-OY2UJ4XK.js → chunk-TDDSWNGD.js} +25 -17
  192. package/dist/{chunk-5DMHMQFP.js → chunk-TGR6PRKG.js} +3 -3
  193. package/dist/{chunk-EGPXEY2K.js → chunk-TKERVBJ3.js} +7 -8
  194. package/dist/{chunk-6C64IBOG.js → chunk-TMXRTYGT.js} +10 -4
  195. package/dist/{chunk-RNIYG6PI.js → chunk-TQ5HHNM3.js} +2 -2
  196. package/dist/{chunk-LF6RTFNK.js → chunk-TWRFVW3J.js} +5 -3
  197. package/dist/{chunk-7FKY6YWU.js → chunk-TXMS7QUJ.js} +3 -3
  198. package/dist/{chunk-H5L2P2GO.js → chunk-UBXIGE2P.js} +3 -2
  199. package/dist/{chunk-7Q2WV6D2.js → chunk-UCIAHSJK.js} +2 -2
  200. package/dist/{chunk-BVYIKLQ5.js → chunk-UD6U4EF5.js} +1 -1
  201. package/dist/{chunk-4CJ6UCX4.js → chunk-UFZXZJJG.js} +5 -5
  202. package/dist/{chunk-SNQ7D5R7.js → chunk-UIHGGWES.js} +51 -11
  203. package/dist/{chunk-CKNOLGRR.js → chunk-UP4JSNDR.js} +1 -1
  204. package/dist/{chunk-3B3K7TD5.js → chunk-USFIDSTO.js} +8 -6
  205. package/dist/{chunk-PZ46S2SY.js → chunk-V3UE3TB7.js} +2 -2
  206. package/dist/{chunk-KDSYZLF6.js → chunk-V5IFI3FV.js} +8 -1
  207. package/dist/{chunk-BSATR6ZO.js → chunk-V62B23VC.js} +13 -1
  208. package/dist/{chunk-NA6WLZ66.js → chunk-VFLMBA2M.js} +68 -18
  209. package/dist/chunk-VJ7VBB6S.js +58 -0
  210. package/dist/{chunk-32IKJMUF.js → chunk-VM5CQ7CG.js} +3 -3
  211. package/dist/{chunk-6WZZADRL.js → chunk-VMGTNB6H.js} +6 -6
  212. package/dist/{chunk-WWIY6BBY.js → chunk-VT7PBGL2.js} +8 -8
  213. package/dist/{chunk-3L2VXXM4.js → chunk-VY2NPB2Q.js} +2 -2
  214. package/dist/{chunk-QEP3X3OV.js → chunk-VY67Q6CJ.js} +20 -20
  215. package/dist/{chunk-W45AR6EW.js → chunk-W5SVS4B6.js} +2 -2
  216. package/dist/{chunk-U7W7GYXP.js → chunk-W7Q6PLT4.js} +37 -37
  217. package/dist/{chunk-7GVYMGLK.js → chunk-WDAZ2MT4.js} +8 -4
  218. package/dist/{chunk-T5Y4HXYO.js → chunk-WE5WVQE4.js} +13 -1
  219. package/dist/chunk-WJQX7HBH.js +54 -0
  220. package/dist/{chunk-EC2PGJ64.js → chunk-WKWCNS6K.js} +6 -6
  221. package/dist/{chunk-2ALFFOKB.js → chunk-WSKZZ2ZB.js} +14 -14
  222. package/dist/{chunk-5SHI57XD.js → chunk-WZB6R2ZX.js} +7 -5
  223. package/dist/{chunk-MEMPP7VZ.js → chunk-X5OVVMZX.js} +1 -1
  224. package/dist/{chunk-UDKYY27B.js → chunk-XCROSJ2Z.js} +1 -1
  225. package/dist/{chunk-ROLR7HRB.js → chunk-XFCBH3TI.js} +3 -3
  226. package/dist/{chunk-XMN3Z43K.js → chunk-XJUZC53Y.js} +1 -1
  227. package/dist/chunk-XN7JDII2.js +2047 -0
  228. package/dist/{chunk-RUWNG2JC.js → chunk-XNV7VOIT.js} +4 -4
  229. package/dist/{chunk-KC52E5G4.js → chunk-XR7VOF2V.js} +10 -8
  230. package/dist/{chunk-Z2X4JQNY.js → chunk-XYUXB5VK.js} +8 -3
  231. package/dist/{chunk-SC42DPNV.js → chunk-Y5IKCXQR.js} +7 -8
  232. package/dist/{chunk-YLC42C3M.js → chunk-Y5WHM2Q5.js} +1 -1
  233. package/dist/{chunk-IGNBQT23.js → chunk-Y7Q3VEYC.js} +96 -5
  234. package/dist/{chunk-O6NJDRXE.js → chunk-YB6QGOCO.js} +2 -2
  235. package/dist/{chunk-AM2CG7VX.js → chunk-YBYV56FS.js} +3 -3
  236. package/dist/{chunk-O4WJWHCH.js → chunk-YCUNFAEE.js} +90 -42
  237. package/dist/{chunk-V7F4F6JA.js → chunk-YFI5PN5O.js} +5 -7
  238. package/dist/{chunk-SBR2RLEQ.js → chunk-YGPLUENN.js} +89 -59
  239. package/dist/chunk-YGZEG3JV.js +123 -0
  240. package/dist/{chunk-WG5CJGLU.js → chunk-YJGFT63R.js} +8 -3
  241. package/dist/{chunk-KEDNHCGB.js → chunk-YNHPPZ7S.js} +1 -1
  242. package/dist/{chunk-EZZ533MH.js → chunk-YO5UKKCQ.js} +1 -1
  243. package/dist/{chunk-SZXKV3BX.js → chunk-YTEJYLU7.js} +5 -1
  244. package/dist/{chunk-33FCWTGT.js → chunk-Z257SH5U.js} +1 -1
  245. package/dist/{chunk-O7W35PT3.js → chunk-Z2BDTZDT.js} +14 -12
  246. package/dist/{chunk-EQRFSVDD.js → chunk-ZDD3MJ2H.js} +1 -1
  247. package/dist/{chunk-APQPYM2Z.js → chunk-ZNX5J7D7.js} +3 -3
  248. package/dist/{chunk-VBVG6NEL.js → chunk-ZSYU6LIH.js} +5 -5
  249. package/dist/{chunk-2YNF6AHH.js → chunk-ZTSJ7NY6.js} +6 -2
  250. package/dist/chunk-ZV3SNRJI.js +122 -0
  251. package/dist/cli/index.js +1 -1
  252. package/dist/{core-6HMJHFRR.js → core-4M4RY7MX.js} +4 -1
  253. package/dist/{core-RPQBIOU4.js → core-4PW4MXWR.js} +4 -1
  254. package/dist/{core-MV6KGAUV.js → core-5S5CJHBG.js} +5 -1
  255. package/dist/{core-XMTKUXLO.js → core-7TTM4KRP.js} +6 -1
  256. package/dist/{core-EYJ3WJK4.js → core-7XKNJM7Y.js} +4 -1
  257. package/dist/{core-3IJPBNGC.js → core-A7HXVSKB.js} +5 -1
  258. package/dist/{core-CLLIG7ZU.js → core-AMWCZTOT.js} +2 -1
  259. package/dist/{core-2YTKFBNZ.js → core-AVA4XLQ2.js} +4 -1
  260. package/dist/{core-UAY2G7LN.js → core-BJZEJ63L.js} +5 -1
  261. package/dist/{core-PTRQPQTO.js → core-CCB3IXGD.js} +4 -1
  262. package/dist/{core-HJUGHAX7.js → core-D2OIGYC7.js} +2 -1
  263. package/dist/{core-NTWHFDM4.js → core-DMDAXVMY.js} +3 -1
  264. package/dist/{core-2SICIP63.js → core-EMSJRGSE.js} +3 -4
  265. package/dist/{core-MEC6A5DD.js → core-FCSA74RT.js} +2 -1
  266. package/dist/{core-CBEGB2NO.js → core-FTQBESDS.js} +3 -1
  267. package/dist/{core-GRWI22NS.js → core-GS4DXDDG.js} +4 -1
  268. package/dist/{core-CAL7YNFC.js → core-JDZDBTID.js} +2 -1
  269. package/dist/{core-H7KMWYP5.js → core-L3UR75IJ.js} +2 -1
  270. package/dist/{core-JMYMIH6Z.js → core-MAW4S3KA.js} +4 -1
  271. package/dist/{core-T4ZH3FAU.js → core-N2JEWJ7D.js} +3 -1
  272. package/dist/{core-T2KHX5LG.js → core-OBPTBKX6.js} +4 -1
  273. package/dist/{core-CTZLHGXE.js → core-OFPPRHYY.js} +5 -1
  274. package/dist/{core-QABTVASG.js → core-QFAVWFI3.js} +5 -1
  275. package/dist/{core-FX7HRKTF.js → core-QM34237W.js} +9 -1
  276. package/dist/{core-GQC6VDW5.js → core-SKMHEA4Y.js} +5 -1
  277. package/dist/{core-VBR253SM.js → core-T3OSZOVV.js} +2 -1
  278. package/dist/{core-7JKE7H32.js → core-UNX4ZV4M.js} +4 -1
  279. package/dist/core-VRVL6LIM.js +49 -0
  280. package/dist/{core-OIC5KJSD.js → core-VT35VDVS.js} +4 -1
  281. package/dist/{core-3647Z25D.js → core-VWYXK2R3.js} +4 -1
  282. package/dist/{core-YEFGEW3Z.js → core-WNT6ZMRO.js} +5 -1
  283. package/dist/{core-VMIBBHXI.js → core-WP73P4CW.js} +4 -1
  284. package/dist/{core-ULZ7XUQP.js → core-WPEYRK6Y.js} +2 -1
  285. package/dist/{core-PMYCLXT7.js → core-WXZJ7V7S.js} +2 -1
  286. package/dist/{core-KEB5PBCO.js → core-XKXDXALI.js} +3 -1
  287. package/dist/{core-OWCTIPHD.js → core-ZACFV6XR.js} +2 -1
  288. package/dist/{core-BMY7OL76.js → core-ZSERZGK6.js} +5 -1
  289. package/dist/{dataTable-2ZXK54TP.js → dataTable-7IO546LM.js} +11 -2
  290. package/dist/{engine-HGXSWGOI.js → engine-US3N6UCH.js} +51 -15
  291. package/dist/fixtures.js +3 -1
  292. package/dist/fonts.js +1 -1
  293. package/dist/geo/dach.js +1 -1
  294. package/dist/geo/de-states.js +1 -1
  295. package/dist/geo/eu27.js +1 -1
  296. package/dist/geo/europe.js +1 -1
  297. package/dist/geo/index.js +2 -2
  298. package/dist/geo/us-states.js +1 -1
  299. package/dist/geo/world.js +1 -1
  300. package/dist/index.js +32 -19
  301. package/dist/{main-PVT6FMGC.js → main-2UWKGUHR.js} +28 -13
  302. package/dist/mcp/server.js +24 -13
  303. package/dist/react/bar.js +6 -1
  304. package/dist/react/bartable.js +8 -1
  305. package/dist/react/box.js +6 -1
  306. package/dist/react/bullet.js +7 -1
  307. package/dist/react/butterfly.js +6 -1
  308. package/dist/react/choropleth.js +8 -1
  309. package/dist/react/cohort.js +9 -1
  310. package/dist/react/column.js +6 -1
  311. package/dist/react/combo.js +6 -1
  312. package/dist/react/creative.js +8 -1
  313. package/dist/react/diagram.js +8 -1
  314. package/dist/react/dimswitch.js +6 -1
  315. package/dist/react/dot.js +6 -1
  316. package/dist/react/export.js +27 -19
  317. package/dist/react/funnel.js +6 -1
  318. package/dist/react/gantt.js +8 -1
  319. package/dist/react/grid.js +5 -1
  320. package/dist/react/heatmap.js +7 -1
  321. package/dist/react/histogram.js +6 -1
  322. package/dist/react/index.js +94 -84
  323. package/dist/react/kpi.js +7 -1
  324. package/dist/react/likert.js +6 -1
  325. package/dist/react/line.js +6 -1
  326. package/dist/react/mekko.js +6 -1
  327. package/dist/react/pareto.js +6 -1
  328. package/dist/react/pie.js +6 -1
  329. package/dist/react/prepare.js +36 -20
  330. package/dist/react/pvm.js +7 -1
  331. package/dist/react/pyramid.js +6 -1
  332. package/dist/react/sankey.js +8 -1
  333. package/dist/react/scatter.js +6 -1
  334. package/dist/react/slope.js +7 -1
  335. package/dist/react/sparkline.js +7 -1
  336. package/dist/react/spec.js +17 -11
  337. package/dist/react/status.js +12 -1
  338. package/dist/react/story.js +5 -3
  339. package/dist/react/table.js +6 -1
  340. package/dist/react/theme.js +8 -3
  341. package/dist/react/tilemap.js +7 -1
  342. package/dist/react/treemap.js +7 -1
  343. package/dist/react/variance.js +6 -1
  344. package/dist/react/waffle.js +7 -1
  345. package/dist/react/waterfall.js +7 -1
  346. package/dist/rows.js +3 -2
  347. package/dist/{rowsModule-JTDPTWXG.js → rowsModule-DYDVHBAX.js} +2 -1
  348. package/dist/{schema-GLN7IHSH.js → schema-3KMU5737.js} +1 -1
  349. package/dist/{schema-NVMEOHAW.js → schema-4JRNXEZF.js} +3 -1
  350. package/dist/{schema-7CPGNCOL.js → schema-626QXX4G.js} +3 -1
  351. package/dist/{schema-BMD5JR3Y.js → schema-6PL46VXZ.js} +3 -1
  352. package/dist/{schema-2Q7IJ22V.js → schema-6V5K3J2V.js} +4 -1
  353. package/dist/{schema-3XLO43SX.js → schema-A2XUZUCV.js} +3 -1
  354. package/dist/{schema-XKY2EQFH.js → schema-CNJ4Y6CT.js} +3 -1
  355. package/dist/{schema-BKHQ3ZUH.js → schema-DHMMGDTI.js} +3 -1
  356. package/dist/{schema-XHKSGMUH.js → schema-F2Q6MH7W.js} +3 -1
  357. package/dist/{schema-GGG2VOY7.js → schema-FC6J6KZC.js} +5 -1
  358. package/dist/{schema-ZE7WUNFS.js → schema-FGE5YK3S.js} +3 -1
  359. package/dist/{schema-WZLWHOMY.js → schema-FSYDLMGD.js} +1 -1
  360. package/dist/{schema-FYULDJFB.js → schema-G5KSSI5W.js} +1 -1
  361. package/dist/{schema-V3BPW4LA.js → schema-GXOG4MXL.js} +1 -1
  362. package/dist/{schema-76XRTBCJ.js → schema-HEB6ZDI5.js} +3 -1
  363. package/dist/{schema-HIDW4BA4.js → schema-I44IDRGD.js} +1 -1
  364. package/dist/{schema-BOGTPL7F.js → schema-IFTIMTS3.js} +1 -1
  365. package/dist/{schema-KIJA53MB.js → schema-IUY7VYHJ.js} +3 -1
  366. package/dist/{schema-C7NVOQNV.js → schema-J4HCSD5C.js} +5 -2
  367. package/dist/{schema-WIZ2TZAT.js → schema-JCU6LTYD.js} +1 -1
  368. package/dist/{schema-5KHDHTIX.js → schema-JJWORI7D.js} +3 -1
  369. package/dist/{schema-BUTNGYTT.js → schema-K4V4PYBO.js} +3 -1
  370. package/dist/{schema-LHMEXFLY.js → schema-LGLQBRC4.js} +3 -1
  371. package/dist/{schema-5753NOAL.js → schema-MD22QYZU.js} +1 -1
  372. package/dist/{schema-2M3LXR35.js → schema-MGETMQYC.js} +3 -1
  373. package/dist/{schema-FZKNIAIH.js → schema-MQB6CE5V.js} +3 -1
  374. package/dist/{schema-U26KG42U.js → schema-NMIYKGHE.js} +3 -1
  375. package/dist/{schema-MT6NA5AL.js → schema-NOBNFD2F.js} +3 -1
  376. package/dist/{schema-3OLBUVMZ.js → schema-OXO2XY4Y.js} +1 -1
  377. package/dist/{schema-G2PLJCYL.js → schema-PHIHMDVB.js} +1 -1
  378. package/dist/{schema-UHHFTVGS.js → schema-UXWKA3PI.js} +3 -1
  379. package/dist/{schema-J53LCIY3.js → schema-WBOPCTPC.js} +1 -1
  380. package/dist/{schema-TA3MSAPQ.js → schema-WFGDVBJK.js} +1 -1
  381. package/dist/{schema-MUTAVQMI.js → schema-WX2RS4OU.js} +3 -1
  382. package/dist/{schema-XATDKZPW.js → schema-XIHAKX3B.js} +18 -1
  383. package/dist/{schema-LEQNLBNG.js → schema-XRSORYBI.js} +3 -1
  384. package/dist/{schema-FNTAAXQ3.js → schema-YDZCGL56.js} +3 -1
  385. package/dist/{specValidation-X5XJBPTP.js → specValidation-XGELWQUU.js} +2 -1
  386. package/dist/theme.js +5 -1
  387. package/dist/types/core/charts/bartable/types.d.ts +14 -1
  388. package/dist/types/core/charts/box/types.d.ts +5 -1
  389. package/dist/types/core/charts/choropleth/layout.d.ts +1 -5
  390. package/dist/types/core/charts/choropleth/types.d.ts +19 -0
  391. package/dist/types/core/charts/cohort/types.d.ts +16 -3
  392. package/dist/types/core/charts/creative/types.d.ts +21 -0
  393. package/dist/types/core/charts/dimswitch/compile.d.ts +15 -2
  394. package/dist/types/core/charts/dimswitch/types.d.ts +24 -1
  395. package/dist/types/core/charts/gantt/calendar.d.ts +20 -0
  396. package/dist/types/core/charts/gantt/columns.d.ts +56 -0
  397. package/dist/types/core/charts/gantt/layout.d.ts +8 -2
  398. package/dist/types/core/charts/gantt/model.d.ts +296 -0
  399. package/dist/types/core/charts/grid/metricStack.d.ts +9 -0
  400. package/dist/types/core/charts/grid/metricStackSchema.d.ts +13 -0
  401. package/dist/types/core/charts/histogram/types.d.ts +8 -0
  402. package/dist/types/core/charts/likert/layout.d.ts +10 -8
  403. package/dist/types/core/charts/pvm/types.d.ts +9 -1
  404. package/dist/types/core/charts/pyramid/types.d.ts +3 -1
  405. package/dist/types/core/charts/sankey/types.d.ts +5 -1
  406. package/dist/types/core/charts/status/layout.d.ts +3 -0
  407. package/dist/types/core/charts/table/resolve.d.ts +14 -0
  408. package/dist/types/core/footer.d.ts +2 -0
  409. package/dist/types/core/format.d.ts +4 -0
  410. package/dist/types/core/formatSpec.d.ts +10 -0
  411. package/dist/types/core/frame.d.ts +1 -1
  412. package/dist/types/core/geo/types.d.ts +2 -0
  413. package/dist/types/core/geometry.d.ts +1 -1
  414. package/dist/types/core/label/categoryRow.d.ts +1 -1
  415. package/dist/types/core/normalize/shared.d.ts +2 -0
  416. package/dist/types/core/registry.d.ts +4 -5
  417. package/dist/types/core/request.d.ts +6 -0
  418. package/dist/types/core/schema/capability.d.ts +20 -7
  419. package/dist/types/core/schema/generatedColumns.d.ts +168 -0
  420. package/dist/types/core/text.d.ts +16 -0
  421. package/dist/types/core/themeGeometry.d.ts +9 -0
  422. package/dist/types/core/timeAxis.d.ts +6 -1
  423. package/dist/types/core/types/diagram.d.ts +7 -0
  424. package/dist/types/core/types/options.d.ts +83 -12
  425. package/dist/types/core/types/table.d.ts +23 -3
  426. package/dist/types/index.d.ts +2 -0
  427. package/dist/types/react/barrelCharts.d.ts +16 -5
  428. package/dist/types/react/charts/butterfly.d.ts +2 -2
  429. package/dist/types/react/charts/dot.d.ts +7 -1
  430. package/dist/types/react/charts/pareto.d.ts +4 -1
  431. package/dist/types/react/charts/variance.d.ts +3 -1
  432. package/dist/types/react/hover/labelCard.d.ts +18 -3
  433. package/dist/types/react/prepare.d.ts +7 -1
  434. package/dist/types/theme.d.ts +2 -0
  435. package/dist/validate.js +16 -5
  436. package/docs/manual.md +31 -3
  437. package/docs/reference/bar.md +3 -0
  438. package/docs/reference/bartable.md +16 -1
  439. package/docs/reference/box.md +8 -1
  440. package/docs/reference/bullet.md +12 -1
  441. package/docs/reference/butterfly.md +7 -1
  442. package/docs/reference/choropleth.md +15 -2
  443. package/docs/reference/cohort.md +25 -5
  444. package/docs/reference/column.md +1 -0
  445. package/docs/reference/combo.md +1 -0
  446. package/docs/reference/creative.md +13 -0
  447. package/docs/reference/diagram.md +5 -0
  448. package/docs/reference/dimswitch.md +50 -32
  449. package/docs/reference/dot.md +7 -2
  450. package/docs/reference/fixtures.md +57 -0
  451. package/docs/reference/funnel.md +5 -0
  452. package/docs/reference/gantt.md +10 -2
  453. package/docs/reference/grid.md +9 -2
  454. package/docs/reference/heatmap.md +6 -0
  455. package/docs/reference/histogram.md +2 -2
  456. package/docs/reference/kpi.md +5 -1
  457. package/docs/reference/likert.md +8 -0
  458. package/docs/reference/line.md +1 -1
  459. package/docs/reference/options.md +4 -3
  460. package/docs/reference/pareto.md +1 -1
  461. package/docs/reference/pvm.md +7 -1
  462. package/docs/reference/pyramid.md +6 -0
  463. package/docs/reference/react.md +1 -2
  464. package/docs/reference/sankey.md +6 -2
  465. package/docs/reference/slope.md +6 -0
  466. package/docs/reference/sparkline.md +1 -1
  467. package/docs/reference/status.md +7 -1
  468. package/docs/reference/table.md +16 -4
  469. package/docs/reference/tilemap.md +2 -2
  470. package/docs/reference/treemap.md +1 -1
  471. package/docs/reference/waffle.md +1 -1
  472. package/docs/reference/waterfall.md +4 -1
  473. package/package.json +1 -1
  474. package/dist/chunk-FI5EXISD.js +0 -27
  475. package/dist/chunk-O36WX56O.js +0 -13
  476. package/dist/chunk-YGTNVZJE.js +0 -89
  477. package/dist/chunk-ZGHBDMYF.js +0 -24
  478. package/dist/chunk-ZLYQWUNR.js +0 -1794
  479. package/dist/core-SKRADU7T.js +0 -41
@@ -28,10 +28,11 @@ import {
28
28
  collapsedHintWidth,
29
29
  columnTracks,
30
30
  encodingReserve,
31
- frameFillExtras,
31
+ frameFillAmounts,
32
32
  groupHeadingFaces,
33
33
  groupHeadingFloors,
34
34
  groupHeadingNeed,
35
+ groupHeadingWrap,
35
36
  headerContentWidth,
36
37
  headsFit,
37
38
  inlineFont,
@@ -43,13 +44,13 @@ import {
43
44
  strongColumnFont,
44
45
  tableFonts,
45
46
  wrapFloorWidth
46
- } from "./chunk-7Z73MM35.js";
47
+ } from "./chunk-HVX2E26J.js";
47
48
  import {
48
49
  toneTextPaint
49
- } from "./chunk-BVYIKLQ5.js";
50
+ } from "./chunk-UD6U4EF5.js";
50
51
  import {
51
52
  fieldHeadText
52
- } from "./chunk-SPSGUFTI.js";
53
+ } from "./chunk-I4NUYVP5.js";
53
54
  import {
54
55
  operatorWidth,
55
56
  qualifierFont
@@ -57,19 +58,19 @@ import {
57
58
  import {
58
59
  bandFor
59
60
  } from "./chunk-263SZKIL.js";
60
- import {
61
- emptyIdRecord
62
- } from "./chunk-LINZPU5D.js";
63
61
  import {
64
62
  closestKey
65
- } from "./chunk-BSATR6ZO.js";
63
+ } from "./chunk-V62B23VC.js";
66
64
  import {
67
65
  caseInsensitiveValue,
68
66
  chartSizing,
67
+ copyPlannedValue,
69
68
  fitsSize,
70
69
  inputConversion,
70
+ memoExactInputKey,
71
+ ownPlanInput,
71
72
  resolveSizing
72
- } from "./chunk-WALYNKBN.js";
73
+ } from "./chunk-AFGQXMKT.js";
73
74
  import {
74
75
  clamp,
75
76
  cleanDiff,
@@ -79,17 +80,23 @@ import {
79
80
  numericVariant,
80
81
  readDateFormat,
81
82
  unitPrinted
82
- } from "./chunk-2ALFFOKB.js";
83
+ } from "./chunk-WSKZZ2ZB.js";
83
84
  import {
84
85
  disclosureNote,
85
86
  disclosuresShown,
86
87
  footerType
87
- } from "./chunk-5SHI57XD.js";
88
+ } from "./chunk-WZB6R2ZX.js";
89
+ import {
90
+ emptyIdRecord
91
+ } from "./chunk-LINZPU5D.js";
88
92
  import {
89
93
  AUTOMATIC_FORMAT,
94
+ LABEL_ONLY_ROW,
90
95
  MAGNITUDE_DIVISOR,
96
+ MAGNITUDE_FIGURES,
91
97
  MAGNITUDE_GROUP,
92
98
  MAGNITUDE_LABEL,
99
+ compileNumberFormat,
93
100
  differenceExample,
94
101
  effectiveScale,
95
102
  formatWithSpec,
@@ -101,11 +108,12 @@ import {
101
108
  specUnitKind,
102
109
  unitOfSpec,
103
110
  withChartMarks
104
- } from "./chunk-GDVR3XHT.js";
111
+ } from "./chunk-D3PQAVFW.js";
105
112
  import {
106
113
  MINUS,
107
114
  chartNumberMarks,
108
115
  currencyWholeNumbers,
116
+ currentSmallValues,
109
117
  formatExactNumber,
110
118
  intervalText,
111
119
  localeStrings,
@@ -113,7 +121,7 @@ import {
113
121
  typicalDecimals,
114
122
  withSmallValues,
115
123
  zeroLifts
116
- } from "./chunk-LHKDZAWN.js";
124
+ } from "./chunk-MSYTF3DZ.js";
117
125
  import {
118
126
  canvasMargin,
119
127
  contrastInkPaint,
@@ -129,7 +137,7 @@ import {
129
137
  tableEmphasis,
130
138
  tableHeadFloorPx,
131
139
  textScaleOf
132
- } from "./chunk-HJRNBKIT.js";
140
+ } from "./chunk-JARJP576.js";
133
141
  import {
134
142
  DEFAULT_TARGET,
135
143
  NormalizeError,
@@ -140,15 +148,15 @@ import {
140
148
  resolveSubtitle,
141
149
  scaleTextPx,
142
150
  targetFloorsPx
143
- } from "./chunk-YOOHNQ3L.js";
151
+ } from "./chunk-FX5VZK5F.js";
144
152
  import {
145
153
  maxOf,
146
154
  minOf,
147
155
  pushAll
148
156
  } from "./chunk-WYJEOMNY.js";
149
157
  import {
150
- twoLineWidth
151
- } from "./chunk-SNQ7D5R7.js";
158
+ lineBlockWidth
159
+ } from "./chunk-UIHGGWES.js";
152
160
 
153
161
  // src/core/charts/table/ladder.ts
154
162
  var COHORT_GRID = {
@@ -679,11 +687,130 @@ function columnHeaderAffix(column) {
679
687
  let affix = [column.scenario, column.unitLabel].filter(Boolean).join(", ");
680
688
  return `${affix ? ` (${affix})` : ""}${column.partial ? ` ${PARTIAL_MARKER}` : ""}`;
681
689
  }
690
+ var preparedData = /* @__PURE__ */ new WeakMap(), sharedPreparedData = /* @__PURE__ */ new Map(), MAX_SHARED_KEY_CHARS = 128 * 1024, MAX_SHARED_TOTAL_CHARS = 2 * 1024 * 1024, sharedKeyChars = 0, modelSymbols = new Map([AUTOMATIC_FORMAT, MAGNITUDE_GROUP, MAGNITUDE_FIGURES, ZERO_LIFT, LABEL_ONLY_ROW].map((symbol, index) => [symbol, index]));
691
+ function modelContentKey(value) {
692
+ let parts = [], seen = /* @__PURE__ */ new Map(), active = /* @__PURE__ */ new Set(), supported = !0, write = (value2) => {
693
+ if (!supported) return;
694
+ if (value2 === null) {
695
+ parts.push("null;");
696
+ return;
697
+ }
698
+ switch (typeof value2) {
699
+ case "undefined":
700
+ parts.push("undefined;");
701
+ return;
702
+ case "string":
703
+ parts.push("s", JSON.stringify(value2));
704
+ return;
705
+ case "boolean":
706
+ parts.push(value2 ? "true;" : "false;");
707
+ return;
708
+ case "number":
709
+ parts.push("n", Object.is(value2, -0) ? "-0" : String(value2), ";");
710
+ return;
711
+ case "object":
712
+ break;
713
+ default:
714
+ supported = !1;
715
+ return;
716
+ }
717
+ let prototype = Object.getPrototypeOf(value2), array = Array.isArray(value2);
718
+ if (!array && prototype !== Object.prototype && prototype !== null) {
719
+ supported = !1;
720
+ return;
721
+ }
722
+ let known = seen.get(value2);
723
+ if (known !== void 0) {
724
+ if (active.has(value2)) {
725
+ supported = !1;
726
+ return;
727
+ }
728
+ parts.push("ref", String(known), ";");
729
+ return;
730
+ }
731
+ seen.set(value2, seen.size), active.add(value2), parts.push(array ? `array${value2.length}{` : prototype === null ? "record{" : "object{");
732
+ for (let key of Reflect.ownKeys(value2)) {
733
+ if (array && key === "length") continue;
734
+ if (!("value" in Object.getOwnPropertyDescriptor(value2, key))) {
735
+ supported = !1;
736
+ return;
737
+ }
738
+ if (typeof key == "symbol") {
739
+ let index = modelSymbols.get(key);
740
+ if (index === void 0) {
741
+ supported = !1;
742
+ return;
743
+ }
744
+ parts.push("symbol", String(index), ":");
745
+ } else parts.push("key", JSON.stringify(key), ":");
746
+ write(Reflect.get(value2, key));
747
+ }
748
+ parts.push("}"), active.delete(value2);
749
+ };
750
+ return write(value), supported ? parts.join("") : void 0;
751
+ }
752
+ function prepareTableData(data, options = {}, magnitudeSource = data) {
753
+ return withSmallValues(options.smallValues, () => {
754
+ let theme = resolveTheme(options.theme), semantic = {
755
+ locale: options.locale,
756
+ strings: options.strings,
757
+ variant: options.variant,
758
+ density: isCohortDensity(options.density ?? "regular"),
759
+ nulls: options.nulls,
760
+ levelOffset: options.levelOffset,
761
+ columnHeads: options.columnHeads,
762
+ disclosures: disclosuresShown(options),
763
+ highlight: options.highlight,
764
+ sort: options.sort,
765
+ topN: options.topN,
766
+ format: options.format,
767
+ unit: options.unit,
768
+ magnitude: options.magnitude,
769
+ target: options.target,
770
+ subtitle: options.subtitle,
771
+ unitShown: options.unitShown,
772
+ encodings: options.encodings,
773
+ signs: options.signs,
774
+ driverTones: options.driverTones,
775
+ judgements: options.judgements,
776
+ totalPosition: options.totalPosition,
777
+ colorblindSafe: options.colorblindSafe,
778
+ theme: { glyphs: theme.table?.glyphs, noPrevious: theme.table?.noPrevious, dataGap: theme.table?.dataGap },
779
+ // Top-N ranks the complete formatted table before folding it. Its inner resolution must retain the current precision.
780
+ ...options.topN ? { columnVisibility: options.columnVisibility, [ZERO_LIFT]: options[ZERO_LIFT] } : {}
781
+ }, dataContent = memoExactInputKey(data, modelContentKey), magnitudeContent = magnitudeSource === data ? "same;" : memoExactInputKey(magnitudeSource, modelContentKey), semanticContent = modelContentKey([semantic, currentSmallValues()]), content = dataContent === void 0 || magnitudeContent === void 0 || semanticContent === void 0 ? void 0 : dataContent.length + ":" + dataContent + magnitudeContent.length + ":" + magnitudeContent + semanticContent, key = content, models = key === void 0 ? void 0 : preparedData.get(data);
782
+ !models && key !== void 0 && preparedData.set(data, models = /* @__PURE__ */ new Map());
783
+ let model = key === void 0 ? void 0 : models.get(key) ?? (content === void 0 ? void 0 : sharedPreparedData.get(content));
784
+ if (!model) {
785
+ let before = zeroLifts.count;
786
+ try {
787
+ let owned = copyPlannedValue(data);
788
+ ownPlanInput(owned);
789
+ let { theme: authoredTheme, measure: _measure, ...kept } = options;
790
+ model = compileTableData(owned, { ...copyPlannedValue(kept), theme: authoredTheme }, magnitudeSource === data ? owned : copyPlannedValue(magnitudeSource)), ownPlanInput(model);
791
+ } finally {
792
+ zeroLifts.count = before;
793
+ }
794
+ if (content !== void 0 && content.length <= MAX_SHARED_KEY_CHARS) {
795
+ for (sharedKeyChars += content.length; sharedPreparedData.size >= 32 || sharedKeyChars > MAX_SHARED_TOTAL_CHARS; ) {
796
+ let oldest = sharedPreparedData.keys().next().value;
797
+ sharedKeyChars -= oldest.length, sharedPreparedData.delete(oldest);
798
+ }
799
+ sharedPreparedData.set(content, model);
800
+ }
801
+ }
802
+ return key !== void 0 && !models.has(key) && (models.size >= 32 && models.delete(models.keys().next().value), models.set(key, model)), model;
803
+ });
804
+ }
805
+ function resolvePreparedTable(model, options = {}) {
806
+ return withSmallValues(options.smallValues, () => model.resolve(options));
807
+ }
682
808
  function resolveTable(data, options = {}, magnitudeSource = data) {
683
- return withSmallValues(options.smallValues, () => resolveTableIn(data, options, magnitudeSource));
809
+ let borrowed = resolvePreparedTable(prepareTableData(data, options, magnitudeSource), options), owned = copyPlannedValue(borrowed);
810
+ return evaluatedStates.set(owned, evaluatedStates.get(borrowed)), owned;
684
811
  }
685
- function resolveTableIn(data, options, magnitudeSource) {
686
- 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) => {
812
+ function compileTableData(data, options, magnitudeSource) {
813
+ let source = data, modelLiftsBefore = zeroLifts.count, formats = /* @__PURE__ */ new Map(), markedLanguage = options.locale?.language, parseFormatExample2 = (example) => {
687
814
  let spec = formats.get(example);
688
815
  return spec === void 0 && (spec = parseFormatExample(example), spec.locale = markedLanguage, formats.set(example, spec)), { ...spec };
689
816
  }, warnings = [], datePatterns = /* @__PURE__ */ new Map();
@@ -748,7 +875,7 @@ function resolveTableIn(data, options, magnitudeSource) {
748
875
  }
749
876
  });
750
877
  }
751
- let records = [], autoFootnotes = /* @__PURE__ */ new Set(), lowerJudged = /* @__PURE__ */ new Set(), higherJudged = /* @__PURE__ */ new Set(), partialColumnIds = /* @__PURE__ */ new Set(), highlightedRows = new Set(resolveHighlight(options.highlight));
878
+ let records = [], autoFootnotes = /* @__PURE__ */ new Set(), partialColumnIds = /* @__PURE__ */ new Set(), headMarksPartial = disclosuresShown(options) && options.columnHeads !== !1, highlightedRows = new Set(resolveHighlight(options.highlight));
752
879
  assertTableRankOptions(options);
753
880
  let folded = applyTableTopN(data, options);
754
881
  data = folded.data;
@@ -766,7 +893,7 @@ function resolveTableIn(data, options, magnitudeSource) {
766
893
  `exactly one rowLabel column required, found ${rowLabelCols.length}`
767
894
  );
768
895
  validateGroups(data, colById), validateCalcRefs(columns, colById);
769
- 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));
896
+ let toggleResolution = resolveColumnToggles(data, { ...options, columnVisibility: void 0 }, colById, warnings), toggleWarningAt = warnings.length, 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));
770
897
  if (![...calcRunIds].some((id) => predecessorIds.has(previousColumnInGroup(data.columnGroups ?? [], id) ?? "")))
771
898
  for (let row of flat)
772
899
  row.calc === void 0 || !calcRefs(row.calc).some((ref) => typeof ref != "string" && ref.previous === !0) || warnings.push({
@@ -786,7 +913,7 @@ function resolveTableIn(data, options, magnitudeSource) {
786
913
  let kept = list.filter((child) => child.inline !== !0);
787
914
  kept.length > 0 && treeChildrenOf.set(parentId, kept);
788
915
  }
789
- let expansion = resolveExpansion(flat, treeChildrenOf, options, warnings, generatedOthers), signTo = (row, stop) => contributionSignOf(row, (id) => flatById.get(id), stop), summandCache = /* @__PURE__ */ new Map(), summandsOf = (parentId) => {
916
+ let expansionWarningAt = warnings.length, expansion = resolveExpansion(flat, treeChildrenOf, {}, warnings, generatedOthers), signTo = (row, stop) => contributionSignOf(row, (id) => flatById.get(id), stop), summandCache = /* @__PURE__ */ new Map(), summandsOf = (parentId) => {
790
917
  let cached = summandCache.get(parentId);
791
918
  if (cached) return cached;
792
919
  let hoisted = [], dissolveSections = (pid) => {
@@ -901,7 +1028,7 @@ function resolveTableIn(data, options, magnitudeSource) {
901
1028
  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')`
902
1029
  }), derived = { raw: null, state: inherited };
903
1030
  } else
904
- blockers.length > 0 && (autoFootnotes.add(PARTIAL_FOOTNOTE), partialColumnIds.add(col.id)), derived = { raw: cleanSum(inputs.map((input) => input.value)), state: "value", ...blockers.length > 0 || partialKid ? { partial: !0, skipped: skippedKey([...blockers.map((b) => b.id), ...skippedKids]) } : {} };
1031
+ blockers.length > 0 && (options.columnHeads !== !1 && autoFootnotes.add(PARTIAL_FOOTNOTE), partialColumnIds.add(col.id)), derived = { raw: cleanSum(inputs.map((input) => input.value)), state: "value", ...blockers.length > 0 || partialKid ? { partial: !0, skipped: skippedKey([...blockers.map((b) => b.id), ...skippedKids]) } : {} };
905
1032
  let policy = row.totalPolicy ?? (authored.raw !== null ? "validate" : "derive");
906
1033
  return policy === "source" ? authored.raw === null ? derived : { raw: authored.raw, state: "value" } : policy === "validate" && authored.raw !== null ? (noSummands ? unauditedRecord() : records.push({
907
1034
  rowId: row.id,
@@ -961,540 +1088,608 @@ function resolveTableIn(data, options, magnitudeSource) {
961
1088
  owner: { rowId, colId }
962
1089
  });
963
1090
  }
964
- 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();
965
- for (let col of [...valueCols, ...computedCols]) {
966
- let inherited = col.kind === "computed" && !calcPreservesScale(col.calc) ? void 0 : options.format, authoredExample = col.format ?? inherited, example = authoredExample ?? defaultExample(col);
967
- authoredExample === void 0 && localeDerivedColumns.add(col.id), formatExamples.set(col.id, example);
968
- let spec = parseFormatExample2(example), sourceExample = sourceColumns.get(col.id)?.format ?? inherited;
969
- 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);
970
- }
971
- let rowSpecs = /* @__PURE__ */ new Map(), rowById = /* @__PURE__ */ new Map(), forcedMagnitude = options.magnitude === "million" ? "m" : options.magnitude === "thousand" ? "k" : void 0, authoredSpec = (example, sourceExample = example) => {
972
- let spec = parseFormatExample2(example);
973
- return forcedMagnitude !== void 0 && scales(sourceExample) && forceScale(spec, forcedMagnitude, locale.thousands), spec;
974
- }, cellsOfRow = /* @__PURE__ */ new Map(), rowCells = (row) => {
975
- let cells = cellsOfRow.get(row.id);
976
- return cells === void 0 && cellsOfRow.set(row.id, cells = rowCellsUncached(row)), cells;
977
- }, rowValues = (row) => rowCells(row).map(([, value]) => value), rowCellsUncached = (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)).flatMap((col) => {
978
- let raw = rawState.get(row.id)?.get(col.id)?.raw;
979
- return typeof raw == "number" ? [[col.id, raw]] : [];
980
- }), 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(), groupColumns = /* @__PURE__ */ new Map();
981
- for (let row of flat) {
982
- let group = groupOf(row);
983
- if (group === void 0) continue;
984
- groupMax.set(group, Math.max(groupMax.get(group) ?? 0, largest(rowValues(row))));
985
- let columns2 = groupColumns.get(group);
986
- columns2 === void 0 && groupColumns.set(group, columns2 = /* @__PURE__ */ new Map());
987
- for (let [colId, value] of rowCells(row)) {
988
- let column = columns2.get(colId);
989
- column === void 0 ? columns2.set(colId, [value]) : column.push(value);
1091
+ let rawWarnings = warnings, rawRecords = records, rawFootnotes = autoFootnotes, rawCells = rawState, childGroups = childrenOf, rawLifts = zeroLifts.count - modelLiftsBefore, rowIds = flat.map((row) => row.id), rowIndex = new Map(rowIds.map((id, index) => [id, index])), columnIndex = new Map(columnIds.map((id, index) => [id, index])), formatted = /* @__PURE__ */ new Map();
1092
+ return { source, rowIds, columnIds, rowIndex, columnIndex, resolve(current) {
1093
+ let formatKey = JSON.stringify([current.columnVisibility, current[ZERO_LIFT]]), display = formatted.get(formatKey);
1094
+ if (display)
1095
+ zeroLifts.count += display.lifts;
1096
+ else {
1097
+ let before = zeroLifts.count;
1098
+ display = { result: formatTable({ ...options, columnVisibility: current.columnVisibility, [ZERO_LIFT]: current[ZERO_LIFT] }), lifts: zeroLifts.count - before, views: /* @__PURE__ */ new Map() }, formatted.size >= 32 && formatted.delete(formatted.keys().next().value), formatted.set(formatKey, display);
990
1099
  }
991
- }
992
- let groupCellSpecs = /* @__PURE__ */ new Map();
993
- for (let row of flat) {
994
- rowById.set(row.id, row);
995
- 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);
996
- if (example) {
997
- let spec = authoredSpec(example, sourceRows.get(row.id)?.format ?? example), authoredRow = sourceRows.get(row.id);
998
- authoredRow?.format !== void 0 && authoredRow[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands);
999
- let group = groupOf(row), rowScale = row.scale === "money" || row.scale === "perUnit";
1000
- if (rowScale || specUnitKind(spec) === "number") {
1001
- 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;
1002
- if (rowScale && !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal) {
1003
- let heldMoney = row.scale === "money" && forcedMagnitude !== void 0;
1004
- if (spec.magnitude = heldMoney ? forcedMagnitude : row.scale === "money" ? climb(1e3) : "none", row.scale === "money")
1005
- spec.decimals = max >= 1e3 && !(heldMoney && forcedMagnitude === "k" && max >= 1e5) ? 1 : 0;
1006
- else if ((!authoredFormat || values.every(Number.isInteger)) && (spec.decimals = max >= 10 ? 0 : 1, !authoredFormat))
1007
- for (let value of values)
1008
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1009
- spec.prefix = "", spec.suffix = "", spec.lockMagnitude = heldMoney, spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = locale.thousands);
1010
- } 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);
1011
- let smallMoney = !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal && !rowScale && forcedMagnitude && scales(example) && values.every((v) => Math.abs(v) < 1e3), changeLine = row.inline === !0 || spec.signed;
1012
- if (smallMoney || !changeLine && group === void 0 && values.some((v) => v !== 0 && roundedNumber(v, spec) === 0)) {
1013
- if (!spec.magnitudeInAffix && (smallMoney || !rowScale && spec.lockMagnitude && spec.magnitude === "k" || row.scale === "money" && spec.magnitude === "k")) {
1014
- let authored = parseFormatExample2(example);
1015
- spec.decimals = !rowScale && authored.magnitude === "none" ? authored.decimals : 0, spec.magnitude = "none";
1016
- }
1017
- spec.decimals = values.reduce((decimals, value) => nonzeroDecimals(value / MAGNITUDE_DIVISOR[spec.magnitude], decimals), spec.decimals);
1018
- }
1019
- if (!changeLine && (spec.magnitude !== "none" || group !== void 0 && row.scale === "money") && !(spec.lockMagnitude && spec.magnitude === "k") && (row.scale === "money" || row.scale === "count" && !authoredFormat))
1020
- if (group === void 0)
1021
- for (let value of values)
1022
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1023
- else {
1024
- let columns2 = groupColumns.get(group);
1025
- for (let column of columns2.values())
1026
- for (let value of column)
1027
- for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > max * 0.01; ) spec.decimals++;
1028
- let inRow = /* @__PURE__ */ new Map();
1029
- for (let [colId, column] of columns2) {
1030
- let cellSpec = { ...spec }, bound = largest(column) * 0.01;
1031
- for (let value of column)
1032
- for (; value !== 0 && cellSpec.decimals < 20 && Math.abs(roundedNumber(value, cellSpec) - value) > bound; ) cellSpec.decimals++;
1033
- inRow.set(colId, cellSpec);
1100
+ zeroLifts.count += rawLifts;
1101
+ let viewKey = JSON.stringify(current.expansion), view = display.views.get(viewKey ?? "");
1102
+ if (!view) {
1103
+ let toggleWarnings = [], expansionWarnings = [], toggles = toggleResolution.toggles.map((toggle) => ({ ...toggle, visible: current.columnVisibility?.[toggle.id] ?? toggle.defaultVisible }));
1104
+ columnVisibilityWarnings(toggles, current, toggleWarnings);
1105
+ let expanded = resolveExpansion(flat, treeChildrenOf, current, expansionWarnings, generatedOthers), base = display.result, rows = base.table.rows.map((row) => row.hasChildren ? { ...row, defaultExpanded: expanded.get(row.id) } : row.inlineRows ? { ...row } : row), rowsById = new Map(rows.map((row) => [row.id, row]));
1106
+ for (let index = 0; index < rows.length; index++) {
1107
+ let row = rows[index];
1108
+ row.inlineRows && (row.inlineRows = row.inlineRows.map((line) => rowsById.get(line.id)));
1109
+ }
1110
+ view = { ...base, table: { ...base.table, rows, columnToggles: toggles }, warnings: [
1111
+ ...base.warnings.slice(0, toggleWarningAt),
1112
+ ...toggleWarnings,
1113
+ ...base.warnings.slice(toggleWarningAt, expansionWarningAt),
1114
+ ...expansionWarnings,
1115
+ ...base.warnings.slice(expansionWarningAt)
1116
+ ] }, evaluatedStates.set(view, evaluatedStates.get(base)), display.views.size >= 32 && display.views.delete(display.views.keys().next().value), display.views.set(viewKey ?? "", view);
1117
+ }
1118
+ return view;
1119
+ } };
1120
+ function formatTable(options2) {
1121
+ let liftsBefore = zeroLifts.count, liftMode = options2[ZERO_LIFT], automaticAs = (on) => on && liftMode !== "none" ? liftMode ?? !0 : !1, warnings2 = rawWarnings.slice(), records2 = rawRecords.map((record) => ({ ...record })), autoFootnotes2 = new Set(rawFootnotes), lowerJudged = /* @__PURE__ */ new Set(), higherJudged = /* @__PURE__ */ new Set(), rawState2 = new Map([...rawCells].map(([id, cells]) => [id, new Map(cells)]));
1122
+ partitionLeafIds.set(rawState2, partitionLeafIds.get(rawCells));
1123
+ let childrenOf2 = new Map([...childGroups].map(([id, rows]) => [id, rows.slice()])), locale = localeDefaults(options2.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();
1124
+ for (let col of [...valueCols, ...computedCols]) {
1125
+ let inherited = col.kind === "computed" && !calcPreservesScale(col.calc) ? void 0 : options2.format, authoredExample = col.format ?? inherited, example = authoredExample ?? defaultExample(col);
1126
+ authoredExample === void 0 && localeDerivedColumns.add(col.id), formatExamples.set(col.id, example);
1127
+ let spec = parseFormatExample2(example), sourceExample = sourceColumns.get(col.id)?.format ?? inherited;
1128
+ spec.automatic = automaticAs(sourceExample === void 0 && options2.unit === void 0 && options2.magnitude !== "million" && options2.magnitude !== "thousand"), authoredExample === void 0 && currencyWholeNumbers(options2.unit, options2.target) && (col.kind !== "computed" || calcPreservesScale(col.calc)) && (spec.currencyWhole = !0), scales(sourceColumns.get(col.id)?.format ?? inherited ?? defaultExample(col)) && (options2.magnitude === "million" || options2.magnitude === "thousand") && forceScale(spec, options2.magnitude === "million" ? "m" : "k", locale.thousands), sourceExample !== void 0 && holdAuthoredScale(spec, locale.thousands), specs.set(col.id, spec);
1129
+ }
1130
+ let rowSpecs = /* @__PURE__ */ new Map(), rowById = /* @__PURE__ */ new Map(), forcedMagnitude = options2.magnitude === "million" ? "m" : options2.magnitude === "thousand" ? "k" : void 0, authoredSpec = (example, sourceExample = example) => {
1131
+ let spec = parseFormatExample2(example);
1132
+ return forcedMagnitude !== void 0 && scales(sourceExample) && forceScale(spec, forcedMagnitude, locale.thousands), spec;
1133
+ }, cellsOfRow = /* @__PURE__ */ new Map(), rowCells = (row) => {
1134
+ let cells = cellsOfRow.get(row.id);
1135
+ return cells === void 0 && cellsOfRow.set(row.id, cells = rowCellsUncached(row)), cells;
1136
+ }, rowValues = (row) => rowCells(row).map(([, value]) => value), rowCellsUncached = (row) => valueCols.filter((col) => col.format === void 0 && cellFormat(row.cells[col.id]) === void 0 && !(data.columnToggles ?? []).some((toggle) => toggle.columns.includes(col.id) && (options2.columnVisibility?.[toggle.id] ?? toggle.defaultVisible ?? !1) === !1)).flatMap((col) => {
1137
+ let raw = rawState2.get(row.id)?.get(col.id)?.raw;
1138
+ return typeof raw == "number" ? [[col.id, raw]] : [];
1139
+ }), 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(), groupColumns = /* @__PURE__ */ new Map();
1140
+ for (let row of flat) {
1141
+ let group = groupOf(row);
1142
+ if (group === void 0) continue;
1143
+ let kept = sourceRows.get(row.id)?.[MAGNITUDE_FIGURES], figures = kept === void 0 ? rowCells(row) : [...rowCells(row), ...kept];
1144
+ groupMax.set(group, Math.max(groupMax.get(group) ?? 0, largest(kept === void 0 ? rowValues(row) : figures.map(([, value]) => value))));
1145
+ let columns2 = groupColumns.get(group);
1146
+ columns2 === void 0 && groupColumns.set(group, columns2 = /* @__PURE__ */ new Map());
1147
+ for (let [colId, value] of figures) {
1148
+ let column = columns2.get(colId);
1149
+ column === void 0 ? columns2.set(colId, [value]) : column.push(value);
1150
+ }
1151
+ }
1152
+ let groupCellSpecs = /* @__PURE__ */ new Map();
1153
+ for (let row of flat) {
1154
+ rowById.set(row.id, row);
1155
+ 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);
1156
+ if (example) {
1157
+ let spec = authoredSpec(example, sourceRows.get(row.id)?.format ?? example), authoredRow = sourceRows.get(row.id);
1158
+ authoredRow?.format !== void 0 && authoredRow[AUTOMATIC_FORMAT] !== !0 && holdAuthoredScale(spec, locale.thousands);
1159
+ let group = groupOf(row), rowScale = row.scale === "money" || row.scale === "perUnit";
1160
+ if (rowScale || specUnitKind(spec) === "number") {
1161
+ 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;
1162
+ if (rowScale && !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal) {
1163
+ let heldMoney = row.scale === "money" && forcedMagnitude !== void 0;
1164
+ if (spec.magnitude = heldMoney ? forcedMagnitude : row.scale === "money" ? climb(1e3) : "none", row.scale === "money")
1165
+ spec.decimals = max >= 1e3 && !(heldMoney && forcedMagnitude === "k" && max >= 1e5) ? 1 : 0;
1166
+ else if ((!authoredFormat || values.every(Number.isInteger)) && (spec.decimals = max >= 10 ? 0 : 1, !authoredFormat))
1167
+ for (let value of values)
1168
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1169
+ spec.prefix = "", spec.suffix = "", spec.lockMagnitude = heldMoney, spec.rollMagnitude = !1, spec.thousandsSep === "" && (spec.thousandsSep = locale.thousands);
1170
+ } 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);
1171
+ let smallMoney = !spec.magnitudeInAffix && !spec.exponent && !spec.ordinal && !rowScale && forcedMagnitude && scales(example) && values.every((v) => Math.abs(v) < 1e3), changeLine = row.inline === !0 || spec.signed;
1172
+ if (smallMoney || !changeLine && group === void 0 && values.some((v) => v !== 0 && roundedNumber(v, spec) === 0)) {
1173
+ if (!spec.magnitudeInAffix && (smallMoney || !rowScale && spec.lockMagnitude && spec.magnitude === "k" || row.scale === "money" && spec.magnitude === "k")) {
1174
+ let authored = parseFormatExample2(example);
1175
+ spec.decimals = !rowScale && authored.magnitude === "none" ? authored.decimals : 0, spec.magnitude = "none";
1034
1176
  }
1035
- groupCellSpecs.set(row.id, inRow);
1177
+ spec.decimals = values.reduce((decimals, value) => nonzeroDecimals(value / MAGNITUDE_DIVISOR[spec.magnitude], decimals), spec.decimals);
1036
1178
  }
1179
+ if (!changeLine && (spec.magnitude !== "none" || group !== void 0 && row.scale === "money") && !(spec.lockMagnitude && spec.magnitude === "k") && (row.scale === "money" || row.scale === "count" && !authoredFormat))
1180
+ if (group === void 0)
1181
+ for (let value of values)
1182
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > Math.abs(value) * 0.01; ) spec.decimals++;
1183
+ else {
1184
+ let columns2 = groupColumns.get(group);
1185
+ for (let column of columns2.values())
1186
+ for (let value of column)
1187
+ for (; value !== 0 && spec.decimals < 20 && Math.abs(roundedNumber(value, spec) - value) > max * 0.01; ) spec.decimals++;
1188
+ let inRow = /* @__PURE__ */ new Map();
1189
+ for (let [colId, column] of columns2) {
1190
+ let cellSpec = { ...spec }, bound = largest(column) * 0.01;
1191
+ for (let value of column)
1192
+ for (; value !== 0 && cellSpec.decimals < 20 && Math.abs(roundedNumber(value, cellSpec) - value) > bound; ) cellSpec.decimals++;
1193
+ inRow.set(colId, cellSpec);
1194
+ }
1195
+ groupCellSpecs.set(row.id, inRow);
1196
+ }
1197
+ }
1198
+ let sourceRow = sourceRows.get(row.id);
1199
+ spec.automatic = automaticAs(group !== void 0 || (sourceRow?.format === void 0 || sourceRow[AUTOMATIC_FORMAT] === !0) && options2.format === void 0 && options2.unit === void 0 && forcedMagnitude === void 0);
1200
+ for (let cellSpec of groupCellSpecs.get(row.id)?.values() ?? []) cellSpec.automatic = spec.automatic;
1201
+ rowSpecs.set(row.id, spec);
1037
1202
  }
1038
- let sourceRow = sourceRows.get(row.id);
1039
- 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);
1040
- for (let cellSpec of groupCellSpecs.get(row.id)?.values() ?? []) cellSpec.automatic = spec.automatic;
1041
- rowSpecs.set(row.id, spec);
1042
- }
1043
- }
1044
- let cellSpecs = /* @__PURE__ */ new Map(), cellFormatCols = [...valueCols, ...computedCols];
1045
- for (let row of flat)
1046
- for (let col of cellFormatCols) {
1047
- let example = cellFormat(row.cells[col.id]);
1048
- if (example !== void 0) {
1049
- 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);
1050
- inRow || cellSpecs.set(row.id, inRow = /* @__PURE__ */ new Map());
1051
- let spec = authoredSpec(example, sourceExample), sourceCell = sourceRow?.cells[col.id];
1052
- 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);
1203
+ }
1204
+ let cellSpecs = /* @__PURE__ */ new Map(), cellFormatCols = [...valueCols, ...computedCols];
1205
+ for (let row of flat)
1206
+ for (let col of cellFormatCols) {
1207
+ let example = cellFormat(row.cells[col.id]);
1208
+ if (example !== void 0) {
1209
+ let sourceRow = sourceRows.get(row.id), sourceColumn = sourceColumns.get(col.id), sourceExample = cellFormat(sourceRow?.cells[col.id]) ?? sourceColumn?.format ?? sourceRow?.format ?? options2.format ?? defaultExample(col), inRow = cellSpecs.get(row.id);
1210
+ inRow || cellSpecs.set(row.id, inRow = /* @__PURE__ */ new Map());
1211
+ let spec = authoredSpec(example, sourceExample), sourceCell = sourceRow?.cells[col.id];
1212
+ 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);
1213
+ }
1053
1214
  }
1215
+ let cellNamesOtherUnit = (rowId, colId, spec) => {
1216
+ let own = cellSpecs.get(rowId)?.get(colId);
1217
+ return own !== void 0 && typeof rawState2.get(rowId)?.get(colId)?.raw == "number" && unitOfSpec(own) !== unitOfSpec(spec);
1218
+ }, hoistedRowUnits = /* @__PURE__ */ new Map();
1219
+ if (forcedMagnitude !== void 0)
1220
+ for (let [rowId, spec] of rowSpecs) {
1221
+ if (rowById.get(rowId)?.scale === "money" || rowById.get(rowId)?.scale === "perUnit" || rowById.get(rowId)?.calc !== void 0 || !scales(sourceRows.get(rowId)?.format ?? "1,234") || valueCols.some((col) => cellNamesOtherUnit(rowId, col.id, spec))) continue;
1222
+ let unit = spec.magnitude === "none" ? null : unitOfSpec(spec);
1223
+ unit !== null && hoistedRowUnits.set(rowId, unit);
1224
+ }
1225
+ let ownFormatColumns = new Set([...valueCols, ...computedCols].filter(columnOwnsFormat).map((col) => col.id)), rowFormattedColumns = /* @__PURE__ */ new Set();
1226
+ for (let row of flat)
1227
+ if (!(row.calc || !rowSpecs.has(row.id)))
1228
+ for (let col of valueCols)
1229
+ !ownFormatColumns.has(col.id) && typeof rawState2.get(row.id)?.get(col.id)?.raw == "number" && rowFormattedColumns.add(col.id);
1230
+ let hoistedUnitSet = new Set(hoistedRowUnits.values()), figureRows = flat.filter((row) => !row.calc && valueCols.some((col) => typeof rawState2.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;
1231
+ function defaultExample(col) {
1232
+ if (col.kind === "computed" && calcYieldsPoints(col.calc)) return `1${locale.decimal}2%`;
1233
+ if (options2.magnitude === "million") return `1${locale.thousands}234${locale.decimal}2m`;
1234
+ if (options2.magnitude === "thousand") return `1${locale.thousands}234k`;
1235
+ let colId = col.id, maxAbs = 0, values = [];
1236
+ for (let r of flat) {
1237
+ let s = rawState2.get(r.id).get(colId);
1238
+ s && typeof s.raw == "number" && (maxAbs = Math.max(maxAbs, Math.abs(s.raw)), values.push(s.raw));
1239
+ }
1240
+ if (maxAbs >= 1e9) return `1${locale.decimal}2bn`;
1241
+ if (maxAbs >= 1e6) return `1${locale.decimal}2m`;
1242
+ if (maxAbs >= 100) return `1${locale.thousands}234`;
1243
+ let decimals = typicalDecimals(values);
1244
+ return decimals > 1 ? `0${locale.decimal}${"1234".slice(0, decimals)}` : `1${locale.decimal}2`;
1054
1245
  }
1055
- let cellNamesOtherUnit = (rowId, colId, spec) => {
1056
- let own = cellSpecs.get(rowId)?.get(colId);
1057
- return own !== void 0 && typeof rawState.get(rowId)?.get(colId)?.raw == "number" && unitOfSpec(own) !== unitOfSpec(spec);
1058
- }, hoistedRowUnits = /* @__PURE__ */ new Map();
1059
- if (forcedMagnitude !== void 0)
1060
- for (let [rowId, spec] of rowSpecs) {
1061
- if (rowById.get(rowId)?.scale === "money" || rowById.get(rowId)?.scale === "perUnit" || rowById.get(rowId)?.calc !== void 0 || !scales(sourceRows.get(rowId)?.format ?? "1,234") || valueCols.some((col) => cellNamesOtherUnit(rowId, col.id, spec))) continue;
1062
- let unit = spec.magnitude === "none" ? null : unitOfSpec(spec);
1063
- unit !== null && hoistedRowUnits.set(rowId, unit);
1064
- }
1065
- let ownFormatColumns = new Set([...valueCols, ...computedCols].filter(columnOwnsFormat).map((col) => col.id)), rowFormattedColumns = /* @__PURE__ */ new Set();
1066
- for (let row of flat)
1067
- if (!(row.calc || !rowSpecs.has(row.id)))
1068
- for (let col of valueCols)
1069
- !ownFormatColumns.has(col.id) && typeof rawState.get(row.id)?.get(col.id)?.raw == "number" && rowFormattedColumns.add(col.id);
1070
- 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;
1071
- function defaultExample(col) {
1072
- if (col.kind === "computed" && calcYieldsPoints(col.calc)) return `1${locale.decimal}2%`;
1073
- if (options.magnitude === "million") return `1${locale.thousands}234${locale.decimal}2m`;
1074
- if (options.magnitude === "thousand") return `1${locale.thousands}234k`;
1075
- let colId = col.id, maxAbs = 0, values = [];
1076
- for (let r of flat) {
1077
- let s = rawState.get(r.id).get(colId);
1078
- s && typeof s.raw == "number" && (maxAbs = Math.max(maxAbs, Math.abs(s.raw)), values.push(s.raw));
1079
- }
1080
- if (maxAbs >= 1e9) return `1${locale.decimal}2bn`;
1081
- if (maxAbs >= 1e6) return `1${locale.decimal}2m`;
1082
- if (maxAbs >= 100) return `1${locale.thousands}234`;
1083
- let decimals = typicalDecimals(values);
1084
- return decimals > 1 ? `0${locale.decimal}${"1234".slice(0, decimals)}` : `1${locale.decimal}2`;
1085
- }
1086
- let unitByCol = /* @__PURE__ */ new Map(), rollsOff = (colId, spec) => spec.magnitude !== "none" && flat.some((row) => {
1087
- if (rowSpecs.has(row.id) && (row.calc !== void 0 || row.inline === !0 || !ownFormatColumns.has(colId)) || cellSpecs.get(row.id)?.has(colId)) return !1;
1088
- let raw = rawState.get(row.id)?.get(colId)?.raw;
1089
- return typeof raw == "number" && raw !== 0 && effectiveScale(Math.abs(raw), spec).magnitude !== spec.magnitude;
1090
- }), lettersInCells = /* @__PURE__ */ new Set();
1091
- for (let col of [...valueCols, ...computedCols]) {
1092
- let spec = specs.get(col.id);
1093
- !rowFormattedColumns.has(col.id) && (rollsOff(col.id, spec) || flat.some((row) => cellNamesOtherUnit(row.id, col.id, spec))) && lettersInCells.add(col.id), unitByCol.set(col.id, rowFormattedColumns.has(col.id) || lettersInCells.has(col.id) ? null : unitOfSpec(spec));
1094
- }
1095
- 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) => {
1096
- let kind = specUnitKind(specs.get(col.id));
1097
- return kind === "percent" || kind === "pp" || headerUnitFor(col.id) === distinctUnits[0];
1098
- }) ? distinctUnits[0] : void 0, frameCarriesUnit = unitPrinted({
1099
- subtitle: resolveSubtitle(options.subtitle),
1100
- unit: candidateUnit,
1101
- unitShown: options.unitShown
1102
- }), authoredUnit = typeof options.unit == "string" ? options.unit.trim() : void 0, scaleWords = (authoredUnit?.split(/[\s$€£¥()]+/) ?? []).filter((word) => Object.values(MAGNITUDE_LABEL).some((label) => label !== "" && sameUnit(word, label))), bareScale = candidateUnit !== void 0 && [...[...valueCols, ...computedCols].map((col) => specs.get(col.id)), ...rowSpecs.values()].every((spec) => specUnitKind(spec) !== "number" || spec.prefix.trim() === "" && spec.suffix.trim() === ""), carriesScale = scaleWords.some((word) => sameUnit(word, candidateUnit ?? "")), composes = bareScale && !!authoredUnit && (carriesScale || scaleWords.length === 0 && /^(?:[A-Z]{3}|\p{Sc})$/u.test(authoredUnit)), composedUnit = composes ? carriesScale ? authoredUnit : `${authoredUnit} ${candidateUnit}` : candidateUnit, uniformUnit = composedUnit && frameCarriesUnit ? composedUnit : null;
1103
- uniformUnit !== null && options.unit !== void 0 && options.unit !== uniformUnit && !composes && warnings.push({
1104
- code: "table-unit-overridden",
1105
- severity: "warn",
1106
- field: ["options", "unit"],
1107
- message: `options.unit '${options.unit}' is not printed. The table prints '${uniformUnit}' because its column formats resolve that shared unit.`,
1108
- suggest: "Remove options.unit so the column formats supply the unit.",
1109
- fix: [{ op: "remove", path: "/options/unit" }]
1110
- });
1111
- let rowOverridesColumn = (rowId) => {
1112
- let row = rowById.get(rowId);
1113
- return row?.calc !== void 0 || row?.inline === !0;
1114
- }, specFor = (colId, rowId) => {
1115
- let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0;
1116
- if (cellSpec) return cellSpec;
1117
- let rowSpec = rowId ? rowSpecs.get(rowId) : void 0;
1118
- return rowSpec && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)) ? groupCellSpecs.get(rowId)?.get(colId) ?? rowSpec : specs.get(colId);
1119
- }, formatNumber = (raw, colId, rowId, lift = !0) => {
1120
- let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0, rowSpec = rowId ? rowSpecs.get(rowId) : void 0, rowPath = rowSpec !== void 0 && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)), base = rowPath ? rowSpec : specs.get(colId);
1121
- if (cellSpec && !sameUnit2(cellSpec, base)) return formatWithSpec(raw, lift ? cellSpec : { ...cellSpec, automatic: !1 });
1122
- let decimals = cellSpec?.decimals ?? (rowPath ? groupCellSpecs.get(rowId)?.get(colId)?.decimals : void 0) ?? base.decimals;
1123
- if (rowPath) {
1124
- if (raw === 0 && lift && !cellSpec && groupOf(rowById.get(rowId)) !== void 0) return "0";
1125
- let hoisted = rowId !== void 0 && hoistedRowUnits.has(rowId), automatic = lift && (cellSpec ? cellSpec.automatic : rowSpec.automatic);
1126
- return hoisted ? formatWithSpec(raw, { ...rowSpec, decimals, automatic, prefix: "", suffix: "", magnitudeInAffix: !0 }) : formatWithSpec(raw, { ...rowSpec, decimals, automatic });
1127
- }
1128
- 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: "", magnitudeInAffix: !0 });
1129
- return localeDerivedColumns.has(colId) && locale.minusGlyph === "-" && rendered.startsWith(MINUS) ? `-${rendered.slice(MINUS.length)}` : rendered;
1130
- }, madeNm = /* @__PURE__ */ new Set();
1131
- for (let record of records) {
1132
- if (record.kind !== "calc" || record.state !== "value") continue;
1133
- 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));
1134
- !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));
1135
- }
1136
- let displayOverride = /* @__PURE__ */ new Map(), overrideAmount = /* @__PURE__ */ new Map();
1137
- for (let col of computedCols) {
1138
- if (!("op" in col.calc) || col.calc.op !== "share") continue;
1139
- let spec = specs.get(col.id);
1140
- reconcileShares(col.id, spec);
1141
- }
1142
- function reconcileShares(colId, spec) {
1143
- let entries = [
1144
- ...leafRows.map((r) => ({ r, s: rawState.get(r.id).get(colId), shown: !0 })),
1145
- ...hiddenLeaves.map(([id, h]) => ({ r: { id }, s: h.states.get(colId), shown: !1 }))
1146
- ].filter((e) => e.s?.state === "value" && typeof e.s.raw == "number"), LAST = Number.MAX_SAFE_INTEGER;
1147
- if (entries.sort((a, b) => (folded.leafOrder.get(a.r.id) ?? LAST) - (folded.leafOrder.get(b.r.id) ?? LAST)), entries.length !== leafRows.length + hiddenLeaves.length || entries.length === 0) return;
1148
- 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), ownPrecision = entries.map((e) => {
1149
- let cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1150
- return cellSpec !== void 0 && (cellSpec.decimals ?? 1) !== decimals;
1151
- }), order = entries.map((_, i) => i).filter((i) => !ownPrecision[i]).sort((a, b) => remainders[b] - remainders[a] || a - b), adjusted = /* @__PURE__ */ new Set();
1152
- for (let i of order) {
1153
- if (deficit <= 0) break;
1154
- adjusted.add(i), deficit--;
1155
- }
1156
- entries.forEach((e, i) => {
1157
- if (ownPrecision[i] || !e.shown) return;
1158
- let shown = floors[i] + (adjusted.has(i) ? unit : 0), cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1159
- displayOverride.set(tableCellKey(e.r.id, colId), shown === 0 && e.s.raw > 0 && spec.automatic && !cellSpec ? `<${formatNumber(unit, colId)}` : formatNumber(shown, colId, e.r.id)), overrideAmount.set(tableCellKey(e.r.id, colId), shown), adjusted.has(i) && Math.abs(shown - e.s.raw) > 1e-9 && records.push({
1160
- rowId: e.r.id,
1161
- colId,
1162
- op: "share-reconcile",
1163
- // The display UNIT is half the calculation: this record says "the
1164
- // exact share, rounded up by one unit". With only the exact share in
1165
- // the receipt, the adjustment could not be checked against anything.
1166
- inputs: [
1167
- { rowId: e.r.id, colId, value: e.s.raw },
1168
- { rowId: SHARE_UNIT_ROW_ID, colId, value: unit }
1169
- ],
1170
- raw: shown,
1171
- state: "value",
1172
- displayed: formatNumber(shown, colId, e.r.id),
1173
- kind: "rounding-adjustment"
1174
- });
1175
- });
1176
- }
1177
- for (let col of [...valueCols, ...computedCols]) {
1178
- if (col.kind === "computed" ? calcYieldsPoints(col.calc) : col.percentScale === "points") continue;
1179
- let spec = col.kind === "computed" || col.format ? specs.get(col.id) : void 0;
1180
- if (!spec || !(spec.suffix ?? "").includes("%")) continue;
1181
- let vals = flat.map((r) => rawState.get(r.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1182
- vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1183
- code: "percent-scale-suspect",
1184
- severity: "warn",
1185
- 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`,
1186
- ...col.kind === "value" ? { suggest: "values already in points: set percentScale: 'points' on the column" } : {}
1187
- });
1188
- }
1189
- for (let row of flat) {
1190
- let rowSpec = rowSpecs.get(row.id);
1191
- if (!rowSpec || row.calc || !(rowSpec.suffix ?? "").includes("%")) continue;
1192
- let vals = valueCols.filter((col) => !ownFormatColumns.has(col.id) && col.percentScale !== "points").map((col) => rawState.get(row.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1193
- vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings.push({
1194
- code: "percent-scale-suspect",
1246
+ let unitByCol = /* @__PURE__ */ new Map(), rollsOff = (colId, spec) => spec.magnitude !== "none" && flat.some((row) => {
1247
+ if (rowSpecs.has(row.id) && (row.calc !== void 0 || row.inline === !0 || !ownFormatColumns.has(colId)) || cellSpecs.get(row.id)?.has(colId)) return !1;
1248
+ let raw = rawState2.get(row.id)?.get(colId)?.raw;
1249
+ return typeof raw == "number" && raw !== 0 && effectiveScale(Math.abs(raw), spec).magnitude !== spec.magnitude;
1250
+ }), lettersInCells = /* @__PURE__ */ new Set();
1251
+ for (let col of [...valueCols, ...computedCols]) {
1252
+ let spec = specs.get(col.id);
1253
+ !rowFormattedColumns.has(col.id) && (rollsOff(col.id, spec) || flat.some((row) => cellNamesOtherUnit(row.id, col.id, spec))) && lettersInCells.add(col.id), unitByCol.set(col.id, rowFormattedColumns.has(col.id) || lettersInCells.has(col.id) ? null : unitOfSpec(spec));
1254
+ }
1255
+ 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) => {
1256
+ let kind = specUnitKind(specs.get(col.id));
1257
+ return kind === "percent" || kind === "pp" || headerUnitFor(col.id) === distinctUnits[0];
1258
+ }) ? distinctUnits[0] : void 0, frameCarriesUnit = unitPrinted({
1259
+ subtitle: resolveSubtitle(options2.subtitle),
1260
+ unit: candidateUnit,
1261
+ unitShown: options2.unitShown
1262
+ }), authoredUnit = typeof options2.unit == "string" ? options2.unit.trim() : void 0, scaleWords = (authoredUnit?.split(/[\s$€£¥()]+/) ?? []).filter((word) => Object.values(MAGNITUDE_LABEL).some((label) => label !== "" && sameUnit(word, label))), bareScale = candidateUnit !== void 0 && [...[...valueCols, ...computedCols].map((col) => specs.get(col.id)), ...rowSpecs.values()].every((spec) => specUnitKind(spec) !== "number" || spec.prefix.trim() === "" && spec.suffix.trim() === ""), carriesScale = scaleWords.some((word) => sameUnit(word, candidateUnit ?? "")), composes = bareScale && !!authoredUnit && (carriesScale || scaleWords.length === 0 && /^(?:[A-Z]{3}|\p{Sc})$/u.test(authoredUnit)), composedUnit = composes ? carriesScale ? authoredUnit : `${authoredUnit} ${candidateUnit}` : candidateUnit, uniformUnit = composedUnit && frameCarriesUnit ? composedUnit : null;
1263
+ uniformUnit !== null && options2.unit !== void 0 && options2.unit !== uniformUnit && !composes && warnings2.push({
1264
+ code: "table-unit-overridden",
1195
1265
  severity: "warn",
1196
- 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`
1266
+ field: ["options", "unit"],
1267
+ message: `options.unit '${options2.unit}' is not printed. The table prints '${uniformUnit}' because its column formats resolve that shared unit.`,
1268
+ suggest: "Remove options.unit so the column formats supply the unit.",
1269
+ fix: [{ op: "remove", path: "/options/unit" }]
1197
1270
  });
1198
- }
1199
- for (let row of flat) {
1200
- if (row.role === "section") continue;
1201
- let kids = summandsOf(row.id);
1202
- if (kids.length !== 0)
1203
- for (let col of valueCols) {
1204
- if (aggregateFor(col, row) !== "sum") continue;
1205
- let spec = specFor(col.id, row.id), p = rawState.get(row.id).get(col.id);
1206
- if (p.state !== "value" || typeof p.raw != "number") continue;
1207
- 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));
1208
- if (childRaw.length !== kids.length) continue;
1209
- 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 = [
1210
- { rowId: row.id, colId: col.id, value: p.raw, role: "raw" },
1211
- { rowId: row.id, colId: col.id, value: parentShown, role: "displayed" },
1212
- ...kids.flatMap((k, i) => [
1213
- { rowId: k.id, colId: col.id, value: childRaw[i], role: "raw" },
1214
- { rowId: k.id, colId: col.id, value: childShown[i], role: "displayed" }
1215
- ])
1216
- ], unitOf2 = (candidate) => Math.pow(10, -candidate.decimals) * MAGNITUDE_DIVISOR[candidate.magnitude], displayUnit = Math.min(unitOf2(spec), minOf(kids.map((k) => unitOf2(specFor(col.id, k.id)))));
1217
- Math.abs(roundingGap) > displayUnit * 0.5 && (autoFootnotes.add(ROUNDING_FOOTNOTE), records.push({
1218
- rowId: row.id,
1219
- colId: col.id,
1220
- op: "rounding-gap",
1221
- inputs,
1222
- raw: roundingGap,
1271
+ let rowOverridesColumn = (rowId) => {
1272
+ let row = rowById.get(rowId);
1273
+ return row?.calc !== void 0 || row?.inline === !0;
1274
+ }, specFor = (colId, rowId) => {
1275
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0;
1276
+ if (cellSpec) return cellSpec;
1277
+ let rowSpec = rowId ? rowSpecs.get(rowId) : void 0;
1278
+ return rowSpec && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)) ? groupCellSpecs.get(rowId)?.get(colId) ?? rowSpec : specs.get(colId);
1279
+ }, displayFormats = /* @__PURE__ */ new Map(), displayFormat = (base, decimals, automatic, hoisted, clearCurrency = !1) => {
1280
+ let variants = displayFormats.get(base);
1281
+ variants || displayFormats.set(base, variants = /* @__PURE__ */ new Map());
1282
+ let key = `${decimals}:${automatic}:${hoisted}:${clearCurrency}`, format = variants.get(key);
1283
+ if (!format) {
1284
+ let spec = {
1285
+ ...base,
1286
+ decimals,
1287
+ automatic,
1288
+ ...clearCurrency ? { currencyWhole: void 0 } : {},
1289
+ ...hoisted ? { prefix: "", suffix: "", magnitudeInAffix: !0 } : {}
1290
+ };
1291
+ variants.set(key, format = compileNumberFormat(spec));
1292
+ }
1293
+ return format;
1294
+ }, formatNumber = (raw, colId, rowId, lift = !0) => {
1295
+ let cellSpec = rowId ? cellSpecs.get(rowId)?.get(colId) : void 0, rowSpec = rowId ? rowSpecs.get(rowId) : void 0, rowPath = rowSpec !== void 0 && (rowOverridesColumn(rowId) || !ownFormatColumns.has(colId)), base = rowPath ? rowSpec : specs.get(colId);
1296
+ if (cellSpec && !sameUnit2(cellSpec, base)) return displayFormat(cellSpec, cellSpec.decimals, lift ? cellSpec.automatic : !1, !1)(raw);
1297
+ let decimals = cellSpec?.decimals ?? (rowPath ? groupCellSpecs.get(rowId)?.get(colId)?.decimals : void 0) ?? base.decimals;
1298
+ if (rowPath) {
1299
+ if (raw === 0 && lift && !cellSpec && groupOf(rowById.get(rowId)) !== void 0) return "0";
1300
+ let hoisted = rowId !== void 0 && hoistedRowUnits.has(rowId), automatic2 = lift && (cellSpec ? cellSpec.automatic : rowSpec.automatic);
1301
+ return displayFormat(rowSpec, decimals, automatic2, hoisted)(raw);
1302
+ }
1303
+ let automatic = lift ? cellSpec ? cellSpec.automatic : base.automatic : !1, rendered = displayFormat(base, decimals, automatic, unitByCol.get(colId) != null, cellSpec !== void 0)(raw);
1304
+ return localeDerivedColumns.has(colId) && locale.minusGlyph === "-" && rendered.startsWith(MINUS) ? `-${rendered.slice(MINUS.length)}` : rendered;
1305
+ }, madeNm = /* @__PURE__ */ new Set();
1306
+ for (let record of records2) {
1307
+ if (record.kind !== "calc" || record.state !== "value") continue;
1308
+ 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));
1309
+ !nearZeroBase && (madeNm.size === 0 || !record.inputs.some((input) => madeNm.has(JSON.stringify([input.rowId, input.colId])))) || (record.raw = null, record.state = "nm", rawState2.get(record.rowId)?.set(record.colId, { raw: null, state: "nm" }), madeNm.add(JSON.stringify([record.rowId, record.colId])), nearZeroBase && autoFootnotes2.add(options2.strings?.nearZeroChange ?? localeStrings(options2.locale?.language).nearZeroChange));
1310
+ }
1311
+ let displayOverride = /* @__PURE__ */ new Map(), overrideAmount = /* @__PURE__ */ new Map();
1312
+ for (let col of computedCols) {
1313
+ if (!("op" in col.calc) || col.calc.op !== "share") continue;
1314
+ let spec = specs.get(col.id);
1315
+ reconcileShares(col.id, spec);
1316
+ }
1317
+ function reconcileShares(colId, spec) {
1318
+ let entries = [
1319
+ ...leafRows.map((r) => ({ r, s: rawState2.get(r.id).get(colId), shown: !0 })),
1320
+ ...hiddenLeaves.map(([id, h]) => ({ r: { id }, s: h.states.get(colId), shown: !1 }))
1321
+ ].filter((e) => e.s?.state === "value" && typeof e.s.raw == "number"), LAST = Number.MAX_SAFE_INTEGER;
1322
+ if (entries.sort((a, b) => (folded.leafOrder.get(a.r.id) ?? LAST) - (folded.leafOrder.get(b.r.id) ?? LAST)), entries.length !== leafRows.length + hiddenLeaves.length || entries.length === 0) return;
1323
+ 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), ownPrecision = entries.map((e) => {
1324
+ let cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1325
+ return cellSpec !== void 0 && (cellSpec.decimals ?? 1) !== decimals;
1326
+ }), order = entries.map((_, i) => i).filter((i) => !ownPrecision[i]).sort((a, b) => remainders[b] - remainders[a] || a - b), adjusted = /* @__PURE__ */ new Set();
1327
+ for (let i of order) {
1328
+ if (deficit <= 0) break;
1329
+ adjusted.add(i), deficit--;
1330
+ }
1331
+ entries.forEach((e, i) => {
1332
+ if (ownPrecision[i] || !e.shown) return;
1333
+ let shown = floors[i] + (adjusted.has(i) ? unit : 0), cellSpec = cellSpecs.get(e.r.id)?.get(colId);
1334
+ displayOverride.set(tableCellKey(e.r.id, colId), shown === 0 && e.s.raw > 0 && spec.automatic && !cellSpec ? `<${formatNumber(unit, colId)}` : formatNumber(shown, colId, e.r.id)), overrideAmount.set(tableCellKey(e.r.id, colId), shown), adjusted.has(i) && Math.abs(shown - e.s.raw) > 1e-9 && records2.push({
1335
+ rowId: e.r.id,
1336
+ colId,
1337
+ op: "share-reconcile",
1338
+ // The display UNIT is half the calculation: this record says "the
1339
+ // exact share, rounded up by one unit". With only the exact share in
1340
+ // the receipt, the adjustment could not be checked against anything.
1341
+ inputs: [
1342
+ { rowId: e.r.id, colId, value: e.s.raw },
1343
+ { rowId: SHARE_UNIT_ROW_ID, colId, value: unit }
1344
+ ],
1345
+ raw: shown,
1223
1346
  state: "value",
1224
- displayed: "",
1347
+ displayed: formatNumber(shown, colId, e.r.id),
1225
1348
  kind: "rounding-adjustment"
1226
- }));
1227
- }
1228
- }
1229
- for (let column of columns)
1230
- (column.kind === "value" || column.kind === "computed") && column.align === "left" && warnings.push({
1231
- code: "align-override-suspect",
1232
- severity: "warn",
1233
- message: `column '${column.id}' forces a numeric column left \u2014 right alignment is the comparison-safe default`,
1234
- owner: { colId: column.id }
1235
- });
1236
- let resolvedColumns = columns.map((c) => ({
1237
- id: c.id,
1238
- kind: c.kind,
1239
- label: c.label ?? (c.kind === "rowLabel" ? "" : c.id),
1240
- ...c.subLabel === void 0 ? {} : { subLabel: c.subLabel },
1241
- format: c.kind === "value" || c.kind === "computed" ? formatExamples.get(c.id) : c.kind === "date" ? c.format : void 0,
1242
- scenario: c.kind === "value" ? c.scenario : void 0,
1243
- polarity: c.kind === "value" || c.kind === "computed" ? c.polarity : void 0,
1244
- aggregate: c.kind === "value" ? c.aggregate ?? (nonAdditiveFormat(c.format) ? "none" : "sum") : "none",
1245
- groupId: data.columnGroups?.find((g) => g.columns.includes(c.id))?.id,
1246
- toggleGroup: toggleResolution.membership.get(c.id),
1247
- width: c.width,
1248
- maxWidth: c.kind === "rowLabel" ? c.maxWidth : void 0,
1249
- maxTextWidth: c.kind === "rowLabel" ? c.maxTextWidth : void 0,
1250
- wrap: c.kind === "text" ? c.wrap : void 0,
1251
- statusMark: c.kind === "status" && c.mark === "square" ? "square" : void 0,
1252
- unitLabel: uniformUnit === null && (c.kind === "value" || c.kind === "computed") ? headerUnitFor(c.id) ?? void 0 : void 0,
1253
- ...uniformUnit === null && (c.kind === "value" || c.kind === "computed") && headerUnitFor(c.id) !== null && headerScaledFor(c.id) ? { unitScaled: !0 } : {},
1254
- ...lettersInCells.has(c.id) ? { magnitudeInCells: !0 } : {},
1255
- encoding: c.kind === "encoding" ? c.encoding : void 0,
1256
- cellEncoding: resolveCellEncoding(encodingFor(options.encodings, c.id), specs.get(c.id)?.suffix.includes("%") === !0),
1257
- // The preset's own two column decisions: a benchmark's first
1258
- // column is the subject and carries the header's weight, a receipts
1259
- // table's dates sit under each other on the right.
1260
- emphasis: c.emphasis ?? (c.kind === "rowLabel" ? language.labelEmphasis : void 0),
1261
- ...c.band === void 0 ? {} : { band: c.band },
1262
- ...c.noteLine === void 0 ? {} : { noteLine: c.noteLine },
1263
- // A cohort grid centres its figures: every cell in a period column is
1264
- // the same two or three digits, and a right edge would draw a ragged
1265
- // column of gaps. A column that names its own alignment, the
1266
- // cohort size beside the label, keeps it.
1267
- 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")
1268
- })), driverToneMode = options.driverTones ?? "grouped";
1269
- function driverToneOf(row) {
1270
- return driverToneMode !== "grouped" ? driverToneMode === "always" : row.parentId !== null && flatById.get(row.parentId)?.role !== "section";
1271
- }
1272
- let resolvedRows = flat.map((row) => {
1273
- let cells = emptyIdRecord();
1274
- for (let col of columns)
1275
- cells[col.id] = resolveCell(row, col);
1276
- let hasChildren = (treeChildrenOf.get(row.id) ?? []).length > 0;
1277
- return {
1278
- id: row.id,
1279
- label: row.label,
1280
- ...row.parentId === null ? {} : { parentId: row.parentId },
1281
- hasChildren,
1282
- ...hasChildren ? { defaultExpanded: expansion.get(row.id) } : {},
1283
- level: row.level,
1284
- step: ladderStep(row, flatById, levelOffset),
1285
- ...row.kind === void 0 ? {} : { kind: row.kind },
1286
- ...row.kind === "driver" && driverToneOf(row) ? { driverTone: !0 } : {},
1287
- ...row.sign === void 0 ? {} : { sign: row.sign },
1288
- ...row.final === void 0 ? {} : { final: row.final },
1289
- ...options.signs === "operators" ? { operator: row.sign === -1 ? "\u2212" : row.kind === "result" ? "=" : row.operator } : {},
1290
- ...row.divider === !0 ? { divider: !0 } : {},
1291
- role: row.role,
1292
- relation: row.relation,
1293
- order: row.order,
1294
- ...row.polarity === void 0 ? {} : { polarity: row.polarity },
1295
- ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1296
- highlightTone: highlightedRows.has(row.id) ? rowHighlightTone(cells) : void 0,
1297
- // A forced magnitude wins: it is a claim about the whole table, and
1298
- // the letter it hoists out of the cells has to be the one the label
1299
- // prints. Without one the author's own affix stands.
1300
- ...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 },
1301
- ...row.spacer === void 0 ? {} : { spacer: row.spacer },
1302
- ...hasChildren && row.foldable === !1 ? { foldable: !1 } : {},
1303
- ...row.badge === void 0 ? {} : { badge: { text: row.badge.text, tone: row.badge.tone ?? "neutral" } },
1304
- cells
1305
- };
1306
- });
1307
- {
1308
- let resolvedById = new Map(resolvedRows.map((row) => [row.id, row]));
1309
- for (let [parentId, list] of childrenOf) {
1310
- if (parentId === null) continue;
1311
- let lines = list.filter((child) => child.inline === !0).map((child) => resolvedById.get(child.id));
1312
- lines.length > 0 && (resolvedById.get(parentId).inlineRows = lines);
1313
- }
1314
- }
1315
- function judgementTone(tone, strong) {
1316
- return options.judgements === "exceptions" && (tone === "warn" || tone === "good" && !strong) ? "neutral" : tone;
1317
- }
1318
- function blankInputs(row, col) {
1319
- let calc = row.calc ?? (col.kind === "computed" ? col.calc : void 0);
1320
- if (calc === void 0) return !1;
1321
- let gaps = calcRefs(calc).flatMap((ref) => {
1322
- 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);
1323
- if (colId === null) return [];
1324
- let state = rawState.get(rowId)?.get(colId);
1325
- return state !== void 0 && state.state === "missing" ? [{ rowId, colId }] : [];
1326
- });
1327
- return gaps.length > 0 && gaps.every(({ rowId, colId }) => {
1328
- let input = flatById.get(rowId), cell = input?.cells[colId];
1329
- return ((isCellObject(cell) ? cell.missing : void 0) ?? input?.missing) === "blank";
1349
+ });
1350
+ });
1351
+ }
1352
+ for (let col of [...valueCols, ...computedCols]) {
1353
+ if (col.kind === "computed" ? calcYieldsPoints(col.calc) : col.percentScale === "points") continue;
1354
+ let spec = col.kind === "computed" || col.format ? specs.get(col.id) : void 0;
1355
+ if (!spec || !(spec.suffix ?? "").includes("%")) continue;
1356
+ let vals = flat.map((r) => rawState2.get(r.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1357
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings2.push({
1358
+ code: "percent-scale-suspect",
1359
+ severity: "warn",
1360
+ 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`,
1361
+ ...col.kind === "value" ? { suggest: "values already in points: set percentScale: 'points' on the column" } : {}
1362
+ });
1363
+ }
1364
+ for (let row of flat) {
1365
+ let rowSpec = rowSpecs.get(row.id);
1366
+ if (!rowSpec || row.calc || !(rowSpec.suffix ?? "").includes("%")) continue;
1367
+ let vals = valueCols.filter((col) => !ownFormatColumns.has(col.id) && col.percentScale !== "points").map((col) => rawState2.get(row.id).get(col.id)).filter((s) => !!s && typeof s.raw == "number");
1368
+ vals.length > 0 && vals.every((v) => Math.abs(v.raw) <= 1.5) && warnings2.push({
1369
+ code: "percent-scale-suspect",
1370
+ severity: "warn",
1371
+ 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`
1372
+ });
1373
+ }
1374
+ for (let row of flat) {
1375
+ if (row.role === "section") continue;
1376
+ let kids = summandsOf(row.id);
1377
+ if (kids.length !== 0)
1378
+ for (let col of valueCols) {
1379
+ if (aggregateFor(col, row) !== "sum") continue;
1380
+ let spec = specFor(col.id, row.id), p = rawState2.get(row.id).get(col.id);
1381
+ if (p.state !== "value" || typeof p.raw != "number") continue;
1382
+ let childRaw = kids.map((k) => rawState2.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));
1383
+ if (childRaw.length !== kids.length) continue;
1384
+ 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 = [
1385
+ { rowId: row.id, colId: col.id, value: p.raw, role: "raw" },
1386
+ { rowId: row.id, colId: col.id, value: parentShown, role: "displayed" },
1387
+ ...kids.flatMap((k, i) => [
1388
+ { rowId: k.id, colId: col.id, value: childRaw[i], role: "raw" },
1389
+ { rowId: k.id, colId: col.id, value: childShown[i], role: "displayed" }
1390
+ ])
1391
+ ], unitOf2 = (candidate) => Math.pow(10, -candidate.decimals) * MAGNITUDE_DIVISOR[candidate.magnitude], displayUnit = Math.min(unitOf2(spec), minOf(kids.map((k) => unitOf2(specFor(col.id, k.id)))));
1392
+ Math.abs(roundingGap) > displayUnit * 0.5 && (autoFootnotes2.add(ROUNDING_FOOTNOTE), records2.push({
1393
+ rowId: row.id,
1394
+ colId: col.id,
1395
+ op: "rounding-gap",
1396
+ inputs,
1397
+ raw: roundingGap,
1398
+ state: "value",
1399
+ displayed: "",
1400
+ kind: "rounding-adjustment"
1401
+ }));
1402
+ }
1403
+ }
1404
+ for (let column of columns)
1405
+ (column.kind === "value" || column.kind === "computed") && column.align === "left" && warnings2.push({
1406
+ code: "align-override-suspect",
1407
+ severity: "warn",
1408
+ message: `column '${column.id}' forces a numeric column left \u2014 right alignment is the comparison-safe default`,
1409
+ owner: { colId: column.id }
1410
+ });
1411
+ let resolvedColumns = columns.map((c) => ({
1412
+ id: c.id,
1413
+ kind: c.kind,
1414
+ label: c.label ?? (c.kind === "rowLabel" ? "" : c.id),
1415
+ ...c.subLabel === void 0 ? {} : { subLabel: c.subLabel },
1416
+ format: c.kind === "value" || c.kind === "computed" ? formatExamples.get(c.id) : c.kind === "date" ? c.format : void 0,
1417
+ scenario: c.kind === "value" ? c.scenario : void 0,
1418
+ polarity: c.kind === "value" || c.kind === "computed" ? c.polarity : void 0,
1419
+ aggregate: c.kind === "value" ? c.aggregate ?? (nonAdditiveFormat(c.format) ? "none" : "sum") : "none",
1420
+ groupId: data.columnGroups?.find((g) => g.columns.includes(c.id))?.id,
1421
+ toggleGroup: toggleResolution.membership.get(c.id),
1422
+ width: c.width,
1423
+ maxWidth: c.kind === "rowLabel" ? c.maxWidth : void 0,
1424
+ maxTextWidth: c.kind === "rowLabel" ? c.maxTextWidth : void 0,
1425
+ wrap: c.kind === "text" ? c.wrap : void 0,
1426
+ statusMark: c.kind === "status" && c.mark === "square" ? "square" : void 0,
1427
+ unitLabel: uniformUnit === null && (c.kind === "value" || c.kind === "computed") ? headerUnitFor(c.id) ?? void 0 : void 0,
1428
+ ...uniformUnit === null && (c.kind === "value" || c.kind === "computed") && headerUnitFor(c.id) !== null && headerScaledFor(c.id) ? { unitScaled: !0 } : {},
1429
+ ...lettersInCells.has(c.id) ? { magnitudeInCells: !0 } : {},
1430
+ encoding: c.kind === "encoding" ? c.encoding : void 0,
1431
+ cellEncoding: resolveCellEncoding(encodingFor(options2.encodings, c.id), specs.get(c.id)?.suffix.includes("%") === !0),
1432
+ // The preset's own two column decisions: a benchmark's first
1433
+ // column is the subject and carries the header's weight, a receipts
1434
+ // table's dates sit under each other on the right.
1435
+ emphasis: c.emphasis ?? (c.kind === "rowLabel" ? language.labelEmphasis : void 0),
1436
+ ...c.band === void 0 ? {} : { band: c.band },
1437
+ ...c.noteLine === void 0 ? {} : { noteLine: c.noteLine },
1438
+ ...c.headAlign === void 0 ? {} : { headAlign: c.headAlign },
1439
+ // A cohort grid centres its figures: every cell in a period column is
1440
+ // the same two or three digits, and a right edge would draw a ragged
1441
+ // column of gaps. A column that names its own alignment, the
1442
+ // cohort size beside the label, keeps it.
1443
+ align: c.align ?? (c.kind === "value" || c.kind === "computed" ? isCohortDensity(options2.density ?? "regular") ? "center" : "right" : c.kind === "status" ? "center" : c.kind === "date" && language.datesRight ? "right" : "left")
1444
+ })), driverToneMode = options2.driverTones ?? "grouped";
1445
+ function driverToneOf(row) {
1446
+ return driverToneMode !== "grouped" ? driverToneMode === "always" : row.parentId !== null && flatById.get(row.parentId)?.role !== "section";
1447
+ }
1448
+ function memoIndentStep(row) {
1449
+ if (row.relation !== "ofWhich" || row.kind !== void 0 || row.parentId === null) return;
1450
+ let siblings = treeChildrenOf.get(row.parentId) ?? [];
1451
+ if (!siblings.slice(0, siblings.findIndex((sibling) => sibling.id === row.id)).some((sibling) => sibling.relation !== "ofWhich")) return;
1452
+ let parentStep = ladderStep(flatById.get(row.parentId), flatById, levelOffset);
1453
+ return parentStep < ladderStep(row, flatById, levelOffset) ? parentStep : void 0;
1454
+ }
1455
+ let resolvedRows = flat.map((row) => {
1456
+ let cells = emptyIdRecord();
1457
+ for (let col of columns)
1458
+ cells[col.id] = resolveCell(row, col);
1459
+ let hasChildren = (treeChildrenOf.get(row.id) ?? []).length > 0, indentStep = memoIndentStep(row);
1460
+ return {
1461
+ id: row.id,
1462
+ label: row.label,
1463
+ ...row.parentId === null ? {} : { parentId: row.parentId },
1464
+ hasChildren,
1465
+ ...hasChildren ? { defaultExpanded: expansion.get(row.id) } : {},
1466
+ level: row.level,
1467
+ step: ladderStep(row, flatById, levelOffset),
1468
+ ...indentStep === void 0 ? {} : { indentStep },
1469
+ ...row.kind === void 0 ? {} : { kind: row.kind },
1470
+ ...row.kind === "driver" && driverToneOf(row) ? { driverTone: !0 } : {},
1471
+ ...row.sign === void 0 ? {} : { sign: row.sign },
1472
+ ...row.final === void 0 ? {} : { final: row.final },
1473
+ ...options2.signs === "operators" ? { operator: row.sign === -1 ? "\u2212" : row.kind === "result" ? "=" : row.operator } : {},
1474
+ ...row.divider === !0 ? { divider: !0 } : {},
1475
+ role: row.role,
1476
+ relation: row.relation,
1477
+ order: row.order,
1478
+ ...row.polarity === void 0 ? {} : { polarity: row.polarity },
1479
+ ...row.inline === !0 ? { inline: !0, inlineGroup: row.inlineGroup ?? row.id } : {},
1480
+ highlightTone: highlightedRows.has(row.id) ? rowHighlightTone(cells) : void 0,
1481
+ // A forced magnitude wins: it is a claim about the whole table, and
1482
+ // the letter it hoists out of the cells has to be the one the label
1483
+ // prints. Without one the author's own affix stands.
1484
+ ...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 },
1485
+ ...row.spacer === void 0 ? {} : { spacer: row.spacer },
1486
+ ...hasChildren && row.foldable === !1 ? { foldable: !1 } : {},
1487
+ ...row.badge === void 0 ? {} : { badge: { text: row.badge.text, tone: row.badge.tone ?? "neutral" } },
1488
+ cells
1489
+ };
1330
1490
  });
1331
- }
1332
- function resolveCell(row, col) {
1333
- 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 = {
1334
- rowId: row.id,
1335
- colId: col.id,
1336
- kind: col.kind,
1337
- raw: null,
1338
- state: "missing",
1339
- displayed: "",
1340
- tone: judgementTone(obj?.tone ?? "neutral", obj?.strong),
1341
- note: obj?.note,
1342
- href: obj?.href,
1343
- ...obj?.heat === !1 ? { heat: !1 } : {},
1344
- ...obj?.strong === !0 && obj.tone !== void 0 && obj.tone !== "neutral" ? { strong: !0 } : {},
1345
- ...typeof obj?.bar == "number" && Number.isFinite(obj.bar) ? { bar: Math.min(1, Math.max(0, obj.bar)) } : {},
1346
- ...(col.kind === "value" || col.kind === "computed") && obj?.format !== void 0 ? { format: obj.format } : {},
1347
- scenario: col.kind === "value" ? col.scenario : void 0,
1348
- role: row.role,
1349
- relation: row.relation,
1350
- level: row.level
1351
- };
1352
- if (row.role === "section" && col.kind !== "rowLabel")
1353
- return { ...base, state: "na", displayed: "" };
1354
- if (obj?.state && col.kind !== "rowLabel" && col.kind !== "encoding")
1355
- return { ...base, raw: null, state: obj.state, displayed: glyphs[obj.state], tone: "neutral", ...obj.muted === !0 ? { deEmphasized: !0 } : {} };
1356
- switch (col.kind) {
1357
- case "rowLabel":
1358
- return { ...base, raw: row.label, state: "value", displayed: row.label };
1359
- case "value":
1360
- case "computed": {
1361
- let evaluated = rawState.get(row.id).get(col.id), s = evaluated ?? { raw: null, state: "missing" }, displayed, negated = !1;
1362
- if (s.state !== "value" || typeof s.raw != "number") {
1363
- 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;
1364
- displayed = state === "missing" && gapWord && missing === void 0 && evaluated !== void 0 && !(noPreviousColumn && noPrevious === "missing") && !blankInputs(row, col) ? glyphs.na : state === "missing" || noPreviousValue ? missingGlyph : glyphs[state];
1365
- } else {
1366
- 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 && (col.kind !== "computed" || row.calc !== void 0 || calcFlipsWithInputs(col.calc));
1367
- negated = negate && s.raw !== 0, 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}`);
1491
+ {
1492
+ let resolvedById = new Map(resolvedRows.map((row) => [row.id, row]));
1493
+ for (let [parentId, list] of childrenOf2) {
1494
+ if (parentId === null) continue;
1495
+ let lines = list.filter((child) => child.inline === !0).map((child) => resolvedById.get(child.id));
1496
+ lines.length > 0 && (resolvedById.get(parentId).inlineRows = lines);
1497
+ }
1498
+ }
1499
+ function judgementTone(tone, strong) {
1500
+ return options2.judgements === "exceptions" && (tone === "warn" || tone === "good" && !strong) ? "neutral" : tone;
1501
+ }
1502
+ function blankInputs(row, col) {
1503
+ let calc = row.calc ?? (col.kind === "computed" ? col.calc : void 0);
1504
+ if (calc === void 0) return !1;
1505
+ let gaps = calcRefs(calc).flatMap((ref) => {
1506
+ 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);
1507
+ if (colId === null) return [];
1508
+ let state = rawState2.get(rowId)?.get(colId);
1509
+ return state !== void 0 && state.state === "missing" ? [{ rowId, colId }] : [];
1510
+ });
1511
+ return gaps.length > 0 && gaps.every(({ rowId, colId }) => {
1512
+ let input = flatById.get(rowId), cell = input?.cells[colId];
1513
+ return ((isCellObject(cell) ? cell.missing : void 0) ?? input?.missing) === "blank";
1514
+ });
1515
+ }
1516
+ function resolveCell(row, col) {
1517
+ 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 = {
1518
+ rowId: row.id,
1519
+ colId: col.id,
1520
+ kind: col.kind,
1521
+ raw: null,
1522
+ state: "missing",
1523
+ displayed: "",
1524
+ tone: judgementTone(obj?.tone ?? "neutral", obj?.strong),
1525
+ note: obj?.note,
1526
+ href: obj?.href,
1527
+ ...obj?.heat === !1 ? { heat: !1 } : {},
1528
+ ...obj?.strong === !0 && obj.tone !== void 0 && obj.tone !== "neutral" ? { strong: !0 } : {},
1529
+ ...typeof obj?.bar == "number" && Number.isFinite(obj.bar) ? { bar: Math.min(1, Math.max(0, obj.bar)) } : {},
1530
+ ...(col.kind === "value" || col.kind === "computed") && obj?.format !== void 0 ? { format: obj.format } : {},
1531
+ scenario: col.kind === "value" ? col.scenario : void 0,
1532
+ role: row.role,
1533
+ relation: row.relation,
1534
+ level: row.level
1535
+ };
1536
+ if (row.role === "section" && col.kind !== "rowLabel")
1537
+ return { ...base, state: "na", displayed: "" };
1538
+ if (obj?.state && col.kind !== "rowLabel" && col.kind !== "encoding")
1539
+ return { ...base, raw: null, state: obj.state, displayed: glyphs[obj.state], tone: "neutral", ...obj.muted === !0 ? { deEmphasized: !0 } : {} };
1540
+ switch (col.kind) {
1541
+ case "rowLabel":
1542
+ return { ...base, raw: row.label, state: "value", displayed: row.label };
1543
+ case "value":
1544
+ case "computed": {
1545
+ let evaluated = rawState2.get(row.id).get(col.id), s = evaluated ?? { raw: null, state: "missing" }, displayed, negated = !1;
1546
+ if (s.state !== "value" || typeof s.raw != "number") {
1547
+ 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;
1548
+ displayed = state === "missing" && gapWord && missing === void 0 && evaluated !== void 0 && !(noPreviousColumn && noPrevious === "missing") && !blankInputs(row, col) ? glyphs.na : state === "missing" || noPreviousValue ? missingGlyph : glyphs[state];
1549
+ } else {
1550
+ 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 = (options2.signs ?? "signed") === "signed" && row.kind !== "driver" && row.kind !== "result" && !relativeChange && signTo(row, null) === -1 && (col.kind !== "computed" || row.calc !== void 0 || calcFlipsWithInputs(col.calc));
1551
+ negated = negate && s.raw !== 0, 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 && !(headMarksPartial && partialColumnIds.has(col.id)) && (displayed = `${displayed} ${options2.strings?.incomplete ?? localeStrings(options2.locale?.language).incomplete}`);
1552
+ }
1553
+ 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;
1554
+ if (s.state === "value" && typeof s.raw == "number" && judgmentRow) {
1555
+ if (polarity && !obj?.tone && band === void 0 && roundedNumber(s.raw, specFor(col.id, row.id)) !== 0) {
1556
+ let goodSign = polarity === "higherIsBetter" ? 1 : -1;
1557
+ tone = Math.sign(s.raw) === goodSign ? "good" : "bad";
1558
+ 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;
1559
+ (polarity === "lowerIsBetter" ? lowerJudged : higherJudged).add(measure);
1560
+ }
1561
+ let mat = col.materiality, threshold = specs.get(col.id).suffix.includes("%") ? mat?.pct : mat?.abs;
1562
+ threshold !== void 0 && Math.abs(s.raw) < threshold && (deEmphasized = !0, tone = "neutral");
1563
+ }
1564
+ obj?.muted === !0 && (deEmphasized = !0, tone = "neutral"), tone = judgementTone(tone, obj?.strong);
1565
+ 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);
1566
+ return {
1567
+ ...base,
1568
+ raw: s.raw,
1569
+ state: s.state,
1570
+ displayed,
1571
+ tone,
1572
+ deEmphasized,
1573
+ polarity,
1574
+ ...zero ? { zero: !0 } : {},
1575
+ ...negated ? { negated: !0 } : {},
1576
+ ...band === void 0 ? {} : { band: { to: band.to, ...bandIndex > 0 ? { from: obj.bands[bandIndex - 1].to } : {}, ...band.label === void 0 ? {} : { label: band.label } } }
1577
+ };
1368
1578
  }
1369
- 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;
1370
- if (s.state === "value" && typeof s.raw == "number" && judgmentRow) {
1371
- if (polarity && !obj?.tone && band === void 0 && roundedNumber(s.raw, specFor(col.id, row.id)) !== 0) {
1372
- let goodSign = polarity === "higherIsBetter" ? 1 : -1;
1373
- tone = Math.sign(s.raw) === goodSign ? "good" : "bad";
1374
- 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;
1375
- (polarity === "lowerIsBetter" ? lowerJudged : higherJudged).add(measure);
1579
+ case "status": {
1580
+ let given = typeof authored == "number" ? authored : obj?.v, written = typeof authored == "string" ? authored : typeof given == "string" ? given : null, v = written;
1581
+ if (typeof given == "number")
1582
+ return warnings2.push({
1583
+ code: "status-value-number",
1584
+ severity: "warn",
1585
+ 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.`,
1586
+ owner: { rowId: row.id, colId: col.id }
1587
+ }), { ...base, displayed: missingGlyph };
1588
+ if (v !== null && !STATUS_VALUES.includes(v)) {
1589
+ let converted = caseInsensitiveValue(v, STATUS_VALUES) ?? (Object.hasOwn(STATUS_WORDS, v.toLowerCase()) ? STATUS_WORDS[v.toLowerCase()] : void 0);
1590
+ if (converted !== void 0) {
1591
+ let rowPath = (rows, base2) => {
1592
+ for (let [index, candidate] of rows.entries()) {
1593
+ let path = [...base2, index];
1594
+ if (candidate.id === row.id) return path;
1595
+ let child = candidate.children && rowPath(candidate.children, [...path, "children"]);
1596
+ if (child) return child;
1597
+ }
1598
+ }, field = [...rowPath(data.rows, ["data", "rows"]), "cells", col.id, ...obj ? ["v"] : []];
1599
+ warnings2.push(inputConversion(field, v, converted)), v = converted;
1600
+ }
1376
1601
  }
1377
- let mat = col.materiality, threshold = specs.get(col.id).suffix.includes("%") ? mat?.pct : mat?.abs;
1378
- threshold !== void 0 && Math.abs(s.raw) < threshold && (deEmphasized = !0, tone = "neutral");
1602
+ if (v !== null && !STATUS_VALUES.includes(v))
1603
+ throw new NormalizeError(
1604
+ "status-value-invalid",
1605
+ `rows[${row.id}].cells[${col.id}]`,
1606
+ `status '${v}' is not one of: ${STATUS_VALUES.join(" \xB7 ")}; for free status text use a text column with a cell tone`,
1607
+ "Use on-track, at-risk, off-track, done or pending, or green, amber, yellow or red (any case). For free status text use a text column with a cell tone."
1608
+ );
1609
+ if (v === null) return { ...base, displayed: missingGlyph };
1610
+ 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, displayed = written === v ? labels?.[v] ?? v : labels?.[written] ?? labels?.[v] ?? v;
1611
+ return { ...base, raw: v, state: "value", displayed, tone: judgementTone(tone, obj?.strong) };
1379
1612
  }
1380
- obj?.muted === !0 && (deEmphasized = !0, tone = "neutral"), tone = judgementTone(tone, obj?.strong);
1381
- 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);
1382
- return {
1383
- ...base,
1384
- raw: s.raw,
1385
- state: s.state,
1386
- displayed,
1387
- tone,
1388
- deEmphasized,
1389
- polarity,
1390
- ...zero ? { zero: !0 } : {},
1391
- ...negated ? { negated: !0 } : {},
1392
- ...band === void 0 ? {} : { band: { to: band.to, ...bandIndex > 0 ? { from: obj.bands[bandIndex - 1].to } : {}, ...band.label === void 0 ? {} : { label: band.label } } }
1393
- };
1394
- }
1395
- case "status": {
1396
- let given = typeof authored == "number" ? authored : obj?.v, written = typeof authored == "string" ? authored : typeof given == "string" ? given : null, v = written;
1397
- if (typeof given == "number")
1398
- return warnings.push({
1399
- code: "status-value-number",
1613
+ case "date": {
1614
+ let given = typeof authored == "number" ? authored : obj?.v, v = typeof authored == "string" ? authored : typeof given == "string" ? given : null;
1615
+ if (typeof given == "number" && warnings2.push({
1616
+ code: "date-value-number",
1400
1617
  severity: "warn",
1401
- 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.`,
1618
+ message: `date cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write an ISO date (YYYY-MM-DD), or use a value or text column.`,
1402
1619
  owner: { rowId: row.id, colId: col.id }
1403
- }), { ...base, displayed: missingGlyph };
1404
- if (v !== null && !STATUS_VALUES.includes(v)) {
1405
- let converted = caseInsensitiveValue(v, STATUS_VALUES) ?? (Object.hasOwn(STATUS_WORDS, v.toLowerCase()) ? STATUS_WORDS[v.toLowerCase()] : void 0);
1406
- if (converted !== void 0) {
1407
- let rowPath = (rows, base2) => {
1408
- for (let [index, candidate] of rows.entries()) {
1409
- let path = [...base2, index];
1410
- if (candidate.id === row.id) return path;
1411
- let child = candidate.children && rowPath(candidate.children, [...path, "children"]);
1412
- if (child) return child;
1413
- }
1414
- }, field = [...rowPath(data.rows, ["data", "rows"]), "cells", col.id, ...obj ? ["v"] : []];
1415
- warnings.push(inputConversion(field, v, converted)), v = converted;
1416
- }
1620
+ }), v === null) return { ...base, displayed: missingGlyph };
1621
+ let d = parseISODate(v);
1622
+ if (!d)
1623
+ throw new NormalizeError(
1624
+ "date-invalid",
1625
+ `rows[${row.id}].cells[${col.id}]`,
1626
+ `'${v}' is not an ISO date (YYYY-MM-DD)`
1627
+ );
1628
+ let pattern = datePatterns.get(col.id);
1629
+ return { ...base, raw: v, state: "value", displayed: formatDate(d, pattern, options2.locale?.language) };
1417
1630
  }
1418
- if (v !== null && !STATUS_VALUES.includes(v))
1419
- throw new NormalizeError(
1420
- "status-value-invalid",
1421
- `rows[${row.id}].cells[${col.id}]`,
1422
- `status '${v}' is not one of: ${STATUS_VALUES.join(" \xB7 ")}; for free status text use a text column with a cell tone`,
1423
- "Use on-track, at-risk, off-track, done or pending, or green, amber, yellow or red (any case). For free status text use a text column with a cell tone."
1424
- );
1425
- if (v === null) return { ...base, displayed: missingGlyph };
1426
- 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, displayed = written === v ? labels?.[v] ?? v : labels?.[written] ?? labels?.[v] ?? v;
1427
- return { ...base, raw: v, state: "value", displayed, tone: judgementTone(tone, obj?.strong) };
1428
- }
1429
- case "date": {
1430
- let given = typeof authored == "number" ? authored : obj?.v, v = typeof authored == "string" ? authored : typeof given == "string" ? given : null;
1431
- if (typeof given == "number" && warnings.push({
1432
- code: "date-value-number",
1433
- severity: "warn",
1434
- message: `date cell rows[${row.id}].cells[${col.id}] holds the number ${given} and draws the missing dash; write an ISO date (YYYY-MM-DD), or use a value or text column.`,
1435
- owner: { rowId: row.id, colId: col.id }
1436
- }), v === null) return { ...base, displayed: missingGlyph };
1437
- let d = parseISODate(v);
1438
- if (!d)
1439
- throw new NormalizeError(
1440
- "date-invalid",
1441
- `rows[${row.id}].cells[${col.id}]`,
1442
- `'${v}' is not an ISO date (YYYY-MM-DD)`
1443
- );
1444
- let pattern = datePatterns.get(col.id);
1445
- return { ...base, raw: v, state: "value", displayed: formatDate(d, pattern, options.locale?.language) };
1446
- }
1447
- case "text": {
1448
- let v = typeof authored == "string" ? authored : typeof authored == "number" ? String(authored) : obj?.v !== void 0 ? String(obj.v) : null;
1449
- return v === null && !obj?.note ? { ...base, displayed: "" } : { ...base, raw: v, state: "value", displayed: v ?? "" };
1631
+ case "text": {
1632
+ let v = typeof authored == "string" ? authored : typeof authored == "number" ? String(authored) : obj?.v !== void 0 ? String(obj.v) : null;
1633
+ return v === null && !obj?.note ? { ...base, displayed: "" } : { ...base, raw: v, state: "value", displayed: v ?? "" };
1634
+ }
1635
+ case "encoding":
1636
+ return { ...base, state: "value", displayed: "" };
1450
1637
  }
1451
- case "encoding":
1452
- return { ...base, state: "value", displayed: "" };
1453
1638
  }
1639
+ stampRecordDisplay(records2, resolvedRows, formatNumber), sortSiblingGroups(childrenOf2, resolvedRows, resolvedColumns, options2, generatedOthers);
1640
+ let totalPos = options2.totalPosition ?? language.totalPosition, ordered = orderRows(resolvedRows, childrenOf2, totalPos);
1641
+ ordered.forEach((r, i) => r.order = i);
1642
+ for (let row of ordered) {
1643
+ if (!generatedOthers.has(row.id) || !row.hasChildren) continue;
1644
+ let members = (treeChildrenOf.get(row.id) ?? []).map((child) => child.label);
1645
+ autoFootnotes2.add(`${row.label} groups ${members.join(", ")}.`);
1646
+ }
1647
+ 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 && autoFootnotes2.add(HEAT_COLUMN_FOOTNOTE);
1648
+ let statusNote = statusDirectionNote(resolvedColumns, heatRanges(resolvedColumns, ordered), options2.colorblindSafe === !0);
1649
+ if (statusNote !== void 0 && autoFootnotes2.add(statusNote), resolvedColumns.some((column) => column.cellEncoding?.type === "arrow" && column.cellEncoding.scale === "relative" && column.kind === "computed" && column.polarity) && autoFootnotes2.add(ARROW_FOOTNOTE), lowerJudged.size && higherJudged.size) {
1650
+ let [fewer, word] = lowerJudged.size <= higherJudged.size ? [lowerJudged, "Lower"] : [higherJudged, "Higher"];
1651
+ autoFootnotes2.add(`${options2.colorblindSafe === !0 ? "The good tone" : "Green"} marks a favourable change. ${word} is better for ${[...fewer].join(", ")}.`);
1652
+ }
1653
+ let footnotes = [...autoFootnotes2];
1654
+ if (headMarksPartial) for (let column of resolvedColumns) partialColumnIds.has(column.id) && (column.partial = !0);
1655
+ if (options2.columnHeads === !1) {
1656
+ let units = [...new Set(resolvedColumns.flatMap((column) => column.unitLabel ?? []))];
1657
+ units.length > 0 && warnings2.push({
1658
+ code: "column-heads-unit-hidden",
1659
+ severity: "warn",
1660
+ field: ["options", "columnHeads"],
1661
+ message: `columnHeads: false removes the only print of the unit ${units.join(", ")}`,
1662
+ suggest: "Name the unit in the subtitle or a footnote, or use formats that print it in each cell."
1663
+ });
1664
+ }
1665
+ let result = {
1666
+ ...zeroLifts.count === liftsBefore && rawLifts === 0 ? {} : { lifted: !0 },
1667
+ table: {
1668
+ columns: resolvedColumns,
1669
+ columnGroups: (data.columnGroups ?? []).map((g) => ({
1670
+ id: g.id,
1671
+ label: g.label,
1672
+ columnIds: g.columns,
1673
+ ...g.band === void 0 ? {} : { band: g.band },
1674
+ ...g.note === void 0 ? {} : { note: g.note },
1675
+ ...g.spacer === void 0 ? {} : { spacer: g.spacer },
1676
+ ...g.heading === void 0 ? {} : { heading: g.heading },
1677
+ ...g.hoverSeries === void 0 ? {} : { hoverSeries: g.hoverSeries }
1678
+ })),
1679
+ columnToggles: toggleResolution.toggles,
1680
+ rows: ordered,
1681
+ unit: uniformUnit ?? void 0,
1682
+ ...data.levelNouns === void 0 ? {} : { levelNouns: data.levelNouns },
1683
+ footnotes,
1684
+ ...partialColumnIds.size > 0 ? { partialColumnIds: [...partialColumnIds] } : {},
1685
+ ...options2.colorblindSafe === !0 ? { colorblindSafe: !0 } : {},
1686
+ provenance: {}
1687
+ },
1688
+ computedCells: records2,
1689
+ warnings: warnings2
1690
+ };
1691
+ return evaluatedStates.set(result, rawState2), result;
1454
1692
  }
1455
- stampRecordDisplay(records, resolvedRows, formatNumber), sortSiblingGroups(childrenOf, resolvedRows, resolvedColumns, options, generatedOthers);
1456
- let totalPos = options.totalPosition ?? language.totalPosition, ordered = orderRows(resolvedRows, childrenOf, totalPos);
1457
- ordered.forEach((r, i) => r.order = i);
1458
- for (let row of ordered) {
1459
- if (!generatedOthers.has(row.id) || !row.hasChildren) continue;
1460
- let members = (treeChildrenOf.get(row.id) ?? []).map((child) => child.label);
1461
- autoFootnotes.add(`${row.label} groups ${members.join(", ")}.`);
1462
- }
1463
- 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);
1464
- let statusNote = statusDirectionNote(resolvedColumns, heatRanges(resolvedColumns, ordered), options.colorblindSafe === !0);
1465
- 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) {
1466
- let [fewer, word] = lowerJudged.size <= higherJudged.size ? [lowerJudged, "Lower"] : [higherJudged, "Higher"];
1467
- autoFootnotes.add(`${options.colorblindSafe === !0 ? "The good tone" : "Green"} marks a favourable change. ${word} is better for ${[...fewer].join(", ")}.`);
1468
- }
1469
- let footnotes = [...autoFootnotes];
1470
- if (disclosuresShown(options)) for (let column of resolvedColumns) partialColumnIds.has(column.id) && (column.partial = !0);
1471
- let result = {
1472
- ...zeroLifts.count === liftsBefore ? {} : { lifted: !0 },
1473
- table: {
1474
- columns: resolvedColumns,
1475
- columnGroups: (data.columnGroups ?? []).map((g) => ({
1476
- id: g.id,
1477
- label: g.label,
1478
- columnIds: g.columns,
1479
- ...g.band === void 0 ? {} : { band: g.band },
1480
- ...g.note === void 0 ? {} : { note: g.note },
1481
- ...g.spacer === void 0 ? {} : { spacer: g.spacer },
1482
- ...g.heading === void 0 ? {} : { heading: g.heading },
1483
- ...g.hoverSeries === void 0 ? {} : { hoverSeries: g.hoverSeries }
1484
- })),
1485
- columnToggles: toggleResolution.toggles,
1486
- rows: ordered,
1487
- unit: uniformUnit ?? void 0,
1488
- ...data.levelNouns === void 0 ? {} : { levelNouns: data.levelNouns },
1489
- footnotes,
1490
- ...partialColumnIds.size > 0 ? { partialColumnIds: [...partialColumnIds] } : {},
1491
- ...options.colorblindSafe === !0 ? { colorblindSafe: !0 } : {},
1492
- provenance: {}
1493
- },
1494
- computedCells: records,
1495
- warnings
1496
- };
1497
- return evaluatedStates.set(result, rawState), result;
1498
1693
  }
1499
1694
  var HEAT_DEFAULT_ALPHA = 0.18, HEAT_STATUS_ALPHA = 0.26;
1500
1695
  function encodingFor(encodings, columnId) {
@@ -1654,6 +1849,7 @@ function flattenRows(rows) {
1654
1849
  level,
1655
1850
  order: order++,
1656
1851
  ...row[MAGNITUDE_GROUP] === void 0 ? {} : { [MAGNITUDE_GROUP]: row[MAGNITUDE_GROUP] },
1852
+ ...row[MAGNITUDE_FIGURES] === void 0 ? {} : { [MAGNITUDE_FIGURES]: row[MAGNITUDE_FIGURES] },
1657
1853
  ...row[AUTOMATIC_FORMAT] === !0 ? { [AUTOMATIC_FORMAT]: !0 } : {}
1658
1854
  });
1659
1855
  for (let child of row.children ?? []) walk(child, row.id, level + 1);
@@ -1756,13 +1952,7 @@ function resolveColumnToggles(data, options, colById, warnings) {
1756
1952
  `every member of toggle '${toggle.id}' must belong to one columnGroup, or none of them to any`
1757
1953
  );
1758
1954
  }
1759
- for (let toggleId of Object.keys(options.columnVisibility ?? {}))
1760
- toggleIds.has(toggleId) || warnings.push({
1761
- code: "column-visibility-ref-unknown",
1762
- severity: "warn",
1763
- message: `columnVisibility references unknown toggle '${toggleId}' \u2014 no columns were changed`
1764
- });
1765
- return {
1955
+ return columnVisibilityWarnings(data.columnToggles ?? [], options, warnings), {
1766
1956
  membership,
1767
1957
  toggles: (data.columnToggles ?? []).map((toggle) => {
1768
1958
  let defaultVisible = toggle.defaultVisible ?? !1;
@@ -1776,6 +1966,15 @@ function resolveColumnToggles(data, options, colById, warnings) {
1776
1966
  })
1777
1967
  };
1778
1968
  }
1969
+ function columnVisibilityWarnings(toggles, options, warnings) {
1970
+ let ids = new Set(toggles.map((toggle) => toggle.id));
1971
+ for (let toggleId of Object.keys(options.columnVisibility ?? {}))
1972
+ ids.has(toggleId) || warnings.push({
1973
+ code: "column-visibility-ref-unknown",
1974
+ severity: "warn",
1975
+ message: `columnVisibility references unknown toggle '${toggleId}' \u2014 no columns were changed`
1976
+ });
1977
+ }
1779
1978
  function validateGroups(data, colById) {
1780
1979
  let groups = data.columnGroups ?? [], claimed = /* @__PURE__ */ new Map(), columnIndex = new Map(data.columns.map((column, index) => [column.id, index]));
1781
1980
  for (let g of groups) {
@@ -2293,19 +2492,36 @@ function inCellBarMaxima(rows, columns) {
2293
2492
 
2294
2493
  // src/core/charts/table/widths.ts
2295
2494
  var FLEX_MIN = 80, HEAT_ONLY_CELL_W = 22;
2296
- function tableWidths(table, theme, measure, options = {}, view = {}) {
2495
+ function tableWidths(table, theme, measure, options = {}, view = {}, probe) {
2496
+ if (options.columnHeads !== !1) return tableWidthsWithHeads(table, theme, measure, options, view, probe);
2497
+ let { columnHeads: _heads, ...withHeads } = options, bare = (columns) => columns.map((col) => {
2498
+ let { subLabel: _sub, unitLabel: _unit, partial: _partial, scenario: _scenario, ...rest } = col;
2499
+ return { ...rest, label: "" };
2500
+ });
2501
+ return tableWidthsWithHeads({ ...table, columns: bare(table.columns), columnGroups: table.columnGroups.map((group) => ({ ...group, heading: !1 })) }, theme, measure, withHeads, {
2502
+ ...view,
2503
+ ...view.columns === void 0 ? {} : { columns: bare(view.columns) },
2504
+ ...view.allColumns === void 0 ? {} : { allColumns: bare(view.allColumns) },
2505
+ ...view.defaultColumns === void 0 ? {} : { defaultColumns: bare(view.defaultColumns) }
2506
+ }, probe);
2507
+ }
2508
+ function tableWidthsWithHeads(table, theme, measure, options, view, probe) {
2297
2509
  let { defaultColumns, ...own } = view, shown = own.columns ?? visibleColumns(table);
2298
2510
  if (own.scroll && defaultColumns !== void 0 && (defaultColumns.length !== shown.length || defaultColumns.some((col, index) => col.id !== shown[index].id))) {
2299
- let base = tableWidths(table, theme, measure, options, { ...own, columns: defaultColumns }), track = base.tracks.find((entry) => entry.id === defaultColumns.find((col) => col.kind === "rowLabel")?.id)?.width;
2511
+ let base = tableWidthsWithHeads(table, theme, measure, options, { ...own, columns: defaultColumns }), track = base.tracks.find((entry) => entry.id === defaultColumns.find((col) => col.kind === "rowLabel")?.id)?.width;
2300
2512
  track !== void 0 && base.labelNeed !== void 0 && (own.labelKeep = Math.min(track, Math.max(base.labelNeed, base.labelBeforeFill ?? 0)));
2301
2513
  }
2302
- let regular = tableWidthsOnce(table, theme, measure, options, own), count = (view.columns ?? visibleColumns(table)).length, densePad = count >= 25 ? 3 : count >= DENSE_COLUMNS ? 5 : regular.cellPadX;
2514
+ let regular = tableWidthsOnce(table, theme, measure, options, own, probe);
2515
+ if ("widthMiss" in regular) return regular;
2516
+ let count = (view.columns ?? visibleColumns(table)).length, densePad = count >= 25 ? 3 : count >= DENSE_COLUMNS ? 5 : regular.cellPadX;
2303
2517
  if (options.cellPadX !== void 0 || densePad >= regular.cellPadX || Math.max(regular.minimumW, regular.totalW) <= (view.available ?? 1 / 0)) return regular;
2304
- let dense = tableWidthsOnce(table, theme, measure, { ...options, cellPadX: densePad }, own), regularOverflow = regular.warnings.find((warning) => warning.code === "table-overflow");
2518
+ let dense = tableWidthsOnce(table, theme, measure, { ...options, cellPadX: densePad }, own);
2519
+ if ("widthMiss" in dense) return dense;
2520
+ let regularOverflow = regular.warnings.find((warning) => warning.code === "table-overflow");
2305
2521
  return regularOverflow && (dense.warnings = dense.warnings.map((warning) => warning.code === "table-overflow" ? regularOverflow : warning)), dense;
2306
2522
  }
2307
- function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2308
- 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();
2523
+ function measureTableTracks(table, theme, measure, options, view) {
2524
+ let cols = view.columns ?? visibleColumns(table), columnIndex = new Map(cols.map((col, index) => [col.id, index])), rows = view.rows ?? visibleRows(table), fullRows = view.fullRows ?? table.rows, widthRows = view.widthRows ?? table.rows, spacerBefore = /* @__PURE__ */ new Map();
2309
2525
  for (let group of table.columnGroups) {
2310
2526
  if (group.spacer === void 0 || group.spacer <= 0) continue;
2311
2527
  let ordered = view.allColumns ?? cols, first = ordered.find((col) => group.columnIds.includes(col.id));
@@ -2318,21 +2534,19 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2318
2534
  let first = cols.find((col) => col.groupId === groupId);
2319
2535
  return first && view.groupStart.has(first.id) ? 1 : 0;
2320
2536
  }
2321
- }, 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);
2322
- function cellFont(cell) {
2323
- 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);
2324
- if (cell.role === "total" && cell.kind !== "rowLabel" && totalFace) return regularFonts.totalValue;
2325
- let font = kindFont(rowFont(theme, ladder, regularFonts, cell.role, cellStep(cell), row?.hasChildren === !0, hasChanges.has(cell.rowId)), kind, cell.kind === "rowLabel", theme);
2326
- return cell.state === "value" ? strongColumnFont(font, cols.find((col) => col.id === cell.colId), cell, kind, theme) : font;
2327
- }
2537
+ }, headingFaces = (faces) => groupHeadingFaces(view.trailingTracking ? { ...faces.group, letterSpacing: Math.round((faces.group.letterSpacing ?? 0) * 1e3) / 1e3 } : faces.group), { ladder, regularFonts, cellStep, indentStep, childCount, cellFont, inlineFont: inlineFont2, hasChanges, bodyWidths } = measuredTypography(table, theme, measure, options, view, cols, rows, widthRows), 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;
2328
2538
  function affixRoom(row, font) {
2329
2539
  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);
2330
2540
  }
2331
- let columnHeaderText = (col) => fieldHeadText(col.label, theme) + columnHeaderAffix(col);
2541
+ let columnHeaderText = (col) => {
2542
+ let text = fieldHeadText(col.label, theme) + columnHeaderAffix(col);
2543
+ return view.headGlue === !1 ? text : text.replace(/ (\S{1,2})$/u, "\xA0$1");
2544
+ };
2332
2545
  function trackWidths(faces) {
2333
- let widths2 = /* @__PURE__ */ new Map(), minimumWidths2 = /* @__PURE__ */ new Map(), wrappedOneLines = /* @__PURE__ */ new Map(), context = {
2546
+ let widths = [], minimumWidths = [], wrappedOneLines = [], context = {
2334
2547
  theme,
2335
2548
  measure,
2549
+ bodyWidths,
2336
2550
  fonts: faces,
2337
2551
  cellFont,
2338
2552
  inlineFont: inlineFont2,
@@ -2354,57 +2568,57 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2354
2568
  hint: (row) => collapsedHintWidth(row, table.levelNouns, childCount.get(row.id) ?? 0, measure, faces.hint),
2355
2569
  ...view.headLines === void 0 ? {} : { headLines: view.headLines }
2356
2570
  };
2357
- for (let col of cols) {
2358
- 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;
2571
+ for (let index = 0; index < cols.length; index++) {
2572
+ let col = cols[index], 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;
2359
2573
  if (col.kind === "encoding") {
2360
2574
  let track = (authoredTrackWidth(col, widthRows, context) ?? intrinsicWidth) + endRule;
2361
- widths2.set(col.id, track), minimumWidths2.set(col.id, track);
2575
+ widths[index] = track, minimumWidths[index] = track;
2362
2576
  continue;
2363
2577
  }
2364
2578
  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;
2365
- minimumWidths2.set(col.id, minimumWidth);
2366
- 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);
2367
- widths2.set(col.id, figures || !heatColumn(col) ? authored ?? (wrapped ? minimumWidth : intrinsicWidth) : heatOnlyWidth), wrapped && wrappedOneLines.set(col.id, intrinsicWidth);
2579
+ minimumWidths[index] = minimumWidth;
2580
+ let wrapped = view.scroll && col.wrap && col.width === void 0 && (figures || !heatColumn(col)), authoredContext = col.kind === "rowLabel" ? { ...context, labelLines: options.rowLabelLines ?? 2 } : context, authored = col.kind === "rowLabel" && col.width !== void 0 && intrinsicWidth <= col.width ? col.width : authoredTrackWidth(col, widthRows, authoredContext);
2581
+ widths[index] = figures || !heatColumn(col) ? authored ?? (wrapped ? minimumWidth : intrinsicWidth) : heatOnlyWidth, wrapped && wrappedOneLines.push({ index, width: intrinsicWidth });
2368
2582
  let extra = (col.kind === "rowLabel" ? labelLead : 0) + endRule;
2369
- if (extra > 0) for (let target of [widths2, minimumWidths2]) target.set(col.id, target.get(col.id) + extra);
2583
+ if (extra > 0) for (let target of [widths, minimumWidths]) target[index] = target[index] + extra;
2370
2584
  }
2371
2585
  {
2372
2586
  let groupFaces = headingFaces(faces), drawn = cols.map((col) => col.id), isFixed = (id) => {
2373
2587
  let col = cols.find((candidate) => candidate.id === id);
2374
2588
  return col !== void 0 && (col.width !== void 0 || !figures && heatColumn(col));
2375
2589
  };
2376
- for (let target of [widths2, minimumWidths2]) {
2377
- let floors = groupHeadingFloors(table.columnGroups, drawn, (id) => target.get(id) ?? 0, isFixed, groupFaces, measure, groupCell);
2378
- for (let [id, extra] of floors) target.set(id, target.get(id) + extra);
2590
+ for (let target of [widths, minimumWidths]) {
2591
+ let floors = groupHeadingFloors(table.columnGroups, drawn, (id) => target[columnIndex.get(id)] ?? 0, isFixed, groupFaces, measure, groupCell);
2592
+ for (let [id, extra] of floors) target[columnIndex.get(id)] = target[columnIndex.get(id)] + extra;
2379
2593
  }
2380
2594
  }
2381
2595
  let chipFloor = sectionChipFloor(widthRows, { ...context, hint: void 0 });
2382
2596
  if (labelColumn !== void 0)
2383
- for (let [target, floor] of [[widths2, sectionChipFloor(widthRows, context)], [minimumWidths2, chipFloor]]) {
2597
+ for (let [target, floor] of [[widths, sectionChipFloor(widthRows, context)], [minimumWidths, chipFloor]]) {
2384
2598
  let span = chipSpan(target);
2385
- span < floor && target.set(labelColumn.id, target.get(labelColumn.id) + floor - span);
2599
+ span < floor && (target[columnIndex.get(labelColumn.id)] = target[columnIndex.get(labelColumn.id)] + floor - span);
2386
2600
  }
2387
2601
  let labelFloor = options[LABEL_WRAP_FLOOR] === !0 && labelColumn !== void 0 ? labelWrapFloor(labelColumn, faces) + labelLead : 0;
2388
- if (labelFloor > 0) for (let target of [widths2, minimumWidths2]) target.set(labelColumn.id, Math.max(target.get(labelColumn.id), labelFloor));
2602
+ if (labelFloor > 0) for (let target of [widths, minimumWidths]) target[columnIndex.get(labelColumn.id)] = Math.max(target[columnIndex.get(labelColumn.id)], labelFloor);
2389
2603
  view.scroll && labelColumn?.width === void 0 && labelColumn !== void 0 && (labelFloor = Math.max(labelFloor, view.labelKeep ?? 0, intrinsicColumnWidth(labelColumn, widthRows, {
2390
2604
  ...context,
2391
2605
  hint: void 0,
2392
- twoLineLabels: options.rowLabelLines !== 1
2606
+ labelLines: options.rowLabelLines ?? 2
2393
2607
  }) + labelLead + (view.groupEnd?.has(labelColumn.id) ? 1 : 0)));
2394
- let wrapFloors = /* @__PURE__ */ new Map(), wouldWrap = cols.filter((col) => {
2608
+ let wrapFloors = [], wouldWrap = cols.filter((col) => {
2395
2609
  if (col.kind !== "text" || col.wrap || col.width !== void 0) return !1;
2396
2610
  let floor = wrapFloorWidth(col, widthRows, measure(columnHeaderText(col), faces.header).width, context);
2397
- return floor >= minimumWidths2.get(col.id) ? !1 : (wrapFloors.set(col.id, floor), !0);
2611
+ return floor >= minimumWidths[columnIndex.get(col.id)] ? !1 : (wrapFloors[columnIndex.get(col.id)] = floor, !0);
2398
2612
  });
2399
- return { widths: widths2, minimumWidths: minimumWidths2, context, wouldWrap, wrapFloors, chipFloor, labelFloor, wrappedOneLines };
2613
+ return { widths, minimumWidths, context, wouldWrap, wrapFloors, chipFloor, labelFloor, wrappedOneLines };
2400
2614
  }
2401
2615
  function labelWrapFloor(col, faces) {
2402
2616
  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));
2403
2617
  for (let row of rows) {
2404
2618
  let cell = row.cells[col.id];
2405
2619
  if (row.role === "section" || row.inline === !0 || !cell?.displayed) continue;
2406
- let font = cellFont(cell), indent = rowIndent(cellStep(cell));
2407
- 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))) {
2620
+ let font = cellFont(cell), indent = rowIndent(indentStep(cell));
2621
+ if (text = Math.max(text, indent + lineBlockWidth(cell.displayed, options.rowLabelLines ?? 2, font, measure, !0)), row.unitAffix !== void 0 && !(row.kind === "member" && open.has(row.id))) {
2408
2622
  let unitFont = theme.table?.qualifier === void 0 ? { ...inlineFont2(row.step, !1), ...font.style ? { style: font.style } : {} } : qualifierFont(font, theme);
2409
2623
  unit = Math.max(unit, indent + measure(row.unitAffix, unitFont).width);
2410
2624
  }
@@ -2414,76 +2628,194 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2414
2628
  return Math.ceil(Math.max(text + 2 * cellPadX2, unit + cellPadX2));
2415
2629
  }
2416
2630
  function chipSpan(target) {
2417
- return cols.slice(cols.indexOf(labelColumn)).reduce((sum, col) => sum + (target.get(col.id) ?? 0), 0);
2418
- }
2419
- 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(
2631
+ return cols.slice(cols.indexOf(labelColumn)).reduce((sum, col) => sum + (target[columnIndex.get(col.id)] ?? 0), 0);
2632
+ }
2633
+ let sumOf = (values) => values.reduce((a, b) => a + b, spacerTotal), oneLineLabelWidth, uncutLabelWidth = () => oneLineLabelWidth ??= Math.ceil(Math.max(0, maxOf(rows.map((row) => {
2634
+ let cell = row.cells[labelColumn.id];
2635
+ if (row.role === "section" || !cell?.displayed) return 0;
2636
+ let font = cellFont(cell);
2637
+ return measure(cell.displayed, font).width + affixRoom(row, font) + rowIndent(indentStep(cell)) + 2 * cellPadX2;
2638
+ })))), regular = trackWidths(regularFonts), denseFonts = cols.length >= DENSE_COLUMNS ? tableFonts(theme, ladder, cols.length) : void 0, dense = denseFonts === void 0 ? void 0 : denseFonts.header.letterSpacing === regularFonts.header.letterSpacing ? regular : trackWidths(denseFonts), sizing = dense ?? regular, reach = spacerTotal;
2639
+ for (let index = 0; index < cols.length; index++) {
2640
+ let col = cols[index], width = sizing.widths[index] ?? 0, minimum = sizing.minimumWidths[index] ?? width;
2641
+ reach += col.kind !== "rowLabel" && col.kind !== "text" ? wideTable ? Math.min(width, minimum) : width : Math.min(width, shrinkFloorWidth(col, wideTable, sizing.minimumWidths[index], sizing.labelFloor), col.kind === "rowLabel" ? minimum : width);
2642
+ }
2643
+ let minimumW = Math.max(sumOf(sizing.minimumWidths), reach), wrapMinimumWidth = dense === void 0 && table.columnGroups.length === 0 && regular.chipFloor === 0 ? cols.reduce((sum, _col, index) => sum + (regular.wrapFloors[index] ?? regular.minimumWidths[index]), spacerTotal) : void 0, regularHeadsFit = dense === void 0 || headsFit(
2420
2644
  cols,
2421
2645
  table.columnGroups,
2422
- (id) => regular.widths.get(id) ?? 0,
2646
+ (id) => regular.widths[columnIndex.get(id)] ?? 0,
2423
2647
  figures,
2424
2648
  regular.context,
2425
2649
  headingFaces(regularFonts),
2426
2650
  groupCell
2427
- ), 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);
2428
- if (view.scroll && view.fit === void 0 && Number.isFinite(available) && chosen.wrappedOneLines.size > 0) {
2429
- 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)));
2430
- if (share > 0) for (let [id, oneLine] of chosen.wrappedOneLines) {
2431
- let natural = widths.get(id);
2432
- widths.set(id, Math.floor(natural + share * Math.max(0, oneLine - natural) / want));
2651
+ ), columnIds = cols.map((col) => col.id), indices = cols.map((_col, index) => index), labelIndices = indices.filter((index) => cols[index].kind === "rowLabel" && (!view.scroll || cols[index].width === void 0)), textIndices = view.scroll ? [] : indices.filter((index) => cols[index].kind === "text"), compactIndices = view.scroll ? [] : indices.filter((index) => cols[index].kind !== "rowLabel" && cols[index].kind !== "text"), growingIndices = indices.filter((index) => {
2652
+ let col = cols[index];
2653
+ return col.width === void 0 && (col.kind === "value" || col.kind === "computed") && (figures || !heatColumn(col));
2654
+ });
2655
+ return { cols, columnIds, columnIndex, indices, labelIndices, textIndices, compactIndices, growingIndices, rows, widthRows, spacerBefore, spacerTotal, figures, wideTable, cellPadX: cellPadX2, labelColumn, labelLead, groupCell, headingFaces, regularFonts, cellStep, indentStep, childCount, indents, operatorSlot, rowIndent, cellFont, affixRoom, columnHeaderText, chipSpan, sumOf, hasChanges, uncutLabelWidth, regular, dense, minimumW, wrapMinimumWidth, regularHeadsFit };
2656
+ }
2657
+ var measuredTables = /* @__PURE__ */ new WeakMap(), measureIds = /* @__PURE__ */ new WeakMap(), nextMeasureId = 0, measureId = (fn) => {
2658
+ if (fn === void 0) return;
2659
+ let id = measureIds.get(fn);
2660
+ return id === void 0 && measureIds.set(fn, id = nextMeasureId++), id;
2661
+ };
2662
+ function measurementTheme(theme) {
2663
+ let table = theme.table;
2664
+ return [
2665
+ theme.type,
2666
+ table?.head && [table.head.size, table.head.weight, table.head.tracking, table.head.case],
2667
+ table?.section && [table.section.size, table.section.weight, table.section.tracking, table.section.case],
2668
+ table?.fixedType,
2669
+ table?.rows !== void 0,
2670
+ table?.weights,
2671
+ table?.driver?.italic,
2672
+ table?.qualifier,
2673
+ table?.operator?.width
2674
+ ];
2675
+ }
2676
+ function prepareWidthTypography(table, theme, options, cols, rows, widthRows) {
2677
+ let ladder = levelLadder(theme, options.density ?? "regular", options.target, textScaleOf(options)), regularFonts = tableFonts(theme, ladder), rowById = new Map([...widthRows, ...rows].map((row) => [row.id, row])), colById = new Map(cols.map((col) => [col.id, col])), 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, indentStep = (cell) => rowById.get(cell.rowId)?.indentStep ?? cellStep(cell), childCount = treeChildCounts(table), inlineFont2 = (level, signed) => inlineFont(theme, ladder, level, signed), cellIndex = /* @__PURE__ */ new Map(), cellFonts = [];
2678
+ function makeCellFont(cell) {
2679
+ 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);
2680
+ if (cell.role === "total" && cell.kind !== "rowLabel" && totalFace) return regularFonts.totalValue;
2681
+ let font = kindFont(rowFont(theme, ladder, regularFonts, cell.role, cellStep(cell), row?.hasChildren === !0, hasChanges.has(cell.rowId)), kind, cell.kind === "rowLabel", theme);
2682
+ return cell.state === "value" ? strongColumnFont(font, colById.get(cell.colId), cell, kind, theme) : font;
2683
+ }
2684
+ for (let row of rowById.values()) for (let col of cols) {
2685
+ let cell = row.cells[col.id];
2686
+ cell === void 0 || cellIndex.has(cell) || (cellIndex.set(cell, cellFonts.length), cellFonts.push(makeCellFont(cell)));
2687
+ }
2688
+ function cellFont(cell) {
2689
+ let index = cellIndex.get(cell);
2690
+ return index === void 0 ? makeCellFont(cell) : cellFonts[index];
2691
+ }
2692
+ let bodyWidths = {
2693
+ columnIndex: new Map(cols.map((col, index) => [col.id, index])),
2694
+ columns: cols.map(() => [])
2695
+ };
2696
+ return { ladder, regularFonts, cellStep, indentStep, childCount, cellFont, inlineFont: inlineFont2, hasChanges, bodyWidths };
2697
+ }
2698
+ var measuredBodies = /* @__PURE__ */ new WeakMap();
2699
+ function measuredTypography(table, theme, measure, options, view, cols, rows, widthRows) {
2700
+ let key = JSON.stringify([
2701
+ measurementTheme(theme),
2702
+ measureId(measure),
2703
+ measureId(view.slack),
2704
+ // Ordinary densities change row air only. Cohort densities also change the measured type.
2705
+ isCohortDensity(options.density ?? "regular") ? options.density : void 0,
2706
+ options.target,
2707
+ textScaleOf(options),
2708
+ options.inlineVisibility,
2709
+ cols.map((col) => col.id),
2710
+ rows.map((row) => row.id),
2711
+ widthRows.map((row) => row.id)
2712
+ ]), variants = measuredBodies.get(table);
2713
+ variants || measuredBodies.set(table, variants = /* @__PURE__ */ new Map());
2714
+ let measured = variants.get(key);
2715
+ return measured || (variants.size >= 64 && variants.delete(variants.keys().next().value), variants.set(key, measured = prepareWidthTypography(table, theme, options, cols, rows, widthRows))), measured;
2716
+ }
2717
+ function measuredTable(table, theme, measure, options, view) {
2718
+ let ids = (entries) => entries?.map((entry) => entry.id), key = JSON.stringify([
2719
+ measurementTheme(theme),
2720
+ measureId(measure),
2721
+ measureId(view.slack),
2722
+ isCohortDensity(options.density ?? "regular") ? options.density : void 0,
2723
+ options.target,
2724
+ textScaleOf(options),
2725
+ options.cellPadX,
2726
+ options.labelIndent,
2727
+ options.outlineMarks,
2728
+ options.figures,
2729
+ options.inlineVisibility,
2730
+ options.rowLabelLines,
2731
+ options[LABEL_WRAP_FLOOR],
2732
+ ids(view.columns),
2733
+ ids(view.rows),
2734
+ ids(view.widthRows),
2735
+ ids(view.fullRows),
2736
+ ids(view.allColumns),
2737
+ view.spacerTotal,
2738
+ view.scroll,
2739
+ view.headLines,
2740
+ view.headGlue,
2741
+ view.withMarks,
2742
+ view.trailingTracking,
2743
+ view.sortable && [...view.sortable],
2744
+ view.groupStart && [...view.groupStart],
2745
+ view.groupEnd && [...view.groupEnd],
2746
+ view.leadWidth,
2747
+ view.labelKeep
2748
+ ]), variants = measuredTables.get(table);
2749
+ variants || measuredTables.set(table, variants = /* @__PURE__ */ new Map());
2750
+ let measured = variants.get(key);
2751
+ return measured || (variants.size >= 64 && variants.delete(variants.keys().next().value), variants.set(key, measured = measureTableTracks(table, theme, measure, options, view))), measured;
2752
+ }
2753
+ function prepareTableWidthRung(table, theme, measure, options, view) {
2754
+ return { table, theme, measure, options, view, measured: measuredTable(table, theme, measure, options, view) };
2755
+ }
2756
+ function solveTableWidthRung(rung, available, options = rung.options, probe) {
2757
+ let { table, theme, measure, view } = rung, { cols, columnIds, columnIndex, indices, labelIndices, textIndices, compactIndices, growingIndices, widthRows, spacerBefore, spacerTotal, figures, wideTable, cellPadX: cellPadX2, labelColumn, labelLead, groupCell, headingFaces, regularFonts, cellStep, indentStep, childCount, indents, operatorSlot, rowIndent, cellFont, columnHeaderText, chipSpan, sumOf, hasChanges, uncutLabelWidth, regular, dense, minimumW, wrapMinimumWidth, regularHeadsFit } = rung.measured, warnings = [], chosen = dense !== void 0 && (!regularHeadsFit || !view.scroll && sumOf(regular.widths) > available) ? dense : regular, fonts = chosen.context.fonts, widths = chosen.widths.slice(), minimumWidths = chosen.minimumWidths, sizingMinimums = (dense ?? regular).minimumWidths;
2758
+ if (view.scroll && view.fit === void 0 && Number.isFinite(available) && chosen.wrappedOneLines.length > 0) {
2759
+ let want = chosen.wrappedOneLines.reduce((sum, entry) => sum + Math.max(0, entry.width - widths[entry.index]), 0), share = Math.max(0, Math.min(want, available - sumOf(widths)));
2760
+ if (share > 0) for (let { index, width: oneLine } of chosen.wrappedOneLines) {
2761
+ let natural = widths[index];
2762
+ widths[index] = Math.floor(natural + share * Math.max(0, oneLine - natural) / want);
2433
2763
  }
2434
2764
  }
2435
- 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)));
2436
- if (totalW > available && flexIds.length > 0) {
2437
- let deficit = totalW - available, beforeShrink = new Map(widths), floorOf = (col) => view.scroll ? chosen.labelFloor : shrinkFloorWidth(col, wideTable, minimumWidths, chosen.labelFloor);
2438
- for (let col of cols.filter((c) => canShrink(c) && c.kind === "rowLabel")) {
2439
- let take = Math.min(deficit, Math.max(0, widths.get(col.id) - Math.max(minimumWidths.get(col.id), view.scroll ? view.labelKeep ?? 0 : 0)));
2440
- take > 0 && (widths.set(col.id, widths.get(col.id) - take), deficit -= take);
2765
+ let totalW = sumOf(widths);
2766
+ if (probe && !view.scroll && options.cellPadX !== void 0 && cellPadX2 === probe.footerInset && probe.canvasWidth < probe.canvasWidth - available + minimumW)
2767
+ return { widthMiss: !0, minimumW, totalW, cellPadX: cellPadX2 };
2768
+ if (totalW > available && labelIndices.length + textIndices.length > 0) {
2769
+ let deficit = totalW - available, beforeShrink = widths.slice(), floorOf = (index) => view.scroll ? chosen.labelFloor : shrinkFloorWidth(cols[index], wideTable, minimumWidths[index], chosen.labelFloor);
2770
+ for (let index of labelIndices) {
2771
+ let take = Math.min(deficit, Math.max(0, widths[index] - Math.max(minimumWidths[index], view.scroll ? view.labelKeep ?? 0 : 0)));
2772
+ take > 0 && (widths[index] = widths[index] - take, deficit -= take);
2441
2773
  }
2442
2774
  for (let kind of ["text", "rowLabel"]) {
2443
2775
  if (deficit <= 0) break;
2444
- let shrinkable = cols.filter((c) => canShrink(c) && c.kind === kind).map((col) => ({
2445
- id: col.id,
2446
- room: Math.max(0, widths.get(col.id) - floorOf(col))
2776
+ let shrinkable = (kind === "text" ? textIndices : labelIndices).map((index) => ({
2777
+ index,
2778
+ room: Math.max(0, widths[index] - floorOf(index))
2447
2779
  })).filter((f) => f.room > 0), totalRoom = shrinkable.reduce((a, f) => a + f.room, 0);
2448
2780
  if (totalRoom <= 0) continue;
2449
2781
  let take = Math.min(deficit, totalRoom);
2450
2782
  for (let f of shrinkable) {
2451
2783
  let cut2 = take * f.room / totalRoom;
2452
- widths.set(f.id, Math.round(widths.get(f.id) - cut2));
2784
+ widths[f.index] = Math.round(widths[f.index] - cut2);
2453
2785
  }
2454
2786
  deficit -= take;
2455
2787
  }
2456
2788
  if (deficit <= 0) {
2457
- let flex = cols.filter((col) => canShrink(col) && (col.kind === "rowLabel" || col.kind === "text"));
2789
+ let flex = indices.filter((index) => labelIndices.includes(index) || textIndices.includes(index));
2458
2790
  for (let over = Math.ceil(sumOf(widths) - available); over > 0; over--) {
2459
- let roomOf2 = (col) => widths.get(col.id) - floorOf(col), widest = flex.reduce((best, col) => best === void 0 || roomOf2(col) > roomOf2(best) ? col : best, void 0);
2791
+ let roomOf2 = (index) => widths[index] - floorOf(index), widest = flex.reduce((best, index) => best === void 0 || roomOf2(index) > roomOf2(best) ? index : best, void 0);
2460
2792
  if (widest === void 0 || roomOf2(widest) < 1) break;
2461
- widths.set(widest.id, widths.get(widest.id) - 1);
2793
+ widths[widest] = widths[widest] - 1;
2462
2794
  }
2463
2795
  }
2464
2796
  let remaining = Math.ceil(sumOf(widths) - available);
2465
2797
  if (remaining > 0 && wideTable) {
2466
- let compactable = cols.filter((col) => canShrink(col) && col.kind !== "rowLabel" && col.kind !== "text").map((col) => col.id);
2798
+ let compactable = compactIndices;
2467
2799
  for (; remaining > 0; ) {
2468
- let changed = !1;
2469
- for (let id of compactable) {
2800
+ let open = compactable.filter((index) => widths[index] > minimumWidths[index]);
2801
+ if (open.length === 0) break;
2802
+ let rounds = Math.max(1, Math.min(Math.floor(remaining / open.length), ...open.map((index) => Math.ceil(widths[index] - minimumWidths[index]))));
2803
+ for (let index of open) {
2470
2804
  if (remaining <= 0) break;
2471
- let current = widths.get(id), minimum = minimumWidths.get(id);
2472
- current <= minimum || (widths.set(id, current - 1), remaining--, changed = !0);
2805
+ widths[index] = widths[index] - rounds, remaining -= rounds;
2473
2806
  }
2474
- if (!changed) break;
2475
2807
  }
2476
2808
  }
2477
- let printsUncut = (col) => col.wrap ? minimumWidths.get(col.id) : intrinsicColumnWidth(col, widthRows, { ...chosen.context, hint: void 0, twoLineLabels: !0 }), flexText = cols.filter((col) => canShrink(col) && col.kind === "text" && col.width === void 0), gapOf = (col) => ({ id: col.id, gap: printsUncut(col) - widths.get(col.id) }), cutGaps = flexText.filter((col) => widths.get(col.id) < beforeShrink.get(col.id)).map(gapOf), wants = cutGaps.filter((entry) => entry.gap > 0), gaps = wants.length === 0 ? [] : flexText.map((col) => cutGaps.find((entry) => entry.id === col.id) ?? gapOf(col)), wanted = wants.reduce((sum, entry) => sum + entry.gap, 0), groupFaces = headingFaces(fonts), spare = new Map(table.columnGroups.filter((group) => group.heading !== !1).map((group) => [
2809
+ let printsUncut = (col) => col.wrap ? minimumWidths[columnIndex.get(col.id)] : intrinsicColumnWidth(col, widthRows, { ...chosen.context, hint: void 0, labelLines: 2 }), flexText = textIndices.map((index) => cols[index]).filter((col) => col.width === void 0), gapOf = (col) => ({ id: col.id, gap: printsUncut(col) - widths[columnIndex.get(col.id)] }), cutGaps = flexText.filter((col) => widths[columnIndex.get(col.id)] < beforeShrink[columnIndex.get(col.id)]).map(gapOf), wants = cutGaps.filter((entry) => entry.gap > 0), gaps = wants.length === 0 ? [] : flexText.map((col) => cutGaps.find((entry) => entry.id === col.id) ?? gapOf(col)), wanted = wants.reduce((sum, entry) => sum + entry.gap, 0), groupFaces = headingFaces(fonts), spare = new Map(table.columnGroups.filter((group) => group.heading !== !1).map((group) => [
2478
2810
  group.id,
2479
- cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths.get(col.id), 0) - groupHeadingNeed(group, groupFaces, measure, groupCell)
2811
+ cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths[columnIndex.get(col.id)], 0) - groupHeadingNeed(group, groupFaces, measure, groupCell)
2480
2812
  ])), donors = gaps.filter((entry) => entry.gap < 0).map((entry) => ({
2481
2813
  id: entry.id,
2482
2814
  slack: Math.floor(-entry.gap),
2483
2815
  groups: table.columnGroups.filter((group) => spare.has(group.id) && group.columnIds.includes(entry.id))
2484
2816
  })), roomOf = (donor) => Math.max(0, Math.min(donor.slack, ...donor.groups.map((group) => spare.get(group.id)))), rooms = donors.map(roomOf), given = rooms.reduce((sum, room2) => sum + room2, 0), move = Math.floor(Math.min(wanted, given)), moved = 0, cut = (donor, amount) => {
2485
2817
  let take = Math.min(amount, roomOf(donor));
2486
- widths.set(donor.id, widths.get(donor.id) - take), donor.slack -= take;
2818
+ widths[columnIndex.get(donor.id)] = widths[columnIndex.get(donor.id)] - take, donor.slack -= take;
2487
2819
  for (let group of donor.groups) spare.set(group.id, spare.get(group.id) - take);
2488
2820
  moved += take;
2489
2821
  };
@@ -2496,12 +2828,12 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2496
2828
  let toTake = moved;
2497
2829
  for (let [index, entry] of wants.entries()) {
2498
2830
  let add = index === wants.length - 1 ? toTake : Math.min(toTake, Math.floor(moved * entry.gap / wanted));
2499
- widths.set(entry.id, widths.get(entry.id) + add), toTake -= add;
2831
+ widths[columnIndex.get(entry.id)] = widths[columnIndex.get(entry.id)] + add, toTake -= add;
2500
2832
  }
2501
2833
  }
2502
- labelColumn !== void 0 && chipSpan(widths) < chosen.chipFloor && widths.set(labelColumn.id, widths.get(labelColumn.id) + chosen.chipFloor - chipSpan(widths));
2834
+ labelColumn !== void 0 && chipSpan(widths) < chosen.chipFloor && (widths[columnIndex.get(labelColumn.id)] = widths[columnIndex.get(labelColumn.id)] + chosen.chipFloor - chipSpan(widths));
2503
2835
  }
2504
- let narrowed = cols.some((col) => col.width !== void 0 && (figures || !heatColumn(col)) && widths.get(col.id) < col.width);
2836
+ let narrowed = cols.some((col) => col.width !== void 0 && (figures || !heatColumn(col)) && widths[columnIndex.get(col.id)] < col.width);
2505
2837
  if (narrowed || sumOf(widths) > available) {
2506
2838
  let margin = resolveCanvasOptions(options).margin, frameWidth = Math.ceil(totalW);
2507
2839
  for (let pass = 0; pass < 4; pass++) {
@@ -2520,47 +2852,53 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2520
2852
  fix: [{ op: "add", path: "/options/size", value: { width: frameWidth, ...height === void 0 ? {} : { height } } }]
2521
2853
  });
2522
2854
  }
2523
- let grownFrom = /* @__PURE__ */ new Map(), grow = (id, add) => {
2524
- grownFrom.has(id) || grownFrom.set(id, widths.get(id)), widths.set(id, widths.get(id) + add);
2855
+ let grownFrom = [], grow = (id, add) => {
2856
+ let index = columnIndex.get(id);
2857
+ grownFrom[index] === void 0 && (grownFrom[index] = widths[index]), widths[index] = widths[index] + add;
2525
2858
  }, room = Number.isFinite(available) ? Math.floor(available - sumOf(widths)) : 1 / 0;
2526
2859
  if (Number.isFinite(available) && options.frameFill !== "none")
2527
2860
  for (let col of cols) {
2528
2861
  if (room < 1) break;
2529
2862
  if (col.width === void 0 || col.kind !== "value" && col.kind !== "computed" || !figures && heatColumn(col)) continue;
2530
- let add = Math.min(room, Math.ceil(minimumWidths.get(col.id) - widths.get(col.id)));
2863
+ let add = Math.min(room, Math.ceil(minimumWidths[columnIndex.get(col.id)] - widths[columnIndex.get(col.id)]));
2531
2864
  add < 1 || (grow(col.id, add), room -= add);
2532
2865
  }
2533
- for (let [id, short] of groupHeadingFloors(table.columnGroups, cols.map((col) => col.id), (member) => widths.get(member) ?? 0, () => !1, headingFaces(fonts), measure, groupCell)) {
2866
+ for (let [id, short] of groupHeadingFloors(table.columnGroups, columnIds, (member) => widths[columnIndex.get(member)] ?? 0, () => !1, headingFaces(fonts), measure, groupCell)) {
2534
2867
  let add = options.frameFill === "none" ? 0 : Math.max(0, Math.min(room, Math.ceil(short)));
2535
- if (add >= 1 && (grow(id, add), room -= add), short - add > 0.5) {
2536
- let group = table.columnGroups.find((candidate) => candidate.columnIds.includes(id));
2537
- warnings.push({
2538
- code: "table-group-heading-overflow",
2539
- severity: "warn",
2540
- message: `column group '${group.id}' heading needs ${Math.ceil(short - add)} px more than its columns' authored widths; it runs past the block`,
2541
- suggest: "Shorten the heading or its note, widen a column of the group, or give the table a wider frame."
2542
- });
2543
- }
2868
+ add >= 1 && (grow(id, add), room -= add);
2869
+ let group = table.columnGroups.find((candidate) => candidate.columnIds.includes(id)), wraps = () => !view.scroll && groupHeadingWrap(
2870
+ group,
2871
+ headingFaces(fonts),
2872
+ measure,
2873
+ cols.filter((col) => group.columnIds.includes(col.id)).reduce((sum, col) => sum + widths[columnIndex.get(col.id)], 0) - 2 * cellPadX2 - (groupCell.startRule?.(group.id) ?? 0)
2874
+ ) !== void 0;
2875
+ short - add > 0.5 && !wraps() && warnings.push({
2876
+ code: "table-group-heading-overflow",
2877
+ severity: "warn",
2878
+ message: `column group '${group.id}' heading needs ${Math.ceil(short - add)} px more than its columns' authored widths; it runs past the block`,
2879
+ suggest: "Shorten the heading or its note, widen a column of the group, or give the table a wider frame."
2880
+ });
2544
2881
  }
2545
2882
  for (let col of cols) if (figures || !heatColumn(col)) {
2546
- 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);
2547
- warnings.push(...grown === void 0 ? found : found.filter((warning) => warning.code === "table-column-widened" || widths.get(col.id) < minimumWidths.get(col.id)));
2883
+ let grown = grownFrom[columnIndex.get(col.id)], track = grown ?? widths[columnIndex.get(col.id)], minimum = col.kind === "rowLabel" && col.width !== void 0 && minimumWidths[columnIndex.get(col.id)] > track ? intrinsicColumnWidth(col, widthRows, { ...chosen.context, labelLines: options.rowLabelLines ?? 2 }) : minimumWidths[columnIndex.get(col.id)], found = authoredWidthWarnings(col, table.columns.findIndex((authored) => authored.id === col.id), track, minimum, chosen.context);
2884
+ warnings.push(...grown === void 0 ? found : found.filter((warning) => warning.code === "table-column-widened" || widths[columnIndex.get(col.id)] < minimumWidths[columnIndex.get(col.id)]));
2548
2885
  }
2549
2886
  let rowToFrame = (options.rowExtent ?? "frame") === "frame";
2550
2887
  if (Number.isFinite(available) && options.lastTrackFlex === !0 && !rowToFrame && cols.length > 0) {
2551
2888
  let slack = available - sumOf(widths), lastCol = cols[cols.length - 1];
2552
- slack > 0 && lastCol.width === void 0 && widths.set(lastCol.id, widths.get(lastCol.id) + slack);
2889
+ slack > 0 && lastCol.width === void 0 && (widths[columnIndex.get(lastCol.id)] = widths[columnIndex.get(lastCol.id)] + slack);
2553
2890
  }
2554
- let beforeFill = new Map(widths);
2891
+ let beforeFill = widths.slice();
2555
2892
  if (Number.isFinite(available) && rowToFrame && options.frameFill !== "none") {
2556
- let growing = cols.filter((col) => col.width === void 0 && (col.kind === "value" || col.kind === "computed") && (figures || !heatColumn(col))), extras = frameFillExtras(
2557
- growing.map((col) => ({ id: col.id, width: widths.get(col.id) })),
2558
- available - sumOf(widths),
2559
- options.maxGrowth,
2560
- labelColumn?.width === void 0 ? labelColumn?.id : void 0
2561
- ), labelCap = labelColumn?.maxWidth;
2562
- 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))));
2563
- for (let [id, extra] of extras) widths.set(id, widths.get(id) + extra);
2893
+ let extras = frameFillAmounts(growingIndices.map((index) => widths[index]), available - sumOf(widths), options.maxGrowth);
2894
+ for (let item = 0; item < extras.values.length; item++) {
2895
+ let index = growingIndices[item];
2896
+ widths[index] = widths[index] + extras.values[item];
2897
+ }
2898
+ if (labelColumn !== void 0 && labelColumn.width === void 0 && extras.remainder > 0) {
2899
+ let index = columnIndex.get(labelColumn.id), extra = labelColumn.maxWidth === void 0 ? extras.remainder : Math.max(0, Math.min(extras.remainder, labelColumn.maxWidth - widths[index]));
2900
+ widths[index] = widths[index] + extra;
2901
+ }
2564
2902
  }
2565
2903
  let labelNeed;
2566
2904
  if (labelColumn !== void 0 && labelColumn.width === void 0) {
@@ -2568,36 +2906,31 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2568
2906
  { ...labelColumn, maxWidth: void 0, maxTextWidth: void 0 },
2569
2907
  widthRows,
2570
2908
  { ...chosen.context, hint: void 0 }
2571
- ) + labelLead : Math.ceil(Math.max(0, maxOf(rows.map((row) => {
2572
- let cell = row.cells[labelId];
2573
- if (row.role === "section" || !cell?.displayed) return 0;
2574
- let font = cellFont(cell);
2575
- return measure(cell.displayed, font).width + affixRoom(row, font) + rowIndent(cellStep(cell)) + 2 * cellPadX2;
2576
- })))), cap = labelColumn.maxWidth !== void 0 && options[SOFT_LABEL_CAP] !== !0 ? labelColumn.maxWidth : 1 / 0;
2909
+ ) + labelLead : uncutLabelWidth(), cap = labelColumn.maxWidth !== void 0 && options[SOFT_LABEL_CAP] !== !0 ? labelColumn.maxWidth : 1 / 0;
2577
2910
  labelNeed = Math.min(need, cap);
2578
- let short = labelNeed - widths.get(labelId);
2911
+ let short = labelNeed - widths[columnIndex.get(labelId)];
2579
2912
  if (short > 0) {
2580
2913
  let outside = Number.isFinite(available) ? Math.min(short, Math.max(0, Math.floor(available - sumOf(widths)))) : 0;
2581
- widths.set(labelId, widths.get(labelId) + outside), short -= outside;
2582
- 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;
2914
+ widths[columnIndex.get(labelId)] = widths[columnIndex.get(labelId)] + outside, short -= outside;
2915
+ let grown = cols.filter((col) => col.id !== labelId && widths[columnIndex.get(col.id)] > beforeFill[columnIndex.get(col.id)]), total = grown.reduce((sum, col) => sum + widths[columnIndex.get(col.id)] - beforeFill[columnIndex.get(col.id)], 0), take = Math.min(short, Math.floor(total)), left = take;
2583
2916
  for (let [index, col] of grown.entries()) {
2584
- 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));
2585
- widths.set(col.id, widths.get(col.id) - back), left -= back;
2917
+ let extra = widths[columnIndex.get(col.id)] - beforeFill[columnIndex.get(col.id)], back = index === grown.length - 1 ? Math.min(left, Math.floor(extra)) : Math.min(left, Math.floor(take * extra / total));
2918
+ widths[columnIndex.get(col.id)] = widths[columnIndex.get(col.id)] - back, left -= back;
2586
2919
  }
2587
- widths.set(labelId, widths.get(labelId) + take - left);
2920
+ widths[columnIndex.get(labelId)] = widths[columnIndex.get(labelId)] + take - left;
2588
2921
  }
2589
2922
  }
2590
- let tracks = columnTracks((view.allColumns ?? cols).map((col) => ({ id: col.id, natural: widths.get(col.id) ?? 0 })), {
2923
+ let tracks = columnTracks((view.allColumns ?? cols).map((col) => ({ id: col.id, natural: widths[columnIndex.get(col.id)] ?? 0 })), {
2591
2924
  fit: rowToFrame ? "content" : view.fit,
2592
2925
  available: Number.isFinite(available) && (!view.scroll || view.fit !== void 0) ? Math.max(0, available - spacerTotal) : void 0,
2593
2926
  anchorId: (view.allColumns ?? cols)[0]?.id,
2594
- hidden: view.allColumns === void 0 ? void 0 : new Set(view.allColumns.filter((col) => !widths.has(col.id)).map((col) => col.id)),
2927
+ hidden: view.allColumns === void 0 ? void 0 : new Set(view.allColumns.filter((col) => !columnIndex.has(col.id)).map((col) => col.id)),
2595
2928
  fixed: new Set(cols.filter((col) => col.width !== void 0 || !figures && heatColumn(col)).map((col) => col.id)),
2596
2929
  ...options.maxGrowth === !1 ? {} : { maxGrowth: options.maxGrowth ?? DEFAULT_TRACK_GROWTH }
2597
- }), labelsWrap = labelColumn !== void 0 && labelNeed !== void 0 && widths.get(labelColumn.id) < labelNeed, gridTracks = tracks.flatMap((track, index) => {
2930
+ }), labelsWrap = labelColumn !== void 0 && labelNeed !== void 0 && widths[columnIndex.get(labelColumn.id)] < labelNeed, gridTracks = tracks.flatMap((track, index) => {
2598
2931
  let spacer = spacerBefore.get(track.id), drawn = index === 0 && (view.frameStart ?? 0) > 0 ? { ...track, width: track.width + view.frameStart } : track;
2599
2932
  return spacer === void 0 ? [drawn] : [{ id: `bp-spacer:${track.id}`, natural: spacer, width: spacer }, drawn];
2600
- }), labelBeforeFill = labelColumn === void 0 ? void 0 : beforeFill.get(labelColumn.id);
2933
+ }), labelBeforeFill = labelColumn === void 0 ? void 0 : beforeFill[columnIndex.get(labelColumn.id)];
2601
2934
  return {
2602
2935
  tracks,
2603
2936
  gridTracks,
@@ -2606,6 +2939,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2606
2939
  labelNeed,
2607
2940
  labelBeforeFill,
2608
2941
  labelsWrap,
2942
+ columnIndex,
2609
2943
  widths,
2610
2944
  minimumWidths,
2611
2945
  sizingMinimums,
@@ -2613,7 +2947,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2613
2947
  minimumW,
2614
2948
  fonts,
2615
2949
  regularFonts,
2616
- context: chosen.context,
2950
+ context: chosen.context.theme === theme ? chosen.context : { ...chosen.context, theme },
2617
2951
  wouldWrap: (dense ?? regular).wouldWrap,
2618
2952
  wrapMinimumWidth,
2619
2953
  warnings,
@@ -2621,6 +2955,7 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2621
2955
  rowIndent,
2622
2956
  cellFont,
2623
2957
  cellStep,
2958
+ indentStep,
2624
2959
  columnHeaderText,
2625
2960
  indents,
2626
2961
  operatorSlot,
@@ -2628,16 +2963,16 @@ function tableWidthsOnce(table, theme, measure, options = {}, view = {}) {
2628
2963
  hasChanges
2629
2964
  };
2630
2965
  }
2631
- function shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor = 0) {
2632
- 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;
2966
+ function materializeTableWidthPlan(plan) {
2967
+ let { columnIndex, ...rest } = plan, map = (values) => new Map([...columnIndex].map(([id, index]) => [id, values[index]]));
2968
+ return { ...rest, widths: map(plan.widths), minimumWidths: map(plan.minimumWidths), sizingMinimums: map(plan.sizingMinimums) };
2633
2969
  }
2634
- function shrinkReach(cols, flexIds, wideTable, drawn, minimumWidths, labelFloor = 0) {
2635
- return new Map(cols.map((col) => {
2636
- let width = drawn.get(col.id) ?? 0, minimum = minimumWidths.get(col.id) ?? width;
2637
- if (!flexIds.includes(col.id)) return [col.id, wideTable ? Math.min(width, minimum) : width];
2638
- let floor = shrinkFloorWidth(col, wideTable, minimumWidths, labelFloor);
2639
- return [col.id, Math.min(width, floor, col.kind === "rowLabel" ? minimum : width)];
2640
- }));
2970
+ function tableWidthsOnce(table, theme, measure, options = {}, view = {}, probe) {
2971
+ let result = solveTableWidthRung(prepareTableWidthRung(table, theme, measure, options, view), view.available ?? 1 / 0, options, probe);
2972
+ return result.widthMiss === !0 ? result : materializeTableWidthPlan(result);
2973
+ }
2974
+ function shrinkFloorWidth(col, wideTable, minimumWidth, labelFloor = 0) {
2975
+ 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, minimumWidth ?? FLEX_MIN) : FLEX_MIN;
2641
2976
  }
2642
2977
  function tableDisplayFloor(table, theme, options, target, width, frame) {
2643
2978
  let ladder = levelLadder(theme, options.density ?? "regular", target, textScaleOf(options)), fonts = tableFonts(theme, ladder), floors = targetFloorsPx(target), scale = 0.9, include = (size, role) => {
@@ -2647,7 +2982,7 @@ function tableDisplayFloor(table, theme, options, target, width, frame) {
2647
2982
  let includeHead = (size) => {
2648
2983
  scale = Math.max(scale, tableHeadFloorPx(target) / size);
2649
2984
  };
2650
- 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);
2985
+ options.columnHeads !== !1 && (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));
2651
2986
  for (let row of table.rows) {
2652
2987
  if (row.inline) continue;
2653
2988
  let hasChanges = visibleInlineRows(row, options.inlineVisibility).length > 0;
@@ -2687,6 +3022,8 @@ export {
2687
3022
  emitHeat,
2688
3023
  ZERO_LIFT,
2689
3024
  columnHeaderAffix,
3025
+ prepareTableData,
3026
+ resolvePreparedTable,
2690
3027
  resolveTable,
2691
3028
  cellHoldsNumber,
2692
3029
  numericCell,
@@ -2711,6 +3048,8 @@ export {
2711
3048
  groupSpans,
2712
3049
  inCellBarMaxima,
2713
3050
  tableWidths,
3051
+ prepareTableWidthRung,
3052
+ solveTableWidthRung,
2714
3053
  tableDisplayFloor,
2715
3054
  belowTableViewportFloor,
2716
3055
  tableFrameMode