boardplot 0.0.0-stage → 0.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (818) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE.md +180 -0
  4. package/README.md +208 -2
  5. package/THIRD_PARTY_NOTICES.md +1110 -0
  6. package/dist/DiagnosticDetails-UNYNYCAH.js +69 -0
  7. package/dist/ReaderBox-VOJSJ66R.js +137 -0
  8. package/dist/annotateEngine-DLMFJZ67.js +30 -0
  9. package/dist/build-identity.json +6 -0
  10. package/dist/chunk-24BHMKDD.js +83 -0
  11. package/dist/chunk-263SZKIL.js +8 -0
  12. package/dist/chunk-27QADBDV.js +211 -0
  13. package/dist/chunk-2CVH5E57.js +128 -0
  14. package/dist/chunk-2DOR5SS6.js +446 -0
  15. package/dist/chunk-2EQE4E3I.js +22 -0
  16. package/dist/chunk-2FNNAPCI.js +24 -0
  17. package/dist/chunk-2L2Q53EP.js +251 -0
  18. package/dist/chunk-2LMCD3ZR.js +6 -0
  19. package/dist/chunk-2ND7ZITT.js +3069 -0
  20. package/dist/chunk-2QT5ZUHO.js +2937 -0
  21. package/dist/chunk-2RSG7JYI.js +24 -0
  22. package/dist/chunk-2V6CLH33.js +1392 -0
  23. package/dist/chunk-2VWJ5BGO.js +566 -0
  24. package/dist/chunk-2WNYRWHG.js +51 -0
  25. package/dist/chunk-323YZWYJ.js +548 -0
  26. package/dist/chunk-33PB4V6K.js +382 -0
  27. package/dist/chunk-33PLBIMA.js +176 -0
  28. package/dist/chunk-3A2IEBCN.js +195 -0
  29. package/dist/chunk-3D3D3D23.js +25 -0
  30. package/dist/chunk-3EZRM4YM.js +92 -0
  31. package/dist/chunk-3H2W76TB.js +2353 -0
  32. package/dist/chunk-3JEQGGVD.js +19 -0
  33. package/dist/chunk-3QWZAEW5.js +26 -0
  34. package/dist/chunk-3SIRPKMP.js +12 -0
  35. package/dist/chunk-3SQCCESO.js +1592 -0
  36. package/dist/chunk-3XHJHQWU.js +42 -0
  37. package/dist/chunk-4G2O2ZPJ.js +83 -0
  38. package/dist/chunk-4JLBVIGW.js +24 -0
  39. package/dist/chunk-4RRNJLCM.js +746 -0
  40. package/dist/chunk-4UVW5WU6.js +76 -0
  41. package/dist/chunk-4X66BTP5.js +344 -0
  42. package/dist/chunk-53OYF4ZT.js +687 -0
  43. package/dist/chunk-57ZGVAU3.js +179 -0
  44. package/dist/chunk-5HECRVXJ.js +62 -0
  45. package/dist/chunk-5LGSRWFC.js +63 -0
  46. package/dist/chunk-5LYXD6ME.js +1112 -0
  47. package/dist/chunk-66RFKRGO.js +28 -0
  48. package/dist/chunk-6KWIQ5KF.js +18 -0
  49. package/dist/chunk-6OCR6ITN.js +72 -0
  50. package/dist/chunk-6RBTTCQD.js +802 -0
  51. package/dist/chunk-6Y7EXYLR.js +563 -0
  52. package/dist/chunk-7CTKTIPF.js +613 -0
  53. package/dist/chunk-7EVIIADO.js +185 -0
  54. package/dist/chunk-7X2ZYVAX.js +89 -0
  55. package/dist/chunk-7X65ZQN4.js +38 -0
  56. package/dist/chunk-A4QZXLXF.js +7 -0
  57. package/dist/chunk-A6CQPJWR.js +49 -0
  58. package/dist/chunk-A7IEVBYI.js +35 -0
  59. package/dist/chunk-ACXX2JNL.js +6 -0
  60. package/dist/chunk-ADKCLH3Z.js +98 -0
  61. package/dist/chunk-ADWSGPH5.js +23 -0
  62. package/dist/chunk-AG2CJ4JY.js +203 -0
  63. package/dist/chunk-AHQ4L3BE.js +30 -0
  64. package/dist/chunk-AOQ6VF5H.js +6 -0
  65. package/dist/chunk-AQROQDLR.js +3303 -0
  66. package/dist/chunk-AWTG3RFF.js +85 -0
  67. package/dist/chunk-B54RN2FD.js +692 -0
  68. package/dist/chunk-B67K6OWJ.js +48 -0
  69. package/dist/chunk-B6GFKYBZ.js +40 -0
  70. package/dist/chunk-BBL3R5YZ.js +186 -0
  71. package/dist/chunk-BBRBCMNR.js +28 -0
  72. package/dist/chunk-BIDIGDGH.js +6 -0
  73. package/dist/chunk-BLFWUMTD.js +12 -0
  74. package/dist/chunk-BM6SFFWF.js +6 -0
  75. package/dist/chunk-BMRD6MAH.js +24 -0
  76. package/dist/chunk-BPKXEMRE.js +197 -0
  77. package/dist/chunk-BUPLB3EX.js +129 -0
  78. package/dist/chunk-BW5VLBSZ.js +15 -0
  79. package/dist/chunk-BWGRWGVA.js +295 -0
  80. package/dist/chunk-BWLOXQDV.js +131 -0
  81. package/dist/chunk-BWTX7LUG.js +203 -0
  82. package/dist/chunk-C54QLNE4.js +69 -0
  83. package/dist/chunk-CAQ5P4VN.js +296 -0
  84. package/dist/chunk-CCCEBIUZ.js +296 -0
  85. package/dist/chunk-CDZHNLO6.js +42 -0
  86. package/dist/chunk-CJGSJKPO.js +25 -0
  87. package/dist/chunk-CN7JRHST.js +25 -0
  88. package/dist/chunk-CNX7EGSU.js +266 -0
  89. package/dist/chunk-COYOTQC2.js +75 -0
  90. package/dist/chunk-CRNMNZJD.js +1161 -0
  91. package/dist/chunk-CUVUDK4O.js +68 -0
  92. package/dist/chunk-CWDHCSL2.js +2919 -0
  93. package/dist/chunk-CYOJZ3GQ.js +631 -0
  94. package/dist/chunk-D4SOADBD.js +19 -0
  95. package/dist/chunk-D7SHZDA3.js +1808 -0
  96. package/dist/chunk-DAVHGK27.js +657 -0
  97. package/dist/chunk-DCCJRLAJ.js +422 -0
  98. package/dist/chunk-DCTCUZ5L.js +51 -0
  99. package/dist/chunk-DDCB7ZA5.js +2511 -0
  100. package/dist/chunk-DDI2W4TR.js +149 -0
  101. package/dist/chunk-DIHUGBZO.js +61 -0
  102. package/dist/chunk-DJHIQWSG.js +25 -0
  103. package/dist/chunk-DO5OZJAO.js +302 -0
  104. package/dist/chunk-DOFYKPTC.js +18 -0
  105. package/dist/chunk-DRTA6JG5.js +160 -0
  106. package/dist/chunk-DRW6KGBK.js +1062 -0
  107. package/dist/chunk-DU4A5AOY.js +1156 -0
  108. package/dist/chunk-DYS7EIXY.js +294 -0
  109. package/dist/chunk-E4IQ6M4S.js +24 -0
  110. package/dist/chunk-EFUWFB64.js +24 -0
  111. package/dist/chunk-EHBB2Z4D.js +290 -0
  112. package/dist/chunk-EHVESNLV.js +30 -0
  113. package/dist/chunk-EJPVVGD7.js +67 -0
  114. package/dist/chunk-EKQK5D6G.js +14 -0
  115. package/dist/chunk-EUADDXAV.js +30 -0
  116. package/dist/chunk-F6CNPC4L.js +47 -0
  117. package/dist/chunk-FBAYZSFC.js +2806 -0
  118. package/dist/chunk-FBB4BWKN.js +30 -0
  119. package/dist/chunk-FF23FYQD.js +1269 -0
  120. package/dist/chunk-FG6EDGMI.js +53 -0
  121. package/dist/chunk-FHA3KMFC.js +43 -0
  122. package/dist/chunk-FIANWJXX.js +19 -0
  123. package/dist/chunk-FIWNDOMO.js +6 -0
  124. package/dist/chunk-FV3VF36K.js +2721 -0
  125. package/dist/chunk-G5FMTRG5.js +37 -0
  126. package/dist/chunk-GCBOHVDZ.js +229 -0
  127. package/dist/chunk-GDOW2KNP.js +19 -0
  128. package/dist/chunk-GTG3IGLF.js +2674 -0
  129. package/dist/chunk-GZTNTHSW.js +21 -0
  130. package/dist/chunk-H4H4O62O.js +46 -0
  131. package/dist/chunk-H5G7T35P.js +24 -0
  132. package/dist/chunk-H63XQ3OO.js +942 -0
  133. package/dist/chunk-H67RTX46.js +43 -0
  134. package/dist/chunk-HA4IPWMM.js +841 -0
  135. package/dist/chunk-HKYTOJLV.js +33 -0
  136. package/dist/chunk-HOAH5XBR.js +542 -0
  137. package/dist/chunk-HTYFQHRC.js +24 -0
  138. package/dist/chunk-HYY5V2KL.js +19 -0
  139. package/dist/chunk-HZI56ASJ.js +79 -0
  140. package/dist/chunk-I6VAWNNU.js +24 -0
  141. package/dist/chunk-IBXXZVG7.js +80 -0
  142. package/dist/chunk-IDDA5INB.js +60 -0
  143. package/dist/chunk-IK4BHOPZ.js +33 -0
  144. package/dist/chunk-IL5T7I2A.js +27 -0
  145. package/dist/chunk-ILSXT6KT.js +24 -0
  146. package/dist/chunk-IV2UXZXX.js +16 -0
  147. package/dist/chunk-IYEFEBRN.js +41 -0
  148. package/dist/chunk-IYMI7YI4.js +829 -0
  149. package/dist/chunk-J6I2YFJH.js +58 -0
  150. package/dist/chunk-JFBEAUJ6.js +24 -0
  151. package/dist/chunk-JR7Y5ONB.js +27 -0
  152. package/dist/chunk-JSEYUJUQ.js +836 -0
  153. package/dist/chunk-JYBT2JNY.js +61 -0
  154. package/dist/chunk-K3HSQPSM.js +24 -0
  155. package/dist/chunk-KAXJFL7N.js +43 -0
  156. package/dist/chunk-KDMKHR5A.js +32 -0
  157. package/dist/chunk-KKWZWP67.js +24 -0
  158. package/dist/chunk-KOJ5QETJ.js +8 -0
  159. package/dist/chunk-KPKXJYQH.js +19 -0
  160. package/dist/chunk-KSJVENRU.js +113 -0
  161. package/dist/chunk-KZJOV4QW.js +33 -0
  162. package/dist/chunk-KZS46KDY.js +58 -0
  163. package/dist/chunk-L3JWM7FR.js +50 -0
  164. package/dist/chunk-L4S6UFTL.js +26 -0
  165. package/dist/chunk-L6DJ4ZY5.js +2008 -0
  166. package/dist/chunk-L7RHB734.js +23 -0
  167. package/dist/chunk-LCWJS34U.js +38 -0
  168. package/dist/chunk-LFTAMH7I.js +24 -0
  169. package/dist/chunk-LFX7W4B7.js +113 -0
  170. package/dist/chunk-LINZPU5D.js +8 -0
  171. package/dist/chunk-LIWLBLCT.js +83 -0
  172. package/dist/chunk-LNKY5Z2X.js +23 -0
  173. package/dist/chunk-LS7HVBI7.js +24 -0
  174. package/dist/chunk-M4EUXOLU.js +170 -0
  175. package/dist/chunk-M4SPKUZE.js +7 -0
  176. package/dist/chunk-M4YLED7M.js +17 -0
  177. package/dist/chunk-MBKZYJRC.js +1424 -0
  178. package/dist/chunk-MCYM3RNF.js +227 -0
  179. package/dist/chunk-MF6IVSBJ.js +48 -0
  180. package/dist/chunk-MIAPBQCA.js +24 -0
  181. package/dist/chunk-MJZHFH5R.js +1075 -0
  182. package/dist/chunk-MQFCG4KS.js +1467 -0
  183. package/dist/chunk-MVV6RQMG.js +128 -0
  184. package/dist/chunk-MYMT5KJL.js +1182 -0
  185. package/dist/chunk-MZL6LGKO.js +587 -0
  186. package/dist/chunk-N23YFPPI.js +47 -0
  187. package/dist/chunk-N3G2FYDL.js +300 -0
  188. package/dist/chunk-N3TPMXS3.js +161 -0
  189. package/dist/chunk-N73IBH55.js +58 -0
  190. package/dist/chunk-N7J7CZS6.js +43 -0
  191. package/dist/chunk-NCB3YLHF.js +28 -0
  192. package/dist/chunk-NHQGRKEA.js +63 -0
  193. package/dist/chunk-NKIYLFXZ.js +2774 -0
  194. package/dist/chunk-NOSDEJ3K.js +25934 -0
  195. package/dist/chunk-NQDVMUHX.js +433 -0
  196. package/dist/chunk-NSSNYY6Y.js +58 -0
  197. package/dist/chunk-NY5NUFDZ.js +117 -0
  198. package/dist/chunk-O3S2KNIW.js +25 -0
  199. package/dist/chunk-O3VN6BTL.js +24 -0
  200. package/dist/chunk-ONZLC47B.js +88 -0
  201. package/dist/chunk-OQEBOVUO.js +30 -0
  202. package/dist/chunk-OUEGGWH7.js +24 -0
  203. package/dist/chunk-OURX73UJ.js +728 -0
  204. package/dist/chunk-P25VEGGX.js +24 -0
  205. package/dist/chunk-P26Z62UV.js +24 -0
  206. package/dist/chunk-P5RNWMZC.js +2984 -0
  207. package/dist/chunk-P6KZIZDV.js +987 -0
  208. package/dist/chunk-PEUSKIFV.js +168 -0
  209. package/dist/chunk-PFVTYFSL.js +24 -0
  210. package/dist/chunk-PWROWDZS.js +137 -0
  211. package/dist/chunk-Q3CV2JJ2.js +3650 -0
  212. package/dist/chunk-QBR6IKIX.js +50 -0
  213. package/dist/chunk-QGCEHR6S.js +13 -0
  214. package/dist/chunk-QHRE2M6V.js +26 -0
  215. package/dist/chunk-QKL7IY42.js +38 -0
  216. package/dist/chunk-QO6HEXIZ.js +272 -0
  217. package/dist/chunk-QOIVXZUF.js +24 -0
  218. package/dist/chunk-QPWRHDLZ.js +17 -0
  219. package/dist/chunk-QSXK6PJL.js +19 -0
  220. package/dist/chunk-QTZVVZ2A.js +54 -0
  221. package/dist/chunk-QWXWVPNE.js +18 -0
  222. package/dist/chunk-QY5ZKUWY.js +383 -0
  223. package/dist/chunk-QZAT46PP.js +95 -0
  224. package/dist/chunk-RA66JA3D.js +24 -0
  225. package/dist/chunk-REOPXBUR.js +600 -0
  226. package/dist/chunk-RGZGLKFB.js +648 -0
  227. package/dist/chunk-RL3NUWMY.js +3378 -0
  228. package/dist/chunk-RNOJSEES.js +16 -0
  229. package/dist/chunk-ROXO4R3J.js +16 -0
  230. package/dist/chunk-RPIW5T55.js +40 -0
  231. package/dist/chunk-RQ5DNYLG.js +10 -0
  232. package/dist/chunk-RZNYW7UP.js +133 -0
  233. package/dist/chunk-S32YYDIB.js +420 -0
  234. package/dist/chunk-S4QSJAGY.js +44 -0
  235. package/dist/chunk-S6UX7KB6.js +335 -0
  236. package/dist/chunk-SDSONLMZ.js +2546 -0
  237. package/dist/chunk-SGD3ZHID.js +250 -0
  238. package/dist/chunk-SKRSCTT5.js +28 -0
  239. package/dist/chunk-SMCDXUIO.js +24 -0
  240. package/dist/chunk-SPTPFY4S.js +528 -0
  241. package/dist/chunk-SREWFAAJ.js +90 -0
  242. package/dist/chunk-SS42FJVN.js +3875 -0
  243. package/dist/chunk-SVZDXFPX.js +891 -0
  244. package/dist/chunk-SZPTTNW7.js +16 -0
  245. package/dist/chunk-T3IGJARD.js +22 -0
  246. package/dist/chunk-TA3TFKYZ.js +86 -0
  247. package/dist/chunk-TBGUEF3M.js +939 -0
  248. package/dist/chunk-TGK6KUGN.js +331 -0
  249. package/dist/chunk-TJSND556.js +1783 -0
  250. package/dist/chunk-TKOJZQAJ.js +24 -0
  251. package/dist/chunk-TM4OC53S.js +97 -0
  252. package/dist/chunk-TNEHPP3H.js +18 -0
  253. package/dist/chunk-TWOREVKJ.js +1760 -0
  254. package/dist/chunk-TXS3U77A.js +60 -0
  255. package/dist/chunk-UB6ODJHO.js +134 -0
  256. package/dist/chunk-UBZXQIDR.js +24 -0
  257. package/dist/chunk-ULTSSIOU.js +38 -0
  258. package/dist/chunk-UMDEWWXT.js +33 -0
  259. package/dist/chunk-V6O6KVOA.js +347 -0
  260. package/dist/chunk-VABRPZVC.js +43 -0
  261. package/dist/chunk-VDAKTZQP.js +18 -0
  262. package/dist/chunk-VDAZPGR2.js +79 -0
  263. package/dist/chunk-VERLFNWR.js +25 -0
  264. package/dist/chunk-VH2UUU7K.js +24 -0
  265. package/dist/chunk-VJ3FCGQF.js +12 -0
  266. package/dist/chunk-VK5ZDV67.js +47 -0
  267. package/dist/chunk-VKQNDOAI.js +40 -0
  268. package/dist/chunk-VTEV3WVF.js +690 -0
  269. package/dist/chunk-VXZFQKBJ.js +21 -0
  270. package/dist/chunk-WI5ITCOH.js +22 -0
  271. package/dist/chunk-WLZ54FWG.js +120 -0
  272. package/dist/chunk-WYJEOMNY.js +31 -0
  273. package/dist/chunk-WZGJSQKN.js +29 -0
  274. package/dist/chunk-WZL4EEBS.js +11 -0
  275. package/dist/chunk-X4YNDLVA.js +54 -0
  276. package/dist/chunk-X6SUFTD7.js +17 -0
  277. package/dist/chunk-XB4KZ6WO.js +81 -0
  278. package/dist/chunk-XJI6SWFS.js +569 -0
  279. package/dist/chunk-XJP5DKIL.js +29 -0
  280. package/dist/chunk-XN4ARQ2W.js +47 -0
  281. package/dist/chunk-XN7MQO45.js +359 -0
  282. package/dist/chunk-XQCQZBGX.js +100 -0
  283. package/dist/chunk-XXOHXA3A.js +69 -0
  284. package/dist/chunk-XZOHR765.js +127 -0
  285. package/dist/chunk-YCNLQYTC.js +133 -0
  286. package/dist/chunk-YCRGWQBS.js +526 -0
  287. package/dist/chunk-YF2PYLC4.js +210 -0
  288. package/dist/chunk-YG5GUELW.js +935 -0
  289. package/dist/chunk-YS6KMYM4.js +91 -0
  290. package/dist/chunk-YWP7XFKD.js +12 -0
  291. package/dist/chunk-Z2MGTKDR.js +20 -0
  292. package/dist/chunk-Z6CL7AR6.js +24 -0
  293. package/dist/chunk-Z7X3RGGA.js +22 -0
  294. package/dist/chunk-ZF43WRG3.js +29 -0
  295. package/dist/chunk-ZMF7WEGG.js +60 -0
  296. package/dist/chunk-ZNHFLJSY.js +375 -0
  297. package/dist/chunk-ZQ4VFQID.js +76 -0
  298. package/dist/chunk-ZQF34VPS.js +72 -0
  299. package/dist/chunk-ZU425HNM.js +24 -0
  300. package/dist/chunk-ZZU5R5UU.js +24 -0
  301. package/dist/cli/index.js +9 -0
  302. package/dist/core-3VCCUFVX.js +32 -0
  303. package/dist/core-4BZQQSHS.js +33 -0
  304. package/dist/core-4VT4MHNB.js +38 -0
  305. package/dist/core-5535KXRD.js +40 -0
  306. package/dist/core-5HQBPCHL.js +35 -0
  307. package/dist/core-6RYHWUJO.js +35 -0
  308. package/dist/core-7BZJCIXN.js +35 -0
  309. package/dist/core-AJTVU6X7.js +37 -0
  310. package/dist/core-C6YUSTZI.js +57 -0
  311. package/dist/core-EEB7HTCL.js +33 -0
  312. package/dist/core-EFMVDWNH.js +38 -0
  313. package/dist/core-ETAGQBZO.js +34 -0
  314. package/dist/core-FVR3WZEC.js +36 -0
  315. package/dist/core-GCTFVYMH.js +29 -0
  316. package/dist/core-GES44OTS.js +33 -0
  317. package/dist/core-GGQREDSI.js +47 -0
  318. package/dist/core-HRYOV6QD.js +38 -0
  319. package/dist/core-IKD3EE3S.js +38 -0
  320. package/dist/core-JM4R426L.js +32 -0
  321. package/dist/core-KKQS3WI2.js +40 -0
  322. package/dist/core-LA6XDYG7.js +40 -0
  323. package/dist/core-MJ7JWQT5.js +37 -0
  324. package/dist/core-MLROKJ2M.js +53 -0
  325. package/dist/core-MR52YBRX.js +31 -0
  326. package/dist/core-NP4VHWXL.js +29 -0
  327. package/dist/core-NQLNZDX5.js +41 -0
  328. package/dist/core-NSIJEKLI.js +44 -0
  329. package/dist/core-OJUQLIQ5.js +35 -0
  330. package/dist/core-PB3VUQSS.js +32 -0
  331. package/dist/core-Q6VLFFYC.js +56 -0
  332. package/dist/core-QY7AVIKZ.js +51 -0
  333. package/dist/core-SBQMHWTA.js +52 -0
  334. package/dist/core-UHECQHJ2.js +38 -0
  335. package/dist/core-V5FV4NWL.js +56 -0
  336. package/dist/core-WGM4XUN3.js +58 -0
  337. package/dist/core-WUQVFARS.js +34 -0
  338. package/dist/core-Z2F3IGSR.js +42 -0
  339. package/dist/dataTable-3CPPIHB3.js +58 -0
  340. package/dist/engine-FXFBCWHB.js +961 -0
  341. package/dist/fixtures.d.ts +1 -0
  342. package/dist/fixtures.js +41 -0
  343. package/dist/fontTables-WYCZNRE7.js +18 -0
  344. package/dist/fonts.d.ts +1 -0
  345. package/dist/fonts.js +19 -0
  346. package/dist/geo/dach.d.ts +1 -0
  347. package/dist/geo/dach.js +14 -0
  348. package/dist/geo/de-states.d.ts +1 -0
  349. package/dist/geo/de-states.js +14 -0
  350. package/dist/geo/eu27.d.ts +1 -0
  351. package/dist/geo/eu27.js +14 -0
  352. package/dist/geo/europe.d.ts +1 -0
  353. package/dist/geo/europe.js +14 -0
  354. package/dist/geo/index.d.ts +1 -0
  355. package/dist/geo/index.js +41 -0
  356. package/dist/geo/us-states.d.ts +1 -0
  357. package/dist/geo/us-states.js +14 -0
  358. package/dist/geo/world.d.ts +1 -0
  359. package/dist/geo/world.js +14 -0
  360. package/dist/index.d.ts +1 -0
  361. package/dist/index.js +364 -0
  362. package/dist/main-YLKBTHJP.js +569 -0
  363. package/dist/mcp/server.js +1025 -0
  364. package/dist/module-SVEW5ZUE.js +137233 -0
  365. package/dist/react/bar.d.ts +1 -0
  366. package/dist/react/bar.js +81 -0
  367. package/dist/react/bartable.d.ts +1 -0
  368. package/dist/react/bartable.js +70 -0
  369. package/dist/react/box.d.ts +1 -0
  370. package/dist/react/box.js +65 -0
  371. package/dist/react/bullet.d.ts +1 -0
  372. package/dist/react/bullet.js +72 -0
  373. package/dist/react/butterfly.d.ts +1 -0
  374. package/dist/react/butterfly.js +66 -0
  375. package/dist/react/choropleth.d.ts +1 -0
  376. package/dist/react/choropleth.js +67 -0
  377. package/dist/react/cohort.d.ts +1 -0
  378. package/dist/react/cohort.js +70 -0
  379. package/dist/react/column.d.ts +1 -0
  380. package/dist/react/column.js +86 -0
  381. package/dist/react/combo.d.ts +1 -0
  382. package/dist/react/combo.js +86 -0
  383. package/dist/react/creative.d.ts +1 -0
  384. package/dist/react/creative.js +61 -0
  385. package/dist/react/diagram.d.ts +1 -0
  386. package/dist/react/diagram.js +60 -0
  387. package/dist/react/dimswitch.d.ts +1 -0
  388. package/dist/react/dimswitch.js +72 -0
  389. package/dist/react/dot.d.ts +1 -0
  390. package/dist/react/dot.js +70 -0
  391. package/dist/react/export.d.ts +1 -0
  392. package/dist/react/export.js +658 -0
  393. package/dist/react/funnel.d.ts +1 -0
  394. package/dist/react/funnel.js +63 -0
  395. package/dist/react/gantt.d.ts +1 -0
  396. package/dist/react/gantt.js +62 -0
  397. package/dist/react/grid.d.ts +1 -0
  398. package/dist/react/grid.js +67 -0
  399. package/dist/react/heatmap.d.ts +1 -0
  400. package/dist/react/heatmap.js +68 -0
  401. package/dist/react/histogram.d.ts +1 -0
  402. package/dist/react/histogram.js +86 -0
  403. package/dist/react/index.d.ts +1 -0
  404. package/dist/react/index.js +504 -0
  405. package/dist/react/kpi.d.ts +1 -0
  406. package/dist/react/kpi.js +67 -0
  407. package/dist/react/likert.d.ts +1 -0
  408. package/dist/react/likert.js +83 -0
  409. package/dist/react/line.d.ts +1 -0
  410. package/dist/react/line.js +81 -0
  411. package/dist/react/mekko.d.ts +1 -0
  412. package/dist/react/mekko.js +71 -0
  413. package/dist/react/pareto.d.ts +1 -0
  414. package/dist/react/pareto.js +90 -0
  415. package/dist/react/pie.d.ts +1 -0
  416. package/dist/react/pie.js +64 -0
  417. package/dist/react/prepare.d.ts +1 -0
  418. package/dist/react/prepare.js +278 -0
  419. package/dist/react/pvm.d.ts +1 -0
  420. package/dist/react/pvm.js +68 -0
  421. package/dist/react/pyramid.d.ts +1 -0
  422. package/dist/react/pyramid.js +67 -0
  423. package/dist/react/sankey.d.ts +1 -0
  424. package/dist/react/sankey.js +59 -0
  425. package/dist/react/scatter.d.ts +1 -0
  426. package/dist/react/scatter.js +63 -0
  427. package/dist/react/slope.d.ts +1 -0
  428. package/dist/react/slope.js +64 -0
  429. package/dist/react/sparkline.d.ts +1 -0
  430. package/dist/react/sparkline.js +59 -0
  431. package/dist/react/spec.d.ts +1 -0
  432. package/dist/react/spec.js +379 -0
  433. package/dist/react/status.d.ts +1 -0
  434. package/dist/react/status.js +64 -0
  435. package/dist/react/story.d.ts +1 -0
  436. package/dist/react/story.js +140 -0
  437. package/dist/react/table.d.ts +1 -0
  438. package/dist/react/table.js +69 -0
  439. package/dist/react/theme.d.ts +1 -0
  440. package/dist/react/theme.js +53 -0
  441. package/dist/react/tilemap.d.ts +1 -0
  442. package/dist/react/tilemap.js +66 -0
  443. package/dist/react/treemap.d.ts +1 -0
  444. package/dist/react/treemap.js +61 -0
  445. package/dist/react/variance.d.ts +1 -0
  446. package/dist/react/variance.js +65 -0
  447. package/dist/react/waffle.d.ts +1 -0
  448. package/dist/react/waffle.js +62 -0
  449. package/dist/react/waterfall.d.ts +1 -0
  450. package/dist/react/waterfall.js +68 -0
  451. package/dist/resvg-ZOVDIZTV.js +23 -0
  452. package/dist/rows.d.ts +1 -0
  453. package/dist/rows.js +23 -0
  454. package/dist/rowsModule-YVLAROIP.js +27 -0
  455. package/dist/schema-2K6C3U24.js +23 -0
  456. package/dist/schema-2KIHLTYI.js +23 -0
  457. package/dist/schema-4HY2MWZC.js +30 -0
  458. package/dist/schema-4S5CXHAO.js +24 -0
  459. package/dist/schema-5BKQV56C.js +27 -0
  460. package/dist/schema-5HA5DSYN.js +24 -0
  461. package/dist/schema-5NKJPSBD.js +23 -0
  462. package/dist/schema-65FOKNHK.js +43 -0
  463. package/dist/schema-6OHZWHUI.js +23 -0
  464. package/dist/schema-6RYJS2GM.js +24 -0
  465. package/dist/schema-6W4M3WJ4.js +23 -0
  466. package/dist/schema-7TLSFG6M.js +24 -0
  467. package/dist/schema-AMFRKUFS.js +27 -0
  468. package/dist/schema-B7CZPPB4.js +28 -0
  469. package/dist/schema-BNRNHGHQ.js +26 -0
  470. package/dist/schema-E4MRCGPZ.js +24 -0
  471. package/dist/schema-F3WYTR65.js +26 -0
  472. package/dist/schema-FA6XIHTW.js +23 -0
  473. package/dist/schema-GZNOW4LX.js +23 -0
  474. package/dist/schema-HEIDGCSL.js +23 -0
  475. package/dist/schema-JB2H6KPA.js +23 -0
  476. package/dist/schema-MPXZNWV3.js +23 -0
  477. package/dist/schema-NHNQK6XO.js +23 -0
  478. package/dist/schema-NN6UPDPW.js +23 -0
  479. package/dist/schema-O4YNAGIY.js +23 -0
  480. package/dist/schema-O7AKK232.js +29 -0
  481. package/dist/schema-OJCML6LV.js +24 -0
  482. package/dist/schema-ORTRMYI6.js +24 -0
  483. package/dist/schema-PJ6P52BC.js +23 -0
  484. package/dist/schema-RTWES6NR.js +24 -0
  485. package/dist/schema-S36SRYGO.js +24 -0
  486. package/dist/schema-S3TCLTYD.js +23 -0
  487. package/dist/schema-SWWMOLOR.js +54 -0
  488. package/dist/schema-WOSEZNKG.js +26 -0
  489. package/dist/schema-Y6KBWUUR.js +23 -0
  490. package/dist/schema-YQYTLKSW.js +23 -0
  491. package/dist/schema-ZUUUY3QS.js +33 -0
  492. package/dist/specValidation-VNWIKLHH.js +49 -0
  493. package/dist/theme.d.ts +1 -0
  494. package/dist/theme.js +24 -0
  495. package/dist/themeShapeRules-2D3KWSPQ.js +11 -0
  496. package/dist/types/core/a11y/accessibility.d.ts +43 -0
  497. package/dist/types/core/a11y/recordsShared.d.ts +44 -0
  498. package/dist/types/core/a11y/structuralRecords.d.ts +6 -0
  499. package/dist/types/core/a11y/types.d.ts +116 -0
  500. package/dist/types/core/annotate.d.ts +300 -0
  501. package/dist/types/core/annotateArms.d.ts +37 -0
  502. package/dist/types/core/annotateFields.d.ts +30 -0
  503. package/dist/types/core/annotateGapBracket.d.ts +66 -0
  504. package/dist/types/core/annotateLinks.d.ts +47 -0
  505. package/dist/types/core/annotateTargets.d.ts +90 -0
  506. package/dist/types/core/axis.d.ts +179 -0
  507. package/dist/types/core/bandSelect.d.ts +10 -0
  508. package/dist/types/core/bands.d.ts +14 -0
  509. package/dist/types/core/calendarLabels.d.ts +101 -0
  510. package/dist/types/core/charts/band/stacks.d.ts +155 -0
  511. package/dist/types/core/charts/bar/fixtures.d.ts +9 -0
  512. package/dist/types/core/charts/bar/layout.d.ts +95 -0
  513. package/dist/types/core/charts/bartable/fixtures.d.ts +4 -0
  514. package/dist/types/core/charts/bartable/types.d.ts +192 -0
  515. package/dist/types/core/charts/box/fixtures.d.ts +12 -0
  516. package/dist/types/core/charts/box/types.d.ts +110 -0
  517. package/dist/types/core/charts/bullet/fixtures.d.ts +11 -0
  518. package/dist/types/core/charts/butterfly/fixtures.d.ts +9 -0
  519. package/dist/types/core/charts/choropleth/fixtures.d.ts +3 -0
  520. package/dist/types/core/charts/choropleth/overlayTypes.d.ts +68 -0
  521. package/dist/types/core/charts/choropleth/types.d.ts +117 -0
  522. package/dist/types/core/charts/cohort/fixtures.d.ts +12 -0
  523. package/dist/types/core/charts/cohort/types.d.ts +165 -0
  524. package/dist/types/core/charts/column/anomaly.d.ts +204 -0
  525. package/dist/types/core/charts/column/fixtures.d.ts +12 -0
  526. package/dist/types/core/charts/column/layout.d.ts +116 -0
  527. package/dist/types/core/charts/column/model.d.ts +295 -0
  528. package/dist/types/core/charts/column/types.d.ts +56 -0
  529. package/dist/types/core/charts/combo/endpoints.d.ts +165 -0
  530. package/dist/types/core/charts/combo/fixtures.d.ts +12 -0
  531. package/dist/types/core/charts/combo/layout.d.ts +48 -0
  532. package/dist/types/core/charts/creative/fixtures.d.ts +4 -0
  533. package/dist/types/core/charts/creative/types.d.ts +73 -0
  534. package/dist/types/core/charts/diagram/fixtures.d.ts +3 -0
  535. package/dist/types/core/charts/dimswitch/compile.d.ts +20 -0
  536. package/dist/types/core/charts/dimswitch/fixtures.d.ts +3 -0
  537. package/dist/types/core/charts/dimswitch/types.d.ts +152 -0
  538. package/dist/types/core/charts/dot/fixtures.d.ts +11 -0
  539. package/dist/types/core/charts/funnel/fixtures.d.ts +11 -0
  540. package/dist/types/core/charts/gantt/fixtures.d.ts +9 -0
  541. package/dist/types/core/charts/gantt/layout.d.ts +63 -0
  542. package/dist/types/core/charts/grid/fixtures.d.ts +3 -0
  543. package/dist/types/core/charts/grid/metricStack.d.ts +108 -0
  544. package/dist/types/core/charts/grid/metricStackSchema.d.ts +74 -0
  545. package/dist/types/core/charts/grid/normalize.d.ts +99 -0
  546. package/dist/types/core/charts/grid/schema.d.ts +168 -0
  547. package/dist/types/core/charts/heatmap/fixtures.d.ts +11 -0
  548. package/dist/types/core/charts/histogram/fixtures.d.ts +15 -0
  549. package/dist/types/core/charts/histogram/types.d.ts +98 -0
  550. package/dist/types/core/charts/kpi/fixtures.d.ts +9 -0
  551. package/dist/types/core/charts/likert/fixtures.d.ts +11 -0
  552. package/dist/types/core/charts/likert/layout.d.ts +111 -0
  553. package/dist/types/core/charts/line/fixtures.d.ts +16 -0
  554. package/dist/types/core/charts/line/types.d.ts +6 -0
  555. package/dist/types/core/charts/mekko/fixtures.d.ts +13 -0
  556. package/dist/types/core/charts/pareto/fixtures.d.ts +5 -0
  557. package/dist/types/core/charts/pareto/layout.d.ts +68 -0
  558. package/dist/types/core/charts/pie/fixtures.d.ts +14 -0
  559. package/dist/types/core/charts/pvm/fixtures.d.ts +13 -0
  560. package/dist/types/core/charts/pvm/types.d.ts +118 -0
  561. package/dist/types/core/charts/pyramid/fixtures.d.ts +4 -0
  562. package/dist/types/core/charts/pyramid/types.d.ts +92 -0
  563. package/dist/types/core/charts/sankey/fixtures.d.ts +4 -0
  564. package/dist/types/core/charts/sankey/types.d.ts +116 -0
  565. package/dist/types/core/charts/scatter/fixtures.d.ts +12 -0
  566. package/dist/types/core/charts/scatter/types.d.ts +58 -0
  567. package/dist/types/core/charts/slope/fixtures.d.ts +13 -0
  568. package/dist/types/core/charts/sparkline/fixtures.d.ts +9 -0
  569. package/dist/types/core/charts/status/fixtures.d.ts +8 -0
  570. package/dist/types/core/charts/status/layout.d.ts +71 -0
  571. package/dist/types/core/charts/table/fitFormats.d.ts +67 -0
  572. package/dist/types/core/charts/table/fixtures.d.ts +7 -0
  573. package/dist/types/core/charts/table/resolve.d.ts +72 -0
  574. package/dist/types/core/charts/table/view.d.ts +156 -0
  575. package/dist/types/core/charts/tilemap/fixtures.d.ts +3 -0
  576. package/dist/types/core/charts/tilemap/types.d.ts +94 -0
  577. package/dist/types/core/charts/treemap/fixtures.d.ts +4 -0
  578. package/dist/types/core/charts/treemap/types.d.ts +78 -0
  579. package/dist/types/core/charts/variance/fixtures.d.ts +12 -0
  580. package/dist/types/core/charts/waffle/fixtures.d.ts +5 -0
  581. package/dist/types/core/charts/waffle/types.d.ts +117 -0
  582. package/dist/types/core/charts/waterfall/fixtures.d.ts +9 -0
  583. package/dist/types/core/claims/browser.d.ts +49 -0
  584. package/dist/types/core/claims/manifest.d.ts +22 -0
  585. package/dist/types/core/dateFormat.d.ts +39 -0
  586. package/dist/types/core/deferred.d.ts +121 -0
  587. package/dist/types/core/diagnostics/describe.d.ts +149 -0
  588. package/dist/types/core/diagnostics/jsonPatch.d.ts +36 -0
  589. package/dist/types/core/doc/bareChart.d.ts +2 -0
  590. package/dist/types/core/doc/diagnostics.d.ts +124 -0
  591. package/dist/types/core/doc/docExpand.d.ts +39 -0
  592. package/dist/types/core/doc/document.d.ts +43 -0
  593. package/dist/types/core/doc/ownedDocumentCopy.d.ts +5 -0
  594. package/dist/types/core/doc/specError.d.ts +6 -0
  595. package/dist/types/core/emptyData.d.ts +27 -0
  596. package/dist/types/core/eventLane.d.ts +208 -0
  597. package/dist/types/core/fontMetrics/index.d.ts +47 -0
  598. package/dist/types/core/fontMetrics/injected.d.ts +40 -0
  599. package/dist/types/core/fontMetrics/tableDocument.d.ts +73 -0
  600. package/dist/types/core/fontMetrics/tables.generated.d.ts +17 -0
  601. package/dist/types/core/footer.d.ts +59 -0
  602. package/dist/types/core/format.d.ts +149 -0
  603. package/dist/types/core/formatPrecision.d.ts +136 -0
  604. package/dist/types/core/formatSpec.d.ts +304 -0
  605. package/dist/types/core/frame.d.ts +583 -0
  606. package/dist/types/core/geo/packs/all.d.ts +7 -0
  607. package/dist/types/core/geo/packs/dach.d.ts +16 -0
  608. package/dist/types/core/geo/packs/de-states.d.ts +16 -0
  609. package/dist/types/core/geo/packs/eu27.d.ts +16 -0
  610. package/dist/types/core/geo/packs/europe.d.ts +16 -0
  611. package/dist/types/core/geo/packs/index.d.ts +22 -0
  612. package/dist/types/core/geo/packs/registry.d.ts +37 -0
  613. package/dist/types/core/geo/packs/us-states.d.ts +16 -0
  614. package/dist/types/core/geo/packs/world.d.ts +16 -0
  615. package/dist/types/core/geo/tiles/eu27.generated.d.ts +412 -0
  616. package/dist/types/core/geo/tiles/europe.generated.d.ts +842 -0
  617. package/dist/types/core/geo/tiles/index.d.ts +8 -0
  618. package/dist/types/core/geo/tiles/types.d.ts +36 -0
  619. package/dist/types/core/geo/tiles/us-states.generated.d.ts +952 -0
  620. package/dist/types/core/geo/tiles/world.generated.d.ts +968 -0
  621. package/dist/types/core/geo/types.d.ts +146 -0
  622. package/dist/types/core/geometry.d.ts +102 -0
  623. package/dist/types/core/grid/sharedScale.d.ts +82 -0
  624. package/dist/types/core/icons.d.ts +227 -0
  625. package/dist/types/core/inputError.d.ts +14 -0
  626. package/dist/types/core/isoDate.d.ts +2 -0
  627. package/dist/types/core/isoTime.d.ts +7 -0
  628. package/dist/types/core/label/categoryRow.d.ts +332 -0
  629. package/dist/types/core/label/occupied.d.ts +41 -0
  630. package/dist/types/core/label/ownership.d.ts +83 -0
  631. package/dist/types/core/label/solver.d.ts +384 -0
  632. package/dist/types/core/label/tickRow.d.ts +78 -0
  633. package/dist/types/core/live/types.d.ts +50 -0
  634. package/dist/types/core/normalize/shared.d.ts +56 -0
  635. package/dist/types/core/notes.d.ts +174 -0
  636. package/dist/types/core/othersShade.d.ts +9 -0
  637. package/dist/types/core/periodYears.d.ts +9 -0
  638. package/dist/types/core/polyline.d.ts +11 -0
  639. package/dist/types/core/rangeRules.d.ts +19 -0
  640. package/dist/types/core/ratioTier.d.ts +120 -0
  641. package/dist/types/core/readerStrings.d.ts +13 -0
  642. package/dist/types/core/reading.d.ts +120 -0
  643. package/dist/types/core/registry.d.ts +178 -0
  644. package/dist/types/core/repaintGeometry.d.ts +19 -0
  645. package/dist/types/core/request.d.ts +124 -0
  646. package/dist/types/core/rows.d.ts +47 -0
  647. package/dist/types/core/scale.d.ts +106 -0
  648. package/dist/types/core/schema/capability.d.ts +229 -0
  649. package/dist/types/core/schema/namedColumns.d.ts +45 -0
  650. package/dist/types/core/schema/reference.d.ts +31 -0
  651. package/dist/types/core/schema/refusals.d.ts +45 -0
  652. package/dist/types/core/schema/unknownKeys.d.ts +45 -0
  653. package/dist/types/core/seriesIdentity.d.ts +120 -0
  654. package/dist/types/core/shareRounding.d.ts +49 -0
  655. package/dist/types/core/sizing.d.ts +330 -0
  656. package/dist/types/core/staticFooter.d.ts +6 -0
  657. package/dist/types/core/story.d.ts +41 -0
  658. package/dist/types/core/structureCounts.d.ts +10 -0
  659. package/dist/types/core/svg/renderSvg.d.ts +51 -0
  660. package/dist/types/core/target.d.ts +89 -0
  661. package/dist/types/core/text.d.ts +113 -0
  662. package/dist/types/core/theme.d.ts +478 -0
  663. package/dist/types/core/themeFields.d.ts +11 -0
  664. package/dist/types/core/themeRules.d.ts +111 -0
  665. package/dist/types/core/themeShape.d.ts +87 -0
  666. package/dist/types/core/themeValidate.d.ts +15 -0
  667. package/dist/types/core/timeAxis.d.ts +106 -0
  668. package/dist/types/core/types/annotations.d.ts +227 -0
  669. package/dist/types/core/types/cell.d.ts +82 -0
  670. package/dist/types/core/types/data.d.ts +314 -0
  671. package/dist/types/core/types/diagram.d.ts +234 -0
  672. package/dist/types/core/types/index.d.ts +8 -0
  673. package/dist/types/core/types/options.d.ts +1583 -0
  674. package/dist/types/core/types/scene.d.ts +990 -0
  675. package/dist/types/core/types/sizing.d.ts +51 -0
  676. package/dist/types/core/types/table.d.ts +873 -0
  677. package/dist/types/core/types/theme.d.ts +806 -0
  678. package/dist/types/core/zoom.d.ts +106 -0
  679. package/dist/types/fixtures/index.d.ts +40 -0
  680. package/dist/types/fixtures/registry.d.ts +15 -0
  681. package/dist/types/fonts.d.ts +10 -0
  682. package/dist/types/index.d.ts +70 -0
  683. package/dist/types/react/BoardplotTheme.d.ts +9 -0
  684. package/dist/types/react/DimSwitchChart.d.ts +36 -0
  685. package/dist/types/react/ScaleGroup.d.ts +31 -0
  686. package/dist/types/react/SceneRenderer.d.ts +23 -0
  687. package/dist/types/react/SizePlaceholder.d.ts +51 -0
  688. package/dist/types/react/StoryFrame.d.ts +42 -0
  689. package/dist/types/react/TableChart.d.ts +220 -0
  690. package/dist/types/react/a11ySurface.d.ts +20 -0
  691. package/dist/types/react/barrelCharts.d.ts +1023 -0
  692. package/dist/types/react/charts/bar.d.ts +28 -0
  693. package/dist/types/react/charts/bartable.d.ts +27 -0
  694. package/dist/types/react/charts/box.d.ts +27 -0
  695. package/dist/types/react/charts/bullet.d.ts +28 -0
  696. package/dist/types/react/charts/butterfly.d.ts +28 -0
  697. package/dist/types/react/charts/choropleth.d.ts +27 -0
  698. package/dist/types/react/charts/cohort.d.ts +52 -0
  699. package/dist/types/react/charts/column.d.ts +27 -0
  700. package/dist/types/react/charts/combo.d.ts +7 -0
  701. package/dist/types/react/charts/creative.d.ts +27 -0
  702. package/dist/types/react/charts/diagram.d.ts +162 -0
  703. package/dist/types/react/charts/dimswitch.d.ts +6 -0
  704. package/dist/types/react/charts/dot.d.ts +28 -0
  705. package/dist/types/react/charts/funnel.d.ts +28 -0
  706. package/dist/types/react/charts/gantt.d.ts +28 -0
  707. package/dist/types/react/charts/grid.d.ts +29 -0
  708. package/dist/types/react/charts/heatmap.d.ts +28 -0
  709. package/dist/types/react/charts/histogram.d.ts +27 -0
  710. package/dist/types/react/charts/kpi.d.ts +28 -0
  711. package/dist/types/react/charts/likert.d.ts +27 -0
  712. package/dist/types/react/charts/line.d.ts +28 -0
  713. package/dist/types/react/charts/mekko.d.ts +28 -0
  714. package/dist/types/react/charts/pareto.d.ts +28 -0
  715. package/dist/types/react/charts/pie.d.ts +28 -0
  716. package/dist/types/react/charts/pvm.d.ts +27 -0
  717. package/dist/types/react/charts/pyramid.d.ts +27 -0
  718. package/dist/types/react/charts/sankey.d.ts +27 -0
  719. package/dist/types/react/charts/scatter.d.ts +28 -0
  720. package/dist/types/react/charts/slope.d.ts +28 -0
  721. package/dist/types/react/charts/sparkline.d.ts +28 -0
  722. package/dist/types/react/charts/status.d.ts +27 -0
  723. package/dist/types/react/charts/table.d.ts +6 -0
  724. package/dist/types/react/charts/tilemap.d.ts +27 -0
  725. package/dist/types/react/charts/treemap.d.ts +27 -0
  726. package/dist/types/react/charts/variance.d.ts +28 -0
  727. package/dist/types/react/charts/waffle.d.ts +28 -0
  728. package/dist/types/react/charts/waterfall.d.ts +28 -0
  729. package/dist/types/react/createChartComponent.d.ts +135 -0
  730. package/dist/types/react/export/clipboard.d.ts +8 -0
  731. package/dist/types/react/export/csv.d.ts +2 -0
  732. package/dist/types/react/export/frame.d.ts +35 -0
  733. package/dist/types/react/export/index.d.ts +7 -0
  734. package/dist/types/react/export/png.d.ts +14 -0
  735. package/dist/types/react/export/svg.d.ts +5 -0
  736. package/dist/types/react/export/types.d.ts +69 -0
  737. package/dist/types/react/export/useExport.d.ts +17 -0
  738. package/dist/types/react/exportLink.d.ts +49 -0
  739. package/dist/types/react/footerFrame.d.ts +25 -0
  740. package/dist/types/react/hover/dataTable.d.ts +13 -0
  741. package/dist/types/react/hover/engine.d.ts +210 -0
  742. package/dist/types/react/hover/keyboard.d.ts +44 -0
  743. package/dist/types/react/hover/labelCard.d.ts +170 -0
  744. package/dist/types/react/hover/placement.d.ts +49 -0
  745. package/dist/types/react/index.d.ts +16 -0
  746. package/dist/types/react/parseChartSpec.d.ts +16 -0
  747. package/dist/types/react/prepare.d.ts +32 -0
  748. package/dist/types/react/prepared.d.ts +53 -0
  749. package/dist/types/react/preparedTable.d.ts +15 -0
  750. package/dist/types/react/rowsInput.d.ts +55 -0
  751. package/dist/types/react/rowsModule.d.ts +18 -0
  752. package/dist/types/react/rowsStore.d.ts +50 -0
  753. package/dist/types/react/scale-group.d.ts +2 -0
  754. package/dist/types/react/scaleGroupContext.d.ts +22 -0
  755. package/dist/types/react/scenePaint.d.ts +10 -0
  756. package/dist/types/react/scrollState.d.ts +26 -0
  757. package/dist/types/react/spec.d.ts +82 -0
  758. package/dist/types/react/specValidation.d.ts +45 -0
  759. package/dist/types/react/story.d.ts +15 -0
  760. package/dist/types/react/theme.d.ts +9 -0
  761. package/dist/types/react/themeContext.d.ts +44 -0
  762. package/dist/types/react/useChartLayout.d.ts +22 -0
  763. package/dist/types/react/useContainerSize.d.ts +57 -0
  764. package/dist/types/react/useHover.d.ts +100 -0
  765. package/dist/types/react/useZoom.d.ts +50 -0
  766. package/dist/types/rows.d.ts +63 -0
  767. package/dist/types/tableLooks.d.ts +6 -0
  768. package/dist/types/theme.d.ts +3 -0
  769. package/dist/types/validate.d.ts +3 -0
  770. package/dist/validate.d.ts +1 -0
  771. package/dist/validate.js +223 -0
  772. package/docs/FONTS.md +68 -0
  773. package/docs/TELEMETRY.md +94 -0
  774. package/docs/manual.md +850 -0
  775. package/docs/reference/bar.md +222 -0
  776. package/docs/reference/bartable.md +143 -0
  777. package/docs/reference/box.md +93 -0
  778. package/docs/reference/bullet.md +118 -0
  779. package/docs/reference/butterfly.md +117 -0
  780. package/docs/reference/choropleth.md +148 -0
  781. package/docs/reference/cohort.md +149 -0
  782. package/docs/reference/column.md +275 -0
  783. package/docs/reference/combo.md +219 -0
  784. package/docs/reference/creative.md +147 -0
  785. package/docs/reference/diagram.md +191 -0
  786. package/docs/reference/dimswitch.md +1395 -0
  787. package/docs/reference/dot.md +117 -0
  788. package/docs/reference/fixtures.md +1089 -0
  789. package/docs/reference/funnel.md +121 -0
  790. package/docs/reference/gantt.md +138 -0
  791. package/docs/reference/grid.md +302 -0
  792. package/docs/reference/heatmap.md +127 -0
  793. package/docs/reference/histogram.md +77 -0
  794. package/docs/reference/kpi.md +115 -0
  795. package/docs/reference/likert.md +113 -0
  796. package/docs/reference/line.md +436 -0
  797. package/docs/reference/mekko.md +114 -0
  798. package/docs/reference/options.md +313 -0
  799. package/docs/reference/pareto.md +102 -0
  800. package/docs/reference/pie.md +114 -0
  801. package/docs/reference/pvm.md +114 -0
  802. package/docs/reference/pyramid.md +99 -0
  803. package/docs/reference/react.md +706 -0
  804. package/docs/reference/reading.md +28 -0
  805. package/docs/reference/sankey.md +110 -0
  806. package/docs/reference/scatter.md +211 -0
  807. package/docs/reference/slope.md +126 -0
  808. package/docs/reference/sparkline.md +74 -0
  809. package/docs/reference/status.md +107 -0
  810. package/docs/reference/table.md +673 -0
  811. package/docs/reference/theme.md +361 -0
  812. package/docs/reference/tilemap.md +121 -0
  813. package/docs/reference/treemap.md +86 -0
  814. package/docs/reference/variance.md +126 -0
  815. package/docs/reference/waffle.md +106 -0
  816. package/docs/reference/waterfall.md +164 -0
  817. package/llms.txt +57 -0
  818. package/package.json +437 -4
@@ -0,0 +1,2721 @@
1
+ import {
2
+ computeMetricStack,
3
+ formatPanelValue,
4
+ isMetricStackData,
5
+ metricStackGrain,
6
+ normalizeMetricStack,
7
+ stackError,
8
+ stackRange
9
+ } from "./chunk-DDI2W4TR.js";
10
+ import {
11
+ scalePanelSemantics
12
+ } from "./chunk-CCCEBIUZ.js";
13
+ import {
14
+ STACK_ROOM
15
+ } from "./chunk-27QADBDV.js";
16
+ import {
17
+ normalizeGridData,
18
+ parseGridLegendPanelData,
19
+ parseGridTextPanelData
20
+ } from "./chunk-57ZGVAU3.js";
21
+ import {
22
+ categoryBandFromCenters
23
+ } from "./chunk-CDZHNLO6.js";
24
+ import {
25
+ structureCount
26
+ } from "./chunk-LFX7W4B7.js";
27
+ import {
28
+ isRecord
29
+ } from "./chunk-MCYM3RNF.js";
30
+ import {
31
+ emptyIdRecord
32
+ } from "./chunk-LINZPU5D.js";
33
+ import {
34
+ CARD_CLASS_WIDTH,
35
+ CARD_MIN_WIDTH,
36
+ DIGIT_SEAT,
37
+ NARROW_SHARE_WIDTH,
38
+ PLOT_FLOOR_RECT,
39
+ VARIANCE_TIER,
40
+ autoPlotPx,
41
+ balanceVarianceTierPlots,
42
+ chartSizing,
43
+ getChart,
44
+ heightOmitted,
45
+ inferLinearYDomain,
46
+ isVarianceTier,
47
+ keysNeedNames,
48
+ legendIsCovered,
49
+ normalizedName,
50
+ prepareFitLayout,
51
+ resolveSizing,
52
+ sizeRefusal,
53
+ stackedColumnPlotPx,
54
+ varianceTierWeights,
55
+ withCalendarLabels
56
+ } from "./chunk-RL3NUWMY.js";
57
+ import {
58
+ LEFT_OUT_OF_NOTE,
59
+ PRIORITY,
60
+ boundsOf,
61
+ collectSeriesIdentities,
62
+ createOccupiedIndex,
63
+ frameTextOptions,
64
+ identityAppearance,
65
+ labelCtx,
66
+ labelsToNodes,
67
+ normalizeLegendOption,
68
+ panelNoteTexts,
69
+ partialFootnotes,
70
+ partialIds,
71
+ saysToDate,
72
+ solveFrame,
73
+ solveLabels,
74
+ stringsIn,
75
+ valueNoteLine
76
+ } from "./chunk-SS42FJVN.js";
77
+ import {
78
+ disclosureNote,
79
+ disclosuresShown
80
+ } from "./chunk-BPKXEMRE.js";
81
+ import {
82
+ authoredStrings,
83
+ chartStrings,
84
+ currentSmallValues,
85
+ localeStrings,
86
+ notApplicableGlyph
87
+ } from "./chunk-53OYF4ZT.js";
88
+ import {
89
+ cellMeta,
90
+ cellValue
91
+ } from "./chunk-O3VN6BTL.js";
92
+ import {
93
+ HATCH_STRENGTH_DEFAULT,
94
+ KPI_HOST_TEXT,
95
+ KPI_VALUE_SIZE,
96
+ WIDE_CANVAS_MIN_WIDTH,
97
+ canvasMargin,
98
+ dashToken,
99
+ emphasisWeight,
100
+ markRolePaint,
101
+ panelTypeClass,
102
+ resolveTheme,
103
+ secondaryFont,
104
+ seriesPaint,
105
+ strokeToken,
106
+ themeForWidth,
107
+ themeRegistrations,
108
+ typeWidthClass
109
+ } from "./chunk-CWDHCSL2.js";
110
+ import {
111
+ requireChartCores
112
+ } from "./chunk-HA4IPWMM.js";
113
+ import {
114
+ fmtPathNumber
115
+ } from "./chunk-WLZ54FWG.js";
116
+ import {
117
+ DEFAULT_TARGET,
118
+ NormalizeError,
119
+ TARGET_SIZE,
120
+ accessibleTitle,
121
+ normalizeCategory,
122
+ normalizeSeriesValues,
123
+ resolveCanvasOptions,
124
+ resolveHighlight,
125
+ resolveSize
126
+ } from "./chunk-SGD3ZHID.js";
127
+ import {
128
+ maxOf,
129
+ minOf,
130
+ pushAll
131
+ } from "./chunk-WYJEOMNY.js";
132
+ import {
133
+ defaultMeasurer,
134
+ wrapText
135
+ } from "./chunk-AG2CJ4JY.js";
136
+
137
+ // src/core/grid/gridKey.ts
138
+ var GRID_KEY_ONLY = /* @__PURE__ */ Symbol("gridKeyOnly");
139
+ function gridPanelsKeepEndNames(options) {
140
+ return options.legend === "none" || options[GRID_KEY_ONLY] !== void 0;
141
+ }
142
+ function gridKeyItems(items, options) {
143
+ let only = options[GRID_KEY_ONLY];
144
+ return only ? items.filter((item) => only.has(item.id)) : items;
145
+ }
146
+ function hatchStrengthFor(panel, grid) {
147
+ let strength = panel.hatchStrength ?? grid.hatchStrength;
148
+ return strength === void 0 ? {} : { hatchStrength: strength };
149
+ }
150
+ function collectGridLegendItems(panels, options, measure) {
151
+ let items = [], seen = /* @__PURE__ */ new Map(), theme = resolveTheme(options.theme), typeClass = panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width);
152
+ for (let panel of panels) {
153
+ if (panel.type === "text" || panel.type === "legend") continue;
154
+ let definition = getChart(panel.type);
155
+ if (!definition) continue;
156
+ let panelOptions = panel.options ?? {}, identities = collectSeriesIdentities(definition.layout, panel.data, {
157
+ ...definition.defaults,
158
+ ...panelOptions,
159
+ ...panel.annotations ? { annotations: panel.annotations } : {},
160
+ ...options.palette !== void 0 && panelOptions.palette === void 0 ? { palette: options.palette } : {},
161
+ target: options.target,
162
+ theme: panelOptions.theme ?? options.theme,
163
+ locale: panelOptions.locale ?? options.locale,
164
+ ...hatchStrengthFor(panelOptions, options),
165
+ ...options.strings ? { strings: { ...authoredStrings(options), ...panelOptions.strings } } : {},
166
+ size: options.size,
167
+ measure,
168
+ typeClass
169
+ });
170
+ for (let item of identities) {
171
+ let { marker, ...look } = item, key = panel.type === "variance" && item.id.startsWith("tone:") ? JSON.stringify([item.label, item.id]) : JSON.stringify([item.label, identityAppearance(look, theme)]), at = seen.get(key);
172
+ if (at === void 0)
173
+ seen.set(key, items.length), items.push(item);
174
+ else if (JSON.stringify(items[at].marker) !== JSON.stringify(marker)) {
175
+ let { marker: _dropped, ...plain } = items[at];
176
+ items[at] = plain;
177
+ }
178
+ }
179
+ }
180
+ return items;
181
+ }
182
+ function gridLegendInput(items, legendOptions, options, warnings) {
183
+ let keyed = gridKeyItems(items, options);
184
+ if (keyed.length === 0) {
185
+ warnings.push({ code: "grid-legend-empty", severity: "warn", message: "grid legend requested but no chart panel contributes legend items \u2014 legend omitted" });
186
+ return;
187
+ }
188
+ if (legendOptions.order) {
189
+ let rank = new Map(legendOptions.order.map((id, index) => [id, index]));
190
+ keyed = [...keyed].sort((a, b) => (rank.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (rank.get(b.id) ?? Number.MAX_SAFE_INTEGER));
191
+ }
192
+ return { options: legendOptions, items: keyed };
193
+ }
194
+ function hasLegendPanel(data) {
195
+ let panels = data?.panels;
196
+ return Array.isArray(panels) && panels.some((panel) => panel?.type === "legend");
197
+ }
198
+ function keyName(candidate, labelId) {
199
+ let label = candidate.scene.find((node) => node.id === labelId);
200
+ return label?.t === "text" ? normalizedName(label.lines.join(" ")) : "";
201
+ }
202
+ function gridRequiredKey(baseline, data, options, fitKeyed) {
203
+ if (hasLegendPanel(data)) return baseline;
204
+ let candidateOptions = { ...options, legend: resolveTheme(options.theme).legend?.required ?? "top" }, tried;
205
+ try {
206
+ tried = fitKeyed(candidateOptions);
207
+ } catch (error) {
208
+ if (!(error instanceof NormalizeError)) throw error;
209
+ return baseline;
210
+ }
211
+ if (tried.refused) return baseline;
212
+ let candidate = tried;
213
+ if (!keysNeedNames(baseline, candidate) || legendIsCovered(baseline, candidate, data, options)) return baseline;
214
+ let items = candidate.legend?.items ?? [], uncovered = items.filter((item) => {
215
+ if (legendIsCovered(baseline, { ...candidate, legend: { ...candidate.legend, items: [item] } }, data, options)) return !1;
216
+ let name = keyName(candidate, item.labelId), fullName = new RegExp(`(?<![\\p{L}\\p{N}_])${name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}(?![\\p{L}\\p{N}_])`, "u");
217
+ return !name || !baseline.scene.some((node) => node.t === "text" && node.part === "legendLabel" && node.id.includes("/") && node.owner.seriesId === item.id && fullName.test(normalizedName(node.lines.join(" "))));
218
+ });
219
+ if (uncovered.length === 0) return baseline;
220
+ let keyed = candidate;
221
+ if (uncovered.length < items.length) {
222
+ let narrow = prepareFitLayout(this, data);
223
+ try {
224
+ let narrowed = narrow(Object.assign({}, candidateOptions, { [GRID_KEY_ONLY]: new Set(uncovered.map((item) => item.id)) }));
225
+ !narrowed.refused && narrowed.legend?.items.length && (keyed = narrowed);
226
+ } catch (error) {
227
+ if (!(error instanceof NormalizeError)) throw error;
228
+ } finally {
229
+ narrow.finish();
230
+ }
231
+ }
232
+ let names = keyed === candidate ? [] : (keyed.legend?.items ?? []).map((item) => keyName(keyed, item.labelId) || item.id);
233
+ return keyed.warnings.push({
234
+ code: "grid-legend-required",
235
+ severity: "info",
236
+ message: names.length > 0 ? `grid legend cannot be hidden: no direct label names ${names.join(", ")}, so the key row lists ${names.length === 1 ? "that series" : "those series"} only` : "grid legend cannot be hidden because no direct label names the colours and markers it keys"
237
+ }), keyed;
238
+ }
239
+
240
+ // src/core/grid/panelAlignment.ts
241
+ function moveChildPlot(child, dl, dr, theme) {
242
+ let effectiveLeft = typeof child.geometry.derived.leftInset == "number" ? child.geometry.derived.leftInset : child.margin.left ?? canvasMargin(theme, child.slot.w).left, effectiveRight = typeof child.geometry.derived.rightInset == "number" ? child.geometry.derived.rightInset : child.margin.right ?? canvasMargin(theme, child.slot.w).right;
243
+ child.margin = { ...child.margin, left: effectiveLeft + dl, right: effectiveRight + dr }, child.geometry = child.relayout(child.margin);
244
+ }
245
+ function alignCategoryPanels(children, theme) {
246
+ let before = new Map(children.map((child) => [child, [child.slot.x + child.geometry.plot.x, child.geometry.plot.w]])), ticksOf = (child) => child.geometry.axes.find((axis) => axis.axis === "x")?.ticks ?? [], candidates = children.filter((child) => child.relayout !== void 0 && ticksOf(child).length >= 2);
247
+ if (candidates.length < 2) return 0;
248
+ let shared = ticksOf(candidates[0]).map((tick) => tick.at).filter((at) => candidates.every((child) => ticksOf(child).some((tick) => tick.at === at)));
249
+ if (shared.length < 2) return 0;
250
+ let [firstId, lastId] = [shared[0], shared.at(-1)], posOf = (child, at) => child.slot.x + ticksOf(child).find((tick) => tick.at === at).pos;
251
+ for (let pass = 0; pass < 3; pass++) {
252
+ let first = maxOf(candidates.map((child) => posOf(child, firstId))), last = minOf(candidates.map((child) => posOf(child, lastId)));
253
+ if (!(last > first)) break;
254
+ let off = candidates.filter((child) => Math.abs(posOf(child, firstId) - first) > 0.01 || Math.abs(posOf(child, lastId) - last) > 0.01);
255
+ if (off.length === 0) break;
256
+ for (let child of off) {
257
+ let x = child.slot.x + child.geometry.plot.x, w = child.geometry.plot.w, f = (posOf(child, firstId) - x) / w, l = (posOf(child, lastId) - x) / w;
258
+ if (!(l > f)) continue;
259
+ let w2 = (last - first) / (l - f), x2 = first - f * w2;
260
+ moveChildPlot(child, x2 - x, x + w - (x2 + w2), theme);
261
+ }
262
+ }
263
+ return Math.max(0, maxOf(children.map((child) => {
264
+ let [x, w] = before.get(child), x2 = child.slot.x + child.geometry.plot.x;
265
+ return Math.max(Math.abs(x2 - x), Math.abs(x2 + child.geometry.plot.w - x - w));
266
+ })));
267
+ }
268
+ function alignValuePanels(children, theme, keep) {
269
+ let members = children.filter((child) => child.relayout !== void 0);
270
+ if (members.length < 2) return;
271
+ let heightOf = (child) => (child.geometry[PLOT_FLOOR_RECT] ?? child.geometry.plot).h;
272
+ for (let pass = 0; pass < 3; pass++) {
273
+ let height = minOf(members.map(heightOf)), off = members.filter((child) => heightOf(child) - height > 0.01);
274
+ if (off.length === 0) break;
275
+ for (let child of off) {
276
+ let cut = heightOf(child) - height, above = keep ? keep.above(child) : 0, bottom = child.margin.bottom ?? canvasMargin(theme, child.slot.w).bottom;
277
+ child.margin = { ...child.margin, bottom: bottom + cut * (1 - above), ...keep ? { top: keep.top(child) + cut * above } : {} }, child.geometry = child.relayout(child.margin);
278
+ }
279
+ }
280
+ }
281
+
282
+ // src/core/strings/grid.ts
283
+ var EN = {
284
+ // reader-facing wording linked only by its consumers.
285
+ maturingCohortNote: "Maturing cohorts have not had the full time to produce an outcome. Their scoped values are provisional.",
286
+ matureCohort: "Mature cohort",
287
+ provisional: "Provisional",
288
+ metricStack: "Metric stack",
289
+ metricStackWidth: "Metric stack needs {v1} px width.",
290
+ metricStackHeight: "Metric stack needs {v1} px height.",
291
+ sourceMeasures: "{v1} source measures",
292
+ metricStackTitle: "Metric stack of {v1} panels",
293
+ metricStackDesc: "Metric stack: {v1}. Top-down order: {v2}. Independent scales start at zero. {v3}",
294
+ gridPanelsTitle: "Grid of {v1} panels",
295
+ authoredRows: "Authored {v1}",
296
+ compositionColumns: "by {v1} composition",
297
+ gridComposition: "Authored {v1} by {v2} composition: {v3}.{v4}",
298
+ notesClause: " Notes: {v1}.",
299
+ legendName: "Legend",
300
+ legendItemsCount: "{v1} legend items.",
301
+ stackChangeMethod: "Change: average per {v1}, {v2} \u2192 {v3}; rates use volume weighting",
302
+ stackLeftMethod: "Left: volume-weighted mature rates and remaining per 100",
303
+ stackAboveMethod: "Above each panel: volume-weighted mature rates and remaining per 100",
304
+ notYetMature: "Not yet mature",
305
+ labelsShowTotals: "Labels show totals"
306
+ }, DE = {
307
+ // reader-facing wording linked only by its consumers.
308
+ maturingCohortNote: "Noch nicht ausgereifte Kohorten hatten nicht die volle Zeit f\xFCr ein Ergebnis. Ihre Werte im angegebenen Bereich sind vorl\xE4ufig.",
309
+ matureCohort: "Ausgereifte Kohorte",
310
+ provisional: "Vorl\xE4ufig",
311
+ metricStack: "Kennzahlenstapel",
312
+ metricStackWidth: "Kennzahlenstapel braucht {v1} px Breite.",
313
+ metricStackHeight: "Kennzahlenstapel braucht {v1} px H\xF6he.",
314
+ sourceMeasures: "{v1} {v1|Quellkennzahl|Quellkennzahlen}",
315
+ metricStackTitle: "Kennzahlenstapel mit {v1} {v1|Feld|Feldern}",
316
+ metricStackDesc: "Kennzahlenstapel: {v1}. Reihenfolge von oben: {v2}. Unabh\xE4ngige Skalen beginnen bei null. {v3}",
317
+ gridPanelsTitle: "Raster mit {v1} {v1|Feld|Feldern}",
318
+ authoredRows: "Angegeben: {v1}",
319
+ compositionColumns: "mal {v1} Anordnung",
320
+ gridComposition: "Angegebene Anordnung: {v1} mal {v2}: {v3}.{v4}",
321
+ notesClause: " Hinweise: {v1}.",
322
+ legendName: "Legende",
323
+ legendItemsCount: "{v1} {v1|Legendeneintrag|Legendeneintr\xE4ge}.",
324
+ stackChangeMethod: "\xC4nderung: Mittelwert je {v1}, {v2} \u2192 {v3}; Raten sind nach Volumen gewichtet",
325
+ stackLeftMethod: "Links: nach Volumen gewichtete ausgereifte Raten und Rest je 100",
326
+ stackAboveMethod: "\xDCber jedem Feld: nach Volumen gewichtete ausgereifte Raten und Rest je 100",
327
+ notYetMature: "Noch nicht ausgereift",
328
+ labelsShowTotals: "Beschriftungen zeigen Summen"
329
+ }, { chartString } = chartStrings(EN, DE);
330
+
331
+ // src/core/charts/grid/metricStackLayout.ts
332
+ var neutral = { token: "markInk" }, muted = { token: "inkMuted" }, accent = { token: "focus" }, wash = (base, weight, pageFloor) => ({ token: "markInk", theme: { kind: "mix", from: base, to: { token: "background" }, weight, ...pageFloor === void 0 ? {} : { pageFloor } } }), NO_WIDER_SEARCH = /* @__PURE__ */ Symbol("boardplot.metricStackNoWiderSearch");
333
+ function widerThatPlaces(raw, options, size, automatic) {
334
+ let draws = (width) => {
335
+ try {
336
+ return layoutMetricStack(raw, { ...options, size: automatic ? { width } : { width, height: size.height }, [NO_WIDER_SEARCH]: !0 }).scene.length > 0;
337
+ } catch (error) {
338
+ if (error instanceof NormalizeError) return !1;
339
+ throw error;
340
+ }
341
+ }, base = Math.floor(size.width), low = base, high;
342
+ for (let step = 4; step <= 512; step *= 2) {
343
+ if (draws(base + step)) {
344
+ high = base + step;
345
+ break;
346
+ }
347
+ low = base + step;
348
+ }
349
+ if (high !== void 0) {
350
+ for (; high - low > 1; ) {
351
+ let mid = Math.floor((low + high) / 2);
352
+ draws(mid) ? high = mid : low = mid;
353
+ }
354
+ return high;
355
+ }
356
+ }
357
+ function layoutMetricStack(raw, options) {
358
+ let data = normalizeMetricStack(raw);
359
+ options.stack || stackError("options.stack", "Shared measures require options.stack: {}"), (options.sharedAxis === "none" || options.sharedScale === !0 || options.columns !== void 0 || options.gutters !== void 0 || options.anchors !== void 0 || options.alignmentRules !== void 0 || options.panelOrder !== void 0) && stackError("options", "A metric stack owns top-down order, shared categories, spacing and independent scales; remove conflicting grid controls");
360
+ let stack = options.stack;
361
+ stack.heights && options.rows && stackError("options", "Use stack.heights or rows, not both"), (stack.heights && stack.heights.length !== data.panels.length || options.rows && options.rows.length !== data.panels.length) && stackError("options", "Supply one height or row weight per panel");
362
+ let theme = themeForWidth(resolveTheme(options.theme), resolveSize(options.size).width), measure = options.measure ?? defaultMeasurer, na = notApplicableGlyph(options.strings), computed = computeMetricStack(data, options.locale?.language, na), font = (role, weight) => ({ family: theme.type.family, ...theme.type[role], ...weight ? { weight } : {} }), valueFont = font("label", 700), nameFont = font("label", 700), unitFont = font("axis"), heroFont = font("title", 700), axisFont = font("axis"), noteFont = font("footnote"), keyFont = secondaryFont(theme), heightOf = (f) => f.size * (f.lineHeight ?? 1.2), textBox = (text, f, width) => {
363
+ let lines = wrapText(text, f, width, Number.MAX_SAFE_INTEGER, measure).lines;
364
+ return { lines, w: Math.max(...lines.map((line) => measure(line, f).width), 0), h: heightOf(f) * lines.length };
365
+ }, spacingError = (field, message, fix) => {
366
+ throw new NormalizeError("metric-stack-spacing", field, message, "Increase the named dimension; the engine does not shrink or overlap required labels.", fix);
367
+ }, heightFix = (i, px) => stack.heights ? [{ op: "replace", path: `/options/stack/heights/${i}`, value: px }] : void 0, minGap = Math.ceil(heightOf(axisFont) + 8), gap = Math.max(26, minGap), arrowWidth = Math.max(unitFont.size, measure("\u2192", unitFont).width), spanSpace = measure(" ", unitFont).width, spanWidths = computed.panels.map((p) => measure(p.readout.spanText, unitFont).width + arrowWidth - measure("\u2192", unitFont).width), minGutter = Math.ceil(Math.max(120, maxOf(computed.panels.map((p, i) => Math.max(
368
+ spanWidths[i],
369
+ measure(p.readout.headlineText, heroFont).width,
370
+ ...`${p.panel.title} ${p.panel.unit}`.split(/\s+/).map((word) => measure(word, nameFont).width)
371
+ )))) + 4), nameWidth = Math.ceil(maxOf(computed.panels.flatMap((p) => p.panel.title.split(`
372
+ `).map((line) => measure(line, nameFont).width)))) + 4, gutter = Math.max(170, minGutter, Math.min(320, nameWidth)), gutterGap = Math.max(28, heightOf(axisFont)), gutterBoxes = computed.panels.map((p) => ({ name: textBox(p.panel.title, nameFont, gutter), unit: textBox(p.panel.unit, keyFont, gutter) })), partial = partialIds(data.categories), notes = [...options.footnotes || []], listed = [], stateNotes = {}, engineNumbers = [], notesOff = frameTextOptions(options).footnotesOff, stateNote = (state, authored, engine) => {
373
+ if (authored === void 0 && (!disclosuresShown(options) || notesOff)) {
374
+ listed.push(disclosureNote(engine()));
375
+ return;
376
+ }
377
+ stateNotes[state] = notes.length + 1, authored === void 0 && engineNumbers.push(notes.length + 1), notes.push(authored ?? engine());
378
+ };
379
+ computed.maturing.length && stateNote("maturing", data.states?.maturing?.footnote, () => chartString(options, "maturingCohortNote")), partial.size && stateNote("partial", data.states?.partial?.footnote, () => partialFootnotes(data.categories, options.strings)[0]);
380
+ let marker = (value) => value === void 0 || notesOff ? "" : String(value).split("").map((c) => "\u2070\xB9\xB2\xB3\u2074\u2075\u2076\u2077\u2078\u2079"[Number(c)]).join(""), visibleValue = (p, i) => p.values[i] !== null, hasProvisional = computed.panels.some((p) => p.states.some((state, i) => state !== "mature" && visibleValue(p, i))), hasMatureLine = (p) => p.panel.type === "line" && p.states.some((state, i) => i > 0 && state === "mature" && p.states[i - 1] === "mature" && visibleValue(p, i) && visibleValue(p, i - 1)), measureIndexes = /* @__PURE__ */ new Map(), emphasizedMeasures = /* @__PURE__ */ new Set();
381
+ for (let p of computed.panels) if (p.panel.type === "column" && "sum" in p.panel.measure && p.parts.length > 1)
382
+ for (let id of p.panel.measure.sum)
383
+ measureIndexes.has(id) || measureIndexes.set(id, measureIndexes.size), p.panel.emphasis && emphasizedMeasures.add(id);
384
+ let columnFill = seriesPaint(0, options.palette), emphasizedFill = markRolePaint("focus", !0), measurePaints = new Map([...measureIndexes].map(([id, i]) => {
385
+ let base2 = emphasizedMeasures.has(id) ? emphasizedFill : columnFill;
386
+ return [id, {
387
+ // A later measure steps back into the page but keeps the 1.4:1 mark floor, as a faded series does.
388
+ mature: i === 0 ? base2 : wash(base2, Math.max(0.16, 0.45 - i * 0.12), 1.4)
389
+ }];
390
+ })), stacked = (p) => p.panel.type === "column" && "sum" in p.panel.measure && p.parts.length > 1, panelKeys = computed.panels.map(() => []), seen = /* @__PURE__ */ new Set();
391
+ computed.panels.forEach((p, pi) => {
392
+ stacked(p) && "sum" in p.panel.measure && p.panel.measure.sum.forEach((id, i) => {
393
+ p.parts[i].some((value, ci) => value !== null && value > 0 && visibleValue(p, ci)) && (seen.add(id), panelKeys[pi].push({ id, label: data.measures.find((m) => m.id === id).label, paint: measurePaints.get(id).mature }));
394
+ });
395
+ }), options.legend === "none" && panelKeys.forEach((items) => items.splice(0));
396
+ let totalsCue = chartString(options, "labelsShowTotals"), keySwatch = 10, keyRow = heightOf(keyFont) + 6, breakWords = (text, width) => text.split(/\r?\n/).flatMap((paragraph) => {
397
+ let lines = [], line = "";
398
+ for (let word of paragraph.split(/[^\S  ]+/).filter(Boolean)) {
399
+ let joined = line ? `${line} ${word}` : word;
400
+ if (measure(joined, keyFont).width <= width) {
401
+ line = joined;
402
+ continue;
403
+ }
404
+ line && lines.push(line), line = "";
405
+ for (let char of word)
406
+ line && measure(`${line}${char}-`, keyFont).width > width && (lines.push(`${line}-`), line = ""), line += char;
407
+ }
408
+ return (line || !lines.length) && lines.push(line), lines;
409
+ }), keyLayout = (pi, width, column) => {
410
+ let items = [...panelKeys[pi], ...panelKeys[pi].length ? [{ id: "stack:totals", label: totalsCue, paint: void 0 }] : []].map((item) => {
411
+ let inset = item.paint ? keySwatch + 5 : 0, wrapped = wrapText(item.label, keyFont, width - inset, Number.MAX_SAFE_INTEGER, measure), lines = wrapped.truncated ? breakWords(item.label, width - inset) : wrapped.lines, textW = Math.max(...lines.map((line) => measure(line, keyFont).width));
412
+ return { ...item, lines, textW, w: inset + textW, extra: (lines.length - 1) * heightOf(keyFont) };
413
+ }), x = 0, dy = 0, rowExtra = 0;
414
+ return { placed: items.map((item, i) => {
415
+ i > 0 && (column || rowExtra > 0 || item.extra > 0 || x + item.w > width) && (x = 0, dy += keyRow + rowExtra, rowExtra = 0);
416
+ let at = { ...item, dx: x, dy };
417
+ return x += item.w + 14, rowExtra = Math.max(rowExtra, item.extra), at;
418
+ }), h: items.length ? dy + keyRow + rowExtra : 0 };
419
+ }, legend = [];
420
+ if (!seen.size) {
421
+ hasProvisional && computed.panels.some((p) => !p.panel.emphasis && hasMatureLine(p)) && legend.push({ id: "stack:mature", label: chartString(options, "matureCohort"), paint: neutral, key: "line" });
422
+ let emphasis = computed.panels.find((p) => p.panel.emphasis && hasMatureLine(p));
423
+ emphasis && legend.push({ id: "stack:emphasis", label: emphasis.panel.title, paint: accent, key: "line", width: strokeToken(theme, "focus") }), hasProvisional && legend.push({ id: "stack:provisional", label: chartString(options, "provisional"), paint: muted, key: "line", dash: dashToken(theme, "reference") });
424
+ }
425
+ let size = resolveSize(options.size), automatic = heightOmitted(options.size), base = canvasMargin(theme, size.width), margin = { ...base, left: Math.min(24, base.left), right: Math.min(24, base.right), ...options.margin }, frameAt = () => {
426
+ let occupied2 = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frame2 = solveFrame({
427
+ size,
428
+ margin,
429
+ ...frameTextOptions(options),
430
+ footnotes: [...notes, ...listed],
431
+ numberedFootnotes: notes,
432
+ unreferencedNotes: [],
433
+ numberedDisclosures: engineNumbers,
434
+ // A state note a marker points at prints with it (an engine-worded one where notes.show lists 'disclosure').
435
+ pointedNotes: [...frameTextOptions(options).pointedNotes ?? [], ...Object.values(stateNotes).map((n) => notes[n - 1])],
436
+ legend: options.legend === "none" ? void 0 : { options: normalizeLegendOption(options.legend, { position: "top" }), items: legend },
437
+ theme,
438
+ measure
439
+ }, occupied2);
440
+ return { occupied: occupied2, frame: frame2 };
441
+ };
442
+ automatic && (size = { ...size, height: Math.max(size.height, 1600) });
443
+ let { occupied, frame } = frameAt(), valueWidth = maxOf(computed.panels.flatMap((p) => p.values.map((v) => v === null ? measure(na, valueFont).width : measure(formatPanelValue(p.panel, v, options.locale?.language), valueFont).width))) + 4, categoryWidth = maxOf(data.categories.flatMap((c) => c.label.split(/\s+/).map((word) => measure(word, keyFont).width))) + 3, valueRoom = Math.max(20, valueWidth, categoryWidth) * data.categories.length, gutterKeys = computed.panels.map((_, i) => keyLayout(i, gutter, !0)), gutterHeights = gutterBoxes.map((box, i) => box.name.h + box.unit.h + heightOf(heroFont) + heightOf(unitFont) + 18 + (gutterKeys[i].h ? gutterKeys[i].h + 6 : 0)), narrow = frame.plot.w - gutter - gutterGap < valueRoom || gutterHeights.some((h, i) => stack.heights !== void 0 && Math.ceil(h) > stack.heights[i]), thin = narrow && frame.plot.w < valueRoom, lastIndex = data.categories.length - 1, named = (ci) => !thin || ci % 2 === lastIndex % 2, plotX = narrow ? frame.plot.x : frame.plot.x + gutter + gutterGap, plotW = narrow ? frame.plot.w : frame.plot.w - gutter - gutterGap, step = plotW / data.categories.length, minimumWidth = Math.ceil(size.width - plotW + (thin ? valueRoom / 2 : valueRoom)), needsWidth = (width) => ({
444
+ type: "grid",
445
+ size,
446
+ plot: frame.plot,
447
+ scene: [],
448
+ labels: [],
449
+ axes: [],
450
+ annotations: [],
451
+ frame: frame.frame,
452
+ marks: { panels: [] },
453
+ derived: {},
454
+ sizing: { aspect: "content", fit: "content", minWidth: width, minHeight: 0, measuredMinWidth: width, measuredMinHeight: 0, naturalWidth: width, naturalHeight: size.height, comfortableWidth: width, comfortableHeight: size.height },
455
+ a11y: { title: chartString(options, "metricStack"), desc: chartString(options, "metricStackWidth", { v1: width }) },
456
+ warnings: [],
457
+ debug: { occupied: [], decisions: [] }
458
+ });
459
+ if (size.width < minimumWidth) return needsWidth(minimumWidth);
460
+ let heads = narrow ? computed.panels.map((p, i) => {
461
+ let name = textBox(p.panel.title, nameFont, frame.plot.w), unit = textBox(p.panel.unit, keyFont, frame.plot.w), unitBeside = name.lines.length === 1 && unit.lines.length === 1 && name.w + 2 * spanSpace + unit.w <= frame.plot.w, spanBeside = measure(p.readout.headlineText, heroFont).width + 3 * spanSpace + spanWidths[i] + 2 * spanSpace <= frame.plot.w, top = unitBeside ? Math.max(name.h, unit.h) : name.h + 2 + unit.h, key = keyLayout(i, frame.plot.w, !1), body = top + 8 + heightOf(heroFont) + (spanBeside ? 0 : 6 + heightOf(unitFont)) + 6;
462
+ return { name, unit, unitBeside, spanBeside, top, key, body, h: body + (key.h ? key.h + 4 : 0) };
463
+ }) : void 0, minimumHeights = gutterHeights.map((h) => Math.ceil(Math.max(narrow ? 0 : h, 3 * heightOf(valueFont) + 20))), heights = computed.panels.map((p, i) => stack.heights?.[i] ?? Math.max(minimumHeights[i], p.panel.type === "column" ? p.parts.length > 1 ? narrow ? 110 : 150 : narrow ? 120 : 200 : narrow ? 90 : 130));
464
+ if (options.rows) {
465
+ let factor = maxOf(minimumHeights.map((h, i) => h / options.rows[i]));
466
+ heights = options.rows.map((w) => w * factor);
467
+ }
468
+ heights.forEach((h, i) => {
469
+ (!Number.isFinite(h) || h < minimumHeights[i]) && spacingError(`options.stack.heights.${i}`, `Panel '${data.panels[i].id}' needs at least ${minimumHeights[i]} px for its readout and value labels`, heightFix(i, minimumHeights[i]));
470
+ });
471
+ let headRoom = heads?.reduce((sum2, head) => sum2 + head.h, 0) ?? 0, partialOnValues = computed.panels.some((p) => p.panel.type === "column" && computed.partial.some((i) => p.values[i] !== null)), partialMark = marker(stateNotes.partial), toDate = ` ${options.strings?.toDate ?? localeStrings(options.locale?.language).toDate}`, categoryName = (c) => c.label + (c.partial ? partialMark ? partialOnValues ? "" : partialMark : saysToDate(c.label, toDate.trim()) ? "" : toDate : ""), categoryBoxes = data.categories.map((c) => textBox(categoryName(c), keyFont, (thin ? 2 : 1) * step - 3)), categoryHeight = maxOf(categoryBoxes.map((b) => b.h)), periodBoxes = data.periods?.map((period) => {
472
+ let indexes = stackRange(data, period), bold = data.windows ? [data.windows.base, data.windows.compare].some((w) => w.from === period.from && w.to === period.to) : indexes.every((i) => computed.mature.includes(i)), f = { ...keyFont, weight: bold ? 700 : keyFont.weight };
473
+ return { ...textBox(period.label, f, indexes.length * step - 4), indexes, bold, font: f };
474
+ }), axisHeight = 12 + categoryHeight + (periodBoxes ? 10 + maxOf(periodBoxes.map((b) => b.h)) : 0) + 10, bandFirstIndex = data.states?.maturing ? data.panels.findIndex((p) => data.states.maturing.panels.includes(p.id)) : -1, firstOverhang = computed.maturing.length ? gap : 0, readLogic = data.panels.some((p) => p.readout === "change") && data.windows ? chartString(options, "stackChangeMethod", { v1: metricStackGrain(data), v2: data.windows.base.label, v3: data.windows.compare.label }) : chartString(options, narrow ? "stackAboveMethod" : "stackLeftMethod"), readLogicBox = textBox(readLogic, keyFont, frame.plot.w), topRoom = readLogicBox.h + 12 + 30 + (bandFirstIndex === 0 ? firstOverhang : 0), neededPlotHeight = topRoom + headRoom + heights.reduce((a, b) => a + b, 0) + gap * (heights.length - 1) + axisHeight, overhead = size.height - frame.plot.h, naturalHeight = Math.ceil(overhead + neededPlotHeight);
475
+ if (automatic)
476
+ size = { ...size, height: naturalHeight }, { occupied, frame } = frameAt();
477
+ else {
478
+ if (frame.plot.h < neededPlotHeight - 0.01)
479
+ return {
480
+ type: "grid",
481
+ size,
482
+ plot: frame.plot,
483
+ scene: [],
484
+ labels: [],
485
+ axes: [],
486
+ annotations: [],
487
+ frame: frame.frame,
488
+ marks: { panels: [] },
489
+ derived: {},
490
+ sizing: { aspect: "content", fit: "content", minWidth: size.width, minHeight: naturalHeight, measuredMinWidth: size.width, measuredMinHeight: naturalHeight, naturalWidth: size.width, naturalHeight, comfortableWidth: size.width, comfortableHeight: naturalHeight },
491
+ a11y: { title: chartString(options, "metricStack"), desc: chartString(options, "metricStackHeight", { v1: naturalHeight }) },
492
+ warnings: [],
493
+ debug: { occupied: [], decisions: [] }
494
+ };
495
+ if (!stack.heights && frame.plot.h > neededPlotHeight) {
496
+ let available = frame.plot.h - topRoom - headRoom - gap * (heights.length - 1) - axisHeight, total = heights.reduce((a, b) => a + b, 0);
497
+ heights = heights.map((h) => h * available / total);
498
+ }
499
+ }
500
+ let scene = [...frame.nodes], requests = [], inks = /* @__PURE__ */ new Map(), put = (id, text, f, rect, owner, ink, role = "label", kind = "point", lines = [text], claimId, below) => {
501
+ if (rect.w > 0 && rect.h > 0) {
502
+ let candidates = [{ slot: "fixed", rect, penalty: 0 }, ...below === void 0 ? [] : [{ slot: "fixed", rect: { ...rect, y: below }, penalty: 1 }]];
503
+ requests.push({ id, kind, owner, text, lines, font: f, typeRole: role, priority: PRIORITY.total, pad: 0, candidates, ...claimId ? { claimId } : {} }), inks.set(id, ink);
504
+ }
505
+ }, centerText = (id, text, f, x, y2, owner, ink, role = "label", kind = "point", claimId, below) => {
506
+ let box = measure(text, f);
507
+ put(id, text, f, { x: x - box.width / 2, y: y2, w: box.width, h: heightOf(f) }, owner, ink, role, kind, [text], claimId, below);
508
+ };
509
+ put("stack:read-logic", readLogic, keyFont, { x: frame.plot.x, y: frame.plot.y, w: readLogicBox.w, h: readLogicBox.h }, {}, muted, "secondary", "annotation", readLogicBox.lines), scene.push({ t: "line", id: "stack:header-rule", x1: frame.plot.x, x2: frame.plot.x + frame.plot.w, y1: frame.plot.y + readLogicBox.h + 10, y2: frame.plot.y + readLogicBox.h + 10, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "headerRule" });
510
+ let plots = [], tops = [], y = frame.plot.y + topRoom;
511
+ heights.forEach((h, i) => {
512
+ tops.push(y), y += heads?.[i].h ?? 0, plots.push({ x: plotX, y, w: plotW, h }), y += h + gap;
513
+ });
514
+ let derived = { gap, gutterWidth: narrow ? 0 : gutter, axisOwner: data.panels.at(-1).id, readouts: computed.panels.map((p) => p.readout), panels: [] }, bandLabelHeight = 0;
515
+ if (computed.maturing.length) {
516
+ let scope = data.states.maturing, indexes = scope.panels.map((id) => data.panels.findIndex((p) => p.id === id)).sort((a, b) => a - b), first = plots[indexes[0]], last = plots[indexes.at(-1)], firstTop = tops[indexes[0]], bandAt = categoryBandFromCenters(data.categories.map((c) => c.id), first, (i) => plotX + (i + 0.5) * step, "x"), left = bandAt(scope.from), right = bandAt(scope.to), rect = { x: left.x, y: firstTop - firstOverhang, w: right.x + right.w - left.x, h: last.y + last.h - firstTop + firstOverhang }, nodeId = "stack:maturing:band";
517
+ derived.band = { rect, panels: indexes.map((i) => data.panels[i].id), categoryIds: computed.maturing.map((i) => data.categories[i].id), nodeId }, scene.push({ t: "rect", id: nodeId, rect, fill: wash(neutral, 0.035), owner: { annotationId: "stack:maturing" }, part: "band" });
518
+ let text = (scope.label ?? chartString(options, "notYetMature")) + marker(stateNotes.maturing), box = textBox(text, noteFont, rect.w - 8);
519
+ bandLabelHeight = box.h, put("stack:maturing:label", text, noteFont, { x: rect.x + (rect.w - box.w) / 2, y: rect.y + 4, w: box.w, h: box.h }, { annotationId: "stack:maturing" }, muted, "footnote", "annotation", box.lines);
520
+ }
521
+ let marks = { panels: [] }, yielding = /* @__PURE__ */ new Set();
522
+ computed.panels.forEach((p, pi) => {
523
+ let formatValue = (value) => formatPanelValue(p.panel, value, options.locale?.language), plot = plots[pi], baseline = plot.y + plot.h, owner = { seriesId: p.panel.id }, color = p.panel.emphasis ? accent : neutral, labelGap = p.panel.type === "line" ? 9 : 5, clearance = heightOf(valueFont) + labelGap + (p.panel.type === "line" ? 4.5 : 0) + 4, bandClear = pi === bandFirstIndex ? Math.max(0, bandLabelHeight + 8 - firstOverhang - (heads?.[pi].h ?? 0)) : 0, headroom = clearance + bandClear;
524
+ plot.h <= headroom + 10 && spacingError(`options.stack.heights.${pi}`, `Panel '${p.panel.id}' needs at least ${Math.ceil(headroom + 11)} px height for its band and labels`, heightFix(pi, Math.ceil(headroom + 11)));
525
+ let visible = (i) => visibleValue(p, i), max = Math.max(maxOf(p.values.map((v, i) => visible(i) ? v ?? 0 : 0)), 0), domainMax = max === 0 ? 1 : max / (1 - headroom / plot.h), py = (v) => baseline - v / domainMax * plot.h, nodeIds = data.categories.map(() => []), displayed = data.categories.map(() => na), emit = (node, ci) => {
526
+ scene.push(node), ci !== void 0 && nodeIds[ci].push(node.id);
527
+ };
528
+ marks.panels.push({ id: p.panel.id, type: p.panel.type, plot, content: { x: frame.plot.x, y: plot.y, w: frame.plot.w, h: plot.h }, title: p.panel.title, row: pi, column: 0 }), derived.panels.push({ id: p.panel.id, domain: [0, domainMax], plot, values: p.values, states: p.states, displayed, nodeIds });
529
+ let boxes = heads?.[pi] ?? gutterBoxes[pi], head = heads?.[pi], gy = tops[pi];
530
+ put(`${p.panel.id}:name`, p.panel.title, nameFont, { x: frame.plot.x, y: gy, w: boxes.name.w, h: boxes.name.h }, owner, { token: "ink" }, "label", "category", boxes.name.lines), head?.unitBeside ? put(`${p.panel.id}:unit`, p.panel.unit, keyFont, { x: frame.plot.x + boxes.name.w + 2 * spanSpace, y: gy + boxes.name.h - boxes.unit.h, w: boxes.unit.w, h: boxes.unit.h }, owner, muted, "secondary", "category", boxes.unit.lines) : (gy += boxes.name.h + 2, put(`${p.panel.id}:unit`, p.panel.unit, keyFont, { x: frame.plot.x, y: gy, w: boxes.unit.w, h: boxes.unit.h }, owner, muted, "secondary", "category", boxes.unit.lines)), gy = head ? tops[pi] + head.top + 8 : gy + boxes.unit.h + 10;
531
+ let hero = measure(p.readout.headlineText, heroFont), headlineClaim = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:headline` || c.id === `stack:${p.panel.id}:rate`);
532
+ put(`${p.panel.id}:headline`, p.readout.headlineText, heroFont, { x: frame.plot.x, y: gy, w: hero.width, h: heightOf(heroFont) }, owner, color, "title", "point", [p.readout.headlineText], headlineClaim.id);
533
+ let before = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:before`), after = p.readout.claims.find((c) => c.id === `stack:${p.panel.id}:after`), gx = frame.plot.x;
534
+ head?.spanBeside ? (gx += hero.width + 3 * spanSpace, gy += heightOf(heroFont) / 2 - heightOf(unitFont) / 2 + 0.36 * (heroFont.size - unitFont.size)) : gy += heightOf(heroFont) + 6;
535
+ for (let [suffix, text, claim] of [["before", before.output.displayed, before.id], ["arrow", "\u2192", void 0], ["after", after.output.displayed, after.id]]) {
536
+ suffix === "arrow" && (gx += spanSpace);
537
+ let width = suffix === "arrow" ? arrowWidth : measure(text, unitFont).width;
538
+ put(`${p.panel.id}:${suffix}`, text, unitFont, { x: gx, y: gy, w: width, h: heightOf(unitFont) }, owner, muted, "axis", "point", [text], claim), gx += width + (suffix === "arrow" ? spanSpace : 0);
539
+ }
540
+ let barWidth = step * 0.64, segmentLabels = stacked(p) && !thin && data.categories.every((_, ci) => {
541
+ let part = p.parts[0][ci];
542
+ return !visible(ci) || !part || part / domainMax * plot.h >= heightOf(valueFont) + 10 && measure(formatValue(part), valueFont).width < barWidth - 6;
543
+ }), key = head ? head.key : gutterKeys[pi], keyTop = head ? tops[pi] + head.body : gy + heightOf(unitFont) + 6;
544
+ for (let item of key.placed) {
545
+ if (item.id === "stack:totals" && segmentLabels) continue;
546
+ let kx = frame.plot.x + item.dx, ky = keyTop + item.dy;
547
+ item.paint && scene.push({ t: "rect", id: `${p.panel.id}:key:${item.id}`, rect: { x: kx, y: ky + (keyRow - keySwatch) / 2, w: keySwatch, h: keySwatch }, fill: item.paint, owner: { seriesId: item.id }, part: "swatch" });
548
+ let tx = item.paint ? kx + keySwatch + 5 : kx;
549
+ put(`${p.panel.id}:key:${item.id}:label`, item.label, keyFont, { x: tx, y: ky + (keyRow - heightOf(keyFont)) / 2, w: item.textW, h: heightOf(keyFont) * item.lines.length }, { seriesId: item.id }, muted, "secondary", "category", item.lines);
550
+ }
551
+ if (p.panel.type === "line") {
552
+ for (let i = 1; i < data.categories.length; i++) if (visible(i - 1) && visible(i) && p.states[i - 1] !== "partial" && p.states[i] !== "partial") {
553
+ let provisional = p.states[i - 1] === "maturing" || p.states[i] === "maturing", x1 = plotX + (i - 0.5) * step, y1 = py(p.values[i - 1]), x2 = plotX + (i + 0.5) * step, y2 = py(p.values[i]);
554
+ emit({ t: "line", id: `${p.panel.id}:line:${i}`, x1, y1, x2, y2, stroke: provisional ? muted : color, width: strokeToken(theme, p.panel.emphasis ? "focus" : "data"), ...provisional ? { dash: dashToken(theme, "reference") } : {}, owner, part: provisional ? "provisionalLine" : "line" });
555
+ let length = Math.hypot(x2 - x1, y2 - y1), dx = -(y2 - y1) / length, dy = (x2 - x1) / length;
556
+ occupied.claim(
557
+ { x: x1 - 1, y: Math.min(y1, y2) - 1, w: x2 - x1 + 2, h: Math.abs(y2 - y1) + 2 },
558
+ "mark",
559
+ { ...owner, pointId: `segment:${i}` },
560
+ "line",
561
+ [
562
+ { x: x1 + dx, y: y1 + dy },
563
+ { x: x2 + dx, y: y2 + dy },
564
+ { x: x2 - dx, y: y2 - dy },
565
+ { x: x1 - dx, y: y1 - dy }
566
+ ]
567
+ );
568
+ }
569
+ }
570
+ let latest = data.categories.reduce((last, _, ci) => visible(ci) ? ci : last, -1), valued = (ci) => named(ci) || ci === latest;
571
+ named(latest) || yielding.add(`${p.panel.id}:value:${data.categories[latest - 1]?.id}`), data.categories.forEach((category, ci) => {
572
+ let x = plotX + (ci + 0.5) * step, cellOwner = { seriesId: p.panel.id, categoryId: category.id };
573
+ if (!visible(ci)) {
574
+ valued(ci) && centerText(`${p.panel.id}:value:${category.id}`, na, valueFont, x, baseline - heightOf(valueFont) - 5, cellOwner, muted);
575
+ return;
576
+ }
577
+ let v = p.values[ci], top = py(v), provisional = p.states[ci] !== "mature", val = formatValue(v);
578
+ displayed[ci] = val;
579
+ let labelText = val + (p.panel.type === "column" && p.states[ci] === "partial" ? marker(stateNotes.partial) : "");
580
+ if (p.panel.type === "column") {
581
+ let width = barWidth, sum2 = 0, values = "sum" in p.panel.measure ? p.parts.map((part) => part[ci]) : [v];
582
+ values.forEach((part, si) => {
583
+ let h = part / domainMax * plot.h;
584
+ sum2 += part;
585
+ let paints = values.length > 1 && "sum" in p.panel.measure ? measurePaints.get(p.panel.measure.sum[si]) : void 0, fill = paints ? paints.mature : p.panel.emphasis ? emphasizedFill : columnFill, rect = { x: x - width / 2, y: py(sum2), w: width, h }, partOwner = { ...cellOwner, segmentId: String(si) };
586
+ if (emit({ t: "rect", id: `${p.panel.id}:bar:${category.id}:${si}`, rect, fill, ...provisional ? { pattern: "hatch45", hatchEdge: !1, ...paints ? { hatch: { strength: options.hatchStrength ?? HATCH_STRENGTH_DEFAULT.sole, cue: "sole", stacked: !0 } } : {} } : {}, owner: partOwner, part: "segment" }, ci), occupied.claim(rect, "mark", partOwner, "segment"), segmentLabels && si === 0 && part) {
587
+ let text = formatValue(part), ink = provisional ? { token: "ink" } : paints && fill !== color ? { token: "ink", theme: { kind: "contrast-ink", fill } } : { token: "inkInverse" }, tw = measure(text, valueFont).width;
588
+ provisional && emit({ t: "rect", id: `${p.panel.id}:segment-tag:${category.id}`, rect: { x: x - tw / 2 - 2, y: rect.y + 4, w: tw + 4, h: heightOf(valueFont) }, fill: { token: "background" }, radius: 2, owner: partOwner, part: "labelTag" }, ci), centerText(`${p.panel.id}:segment:${category.id}`, text, valueFont, x, rect.y + 4, partOwner, ink);
589
+ }
590
+ }), provisional && emit({ t: "path", id: `${p.panel.id}:outline:${category.id}`, d: `M${fmtPathNumber(x - width / 2)} ${fmtPathNumber(baseline)}V${fmtPathNumber(top)}H${fmtPathNumber(x + width / 2)}V${fmtPathNumber(baseline)}`, stroke: muted, width: strokeToken(theme, "mark"), dash: dashToken(theme, "reference"), owner: cellOwner, part: "provisionalOutline" }, ci);
591
+ } else
592
+ emit({ t: "circle", id: `${p.panel.id}:point:${category.id}`, cx: x, cy: top, r: 4.5, fill: provisional ? { token: "background" } : color, ...provisional ? { stroke: muted, strokeWidth: strokeToken(theme, "mark") } : {}, owner: cellOwner, part: provisional ? "provisionalPoint" : "point" }, ci), occupied.claim({ x: x - 4.5, y: top - 4.5, w: 9, h: 9 }, "mark", cellOwner, "point");
593
+ valued(ci) && centerText(`${p.panel.id}:value:${category.id}`, labelText, valueFont, x, top - labelGap - heightOf(valueFont), cellOwner, provisional ? muted : { token: "ink" }, "label", "point", void 0, p.panel.type === "line" && top + labelGap + heightOf(valueFont) < baseline - 2 ? top + labelGap : void 0);
594
+ }), emit({ t: "line", id: `${p.panel.id}:baseline`, x1: plotX, x2: plotX + plotW, y1: baseline, y2: baseline, stroke: { token: "axis" }, width: strokeToken(theme, "rule"), owner, part: "baseline" }), occupied.claim({ x: plotX, y: baseline - 0.5, w: plotW, h: 1 }, "axis", owner, "baseline");
595
+ });
596
+ let axisY = plots.at(-1).y + plots.at(-1).h + 8;
597
+ data.categories.forEach((category, i) => {
598
+ let box = categoryBoxes[i], text = categoryName(category);
599
+ if (!named(i)) {
600
+ scene.push({ t: "line", id: `stack:category:tick:${category.id}`, x1: plotX + (i + 0.5) * step, x2: plotX + (i + 0.5) * step, y1: axisY + 2, y2: axisY + 7, stroke: muted, width: strokeToken(theme, "rule"), owner: { categoryId: category.id }, part: "categoryTick" });
601
+ return;
602
+ }
603
+ put(`stack:category:${category.id}`, text, keyFont, { x: plotX + (i + 0.5) * step - box.w / 2, y: axisY, w: box.w, h: box.h }, { categoryId: category.id }, { token: "ink" }, "secondary", "category", box.lines);
604
+ }), data.periods?.forEach((period, i) => {
605
+ let box = periodBoxes[i], { indexes, bold, font: f } = box, x = plotX + indexes[0] * step, y2 = axisY + categoryHeight + 8;
606
+ put(`stack:period:${i}`, period.label, f, { x: x + 2, y: y2 + 4, w: box.w, h: box.h }, { categoryId: period.from }, bold ? { token: "ink" } : muted, "secondary", "category", box.lines), scene.push({ t: "line", id: `stack:period:rule:${i}`, x1: x + 1.5, x2: x + indexes.length * step - 1.5, y1: y2, y2, stroke: bold ? { token: "ink" } : { token: "grid" }, width: strokeToken(theme, bold ? "data" : "rule"), owner: {}, part: "periodRule" });
607
+ });
608
+ for (let request of requests) yielding.has(request.id) && (request.priority = PRIORITY.interior);
609
+ let solved = solveLabels(requests, occupied, { density: "full", pins: options.labelPlacements ?? {}, measure, plot: frame.plot, canvas: { x: 0, y: 0, w: size.width, h: size.height }, darkInk: theme.color.ink, lightInk: theme.color.inkInverse, labelPad: 0 }), fonts = new Map(requests.map((request) => [request.id, request.font]));
610
+ for (let label of solved.placed)
611
+ label.ink = inks.get(label.id) ?? label.ink, label.font = fonts.get(label.id);
612
+ let hidden = solved.placed.filter((l) => l.hidden && !yielding.has(l.id));
613
+ if (hidden.length) {
614
+ let width = options[NO_WIDER_SEARCH] ? void 0 : widerThatPlaces(raw, options, size, automatic);
615
+ if (width !== void 0) return needsWidth(width);
616
+ spacingError("options.size", `Metric stack cannot place ${hidden.map((l) => `'${l.text}'`).join(", ")} at ${size.width} \xD7 ${size.height} px`);
617
+ }
618
+ pushAll(scene, labelsToNodes(theme, solved.placed, () => valueFont));
619
+ let counts = [structureCount("panels", data.panels.length, void 0, options), structureCount("categories", data.categories.length, void 0, options), structureCount("series", data.measures.length, chartString(options, "sourceMeasures", { v1: data.measures.length }))];
620
+ return {
621
+ type: "grid",
622
+ size,
623
+ plot: frame.plot,
624
+ scene,
625
+ labels: solved.placed,
626
+ axes: [{ axis: "x", baselineNodeId: `${data.panels.at(-1).id}:baseline`, ticks: data.categories.map((c, i) => ({ at: c.id, pos: plotX + (i + 0.5) * step, labelId: `stack:category:${c.id}` })) }],
627
+ annotations: [],
628
+ frame: frame.frame,
629
+ legend: frame.legend,
630
+ marks,
631
+ derived: { metricStack: derived, sharedPlotX: plotX, sharedPlotW: plotW, tierGap: gap },
632
+ sizing: { aspect: "content", fit: "content", minWidth: size.width, minHeight: naturalHeight, measuredMinWidth: size.width, measuredMinHeight: naturalHeight, naturalWidth: size.width, naturalHeight, comfortableWidth: size.width, comfortableHeight: naturalHeight },
633
+ a11y: { title: accessibleTitle(options.title, chartString(options, "metricStackTitle", { v1: data.panels.length })), counts, desc: chartString(options, "metricStackDesc", { v1: counts.map((c) => c.text).join(", "), v2: data.panels.map((p) => p.title).join("; "), v3: computed.panels.map((p) => `${p.panel.title}: ${p.readout.headlineText}; ${p.readout.spanText}.`).join(" ") }) },
634
+ warnings: solved.warnings,
635
+ debug: { occupied: occupied.snapshot(), decisions: solved.decisions }
636
+ };
637
+ }
638
+
639
+ // src/core/strings/layoutGrid.ts
640
+ var EN2 = {
641
+ // reader-facing wording linked only by its consumers.
642
+ notesClause: " Notes: {v1}.",
643
+ gridChartsTitle: "Grid of {v1} charts",
644
+ gridChartsDesc: "{v1}: {v2}.{v3}",
645
+ alignedExhibit: "Aligned multi-tier exhibit",
646
+ chartGrid: "Chart grid"
647
+ }, DE2 = {
648
+ // reader-facing wording linked only by its consumers.
649
+ notesClause: " Hinweise: {v1}.",
650
+ gridChartsTitle: "Raster mit {v1} {v1|Diagramm|Diagrammen}",
651
+ gridChartsDesc: "{v1}: {v2}.{v3}",
652
+ alignedExhibit: "Ausgerichtete Darstellung mit mehreren Ebenen",
653
+ chartGrid: "Diagrammraster"
654
+ }, { chartString: chartString2 } = chartStrings(EN2, DE2);
655
+
656
+ // src/core/panelNoteData.ts
657
+ function panelNoteData(type, data, language) {
658
+ let def = getChart(type);
659
+ return def?.categoryLabels ? withCalendarLabels(data, language, def.categoryLabels) : data;
660
+ }
661
+
662
+ // src/core/grid/childLayout.ts
663
+ var hasKpiFigure = (type) => type === "kpi" || type === "waffle";
664
+ function smallestKpiValueSize(children) {
665
+ let figures = (child) => child.scene.filter((node) => (child.type === "kpi" ? node.id === "label:total:value" : node.id.startsWith("label:total:")) && node.t === "text"), sizes = children.filter((child) => hasKpiFigure(child.type)).map((child) => ({ type: child.type, nodes: figures(child) })).filter(({ type, nodes }) => type !== "waffle" || nodes.length <= 1).flatMap(({ nodes }) => nodes.map((node) => node.t === "text" ? node.font.size : 1 / 0));
666
+ return sizes.length > 1 && maxOf(sizes) > minOf(sizes) ? minOf(sizes) : void 0;
667
+ }
668
+ function layoutChildChart(data, options, layout) {
669
+ let geometry = layout(data, options);
670
+ if (geometry.refused) return geometry;
671
+ if (geometry.sizing?.fit === "content") {
672
+ let height = geometry.sizing.naturalHeight;
673
+ height < geometry.size.height && (geometry = layout(data, { ...options, size: { width: geometry.size.width, height } }));
674
+ }
675
+ if (geometry.refused) return geometry;
676
+ let { sizing, frame } = geometry;
677
+ if (sizing) {
678
+ let minWidth = sizing.measuredMinWidth, minHeight = Math.ceil(Math.max(
679
+ frame.minHeight ?? 0,
680
+ isVarianceTier(options) ? 0 : frame.plotMinHeight ?? 0,
681
+ sizing.measuredMinHeight
682
+ ));
683
+ geometry.sizing = resolveSizing({ ...sizing, minWidth, minHeight }, geometry.size, {
684
+ minWidth,
685
+ minHeight,
686
+ naturalWidth: sizing.naturalWidth,
687
+ naturalHeight: sizing.naturalHeight
688
+ });
689
+ }
690
+ return geometry;
691
+ }
692
+ var sum = (values) => values.reduce((a, b) => a + b, 0);
693
+ function contentRows(children, rows, gaps, automatic) {
694
+ return rows.map((_, row) => {
695
+ let occupants = children.filter((child) => child.row <= row && row < child.row + child.rowSpan);
696
+ if (!(!automatic || occupants.length === 0 || occupants.some((child) => child.geometry.sizing?.fit !== "content")))
697
+ return maxOf(occupants.map((child) => {
698
+ let weight = sum(rows.slice(child.row, child.row + child.rowSpan)), height = child.geometry.sizing.naturalHeight - sum(gaps.slice(child.row, child.row + child.rowSpan - 1));
699
+ return Math.max(0, height) * rows[row] / weight;
700
+ }));
701
+ });
702
+ }
703
+ function gridRowHeights(height, children, rows, gaps) {
704
+ let fixed = contentRows(children, rows, gaps, !0);
705
+ if (fixed.every((value) => value === void 0)) return;
706
+ let flexibleWeight = sum(rows.filter((_, row) => fixed[row] === void 0)), remaining = Math.max(0, height - sum(gaps) - sum(fixed.map((value) => value ?? 0)));
707
+ return rows.map((weight, row) => fixed[row] ?? remaining * weight / flexibleWeight);
708
+ }
709
+ function gridSizing(size, area, children, rows, columns, rowGaps, columnGaps, automaticRows = !1) {
710
+ let fixed = contentRows(children, rows, rowGaps, automaticRows), required = (axis, weights, gaps, natural = !1) => {
711
+ let heights = weights.map((_, row) => axis === "row" ? fixed[row] : void 0), flexible = weights.map((weight, row) => heights[row] === void 0 ? weight : 0), total = sum(flexible);
712
+ return sum(gaps) + sum(heights.map((value) => value ?? 0)) + Math.max(0, maxOf(children.map((child) => {
713
+ let start = child[axis], span = axis === "row" ? child.rowSpan : child.columnSpan, g = child.geometry, need = axis === "column" ? g.sizing?.minWidth ?? 0 : (natural ? g.sizing?.naturalHeight : g.sizing?.minHeight) ?? (g.refused ? 0 : Math.max(g.frame.minHeight ?? 0, g.frame.plotMinHeight ?? 0)), weight = sum(flexible.slice(start, start + span)), held = sum(heights.slice(start, start + span).map((value) => value ?? 0));
714
+ return weight === 0 ? 0 : Math.max(0, need - held - sum(gaps.slice(start, start + span - 1))) * total / weight;
715
+ })));
716
+ }, hasContentRows = fixed.some((value) => value !== void 0), content = hasContentRows || children.length > 0 && children.every((child) => child.geometry.sizing?.fit === "content"), policy = chartSizing("grid"), chrome = size.height - area.h, minimumRows = required("row", rows, rowGaps), naturalRows = hasContentRows ? Math.max(
717
+ minimumRows,
718
+ sum(rowGaps) + sum(fixed.map((value) => value ?? 0)) + Math.max(0, resolveSizing(policy, size).naturalHeight - chrome - sum(rowGaps)) * sum(rows.filter((_, row) => fixed[row] === void 0)) / sum(rows)
719
+ ) : required("row", rows, rowGaps, !0);
720
+ return resolveSizing(content ? { ...policy, fit: "content", aspect: "content", minHeight: 0 } : policy, size, {
721
+ minWidth: size.width - area.w + required("column", columns, columnGaps),
722
+ minHeight: chrome + minimumRows,
723
+ ...content ? { naturalHeight: chrome + naturalRows } : {}
724
+ });
725
+ }
726
+ var GridChildRefusal = class extends Error {
727
+ constructor(panelId, child) {
728
+ super(`Grid panel '${panelId}' refused layout`);
729
+ this.panelId = panelId;
730
+ this.child = child;
731
+ }
732
+ panelId;
733
+ child;
734
+ result(size, sizing, panelIndex) {
735
+ let result = sizeRefusal("grid", "Grid", size, sizing), childWarnings = this.child.warnings.map((warning) => ({
736
+ ...warning,
737
+ field: ["data", "panels", panelIndex, ...warning.field ?? []],
738
+ ...warning.fix ? { fix: warning.fix.map((fix) => ({
739
+ ...fix,
740
+ path: `/data/panels/${panelIndex}${fix.path}`
741
+ })) } : {}
742
+ }));
743
+ return result.warnings = this.child.warnings[0]?.code === "size-below-floor" ? [...result.warnings, ...childWarnings] : [...childWarnings, ...result.warnings], result;
744
+ }
745
+ };
746
+
747
+ // src/core/grid/layoutGrid.ts
748
+ function serializableOptions(options) {
749
+ let { measure: _measure, ...rest } = options;
750
+ return rest;
751
+ }
752
+ var TIER_WEIGHT_FIRST = 2.2, TIER_SLACK_PASSES = 32, TIER_SLACK_BACKOFFS = 8;
753
+ function sharedYGroup(panels) {
754
+ let group = null;
755
+ for (let p of panels) {
756
+ let sg = p.options?.scaleGroup, y = sg !== null && typeof sg == "object" && !Array.isArray(sg) ? sg.y : void 0;
757
+ if (typeof y != "string") return null;
758
+ if (group === null) group = y;
759
+ else if (group !== y) return null;
760
+ }
761
+ return group;
762
+ }
763
+ function tierWeights(panels) {
764
+ let uniformScale = sharedYGroup(panels) !== null, varianceWeights = uniformScale ? void 0 : varianceTierWeights(panels);
765
+ return varianceWeights || panels.map(
766
+ (_, index) => index === 0 && panels.length > 1 && !uniformScale ? TIER_WEIGHT_FIRST : 1
767
+ );
768
+ }
769
+ function sharedCategoryLabelOwner(panels) {
770
+ return panels.findIndex((panel) => {
771
+ let options = isRecord(panel.options) ? panel.options : {};
772
+ return options.labels === !1 ? !1 : !isRecord(options.labels) || options.labels.category !== !1;
773
+ });
774
+ }
775
+ function bottomUpTierOrder(panels) {
776
+ let owner = sharedCategoryLabelOwner(panels), indexes = panels.map((_, index) => index);
777
+ return owner < 0 ? indexes : [owner, ...indexes.filter((index) => index !== owner)];
778
+ }
779
+ function gridShare(panels, share) {
780
+ return share ?? (varianceTierWeights(panels) ? "category" : "none");
781
+ }
782
+ function soloPanelReserve(share, panels) {
783
+ if (share !== "category" || panels.length !== 1) return 0;
784
+ let panel = panels[0], hasCaption = typeof panel.title == "string" && panel.title.trim().length > 0 || typeof panel.caption == "string" && panel.caption.trim().length > 0, marginTop = panel.options?.margin?.top;
785
+ return hasCaption ? typeof marginTop == "number" ? marginTop : 20 : 0;
786
+ }
787
+ var PANEL_VALUE_NOTE = /* @__PURE__ */ Symbol("panelValueNote"), FACET_HEADED_ROW_GAP = 5, FACET_HEADED_COLUMN_LADDER = [[320, 20], [400, 24], [480, 32], [720, 40], [960, 48]], FACET_GAP_BASE = 28;
788
+ function facetHeadedColumnGap(facetGap, width) {
789
+ let ladder = FACET_HEADED_COLUMN_LADDER, i = ladder.findIndex(([w]) => w >= width), gap;
790
+ if (i === 0) gap = ladder[0][1];
791
+ else if (i < 0) gap = ladder[ladder.length - 1][1];
792
+ else {
793
+ let [w0, g0] = ladder[i - 1], [w1, g1] = ladder[i];
794
+ gap = g0 + (g1 - g0) * (width - w0) / (w1 - w0);
795
+ }
796
+ return Math.round(gap * facetGap / FACET_GAP_BASE);
797
+ }
798
+ function facetHeadedGaps(facetGap, width) {
799
+ return { row: FACET_HEADED_ROW_GAP, column: facetHeadedColumnGap(facetGap, width) };
800
+ }
801
+ var FACET_GAPS = /* @__PURE__ */ Symbol("facetGaps"), SCALE_GROUP_MEMBERS = /* @__PURE__ */ Symbol("scaleGroupMembers");
802
+ function layoutGrid(data, options = {}) {
803
+ let named = [], geometry = layoutGridPass(data, options);
804
+ for (let round = 0; round < 2; round++) {
805
+ if (geometry.refused) return geometry;
806
+ let unprinted = unprintedPanelValues(data, geometry);
807
+ if (unprinted.every((item) => named.includes(item))) break;
808
+ named = [.../* @__PURE__ */ new Set([...named, ...unprinted])], geometry = layoutGridPass(data, { ...options, [PANEL_VALUE_NOTE]: named });
809
+ }
810
+ return geometry;
811
+ }
812
+ function unprintedPanelValues(data, geometry) {
813
+ let byPanel = data.panels.map((panel) => {
814
+ if (panel.type === "likert") return { title: panel.title ?? panel.id, items: [] };
815
+ let prefix = `${panel.id}/`, panelData = panel.data, nameOf = (list, id) => {
816
+ let found = list?.find((entry) => (typeof entry == "string" ? entry : entry.id) === id);
817
+ return found === void 0 ? String(id) : typeof found == "string" ? found : found.label ?? found.id;
818
+ }, unprefix = (id) => id?.startsWith(prefix) ? id.slice(prefix.length) : id, order = (id) => panelData?.categories?.findIndex((entry) => (typeof entry == "string" ? entry : entry.id) === id) ?? -1, items = geometry.labels.filter((label) => label.id.startsWith(prefix) && label.hidden && label.kind === "segment" && /\d/.test(label.text)).sort((a, b) => order(unprefix(a.owner.categoryId)) - order(unprefix(b.owner.categoryId))).map((label) => `${nameOf(panelData?.series, unprefix(label.owner.seriesId))} in ${nameOf(panelData?.categories, unprefix(label.owner.categoryId))} ${label.text}`);
819
+ return { title: panel.title ?? panel.id, items };
820
+ }).filter((entry) => entry.items.length > 0);
821
+ return byPanel.flatMap((entry) => byPanel.length > 1 ? entry.items.map((item) => `${entry.title}: ${item}`) : entry.items);
822
+ }
823
+ function layoutGridPass(data, options = {}) {
824
+ if (options = resolveCanvasOptions(options), !data || !Array.isArray(data.panels) || data.panels.length === 0)
825
+ throw new NormalizeError("empty-data", "panels", "grid requires at least one panel");
826
+ let size = resolveSize(options.size), gridClass = panelTypeClass(options) ?? typeWidthClass(size.width), theme = themeForWidth(resolveTheme(options.theme), gridClass), measure = options.measure ?? defaultMeasurer, share = gridShare(data.panels, options.sharedAxis), compactTiers = share === "category" && data.panels.length > 1, varianceTiers = compactTiers && varianceTierWeights(data.panels) !== void 0, varianceWeights = varianceTiers && sharedYGroup(data.panels) === null ? tierWeights(data.panels) : void 0, warnings = [];
827
+ share === "category" && ((options.columns ?? 1) !== 1 || options.panelOrder !== void 0) && warnings.push({
828
+ code: "grid-tier-order",
829
+ severity: "warn",
830
+ message: "Category tiers use one column and bottom-up order, with the category-axis owner at the bottom; columns and panelOrder do not set their visual order",
831
+ suggest: "use sharedAxis: 'none' for facet columns in array or panelOrder order"
832
+ }), options.valueAxis?.break && warnings.push({ code: "axis-break-unsupported", severity: "warn", message: "chart type 'grid' does not support valueAxis.break \u2014 ignored" });
833
+ let legendInput;
834
+ if (options.legend && options.legend !== "none" && options.legend !== "auto") {
835
+ let legendOptions = typeof options.legend == "string" ? { position: options.legend } : options.legend;
836
+ legendInput = gridLegendInput(collectGridLegendItems(data.panels, options, measure), legendOptions, options, warnings);
837
+ }
838
+ let occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), margin = { ...canvasMargin(theme, size.width), ...options.margin }, frameResult = solveFrame(
839
+ {
840
+ size,
841
+ margin,
842
+ ...frameTextOptions(options),
843
+ ...panelValueFootnotes(options),
844
+ legend: legendInput,
845
+ theme,
846
+ measure
847
+ },
848
+ occupied
849
+ ), area = frameResult.plot, n = data.panels.length, categoryOwner = compactTiers ? sharedCategoryLabelOwner(data.panels) : -1, bottomUpOrder = bottomUpTierOrder(data.panels), columns = share === "category" ? 1 : Math.max(1, options.columns ?? 1), rows = Math.ceil(n / columns), facetGaps = options[FACET_GAPS], gap = columns === 1 ? theme.space.tierGap : facetGaps?.column ?? theme.space.facetGap, rowGap = columns === 1 ? gap : facetGaps?.row ?? gap, slots = [];
850
+ if (share === "category") {
851
+ let gap2 = theme.space.tierGap, weights = tierWeights(data.panels), wSum = weights.reduce((a, b) => a + b, 0), usable = area.h - gap2 * (n - 1), y = area.y + area.h;
852
+ for (let i of bottomUpOrder) {
853
+ let h = usable * weights[i] / wSum;
854
+ y -= h, slots[i] = { x: area.x, y, w: area.w, h }, y -= gap2;
855
+ }
856
+ } else {
857
+ let cols = columns, cw = (area.w - gap * (cols - 1)) / cols, ch = (area.h - rowGap * (rows - 1)) / rows;
858
+ for (let i = 0; i < n; i++) {
859
+ let c = i % cols, r = Math.floor(i / cols);
860
+ slots.push({ x: area.x + c * (cw + gap), y: area.y + r * (ch + rowGap), w: cw, h: ch });
861
+ }
862
+ }
863
+ if (share === "category") {
864
+ let idLists = data.panels.map((p) => {
865
+ let d = p.data;
866
+ return Array.isArray(d?.categories) ? d.categories.map((c) => typeof c == "string" ? c : c.id) : null;
867
+ }), first = idLists.findIndex((ids) => ids !== null), firstIds = idLists[first], other = idLists.findIndex((ids) => ids !== null && firstIds != null && (ids.length !== firstIds.length || ids.some((id, index) => id !== firstIds[index])));
868
+ other >= 0 && warnings.push({
869
+ code: "grid-category-mismatch",
870
+ severity: "error",
871
+ message: `sharedAxis "category" aligns every panel on one category axis, but panel '${data.panels[other].id}' has categories ${idLists[other].join(", ")} where panel '${data.panels[first].id}' has ${firstIds.join(", ")}`,
872
+ suggest: "give every panel the same category ids in the same order, or set options.sharedAxis to 'none' so each panel keeps its own axis. The independent axes can need more room; leave the height open or increase the chart size.",
873
+ field: ["data", "panels", other, "data", "categories"]
874
+ });
875
+ }
876
+ let uniformLineEndpointLegend = !1, keepEndNames = gridPanelsKeepEndNames(options), kpiValueSize, layoutPanel = (panel, panelIndex, slot, marginLR) => {
877
+ let def = getChart(panel.type);
878
+ if (!def)
879
+ throw new NormalizeError("unknown-type", `panels[${panel.id}].type`, `unknown chart type '${panel.type}'`);
880
+ let panelOpts = resolveCanvasOptions(panel.options ?? {}), authoredTitle = typeof panelOpts.title == "string" && panelOpts.title.trim().length > 0 ? panelOpts.title : void 0, panelCaption = panel.caption, tierDetail = compactTiers && typeof panelCaption == "string" && panelCaption.trim().length > 0 ? panelCaption.trim() : void 0, labels = compactTiers && panelIndex !== categoryOwner ? withoutCategoryLabels(panelOpts.labels) : panelOpts.labels, suppressTitle = compactTiers && panelOpts.title !== !1 && (authoredTitle !== void 0 || def.type === "variance"), opts = {
881
+ ...def.defaults,
882
+ ...panelOpts,
883
+ ...hasKpiFigure(def.type) && kpiValueSize !== void 0 ? { [KPI_VALUE_SIZE]: kpiValueSize } : {},
884
+ ...def.type === "kpi" ? { [KPI_HOST_TEXT]: stringsIn([panelCaption, panel.title, options.title, options.subtitle, options.footnotes, options.source]) } : {},
885
+ // The value is the panel count, so a tier knows whether it is the only one (isSingleVarianceTier).
886
+ ...varianceTiers && def.type === "variance" ? { [VARIANCE_TIER]: data.panels.length } : {},
887
+ ...compactTiers ? { ...suppressTitle ? { title: "" } : {}, ...labels !== void 0 ? { labels } : {} } : {},
888
+ ...panel.annotations ? { annotations: panel.annotations } : {},
889
+ ...legendInput && def.type === "column" ? { [/* @__PURE__ */ Symbol.for("boardplot.panelKeyed")]: !0 } : {},
890
+ ...uniformLineEndpointLegend && def.type === "line" ? { gridEndpointIdentity: "legend" } : {},
891
+ target: options.target,
892
+ theme: panelOpts.theme ?? options.theme,
893
+ locale: panelOpts.locale ?? options.locale,
894
+ ...hatchStrengthFor(panelOpts, options),
895
+ ...options.strings ? { strings: { ...authoredStrings(options), ...panelOpts.strings } } : {},
896
+ size: { width: slot.w, height: slot.h },
897
+ ...marginLR ? { margin: { ...panelOpts.margin, ...marginLR } } : {},
898
+ measure,
899
+ typeClass: panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width)
900
+ }, probe = layoutChildChart(panel.data, opts, def.layout);
901
+ if (probe.refused) throw new GridChildRefusal(panel.id, probe);
902
+ let autoTierName = probe.derived.tierName, tierCaption = compactTiers && panelOpts.title !== !1 ? authoredTitle ?? (typeof autoTierName == "string" ? autoTierName : void 0) : void 0, tierFont = { family: theme.type.family, ...theme.type.axis }, tierReserve = compactTiers ? (tierCaption ? measure(tierCaption, tierFont).height : 0) + (tierCaption && tierDetail ? theme.space.labelPad : 0) + (tierDetail ? measure(tierDetail, tierFont).height : 0) + (tierCaption || tierDetail ? theme.space.labelPad : 0) : 0, childMargin = isRecord(opts.margin) ? opts.margin : {}, marginTop = typeof childMargin.top == "number" ? childMargin.top : 20, finalOptions = tierReserve > 0 ? { ...opts, margin: { ...childMargin, top: Math.max(marginTop, tierReserve) } } : opts, geo = tierReserve > marginTop ? layoutChildChart(panel.data, finalOptions, def.layout) : probe;
903
+ if (geo.refused) throw new GridChildRefusal(panel.id, geo);
904
+ if (options.target && tierReserve > 0)
905
+ for (let pass = 0; pass < 3; pass++) {
906
+ let missing = Math.ceil(tierReserve - occupiedBounds(geo).y);
907
+ if (missing <= 0) break;
908
+ let margin2 = finalOptions.margin;
909
+ if (finalOptions = { ...finalOptions, margin: { ...margin2, top: (margin2?.top ?? marginTop) + missing } }, geo = layoutChildChart(panel.data, finalOptions, def.layout), geo.refused) throw new GridChildRefusal(panel.id, geo);
910
+ }
911
+ return {
912
+ def,
913
+ geo,
914
+ recordOptions: serializableOptions(finalOptions),
915
+ tierCaption,
916
+ ...tierDetail ? { tierDetail } : {}
917
+ };
918
+ }, baseMargins = data.panels.map((p) => {
919
+ let m = resolveCanvasOptions(p.options ?? {}).margin;
920
+ return { left: m?.left ?? 28, right: m?.right ?? 28 };
921
+ }), sharedX, sharedW, landsOnEndpointLegend = (children) => children.some(
922
+ (child) => child.def?.type === "line" && child.geo.derived.endpointLabelEconomy?.strategy === "legend"
923
+ ), alignedPanels = (children) => children.map((child, i) => ({
924
+ geometry: child.geo,
925
+ slot: slots[i],
926
+ margin: child.recordOptions.margin ?? {},
927
+ relayout: (margin2) => (Object.assign(child, layoutPanel(data.panels[i], i, slots[i], margin2)), child.geo)
928
+ })), alignSharedValues = (children) => {
929
+ let panels = alignedPanels(children), resolved = options[SCALE_GROUP_MEMBERS];
930
+ if (resolved) {
931
+ for (let ids of Object.values(resolved)) alignValuePanels(panels.filter((_, i) => ids.includes(data.panels[i].id)), theme);
932
+ return children;
933
+ }
934
+ let groups = new Set(data.panels.map((panel) => panel.options?.scaleGroup?.y));
935
+ for (let group of groups) group !== void 0 && alignValuePanels(panels.filter((_, i) => data.panels[i].options?.scaleGroup?.y === group), theme);
936
+ return children;
937
+ }, layoutChildren = () => {
938
+ if (share === "category" && n > 1) {
939
+ let pass1 = data.panels.map((p, i) => layoutPanel(p, i, slots[i], baseMargins[i]));
940
+ !uniformLineEndpointLegend && !keepEndNames && landsOnEndpointLegend(pass1) && (uniformLineEndpointLegend = !0, pass1 = data.panels.map((p, i) => layoutPanel(p, i, slots[i], baseMargins[i]))), sharedX = maxOf(pass1.map((c) => c.geo.plot.x));
941
+ let sharedR = minOf(pass1.map((c) => c.geo.plot.x + c.geo.plot.w));
942
+ sharedW = sharedR - sharedX;
943
+ let aligned = data.panels.map((p, i) => {
944
+ let c1 = pass1[i], effRight = typeof c1.geo.derived.rightInset == "number" ? c1.geo.derived.rightInset : baseMargins[i].right, effLeft = typeof c1.geo.derived.leftInset == "number" ? c1.geo.derived.leftInset : baseMargins[i].left;
945
+ return layoutPanel(p, i, slots[i], {
946
+ left: effLeft + (sharedX - c1.geo.plot.x),
947
+ right: effRight + (c1.geo.plot.x + c1.geo.plot.w - sharedR)
948
+ });
949
+ });
950
+ return alignCategoryPanels(alignedPanels(aligned), theme), alignSharedValues(aligned);
951
+ }
952
+ let children = data.panels.map((p, i) => layoutPanel(p, i, slots[i]));
953
+ return !uniformLineEndpointLegend && !keepEndNames && landsOnEndpointLegend(children) && (uniformLineEndpointLegend = !0, children = data.panels.map((p, i) => layoutPanel(p, i, slots[i]))), alignSharedValues(children);
954
+ }, measureTierContents = (laidOut) => {
955
+ let childContent = laidOut.map((child) => occupiedBounds(child.geo)), tierLabels = laidOut.map((child, index) => {
956
+ if (!child.tierCaption && !child.tierDetail) return;
957
+ let font = { family: theme.type.family, ...theme.type.axis }, titleSize = child.tierCaption ? measure(child.tierCaption, font) : void 0, detailSize = child.tierDetail ? measure(child.tierDetail, font) : void 0, lineGap = titleSize && detailSize ? theme.space.labelPad : 0, height = (titleSize?.height ?? 0) + lineGap + (detailSize?.height ?? 0), y = childContent[index].y - theme.space.labelPad - height, title = titleSize ? { x: 0, y, w: titleSize.width, h: titleSize.height } : void 0;
958
+ y += (titleSize?.height ?? 0) + lineGap;
959
+ let detail = detailSize ? { x: 0, y, w: detailSize.width, h: detailSize.height } : void 0, occupied2 = createOccupiedIndex({ x: 0, y: 0, w: child.geo.size.width, h: child.geo.size.height });
960
+ for (let claim of child.geo.debug.occupied)
961
+ occupied2.claim(claim.rect, claim.kind, claim.owner, claim.part);
962
+ let requests = [], candidates = (rect) => [
963
+ { slot: "tierLeft", rect, penalty: 0 },
964
+ { slot: "tierPlotLeft", rect: { ...rect, x: child.geo.plot.x }, penalty: 1 }
965
+ ];
966
+ for (let [id, text, rect, priority] of [
967
+ ["tier:caption", child.tierCaption, title, PRIORITY.total],
968
+ ["tier:detail", child.tierDetail, detail, PRIORITY.valueLine]
969
+ ])
970
+ text && rect && requests.push({
971
+ id,
972
+ kind: "axisTitle",
973
+ typeRole: "axis",
974
+ owner: {},
975
+ text,
976
+ lines: [text],
977
+ font,
978
+ priority,
979
+ candidates: candidates(rect)
980
+ });
981
+ let solved = solveLabels(requests, occupied2, {
982
+ density: "full",
983
+ pins: {},
984
+ measure,
985
+ plot: child.geo.plot,
986
+ canvas: { x: 0, y: 0, w: child.geo.size.width, h: child.geo.size.height },
987
+ darkInk: theme.color.ink,
988
+ lightInk: theme.color.inkInverse,
989
+ labelPad: theme.space.labelPad
990
+ });
991
+ for (let label of solved.placed) label.ink = { token: "inkMuted" };
992
+ return { font, solved };
993
+ }), localContent = childContent.map((bounds, index) => {
994
+ let placed = tierLabels[index]?.solved.placed.filter((label) => !label.hidden).map((label) => label.rect) ?? [];
995
+ return placed.length > 0 ? boundsOf([bounds, ...placed]) : bounds;
996
+ });
997
+ return { tierLabels, localContent };
998
+ }, packedTiers = share === "category" && data.panels.every((panel) => getChart(panel.type)?.sizing.fit !== "content"), packReserve = soloPanelReserve(share, data.panels), rowOf = (index) => share === "category" ? n - 1 - bottomUpOrder.indexOf(index) : Math.floor(index / columns), rowWeights = share === "category" ? [...bottomUpOrder].reverse().map((index) => tierWeights(data.panels)[index]) : Array(rows).fill(1), rowGaps = Array(rows - 1).fill(rowGap);
999
+ try {
1000
+ let children = layoutChildren();
1001
+ kpiValueSize = smallestKpiValueSize(children.map((child) => child.geo)), kpiValueSize !== void 0 && (children = layoutChildren());
1002
+ let sizingChildren = () => children.map((child, i) => ({
1003
+ geometry: child.geo,
1004
+ row: rowOf(i),
1005
+ column: i % columns,
1006
+ rowSpan: 1,
1007
+ columnSpan: 1
1008
+ })), heights = gridRowHeights(area.h, sizingChildren(), rowWeights, rowGaps);
1009
+ if (heights) {
1010
+ let y = area.y, starts = heights.map((height, row) => {
1011
+ let start = y;
1012
+ return y += height + (rowGaps[row] ?? 0), start;
1013
+ });
1014
+ slots.forEach((slot, index) => {
1015
+ slot.y = starts[rowOf(index)], slot.h = heights[rowOf(index)];
1016
+ }), children = layoutChildren();
1017
+ }
1018
+ children = balanceVarianceTierPlots(slots, children, varianceWeights, layoutChildren);
1019
+ let tierContents = measureTierContents(children), effectiveTierGap = theme.space.tierGap, requirements = () => gridSizing(
1020
+ size,
1021
+ area,
1022
+ sizingChildren(),
1023
+ packedTiers ? [...bottomUpOrder].reverse().map((index) => children[index].geo.sizing.minHeight) : rowWeights,
1024
+ Array(columns).fill(1),
1025
+ rowGaps,
1026
+ Array(columns - 1).fill(gap),
1027
+ !0
1028
+ );
1029
+ if (packedTiers && requirements().minHeight <= size.height) {
1030
+ let weights = tierWeights(data.panels), wSum = weights.reduce((sum2, weight) => sum2 + weight, 0), gapFloor = Math.min(4, theme.space.tierGap), gapCapacity = (theme.space.tierGap - gapFloor) * (n - 1);
1031
+ for (let pass = 0; pass < TIER_SLACK_PASSES; pass++) {
1032
+ let slack = area.h - packReserve - theme.space.tierGap * (n - 1) - tierContents.localContent.reduce((sum2, bounds) => sum2 + bounds.h, 0);
1033
+ if (slack < 0 && slack >= -gapCapacity) {
1034
+ effectiveTierGap = theme.space.tierGap + slack / (n - 1);
1035
+ break;
1036
+ }
1037
+ if (slack <= theme.space.tierGap) break;
1038
+ let previousSlots = slots.map((slot) => ({ ...slot })), previousChildren = children, previousTierContents = tierContents, previousSharedX = sharedX, previousSharedW = sharedW, growth = Math.max(slack, wSum * theme.space.tierGap), accepted = !1;
1039
+ for (let backoff = 0; backoff < TIER_SLACK_BACKOFFS; backoff++) {
1040
+ previousSlots.forEach((slot, index) => {
1041
+ slots[index] = { ...slot };
1042
+ });
1043
+ let fraction = 2 ** -backoff;
1044
+ for (let i = 0; i < n; i++)
1045
+ slots[i] = { ...slots[i], h: slots[i].h + growth * fraction * weights[i] / wSum };
1046
+ children = balanceVarianceTierPlots(slots, layoutChildren(), varianceWeights, layoutChildren), tierContents = measureTierContents(children);
1047
+ let remaining = area.h - packReserve - theme.space.tierGap * (n - 1) - tierContents.localContent.reduce((sum2, bounds) => sum2 + bounds.h, 0);
1048
+ if (remaining >= -gapCapacity) {
1049
+ effectiveTierGap = remaining < 0 ? theme.space.tierGap + remaining / (n - 1) : theme.space.tierGap, accepted = !0;
1050
+ break;
1051
+ }
1052
+ }
1053
+ if (!accepted) {
1054
+ previousSlots.forEach((slot, index) => {
1055
+ slots[index] = slot;
1056
+ }), children = previousChildren, tierContents = previousTierContents, sharedX = previousSharedX, sharedW = previousSharedW;
1057
+ break;
1058
+ }
1059
+ }
1060
+ }
1061
+ let sizing = requirements(), { tierLabels, localContent } = tierContents, panelY = slots.map((slot) => slot.y);
1062
+ if (packedTiers) {
1063
+ let cursor = area.y + area.h;
1064
+ for (let i of bottomUpOrder) {
1065
+ let bounds = localContent[i];
1066
+ panelY[i] = cursor - (bounds.y + bounds.h), cursor = bounds.y + panelY[i] - effectiveTierGap;
1067
+ }
1068
+ }
1069
+ let scene = [...frameResult.nodes], labels = [], axes = [], annotations = [], occupiedAll = occupied.snapshot().slice(), decisions = [], marks = { panels: [] };
1070
+ children.forEach((child, i) => {
1071
+ let panel = data.panels[i], slot = slots[i], prefix = `${panel.id}/`, dx = slot.x, dy = panelY[i], geo = child.geo;
1072
+ appendPanelScene(scene, geo, panel.id, prefix, dx, dy);
1073
+ let noteData = panelNoteData(panel.type, panel.data, panel.options?.locale?.language), noteTexts = panelNoteTexts(geo, noteData, panel.options, panel.annotations);
1074
+ for (let label of geo.labels) {
1075
+ let noteText = noteTexts.texts.get(label.id);
1076
+ labels.push({
1077
+ ...label,
1078
+ ...noteText === void 0 ? {} : { noteText },
1079
+ ...noteTexts.leftOut.has(label.id) ? { [LEFT_OUT_OF_NOTE]: !0 } : {},
1080
+ id: prefix + label.id,
1081
+ ...label.claimId ? { claimId: prefix + label.claimId } : {},
1082
+ nodeId: label.nodeId ? prefix + label.nodeId : void 0,
1083
+ rect: { ...label.rect, x: label.rect.x + dx, y: label.rect.y + dy },
1084
+ backing: label.backing ? { ...label.backing, x: label.backing.x + dx, y: label.backing.y + dy } : void 0
1085
+ });
1086
+ }
1087
+ for (let axis of geo.axes)
1088
+ axes.push({
1089
+ ...axis,
1090
+ baselineNodeId: axis.baselineNodeId ? prefix + axis.baselineNodeId : void 0,
1091
+ ticks: axis.ticks.map((t) => ({
1092
+ ...t,
1093
+ pos: t.pos + (axis.axis === "x" ? dx : dy),
1094
+ labelId: t.labelId ? prefix + t.labelId : void 0,
1095
+ gridNodeId: t.gridNodeId ? prefix + t.gridNodeId : void 0
1096
+ })),
1097
+ scenarioBands: axis.scenarioBands?.map((b) => ({
1098
+ ...b,
1099
+ rect: { ...b.rect, x: b.rect.x + dx, y: b.rect.y + dy }
1100
+ }))
1101
+ });
1102
+ for (let ann of geo.annotations)
1103
+ annotations.push({
1104
+ ...ann,
1105
+ id: prefix + ann.id,
1106
+ // The event anchor is a child-scene rect: move it with the panel.
1107
+ ...ann.event?.anchor ? { event: { ...ann.event, anchor: { ...ann.event.anchor, x: ann.event.anchor.x + dx, y: ann.event.anchor.y + dy } } } : {},
1108
+ nodeIds: ann.nodeIds.map((id) => prefix + id),
1109
+ labelId: ann.labelId ? prefix + ann.labelId : void 0,
1110
+ // The label NODE is prefixed as a node (`<panel>/label:<id>`), not as a
1111
+ // labelId — see PlacedAnnotation.labelNodeId. Concatenating `label:`
1112
+ // onto the prefixed labelId names a node that does not exist.
1113
+ labelNodeId: ann.labelId ? prefix + (ann.labelNodeId ?? `label:${ann.labelId}`) : void 0
1114
+ });
1115
+ for (let occ of geo.debug.occupied)
1116
+ occupiedAll.push({ ...occ, rect: { ...occ.rect, x: occ.rect.x + dx, y: occ.rect.y + dy } });
1117
+ for (let d of geo.debug.decisions)
1118
+ decisions.push({ ...d, labelId: prefix + d.labelId });
1119
+ let warningOffset = warnings.length;
1120
+ for (let w of geo.warnings)
1121
+ warnings.push({ ...w, message: `[${panel.id}] ${w.message}` });
1122
+ let tier = tierLabels[i], titleNodeId, captionNodeId;
1123
+ for (let label of tier?.solved.placed ?? []) {
1124
+ let moved = {
1125
+ ...label,
1126
+ id: prefix + label.id,
1127
+ ...label.claimId ? { claimId: prefix + label.claimId } : {},
1128
+ rect: { ...label.rect, x: label.rect.x + dx, y: label.rect.y + dy }
1129
+ };
1130
+ if (label.hidden) {
1131
+ labels.push(moved);
1132
+ continue;
1133
+ }
1134
+ let part = label.id === "tier:caption" ? "tierCaption" : "panelCaption", nodeId = `${prefix}${label.id}`;
1135
+ moved.nodeId = nodeId, labels.push(moved), scene.push({
1136
+ t: "text",
1137
+ typeRole: "axis",
1138
+ id: nodeId,
1139
+ x: moved.rect.x,
1140
+ y: moved.rect.y,
1141
+ lines: moved.lines,
1142
+ align: "start",
1143
+ font: tier.font,
1144
+ ink: moved.ink,
1145
+ owner: moved.owner,
1146
+ part,
1147
+ origin: { owner: moved.owner, panels: [panel.id] }
1148
+ }), occupiedAll.push({ rect: moved.rect, kind: "label", owner: moved.owner, part }), label.id === "tier:caption" ? titleNodeId = nodeId : captionNodeId = nodeId;
1149
+ }
1150
+ for (let decision of tier?.solved.decisions ?? [])
1151
+ decisions.push({ ...decision, labelId: prefix + decision.labelId });
1152
+ for (let warning of tier?.solved.warnings ?? [])
1153
+ warnings.push({ ...warning, message: `[${panel.id}] ${warning.message}` });
1154
+ let content = localContent[i];
1155
+ marks.panels.push({
1156
+ id: panel.id,
1157
+ type: panel.type,
1158
+ chart: { options: child.recordOptions, geometry: geo, offset: { x: dx, y: dy }, warningOffset, ...panel.options?.theme ? { theme: panel.options.theme } : {} },
1159
+ plot: { x: geo.plot.x + dx, y: geo.plot.y + dy, w: geo.plot.w, h: geo.plot.h },
1160
+ content: { x: content.x + dx, y: content.y + dy, w: content.w, h: content.h },
1161
+ title: child.tierCaption ?? (geo.a11y.title || child.def?.title || panel.id),
1162
+ ...titleNodeId ? { titleNodeId } : {},
1163
+ ...captionNodeId ? { captionNodeId } : {}
1164
+ });
1165
+ });
1166
+ let compactNotes = children.flatMap((child) => child.geo.a11y.compactNotes ?? []);
1167
+ return {
1168
+ type: "grid",
1169
+ size,
1170
+ sizing,
1171
+ plot: area,
1172
+ scene,
1173
+ labels,
1174
+ axes,
1175
+ annotations,
1176
+ frame: frameResult.frame,
1177
+ legend: frameResult.legend,
1178
+ marks,
1179
+ derived: {
1180
+ sharedPlotX: sharedX,
1181
+ sharedPlotW: sharedW,
1182
+ ...compactTiers ? { tierGap: effectiveTierGap } : {}
1183
+ },
1184
+ a11y: {
1185
+ title: accessibleTitle(options.title, chartString2(options, "gridChartsTitle", { v1: n })),
1186
+ counts: children.flatMap((child, i) => [...child.geo.a11y.counts ?? [], ...child.geo.a11y.titleCounts ?? []].filter((count) => marks.panels[i].title.includes(count.text))),
1187
+ desc: chartString2(options, "gridChartsDesc", { v1: share === "category" && n > 1 ? chartString2(options, "alignedExhibit") : chartString2(options, "chartGrid"), v2: marks.panels.map((p) => p.title).join("; "), v3: compactNotes.length > 0 ? chartString2(options, "notesClause", { v1: compactNotes.join("; ") }) : "" }),
1188
+ ...compactNotes.length > 0 ? { compactNotes } : {}
1189
+ },
1190
+ warnings,
1191
+ debug: { occupied: occupiedAll, decisions }
1192
+ };
1193
+ } catch (error) {
1194
+ if (!(error instanceof GridChildRefusal)) throw error;
1195
+ let index = data.panels.findIndex((panel) => panel.id === error.panelId);
1196
+ return error.result(size, gridSizing(size, area, [{
1197
+ geometry: error.child,
1198
+ row: rowOf(index),
1199
+ column: index % columns,
1200
+ rowSpan: 1,
1201
+ columnSpan: 1
1202
+ }], rowWeights, Array(columns).fill(1), rowGaps, Array(columns - 1).fill(gap), !0), index);
1203
+ }
1204
+ }
1205
+ function appendPanelScene(scene, geometry, panelId, prefix, dx, dy) {
1206
+ let legendItems = new Map((geometry.legend?.items ?? []).flatMap((item) => [
1207
+ [item.swatchNodeId, item.id],
1208
+ [item.labelId, item.id]
1209
+ ]));
1210
+ for (let node of geometry.scene) {
1211
+ let legendItem = node.origin?.legendItem ?? legendItems.get(node.id), moved = {
1212
+ ...node,
1213
+ id: prefix + node.id,
1214
+ tx: (node.tx ?? 0) + dx,
1215
+ ty: (node.ty ?? 0) + dy,
1216
+ origin: {
1217
+ owner: node.origin?.owner ?? node.owner,
1218
+ panels: [panelId, ...node.origin?.panels ?? []],
1219
+ ...legendItem === void 0 ? {} : { legendItem }
1220
+ }
1221
+ };
1222
+ scene.push(moved);
1223
+ }
1224
+ }
1225
+ function withoutCategoryLabels(labels) {
1226
+ return labels === !1 ? !1 : { ...isRecord(labels) ? labels : {}, category: !1 };
1227
+ }
1228
+ function occupiedBounds(geometry) {
1229
+ let rects = geometry.debug.occupied.filter((item) => item.kind !== "reserved").map((item) => item.rect);
1230
+ if (rects.length === 0) return geometry.plot;
1231
+ let x1 = minOf(rects.map((rect) => rect.x)), y1 = minOf(rects.map((rect) => rect.y)), x2 = maxOf(rects.map((rect) => rect.x + rect.w)), y2 = maxOf(rects.map((rect) => rect.y + rect.h));
1232
+ return { x: x1, y: y1, w: x2 - x1, h: y2 - y1 };
1233
+ }
1234
+ function panelValueFootnotes(options) {
1235
+ let named = options[PANEL_VALUE_NOTE] ?? [];
1236
+ return named.length === 0 || options.footnotes === !1 ? {} : { footnotes: [...frameTextOptions(options).footnotes ?? [], ...valueNoteLine(chartString2(options, "valuesNotOnColumns"), named, options)] };
1237
+ }
1238
+
1239
+ // src/core/charts/grid/layout.ts
1240
+ function assertTrackLimits(options, panels = []) {
1241
+ let refuse = (field, what) => {
1242
+ throw new NormalizeError("grid-too-many-tracks", field, `${what} is over the limit of ${50} tracks`, `use at most ${50} row tracks and ${50} column tracks`);
1243
+ }, over = (value) => typeof value == "number" && !(value <= 50);
1244
+ over(options.columns) && refuse("options.columns", `options.columns ${options.columns}`), Array.isArray(options.columns) && options.columns.length > 50 && refuse("options.columns", "options.columns"), Array.isArray(options.rows) && options.rows.length > 50 && refuse("options.rows", "options.rows"), panels.forEach((panel, index) => {
1245
+ let reach = (start, span) => (start ?? 0) + (span ?? 1);
1246
+ over(reach(panel.row, panel.span?.rows)) && refuse(`panels[${index}]`, `panels[${index}] reaching row ${reach(panel.row, panel.span?.rows)}`), over(reach(panel.column, panel.span?.columns)) && refuse(`panels[${index}]`, `panels[${index}] reaching column ${reach(panel.column, panel.span?.columns)}`);
1247
+ });
1248
+ }
1249
+ function layoutGrid2(data, options = {}) {
1250
+ options = resolveCanvasOptions(options), assertTrackLimits(options);
1251
+ let metricStack = isMetricStackData(data), formatWarnings = options.format === void 0 ? [] : [{
1252
+ code: "format-unused",
1253
+ severity: "warn",
1254
+ field: ["options", "format"],
1255
+ message: "Grid-level options.format is ignored in this release and will be refused in the next release",
1256
+ suggest: metricStack ? "Set decimals and divisor on each metric stack panel; remove the grid-level format." : "Set format on each numeric panel in data.panels[].options.format; remove the grid-level format.",
1257
+ fix: [{ op: "remove", path: "/options/format" }]
1258
+ }];
1259
+ if (metricStack)
1260
+ return requireChartCores(data.panels.map((panel) => panel.type), (type) => getChart(type) !== void 0), withWarnings(layoutMetricStack(data, options), formatWarnings);
1261
+ options.stack && stackError("data", "Metric stack mode needs shared categories and measures");
1262
+ let normalized = normalizeGridData(data);
1263
+ requireChartCores(normalized.panels.map((panel) => panel.type), (type) => getChart(type) !== void 0), assertTrackLimits(options, normalized.panels), normalized.panels = normalized.panels.map((panel) => panel.options ? { ...panel, options: resolveCanvasOptions(panel.options) } : panel);
1264
+ let authored = usesAuthoredLayout(normalized.panels, options);
1265
+ authored && normalized.rowCaption && (normalized.panels = normalized.panels.map((panel) => ({ ...panel, caption: panel.caption ?? normalized.rowCaption })), delete normalized.rowCaption), options = { ...options, sharedAxis: gridShare(normalized.panels, options.sharedAxis) };
1266
+ let ordered = orderPanels(normalized.panels, options, authored);
1267
+ if (pushAll(ordered.warnings, formatWarnings), options.sharedScale === !0) {
1268
+ let charts = ordered.panels.filter((panel) => panel.type !== "text" && panel.type !== "legend"), semantics = charts.map(panelScaleSemantics), first = semantics[0], matching = first != null && semantics.every((candidate) => candidate !== null && candidate.unit === first.unit && candidate.format === first.format);
1269
+ if (charts.length > 1 && !matching)
1270
+ throw new NormalizeError(
1271
+ "scale-mix",
1272
+ "options.sharedScale",
1273
+ "sharedScale:true needs matching unit and format on every numeric panel",
1274
+ "drop sharedScale, set sharedScale:false, or give every panel the same unit and format"
1275
+ );
1276
+ }
1277
+ let legacy = (at) => layoutLegacyGrid({ ...normalized, panels: ordered.panels }, at), legacyGrid = (at) => withSliverRoom(withOnePanelContent(withTierPlot(legacy(at), ordered.panels, at), legacy, ordered.panels, at), legacy, at, data), geometry = withWarnings(authored ? layoutAuthoredGrid(ordered.panels, options, normalized.repeatFacet === !0) : legacyGrid(reflowed(legacyGrid, ordered.panels, options, data)), ordered.warnings);
1278
+ return !geometry.refused && heightOmitted(options.size) && geometry.sizing?.fit === "content" && Math.abs(geometry.size.height - geometry.sizing.naturalHeight) > 1 ? layoutGrid2(data, { ...options, size: { width: geometry.size.width, height: geometry.sizing.naturalHeight } }) : withCardFloor(geometry, ordered.panels.map((panel) => panel.type), options);
1279
+ }
1280
+ var seats = (geometry, height) => !geometry.refused && (geometry.sizing?.minHeight ?? 0) <= height, strideLosses = (geometry) => geometry.refused ? Number.POSITIVE_INFINITY : geometry.warnings.filter((warning) => warning.code === "category-stride").length;
1281
+ function reflowed(relayout, panels, options, data) {
1282
+ let columns = options.columns, width = resolveSize(options.size).width;
1283
+ if (options.reflow === !1 || typeof columns != "number" || columns < 3 || panels.length <= columns || width >= CARD_CLASS_WIDTH || legacyGridForm(panels, options) !== "facets") return options;
1284
+ let height = options[TARGET_SIZE]?.fixed.height ?? !heightOmitted(options.size) ? resolveSize(options.size).height : void 0, choose = () => {
1285
+ let open = (count) => strideLosses(relayout({ ...options, columns: count, size: { width } }));
1286
+ if (open(columns) === 0) return columns;
1287
+ for (let fewer = columns - 1; fewer >= 2; fewer--)
1288
+ if (open(fewer) === 0 && (height === void 0 || seats(relayout({ ...options, columns: fewer }), height))) return fewer;
1289
+ return columns;
1290
+ }, { size: _size, measure, ...rest } = options, key = `${width}:${height ?? "auto"}:${currentSmallValues()}:${themeRegistrations()}:${JSON.stringify(rest)}:${JSON.stringify(data)}`, cache = REFLOW_CACHE.get(measure ?? DEFAULT_MEASURER);
1291
+ cache || REFLOW_CACHE.set(measure ?? DEFAULT_MEASURER, cache = /* @__PURE__ */ new Map()), cache.has(key) || (cache.size >= REFLOW_CACHE_SIZE && cache.delete(cache.keys().next().value), cache.set(key, choose()));
1292
+ let chosen = cache.get(key);
1293
+ return chosen === columns ? options : { ...options, columns: chosen };
1294
+ }
1295
+ var REFLOW_CACHE = /* @__PURE__ */ new WeakMap(), DEFAULT_MEASURER = {}, REFLOW_CACHE_SIZE = 64, SLIVER_HIDDEN = "sliver-labels-hidden";
1296
+ function sliversHidden(probe) {
1297
+ return probe.warnings.some((warning) => warning.code === SLIVER_HIDDEN) || (probe.labels ?? []).some((label) => label[DIGIT_SEAT] !== void 0);
1298
+ }
1299
+ var SLIVER_ROOM_STEP = 4, SLIVER_ROOM_MAX = 1.3;
1300
+ function withSliverRoom(geometry, relayout, options, data) {
1301
+ let sizing = geometry.sizing, hides = sliversHidden;
1302
+ if (!sizing || sizing.fit === "content" || geometry.refused || !hides(geometry) || (options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1))) > 1 || geometry.marks.panels.filter((panel) => panel.chart).length !== 1) return geometry;
1303
+ let { width, height } = geometry.size, at = (h) => relayout({ ...options, size: { ...resolveSize(options.size), width, height: h } }), start = Math.max(height, sizing.naturalHeight), withNatural = (found) => found === void 0 ? geometry : { ...geometry, sizing: { ...sizing, naturalHeight: found } }, { size: _size, measure, ...rest } = options, key = `${width}:${start}:${currentSmallValues()}:${themeRegistrations()}:${JSON.stringify(rest)}:${JSON.stringify(data)}`, cache = SLIVER_ROOM_CACHE.get(measure ?? DEFAULT_MEASURER);
1304
+ return cache || SLIVER_ROOM_CACHE.set(measure ?? DEFAULT_MEASURER, cache = /* @__PURE__ */ new Map()), cache.has(key) || (cache.size >= SLIVER_ROOM_CACHE_SIZE && cache.delete(cache.keys().next().value), cache.set(key, sliverRoomHeight(start, height, at, hides))), withNatural(cache.get(key));
1305
+ }
1306
+ var SLIVER_ROOM_CACHE = /* @__PURE__ */ new WeakMap(), SLIVER_ROOM_CACHE_SIZE = 64;
1307
+ function sliverRoomHeight(start, height, at, hides) {
1308
+ if (start !== height) {
1309
+ let probe = at(start);
1310
+ if (probe.refused || !hides(probe)) return;
1311
+ }
1312
+ let low = start, high = Math.floor(start * SLIVER_ROOM_MAX), top = at(high);
1313
+ if (!(top.refused || hides(top))) {
1314
+ for (; high - low > SLIVER_ROOM_STEP; ) {
1315
+ let mid = Math.floor((low + high) / 2), probe = at(mid);
1316
+ !probe.refused && !hides(probe) ? high = mid : low = mid;
1317
+ }
1318
+ return high;
1319
+ }
1320
+ }
1321
+ var STANDALONE_COMPACT = /* @__PURE__ */ new Set(["bullet", "pie", "slope"]), panelCompacts = (type) => !STANDALONE_COMPACT.has(type) && type !== "grid" && (getChart(type)?.sizing ?? chartSizing(type)).compactFloor !== void 0;
1322
+ function withCardFloor(geometry, types, options) {
1323
+ if (geometry.refused) return geometry;
1324
+ let sizing = geometry.sizing;
1325
+ if (sizing && options.mode === "compact" && geometry.size.width < CARD_CLASS_WIDTH && sizing.minWidth > Math.max(CARD_MIN_WIDTH, sizing.measuredMinWidth)) {
1326
+ let minWidth = Math.max(CARD_MIN_WIDTH, sizing.measuredMinWidth);
1327
+ return { ...geometry, sizing: { ...sizing, minWidth, comfortableWidth: Math.ceil(minWidth * 1.25) } };
1328
+ }
1329
+ let charts = types.filter((type) => type !== "text" && type !== "legend");
1330
+ return !sizing || sizing.minWidth <= CARD_MIN_WIDTH || charts.length === 0 || !charts.every(panelCompacts) ? geometry : { ...geometry, sizing: { ...sizing, minWidth: CARD_MIN_WIDTH, measuredMinWidth: Math.min(sizing.measuredMinWidth, CARD_MIN_WIDTH), comfortableWidth: Math.ceil(CARD_MIN_WIDTH * 1.25) } };
1331
+ }
1332
+ function compactPanelMode(panel, canvasWidth) {
1333
+ return panel.type === "text" || panel.type === "legend" || panel.options?.mode !== void 0 ? {} : panelCompacts(panel.type) && canvasWidth < CARD_CLASS_WIDTH ? { mode: "compact" } : {};
1334
+ }
1335
+ function withWarnings(geometry, warnings) {
1336
+ return warnings.length === 0 ? geometry : { ...geometry, warnings: [...geometry.warnings ?? [], ...warnings] };
1337
+ }
1338
+ function orderPanels(panels, options, authored) {
1339
+ let order = options.panelOrder ?? "sheet";
1340
+ if (order === "sheet" || options.sharedAxis === "category") return { panels, warnings: [] };
1341
+ if (authored)
1342
+ return {
1343
+ panels,
1344
+ warnings: [
1345
+ {
1346
+ code: "panel-order-authored-placement",
1347
+ severity: "warn",
1348
+ message: `panelOrder '${order}' is ignored: this grid places its panels with authored row/column coordinates, so the array order does not decide what sits where`,
1349
+ suggest: "remove the authored row/column coordinates, or drop panelOrder"
1350
+ }
1351
+ ]
1352
+ };
1353
+ let key = (panel) => {
1354
+ let data = panel.data, series = data?.series;
1355
+ if (!Array.isArray(series)) return null;
1356
+ let categories = Array.isArray(data?.categories) ? data.categories.map(normalizeCategory) : void 0, normalized = categories ? series.map((entry, si) => ({ ...entry, values: normalizeSeriesValues(entry, categories, si) })) : series;
1357
+ categories && (panel.data = { ...data, categories, series: normalized });
1358
+ let measured = normalized.filter((entry) => entry?.role !== "reference"), total = null;
1359
+ for (let entry of measured) {
1360
+ let values = Array.isArray(entry.values) ? entry.values : [], cells = order.startsWith("last") ? values.slice(-1) : values;
1361
+ for (let cell of cells) {
1362
+ let value = cellValue(cell);
1363
+ value !== null && (total = (total ?? 0) + value);
1364
+ }
1365
+ }
1366
+ return total;
1367
+ }, keys = new Map(panels.map((panel, index) => [index, key(panel)])), descending = order.endsWith("Desc"), sorted = panels.map((panel, index) => ({ panel, index })).sort((left, right) => {
1368
+ let a = keys.get(left.index) ?? null, b = keys.get(right.index) ?? null;
1369
+ return a === null && b === null ? left.index - right.index : a === null ? 1 : b === null ? -1 : a !== b ? descending ? b - a : a - b : left.index - right.index;
1370
+ }).map((entry) => entry.panel), unmeasured = panels.filter((_, index) => keys.get(index) === null), warnings = unmeasured.length === 0 ? [] : [
1371
+ {
1372
+ code: "panel-order-unmeasured",
1373
+ severity: "info",
1374
+ message: `panelOrder '${order}' could not rank ${unmeasured.length} panel(s) with no numeric value; they keep authored order at the end`
1375
+ }
1376
+ ];
1377
+ return { panels: sorted, warnings };
1378
+ }
1379
+ function gridTypeClass(options) {
1380
+ return panelTypeClass(options) ?? typeWidthClass(resolveSize(options.size).width);
1381
+ }
1382
+ function measuredCaption(text, font, width, measure) {
1383
+ let lines = wrapText(text, font, width, Number.MAX_SAFE_INTEGER, measure).lines, sizes = lines.map((line) => measure(line, font));
1384
+ return {
1385
+ lines,
1386
+ width: Math.max(...sizes.map((size) => size.width)),
1387
+ height: Math.max(...sizes.map((size) => size.height)) + (lines.length - 1) * font.size * (font.lineHeight ?? 1.2)
1388
+ };
1389
+ }
1390
+ function panelCaptionBand(panel, theme, measure, slot, highlighted, compact = !1, shift = 0) {
1391
+ let margin = isRecord(panel.options?.margin) ? panel.options.margin : {}, sides = canvasMargin(theme, slot.w), x = slot.x + numeric(margin.left, sides.left), y = slot.y + numeric(margin.top, 20) - measureCaptionBand(panel, theme, measure, slot.w, compact) + shift, nodes = [], claims = [];
1392
+ for (let [part, value, font, ink] of [
1393
+ [compact ? "tierCaption" : "panelTitle", panel.title, compact ? { family: theme.type.family, ...theme.type.axis } : { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, { token: compact ? "inkMuted" : highlighted.size === 0 || highlighted.has(panel.id) ? "ink" : "inkMuted" }],
1394
+ ["panelCaption", panel.caption, { family: theme.type.family, ...theme.type.axis }, { token: "inkMuted" }]
1395
+ ]) {
1396
+ if (!value) continue;
1397
+ let width = Math.max(1, slot.w - numeric(margin.left, sides.left) - numeric(margin.right, sides.right)), text = measuredCaption(value, font, width, measure), { lines } = text, id = `panel:${panel.id}:${part === "panelCaption" ? "caption" : "title"}`, rect = { x, y, w: text.width, h: text.height }, occupied = createOccupiedIndex(rect), solved = solveLabels([{
1398
+ id,
1399
+ kind: "annotation",
1400
+ typeRole: "axis",
1401
+ owner: {},
1402
+ text: value,
1403
+ lines,
1404
+ font,
1405
+ priority: PRIORITY.total,
1406
+ candidates: [{ slot: "panelCaption", rect, penalty: 0 }],
1407
+ role: "note"
1408
+ }], occupied, {
1409
+ density: "full",
1410
+ pins: {},
1411
+ measure,
1412
+ plot: rect,
1413
+ canvas: rect,
1414
+ darkInk: theme.color.ink,
1415
+ lightInk: theme.color.inkInverse,
1416
+ labelPad: 0
1417
+ });
1418
+ pushAll(nodes, labelsToNodes(theme, solved.placed.map((label) => ({ ...label, capHeight: void 0 })), () => font).map((node) => node.t === "text" ? { ...node, ink, part } : node)), claims.push({ rect, kind: "frame", owner: {} }), y += text.height + 2;
1419
+ }
1420
+ return { nodes, claims };
1421
+ }
1422
+ function shareRowGridlines(geometry, columns) {
1423
+ let panels = geometry.marks.panels;
1424
+ for (let start = 0; start < panels.length; start += columns) {
1425
+ let first = panels[start], source = first?.chart?.geometry.plot;
1426
+ if (!first || !source) continue;
1427
+ let lines = geometry.scene.filter((node) => node.t === "line" && node.part === "gridline" && node.id.startsWith(`${first.id}/`));
1428
+ for (let panel of panels.slice(start + 1, start + columns)) {
1429
+ let chart = panel.chart;
1430
+ if (!chart) continue;
1431
+ let plot = chart.geometry.plot, at = (y) => plot.y + (y - source.y) * (plot.h / Math.max(1, source.h)), copies = lines.map((line) => ({
1432
+ ...line,
1433
+ id: `${panel.id}/${line.id.slice(first.id.length + 1)}`,
1434
+ owner: {},
1435
+ x1: plot.x,
1436
+ x2: plot.x + plot.w,
1437
+ y1: at(line.y1),
1438
+ y2: at(line.y2),
1439
+ tx: chart.offset.x,
1440
+ ty: chart.offset.y
1441
+ })), index = geometry.scene.findIndex((node) => node.id.startsWith(`${panel.id}/`)), tail = geometry.scene.splice(index < 0 ? geometry.scene.length : index);
1442
+ pushAll(geometry.scene, copies), pushAll(geometry.scene, tail);
1443
+ }
1444
+ }
1445
+ }
1446
+ var SHARED_AXIS_EDGE = 8, FACET_PLOT_SHARE = 0.5, FACET_COLUMN_SHARE = 0.85, FACET_HEAD_TOP = 5, FACET_HEAD_PULL = 11;
1447
+ function facetSpan(geometry) {
1448
+ let plot = geometry.plot, bars = geometry.marks?.bars, tops = Array.isArray(bars) ? bars.flatMap((bar) => bar.rect && bar.rect.h > 0 ? [bar.rect.y] : []) : [];
1449
+ return tops.length > 0 ? plot.y + plot.h - minOf(tops) : plot.h;
1450
+ }
1451
+ function facetPlotHeight(width, share, rowCount) {
1452
+ return Math.max(share * width, rowCount === 1 ? 0.5 * width + 90 : 0);
1453
+ }
1454
+ var ROW_CAPTION_TOP = 6;
1455
+ function legacyGridForm(panels, options) {
1456
+ let category = (options.sharedAxis ?? "category") === "category";
1457
+ return category && panels.length > 1 ? "tiers" : (category ? 1 : Math.max(1, Number(options.columns ?? 1))) > 1 && panels.length > 1 && new Set(panels.map((panel) => panel.type)).size === 1 && chartSizing(panels[0].type).fit === "fill" ? "facets" : "panels";
1458
+ }
1459
+ function compactStacks(data, options = {}) {
1460
+ if (isMetricStackData(data) || options.anchors !== void 0 || options.alignmentRules !== void 0) return !1;
1461
+ let { panels: placed, ...rest } = data, key = Array.isArray(placed) ? JSON.stringify([
1462
+ options.columns,
1463
+ options.rows,
1464
+ options.gutters,
1465
+ options.sharedAxis,
1466
+ rest,
1467
+ placed.map((panel) => [panel.type, panel.row, panel.column, panel.span, panel.align, panel.options?.variant])
1468
+ ]) : void 0, answer = key === void 0 ? void 0 : COMPACT_STACKS.get(key);
1469
+ if (answer === void 0) {
1470
+ let { panels } = normalizeGridData(data), authored = Array.isArray(options.columns) ? options.columns.length : options.columns ?? (options.rows ? Math.ceil(panels.length / options.rows.length) : Math.ceil(Math.sqrt(panels.length)));
1471
+ answer = usesAuthoredLayout(panels, options) && gridShare(panels, options.sharedAxis) !== "category" && Math.max(authored, ...panels.map((panel) => (panel.column ?? 0) + (panel.span?.columns ?? 1))) >= 2, key !== void 0 && (COMPACT_STACKS.size >= 64 && COMPACT_STACKS.delete(COMPACT_STACKS.keys().next().value), COMPACT_STACKS.set(key, answer));
1472
+ }
1473
+ return answer;
1474
+ }
1475
+ var COMPACT_STACKS = /* @__PURE__ */ new Map();
1476
+ function gridFormOf(data, options = {}) {
1477
+ if (isMetricStackData(data)) return "metric-stack";
1478
+ let { panels } = normalizeGridData(data);
1479
+ return usesAuthoredLayout(panels, options) ? "panels" : legacyGridForm(panels, { ...options, sharedAxis: gridShare(panels, options.sharedAxis) });
1480
+ }
1481
+ function layoutLegacyGrid(normalized, options) {
1482
+ let theme = themeForWidth(resolveTheme(options.theme), gridTypeClass(options)), measure = options.measure ?? defaultMeasurer, groupResult = resolveSharedYDomains(normalized.panels, options, normalized.repeatFacet === !0), form = legacyGridForm(groupResult.panels, options), compactTiers = form === "tiers", canvasWidth = resolveSize(options.size).width, gridMargin = { ...canvasMargin(theme, canvasWidth), ...options.margin }, columns = options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1)), facets = form === "facets", sharedAxis = facets && sharedYGroup(groupResult.panels) !== null && groupResult.panels.every((panel) => {
1483
+ let axis = panel.options?.valueAxis;
1484
+ return isRecord(axis) && axis.show === !0;
1485
+ }), rowCaption = facets ? normalized.rowCaption : void 0, facetHeads = facets && !sharedAxis, headedGaps = facetHeads ? facetHeadedGaps(theme.space.facetGap, canvasWidth) : void 0, gap = columns === 1 ? theme.space.tierGap : headedGaps?.column ?? theme.space.facetGap, slotWidth = (canvasWidth - gridMargin.left - gridMargin.right - gap * (columns - 1)) / columns, rowCaptionFont = { family: theme.type.family, ...theme.type.axis }, rowCaptionHeight = rowCaption ? measuredCaption(rowCaption, rowCaptionFont, canvasWidth - gridMargin.left - gridMargin.right, measure).height + 6 : 0, preparedPanels = groupResult.panels.map((authoredPanel, index) => {
1486
+ let childTitle = authoredPanel.options?.title, panel = facets && authoredPanel.title === void 0 && typeof childTitle == "string" && childTitle.trim().length > 0 ? { ...authoredPanel, title: childTitle, options: Object.fromEntries(Object.entries(authoredPanel.options).filter(([key]) => key !== "title")) } : authoredPanel, captionHeight = compactTiers ? 0 : measureCaptionBand(panel, theme, measure, slotWidth), panelOptions = panel.options ?? {}, margin = isRecord(panelOptions.margin) ? panelOptions.margin : {}, { title: panelTitle, ...panelWithoutTitle } = panel, axis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, firstRow = index < columns, headTop = facetHeads ? FACET_HEAD_TOP : 20, pull = facetHeads && captionHeight > 0 ? FACET_HEAD_PULL : 0;
1487
+ return {
1488
+ ...compactTiers ? panelWithoutTitle : panel,
1489
+ options: {
1490
+ ...panelOptions,
1491
+ ...sharedAxis ? { valueAxis: { ...axis, gridlines: axis.gridlines ?? !0, ...index % columns === 0 ? {} : { show: !1 } } } : {},
1492
+ ...compactTiers && panelOptions.title === void 0 && panelTitle ? { title: panelTitle } : {},
1493
+ ...options.palette !== void 0 && panelOptions.palette === void 0 ? { palette: options.palette } : {},
1494
+ ...compactPanelMode(panel, canvasWidth),
1495
+ // Facets: the grid's canvas margin and gutter are the panel's side margins; a
1496
+ // facet adds none of its own, so its plot spans the panel.
1497
+ // A compact panel on a narrow card spends no width on side margins either.
1498
+ margin: { ...facets ? { left: 0, right: 0, bottom: 0 } : compactPanelMode(panel, canvasWidth).mode ? { left: 0, right: 0 } : {}, ...margin, top: numeric(margin.top, firstRow && rowCaptionHeight > 0 ? ROW_CAPTION_TOP : headTop) + captionHeight + (firstRow ? rowCaptionHeight : 0) - pull }
1499
+ }
1500
+ };
1501
+ }), members = Object.fromEntries(Object.entries(groupResult.members).filter(([group]) => group !== DEFAULT_Y_GROUP && groupResult.domains[group])), composeOptions = { ...options, [SCALE_GROUP_MEMBERS]: members, ...headedGaps ? { [FACET_GAPS]: headedGaps } : {} }, geometry = layoutGrid(
1502
+ { panels: preparedPanels },
1503
+ composeOptions
1504
+ );
1505
+ if (geometry.refused) return geometry;
1506
+ if (sharedAxis) {
1507
+ let reserve = Math.max(0, maxOf(geometry.marks.panels.filter((_, index) => index % columns === 0).map((panel) => panel.chart?.geometry.plot.x ?? 0))), hang = Math.min(reserve, Math.max(0, gridMargin.left - SHARED_AXIS_EDGE));
1508
+ if (hang > 0 && (geometry = layoutGrid(
1509
+ { panels: preparedPanels.map((panel, index) => index % columns === 0 ? { ...panel, options: { ...panel.options, margin: { ...panel.options.margin, left: -hang } } } : panel) },
1510
+ composeOptions
1511
+ )), geometry.refused) return geometry;
1512
+ shareRowGridlines(geometry, columns);
1513
+ }
1514
+ let slots = geometry.marks.panels.map((panel) => ({
1515
+ ...geometry.plot,
1516
+ ...(options.sharedAxis ?? "category") !== "category" && panel.chart ? { x: panel.chart.offset.x, y: panel.chart.offset.y, w: slotWidth } : {}
1517
+ })), captionSlots = compactTiers ? [] : preparedPanels.map((panel, index) => ({ panel, slot: slots[index] })), captionNodes = [], captionClaims = [], highlighted = new Set(
1518
+ resolveHighlight(options.highlight).filter((id) => preparedPanels.some((panel) => panel.id === id))
1519
+ ), facetPull = facetHeads && preparedPanels[0] && measureCaptionBand(preparedPanels[0], theme, measure, slotWidth) > 0 ? FACET_HEAD_PULL : 0;
1520
+ if (rowCaption && preparedPanels.length > 0) {
1521
+ let first = preparedPanels[0], top = numeric(first.options.margin.top, 20) - measureCaptionBand(first, theme, measure, slotWidth), band = panelCaptionBand(
1522
+ { id: "grid", type: "text", data: {}, caption: rowCaption, options: { margin: { left: 0, right: 0, top } } },
1523
+ theme,
1524
+ measure,
1525
+ { ...slots[0], w: canvasWidth - gridMargin.left - gridMargin.right },
1526
+ highlighted,
1527
+ !1,
1528
+ facetPull
1529
+ );
1530
+ pushAll(captionNodes, band.nodes), pushAll(captionClaims, band.claims);
1531
+ }
1532
+ for (let entry of captionSlots) {
1533
+ let band = panelCaptionBand(entry.panel, theme, measure, entry.slot, highlighted, !1, facetHeads && measureCaptionBand(entry.panel, theme, measure, slotWidth) > 0 ? FACET_HEAD_PULL : 0);
1534
+ entry.titleNodeId = band.nodes.find((n) => n.part === "panelTitle")?.id, entry.captionNodeId = band.nodes.find((n) => n.part === "panelCaption")?.id, pushAll(captionNodes, band.nodes), pushAll(captionClaims, band.claims);
1535
+ }
1536
+ let markById = new Map(geometry.marks.panels.map((panel) => [panel.id, panel]));
1537
+ for (let entry of captionSlots) {
1538
+ let mark = markById.get(entry.panel.id);
1539
+ mark && (entry.titleNodeId && !mark.titleNodeId && (mark.titleNodeId = entry.titleNodeId), entry.captionNodeId && (mark.captionNodeId = entry.captionNodeId));
1540
+ }
1541
+ let rowCount = Math.ceil(geometry.marks.panels.length / columns), share = Math.max(FACET_PLOT_SHARE, FACET_COLUMN_SHARE / rowCount), tallest = geometry.marks.panels.flatMap((panel) => panel.chart ? [panel.chart.geometry] : []).reduce((best, chart) => !best || facetSpan(chart) > facetSpan(best) ? chart : best, void 0), headedChange = (target) => {
1542
+ let span = tallest ? facetSpan(tallest) : 0;
1543
+ return span > 0 ? (target - span) * (tallest.plot.h / span) : -1 / 0;
1544
+ }, rowChange = facets && geometry.sizing ? Array.from({ length: rowCount }, (_, row) => maxOf(geometry.marks.panels.slice(row * columns, (row + 1) * columns).map((panel) => panel.chart ? facetHeads ? headedChange(facetPlotHeight(panel.chart.geometry.plot.w, share, rowCount)) : facetPlotHeight(panel.chart.geometry.plot.w, share, rowCount) - panel.chart.geometry.plot.h : -1 / 0))) : [], change = rowChange.every(Number.isFinite) ? rowChange.reduce((total, value) => total + value, 0) : 0, sizing = rowChange.length > 0 && Math.abs(change) > 0.5 && geometry.sizing ? { ...geometry.sizing, naturalHeight: Math.max(geometry.sizing.minHeight, Math.ceil(geometry.size.height + change)) } : geometry.sizing;
1545
+ return {
1546
+ ...geometry,
1547
+ ...sizing ? { sizing } : {},
1548
+ scene: [...geometry.scene, ...captionNodes],
1549
+ warnings: [...geometry.warnings, ...groupResult.warnings],
1550
+ derived: {
1551
+ ...geometry.derived,
1552
+ ...Object.keys(groupResult.domains).length > 0 ? { sharedYDomains: groupResult.domains } : {}
1553
+ },
1554
+ debug: {
1555
+ ...geometry.debug,
1556
+ occupied: [...geometry.debug.occupied, ...captionClaims]
1557
+ }
1558
+ };
1559
+ }
1560
+ var TIER_PLOT_FLOOR = 10.5, TIER_HEIGHT_STEP = 16;
1561
+ function withTierPlot(geometry, panels, options) {
1562
+ let sizing = geometry.sizing, weights = options.sharedAxis === "category" && sharedYGroup(panels) === null ? varianceTierWeights(panels) : void 0;
1563
+ if (!weights || !sizing || geometry.refused) return geometry;
1564
+ let column = panels.findIndex((panel) => panel.type === "column"), columnOptions = panels[column].options;
1565
+ if (columnOptions?.variant !== "stacked") return geometry;
1566
+ let open = options[TARGET_SIZE]?.fixed.height === !1, hides = open && sliversHidden(geometry), { width, height } = geometry.size, plots = geometry.marks.panels.map((panel) => panel.chart?.geometry.plot.h ?? 0), share = weights.reduce((sum2, weight) => sum2 + weight, 0) / weights[column], need = autoPlotPx(options.target ?? DEFAULT_TARGET, width) * share, reservePlot = stackedColumnPlotPx("column", columnOptions, width), reserve = Math.ceil(reservePlot * share), reach = need / share + reservePlot, squashed = plots.some((plot) => plot <= TIER_PLOT_FLOOR), id = panels[column].id, columnData = panels[column].data, withheld = new Set(columnData?.series?.flatMap((series) => series.values.flatMap((cell, index) => cellMeta(cell)?.label === !1 ? [`${id}/segment:${series.id}:${columnData.categories?.[index]?.id}`] : [])) ?? []), needs = hides ? geometry.labels.filter((label) => label.id.startsWith(`${id}/segment:`) && !withheld.has(label.id)).map((label) => {
1567
+ let mark = geometry.scene.find((node) => node.id === label.id.replace("/segment:", "/mark:"));
1568
+ return plots[column] * ((label[DIGIT_SEAT]?.lineH ?? label.rect.h) + STACK_ROOM) / (mark?.rect?.h ?? 0);
1569
+ }) : [], wanted = Math.max(0, maxOf(needs.filter((plot) => plot <= reach))), drawn = plots[column] + (sizing.naturalHeight - height) / share;
1570
+ if (weights.length > 2 && (!open || !hides || wanted <= drawn + 0.5))
1571
+ return open && !hides && height > sizing.naturalHeight ? { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight: height } } : geometry;
1572
+ let tierHeight = Math.ceil(height + need - plots.reduce((sum2, plot) => sum2 + plot, 0) - (squashed ? Math.max(0, sizing.minHeight - height) : 0) - 1e-6);
1573
+ if (open && !squashed && !hides && height > sizing.naturalHeight && height > tierHeight + 2 * TIER_HEIGHT_STEP && height <= tierHeight + reserve + 2 * TIER_HEIGHT_STEP)
1574
+ return { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight: height } };
1575
+ let found = !squashed && wanted > Math.max(need / share, drawn) ? tierHeight + reserve : tierHeight;
1576
+ if (found <= sizing.naturalHeight + (squashed ? TIER_HEIGHT_STEP : 0))
1577
+ return squashed ? { ...geometry, sizing: { ...sizing, fit: "content" } } : geometry;
1578
+ let naturalHeight = !squashed && found - height <= TIER_HEIGHT_STEP && height - found <= 2 * TIER_HEIGHT_STEP ? height : found;
1579
+ return { ...geometry, sizing: { ...sizing, fit: "content", naturalHeight } };
1580
+ }
1581
+ function withOnePanelContent(geometry, relayout, panels, options) {
1582
+ let sizing = geometry.sizing, target = options.target ?? DEFAULT_TARGET, { width, height } = geometry.size, columns = options.sharedAxis === "category" || options.sharedAxis === void 0 ? 1 : Math.max(1, Number(options.columns ?? 1));
1583
+ if (!sizing || sizing.fit !== "fill" || geometry.refused || columns !== 1 || panels.length !== 1 || width < NARROW_SHARE_WIDTH || width >= WIDE_CANVAS_MIN_WIDTH) return geometry;
1584
+ let panel = panels[0], plotPx = autoPlotPx(target, width) + stackedColumnPlotPx(panel.type, panel.options, width), content = (probe) => {
1585
+ let chart = probe.marks.panels[0]?.chart?.geometry;
1586
+ return chart && chart.sizing?.fit === "fill" ? Math.ceil(probe.size.height - chart.plot.h + plotPx - 1e-6) : void 0;
1587
+ }, found = content(geometry);
1588
+ if (found === void 0) return geometry;
1589
+ if (found = Math.min(sizing.naturalHeight, found), Math.abs(found - height) > 1) {
1590
+ let probe = relayout({ ...options, size: { ...resolveSize(options.size), width, height: found } }), again = probe.refused ? void 0 : content(probe);
1591
+ again !== void 0 && (found = Math.min(sizing.naturalHeight, again));
1592
+ }
1593
+ let naturalHeight = Math.max(sizing.minHeight, found);
1594
+ return naturalHeight === sizing.naturalHeight ? geometry : { ...geometry, sizing: { ...sizing, naturalHeight } };
1595
+ }
1596
+ function usesAuthoredLayout(panels, options) {
1597
+ return Array.isArray(options.columns) || options.rows !== void 0 || options.gutters !== void 0 || options.anchors !== void 0 || options.alignmentRules !== void 0 || panels.some(
1598
+ (panel) => panel.type === "text" || panel.type === "legend" || panel.row !== void 0 || panel.column !== void 0 || panel.span !== void 0 || panel.align !== void 0
1599
+ );
1600
+ }
1601
+ function isAuthoredVarianceStack(panels, options) {
1602
+ if ((options.sharedAxis ?? "category") !== "category" || !varianceTierWeights(panels)) return !1;
1603
+ let columns = Array.isArray(options.columns) ? options.columns.length : options.columns ?? Math.max(1, Math.ceil(Math.sqrt(panels.length))), placements = panels.map((panel, index) => ({
1604
+ row: panel.row ?? Math.floor(index / columns),
1605
+ column: panel.column ?? index % columns
1606
+ }));
1607
+ return new Set(placements.map((placement) => placement.column)).size === 1 && new Set(placements.map((placement) => placement.row)).size === panels.length && panels.every((panel) => (panel.span?.rows ?? 1) === 1 && (panel.span?.columns ?? 1) === 1);
1608
+ }
1609
+ function layoutAuthoredGrid(rawPanels, options, repeatFacet) {
1610
+ let theme = themeForWidth(resolveTheme(options.theme), gridTypeClass(options)), size = resolveSize(options.size), measure = options.measure ?? defaultMeasurer, warnings = [], automaticRows = options.rows === void 0, naturalTierWeights = options.sharedAxis === "category" && options.rows === void 0 && sharedYGroup(rawPanels) === null ? varianceTierWeights(rawPanels) : void 0;
1611
+ if (options.sharedAxis === "category") {
1612
+ let bottomUp = bottomUpTierOrder(rawPanels), weights = tierWeights(rawPanels);
1613
+ (((Array.isArray(options.columns) ? options.columns.length : options.columns) ?? 1) !== 1 || options.panelOrder !== void 0 || rawPanels.some((panel) => panel.row !== void 0 || panel.column !== void 0 || panel.span !== void 0) || options.rows !== void 0 && options.rows.length !== rawPanels.length) && warnings.push({
1614
+ code: "grid-tier-order",
1615
+ severity: "warn",
1616
+ message: "Category tiers use one column and bottom-up order, with the category-axis owner at the bottom; authored placement and panelOrder do not set their visual order",
1617
+ suggest: "use sharedAxis: 'none' for authored facet placement"
1618
+ });
1619
+ let authoredWeights = options.rows?.length === rawPanels.length ? options.rows : weights;
1620
+ options = { ...options, columns: 1, rows: [...bottomUp].reverse().map((index) => authoredWeights[index]) }, rawPanels = rawPanels.map((panel, index) => ({
1621
+ ...panel,
1622
+ row: rawPanels.length - 1 - bottomUp.indexOf(index),
1623
+ column: 0,
1624
+ span: void 0
1625
+ }));
1626
+ }
1627
+ ({ panels: rawPanels, options } = stackNarrowReadouts(rawPanels, options, theme, measure, size.width));
1628
+ let stacked = stackCompactPanels(rawPanels, options, size.width);
1629
+ stacked.options !== options && (automaticRows = !0), { panels: rawPanels, options } = stacked, options.valueAxis?.break && warnings.push({
1630
+ code: "axis-break-unsupported",
1631
+ severity: "warn",
1632
+ message: "chart type 'grid' does not support valueAxis.break \u2014 ignored"
1633
+ });
1634
+ let legendItems = collectGridLegendItems(rawPanels, options, measure), legendInput;
1635
+ if (options.legend && options.legend !== "none" && options.legend !== "auto") {
1636
+ let legendOptions = normalizeLegendOption(options.legend);
1637
+ legendInput = gridLegendInput(legendItems, legendOptions, options, warnings);
1638
+ }
1639
+ let occupied = createOccupiedIndex({ x: 0, y: 0, w: size.width, h: size.height }), frameResult = solveFrame(
1640
+ {
1641
+ size,
1642
+ margin: { ...canvasMargin(theme, size.width), ...options.margin },
1643
+ ...frameTextOptions(options),
1644
+ legend: legendInput,
1645
+ theme,
1646
+ measure
1647
+ },
1648
+ occupied
1649
+ ), area = frameResult.plot, authoredColumnCount = Array.isArray(options.columns) ? options.columns.length : typeof options.columns == "number" ? options.columns : void 0, fallbackColumns = authoredColumnCount ?? (options.rows ? Math.max(1, Math.ceil(rawPanels.length / options.rows.length)) : Math.max(1, Math.ceil(Math.sqrt(rawPanels.length)))), provisional = rawPanels.map((panel, index) => ({
1650
+ row: panel.row ?? Math.floor(index / fallbackColumns),
1651
+ column: panel.column ?? index % fallbackColumns,
1652
+ rowSpan: panel.span?.rows ?? 1,
1653
+ columnSpan: panel.span?.columns ?? 1
1654
+ }));
1655
+ provisional.forEach((entry, index) => {
1656
+ let exceedsRows = options.rows !== void 0 && entry.row + entry.rowSpan > options.rows.length, exceedsColumns = authoredColumnCount !== void 0 && entry.column + entry.columnSpan > authoredColumnCount;
1657
+ if (!exceedsRows && !exceedsColumns) return;
1658
+ let panel = rawPanels[index];
1659
+ throw new NormalizeError(
1660
+ "grid-span-exceeds-tracks",
1661
+ `panels[${index}].span`,
1662
+ `panel '${panel.id}' spans to row ${entry.row + entry.rowSpan} and column ${entry.column + entry.columnSpan}, outside the authored ${options.rows?.length ?? "derived"}\xD7${authoredColumnCount ?? "derived"} grid`,
1663
+ "add tracks or reduce the span"
1664
+ );
1665
+ });
1666
+ let occupant = /* @__PURE__ */ new Map();
1667
+ provisional.forEach((entry, index) => {
1668
+ for (let r = entry.row; r < entry.row + entry.rowSpan; r++)
1669
+ for (let c = entry.column; c < entry.column + entry.columnSpan; c++) {
1670
+ let first = occupant.get(`${r}:${c}`);
1671
+ if (first !== void 0)
1672
+ throw new NormalizeError(
1673
+ "grid-cell-overlap",
1674
+ `panels[${index}]`,
1675
+ `panels '${rawPanels[first].id}' and '${rawPanels[index].id}' both occupy row ${r}, column ${c}`,
1676
+ "move a panel or reduce its span"
1677
+ );
1678
+ occupant.set(`${r}:${c}`, index);
1679
+ }
1680
+ });
1681
+ let columnCount = Math.max(
1682
+ authoredColumnCount ?? 0,
1683
+ maxOf(provisional.map((entry) => entry.column + entry.columnSpan))
1684
+ ), rowCount = Math.max(
1685
+ options.rows?.length ?? 0,
1686
+ maxOf(provisional.map((entry) => entry.row + entry.rowSpan))
1687
+ );
1688
+ if (columnCount <= 0 || rowCount <= 0)
1689
+ throw new NormalizeError("grid-empty-tracks", "options.rows", "grid requires row and column tracks");
1690
+ let rowWeights = options.rows ?? Array.from({ length: rowCount }, () => 1), columnWeights = Array.isArray(options.columns) ? options.columns : Array.from({ length: columnCount }, () => 1);
1691
+ if (rowWeights.length !== rowCount || columnWeights.length !== columnCount)
1692
+ throw new NormalizeError(
1693
+ "grid-track-count",
1694
+ "options",
1695
+ `tracks declare ${rowWeights.length}\xD7${columnWeights.length}; panels require ${rowCount}\xD7${columnCount}`
1696
+ );
1697
+ let rowGaps = resolveGaps(options.gutters?.rows, rowCount - 1, theme.space.tierGap, "rows"), columnGaps = resolveGaps(options.gutters?.columns, columnCount - 1, theme.space.facetGap, "columns"), rowBands = trackBands(area.y, area.h, rowWeights, rowGaps, options.gutters?.rows !== void 0), baseColumnBands = trackBands(area.x, area.w, columnWeights, columnGaps, options.gutters?.columns !== void 0), scaledPanels = resolveSharedYDomains(
1698
+ rawPanels.filter((panel) => panel.type !== "text" && panel.type !== "legend"),
1699
+ options,
1700
+ repeatFacet
1701
+ );
1702
+ pushAll(warnings, scaledPanels.warnings);
1703
+ let scaledById = new Map(scaledPanels.panels.map((panel) => [panel.id, panel])), panels = rawPanels.map((panel) => scaledById.get(panel.id) ?? panel), baseChildSlots = provisional.map((placement, index) => {
1704
+ let raw = spanRect(rowBands, baseColumnBands, placement);
1705
+ return alignInside(raw, panels[index].align);
1706
+ }), uniformLineEndpointLegend = !1, layoutChildren = (slots) => panels.map(
1707
+ (panel, index) => layoutAuthoredChild(
1708
+ panel,
1709
+ provisional[index],
1710
+ slots[index],
1711
+ panels,
1712
+ options,
1713
+ legendItems,
1714
+ theme,
1715
+ measure
1716
+ )
1717
+ ), uniformizeLineEndpointIdentity = (children, slots) => uniformLineEndpointLegend || gridPanelsKeepEndNames(options) || !children.some(
1718
+ (child) => child.panel.type === "line" && child.geometry.derived.endpointLabelEconomy?.strategy === "legend"
1719
+ ) ? children : (uniformLineEndpointLegend = !0, panels = panels.map(
1720
+ (panel) => panel.type === "line" ? {
1721
+ ...panel,
1722
+ options: { ...panel.options, gridEndpointIdentity: "legend" }
1723
+ } : panel
1724
+ ), layoutChildren(slots));
1725
+ try {
1726
+ let children = uniformizeLineEndpointIdentity(layoutChildren(baseChildSlots), baseChildSlots), sharedAnchors = emptyIdRecord(), columnBands = baseColumnBands;
1727
+ if (options.anchors?.categories === "column" || options.anchors?.categories === "all") {
1728
+ if (columnBands = categoryColumnBands(
1729
+ children,
1730
+ baseColumnBands,
1731
+ columnGaps,
1732
+ warnings
1733
+ ), columnBands !== baseColumnBands) {
1734
+ let anchoredSlots = provisional.map((placement, index) => {
1735
+ let columns = placement.columnSpan === 1 ? columnBands : baseColumnBands;
1736
+ return alignInside(
1737
+ spanRect(rowBands, columns, placement),
1738
+ panels[index].align
1739
+ );
1740
+ });
1741
+ children = uniformizeLineEndpointIdentity(layoutChildren(anchoredSlots), anchoredSlots);
1742
+ }
1743
+ let indents = readoutIndents(children, columnBands.length);
1744
+ indents.size > 0 && (panels = panels.map((panel) => indents.has(panel.id) ? { ...panel, readoutIndent: indents.get(panel.id) } : panel), children = children.map((child, index) => indents.has(child.panel.id) ? layoutAuthoredChild(panels[index], child.placement, child.slot, panels, options, legendItems, theme, measure) : child));
1745
+ }
1746
+ let columnRects = columnBands.map((band) => ({
1747
+ x: band.start,
1748
+ y: area.y,
1749
+ w: band.size,
1750
+ h: area.h
1751
+ })), edgeScopes = new Set(options.sharedAxis === "category" ? ["column"] : []);
1752
+ options.anchors?.plotEdges && edgeScopes.add(options.anchors.plotEdges), options.anchors?.categories && edgeScopes.add(options.anchors.categories);
1753
+ for (let scope of edgeScopes)
1754
+ scope !== "row" && (children = alignPlotEdges(children, scope, sharedAnchors, warnings, theme));
1755
+ if (options.anchors?.categories && options.anchors.categories !== "row") {
1756
+ let moved = Math.max(0, maxOf(scopeGroups(children, options.anchors.categories).map((group) => alignCategoryPanels(group, theme))));
1757
+ if (moved > 0.01) for (let key of Object.keys(sharedAnchors)) key.startsWith("plotEdges:") && delete sharedAnchors[key];
1758
+ moved > 0.01 && options.anchors.plotEdges && warnings.push({
1759
+ code: "grid-anchor-incompatible",
1760
+ severity: "warn",
1761
+ message: `category centres are aligned across panels whose types inset their categories differently, so their plot edges differ by up to ${Math.round(moved * 10) / 10}px`
1762
+ });
1763
+ }
1764
+ if (automaticRows) {
1765
+ let valueSize = smallestKpiValueSize(children.map((child) => child.geometry));
1766
+ if (valueSize !== void 0)
1767
+ for (let child of children)
1768
+ hasKpiFigure(child.panel.type) && (child.geometry = child.relayout(child.margin, valueSize));
1769
+ let heights = gridRowHeights(area.h, children.map((child) => ({ geometry: child.geometry, ...child.placement })), rowWeights, rowGaps);
1770
+ if (heights) {
1771
+ let y = area.y;
1772
+ rowBands = heights.map((height, row) => {
1773
+ let band = { start: y, size: height };
1774
+ return y += height + (rowGaps[row] ?? 0), band;
1775
+ }), children = children.map((child) => (Object.assign(child.slot, alignInside(spanRect(
1776
+ rowBands,
1777
+ child.placement.columnSpan === 1 ? columnBands : baseColumnBands,
1778
+ child.placement
1779
+ ), child.panel.align)), child.relayout ? { ...child, geometry: child.relayout(child.margin, valueSize) } : layoutAuthoredChild(child.panel, child.placement, child.slot, panels, options, legendItems, theme, measure)));
1780
+ }
1781
+ }
1782
+ if (naturalTierWeights) {
1783
+ let wrap = () => children.map((child) => ({ child, geo: child.geometry })), tierSlots = children.map((child) => child.slot);
1784
+ for (let pass = 0; pass < 3; pass++)
1785
+ balanceVarianceTierPlots(tierSlots, wrap(), naturalTierWeights, () => {
1786
+ for (let child of children) child.geometry = child.relayout(child.margin);
1787
+ return wrap();
1788
+ });
1789
+ let contentHeight = () => children.reduce((sum2, child) => sum2 + authoredOccupiedBounds(child.geometry).h, 0), available = area.h - rowGaps.reduce((sum2, gap) => sum2 + gap, 0), weight = naturalTierWeights.reduce((sum2, value) => sum2 + value, 0), packed = children.every((child) => !child.panel.align) && !options.anchors?.baselines;
1790
+ if (packed && children.every((child) => child.slot.h >= (child.geometry.sizing?.minHeight ?? 0)))
1791
+ for (let pass = 0; pass < 8; pass++) {
1792
+ let slack = available - contentHeight();
1793
+ if (slack < 1) break;
1794
+ let previous = children.map((child) => child.slot.h), accepted = !1;
1795
+ for (let backoff = 0; backoff < 8; backoff++)
1796
+ if (children.forEach((child, index) => {
1797
+ child.slot.h = previous[index] + slack * naturalTierWeights[index] / weight / 2 ** backoff, child.geometry = child.relayout(child.margin);
1798
+ }), balanceVarianceTierPlots(tierSlots, wrap(), naturalTierWeights, () => {
1799
+ for (let child of children) child.geometry = child.relayout(child.margin);
1800
+ return wrap();
1801
+ }), contentHeight() <= available) {
1802
+ accepted = !0;
1803
+ break;
1804
+ }
1805
+ if (!accepted) {
1806
+ children.forEach((child, index) => {
1807
+ child.slot.h = previous[index], child.geometry = child.relayout(child.margin);
1808
+ });
1809
+ break;
1810
+ }
1811
+ }
1812
+ rowWeights = rowWeights.map((_, row) => tierSlots[provisional.findIndex((p) => p.row === row)].h), rowBands = trackBands(area.y, area.h, rowWeights, rowGaps, options.gutters?.rows !== void 0), tierSlots.forEach((slot, index) => {
1813
+ slot.y = rowBands[provisional[index].row].start;
1814
+ });
1815
+ let bottom = area.y + area.h;
1816
+ for (let index of packed ? bottomUpTierOrder(panels) : []) {
1817
+ let child = children[index], bounds = authoredOccupiedBounds(child.geometry);
1818
+ child.slot.y = bottom - bounds.y - bounds.h, rowBands[child.placement.row] = { start: bottom - bounds.h, size: bounds.h }, bottom -= bounds.h + (rowGaps[child.placement.row - 1] ?? 0);
1819
+ }
1820
+ }
1821
+ let rowRects = rowBands.map((band) => ({ x: area.x, y: band.start, w: area.w, h: band.size }));
1822
+ (options.anchors?.categories === "column" || options.anchors?.categories === "all") && recordCategoryColumnAnchors(children, columnBands, sharedAnchors, warnings), options.anchors?.baselines && (children = alignBaselines(children, options.anchors.baselines, sharedAnchors));
1823
+ let keepBaselines = options.anchors?.baselines ? {
1824
+ top: (child) => child.margin.top ?? numeric(isRecord(child.panel.options?.margin) ? child.panel.options.margin.top : void 0, 20),
1825
+ above: (child) => {
1826
+ let baseline = baselineY(child.geometry), { y, h } = child.geometry.plot;
1827
+ return baseline === null || !(h > 0) ? 1 : Math.min(1, Math.max(0, (baseline - y) / h));
1828
+ }
1829
+ } : void 0;
1830
+ for (let [group, ids] of Object.entries(scaledPanels.members))
1831
+ group === DEFAULT_Y_GROUP || !scaledPanels.domains[group] || alignValuePanels(children.filter((child) => ids.includes(child.panel.id)), theme, keepBaselines);
1832
+ let kpiValueSize = smallestKpiValueSize(children.map((child) => child.geometry));
1833
+ if (kpiValueSize !== void 0)
1834
+ for (let child of children)
1835
+ hasKpiFigure(child.panel.type) && (child.geometry = child.relayout(child.margin, kpiValueSize));
1836
+ let scene = [...frameResult.nodes], labels = [], axes = [], annotations = [], occupiedAll = occupied.snapshot().slice(), decisions = [], marks = { panels: [], alignmentRules: [] };
1837
+ for (let child of children) {
1838
+ let need = child.geometry.sizing;
1839
+ options.sharedAxis === "category" && child.geometry.size.height + 1e-6 < (child.geometry.frame.plotMinHeight ?? 0) && warnings.push({
1840
+ code: "grid-panel-too-short",
1841
+ severity: "warn",
1842
+ message: `panel '${child.panel.id}' is below its measured plot height floor`,
1843
+ suggest: "increase its authored rows weight or increase the grid height"
1844
+ }), child.panel.align && (child.slot.w < (need?.minWidth ?? 0) || child.slot.h < (need?.minHeight ?? child.geometry.frame.minHeight ?? 0)) && warnings.push({
1845
+ code: "grid-panel-too-short",
1846
+ severity: "error",
1847
+ message: `panel '${child.panel.id}' needs a larger fixed alignment size`
1848
+ }), appendAuthoredChild(child, scene, labels, axes, annotations, occupiedAll, decisions, warnings, marks);
1849
+ }
1850
+ let childById = new Map(children.map((child) => [child.panel.id, child])), ruleIds = /* @__PURE__ */ new Set();
1851
+ for (let rule of options.alignmentRules ?? []) {
1852
+ if (ruleIds.has(rule.id))
1853
+ throw new NormalizeError(
1854
+ "duplicate-id",
1855
+ "options.alignmentRules",
1856
+ `duplicate alignment rule id '${rule.id}' \u2014 ids key guide scene identities`
1857
+ );
1858
+ ruleIds.add(rule.id);
1859
+ let source = childById.get(rule.at.panelId);
1860
+ if (!source)
1861
+ throw new NormalizeError(
1862
+ "grid-rule-panel",
1863
+ `options.alignmentRules.${rule.id}.at.panelId`,
1864
+ `alignment rule '${rule.id}' names unknown panel '${rule.at.panelId}'`
1865
+ );
1866
+ let coordinate = resolveRuleCoordinate(source, rule.at.anchor, rule.at.categoryId);
1867
+ if (coordinate === null || coordinate.axis !== (rule.orientation === "vertical" ? "x" : "y"))
1868
+ throw new NormalizeError(
1869
+ "grid-rule-anchor",
1870
+ `options.alignmentRules.${rule.id}.at`,
1871
+ `alignment rule '${rule.id}' cannot resolve ${rule.orientation} guide from ${rule.at.anchor}${rule.at.categoryId ? ` '${rule.at.categoryId}'` : ""} on panel '${source.panel.id}'`
1872
+ );
1873
+ let from = rule.fromPanelId ? childById.get(rule.fromPanelId) : void 0, to = rule.toPanelId ? childById.get(rule.toPanelId) : void 0;
1874
+ if (rule.fromPanelId && !from || rule.toPanelId && !to)
1875
+ throw new NormalizeError(
1876
+ "grid-rule-panel",
1877
+ `options.alignmentRules.${rule.id}`,
1878
+ `alignment rule '${rule.id}' names an unknown from/to panel`
1879
+ );
1880
+ let nodeId = `grid:alignment:${rule.id}`;
1881
+ if (rule.orientation === "vertical") {
1882
+ let y1 = from?.slot.y ?? area.y, y2 = (to?.slot.y ?? area.y) + (to?.slot.h ?? area.h), runs = guideRuns(occupiedAll, "vertical", coordinate.value, y1, y2);
1883
+ scene.push(runs.length === 1 && runs[0][0] === Math.min(y1, y2) && runs[0][1] === Math.max(y1, y2) ? { t: "line", id: nodeId, x1: coordinate.value, y1, x2: coordinate.value, y2, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" } : { t: "path", id: nodeId, d: runs.map(([a, b]) => `M${fmtPathNumber(coordinate.value)} ${fmtPathNumber(a)}V${fmtPathNumber(b)}`).join(""), stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" }), occupiedAll.push({
1884
+ rect: { x: coordinate.value - 0.5, y: Math.min(y1, y2), w: 1, h: Math.abs(y2 - y1) },
1885
+ kind: "axis",
1886
+ owner: {},
1887
+ part: "alignmentRule"
1888
+ });
1889
+ } else {
1890
+ let x1 = from?.slot.x ?? area.x, x2 = (to?.slot.x ?? area.x) + (to?.slot.w ?? area.w), runs = guideRuns(occupiedAll, "horizontal", coordinate.value, x1, x2);
1891
+ scene.push(runs.length === 1 && runs[0][0] === Math.min(x1, x2) && runs[0][1] === Math.max(x1, x2) ? { t: "line", id: nodeId, x1, y1: coordinate.value, x2, y2: coordinate.value, stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" } : { t: "path", id: nodeId, d: runs.map(([a, b]) => `M${fmtPathNumber(a)} ${fmtPathNumber(coordinate.value)}H${fmtPathNumber(b)}`).join(""), stroke: { token: "grid" }, width: strokeToken(theme, "hair"), owner: {}, part: "alignmentRule" }), occupiedAll.push({
1892
+ rect: { x: Math.min(x1, x2), y: coordinate.value - 0.5, w: Math.abs(x2 - x1), h: 1 },
1893
+ kind: "axis",
1894
+ owner: {},
1895
+ part: "alignmentRule"
1896
+ });
1897
+ }
1898
+ marks.alignmentRules.push({ id: rule.id, nodeId, orientation: rule.orientation });
1899
+ }
1900
+ let compactNotes = children.flatMap((child) => child.geometry.a11y.compactNotes ?? []);
1901
+ return {
1902
+ type: "grid",
1903
+ size,
1904
+ sizing: withReadoutPlotHeight(
1905
+ gridSizing(size, area, children.map((child) => ({ geometry: child.geometry, ...child.placement })), rowWeights, columnWeights, rowGaps, columnGaps, automaticRows),
1906
+ size,
1907
+ automaticRows ? children : []
1908
+ ),
1909
+ plot: area,
1910
+ scene,
1911
+ labels,
1912
+ axes,
1913
+ annotations,
1914
+ frame: frameResult.frame,
1915
+ legend: frameResult.legend,
1916
+ marks,
1917
+ derived: {
1918
+ tracks: { rows: rowRects, columns: columnRects, rowGaps, columnGaps },
1919
+ ...Object.keys(sharedAnchors).length > 0 ? { sharedAnchors } : {},
1920
+ ...Object.keys(scaledPanels.domains).length > 0 ? { sharedYDomains: scaledPanels.domains } : {}
1921
+ },
1922
+ a11y: {
1923
+ titleCounts: [structureCount("panels", panels.length, void 0, options)],
1924
+ title: accessibleTitle(options.title, chartString(options, "gridPanelsTitle", { v1: panels.length })),
1925
+ counts: [
1926
+ structureCount("rows", rowCount, chartString(options, "authoredRows", { v1: rowCount })),
1927
+ structureCount("columns", columnCount, chartString(options, "compositionColumns", { v1: columnCount })),
1928
+ ...children.flatMap((child) => {
1929
+ let title = child.panel.title ?? child.geometry.a11y.title;
1930
+ return [...child.geometry.a11y.counts ?? [], ...child.geometry.a11y.titleCounts ?? []].filter((count) => title.includes(count.text));
1931
+ })
1932
+ ],
1933
+ desc: chartString(options, "gridComposition", { v1: rowCount, v2: columnCount, v3: marks.panels.map((panel) => panel.title).join("; "), v4: compactNotes.length > 0 ? chartString(options, "notesClause", { v1: compactNotes.join("; ") }) : "" }),
1934
+ ...compactNotes.length > 0 ? { compactNotes } : {}
1935
+ },
1936
+ warnings,
1937
+ debug: { occupied: occupiedAll, decisions }
1938
+ };
1939
+ } catch (error) {
1940
+ if (!(error instanceof GridChildRefusal)) throw error;
1941
+ let index = panels.findIndex((panel) => panel.id === error.panelId);
1942
+ return error.result(size, gridSizing(
1943
+ size,
1944
+ area,
1945
+ [{ geometry: error.child, ...provisional[index] }],
1946
+ rowWeights,
1947
+ columnWeights,
1948
+ rowGaps,
1949
+ columnGaps,
1950
+ automaticRows
1951
+ ), index);
1952
+ }
1953
+ }
1954
+ function layoutAuthoredChild(panel, placement, slot, panels, parentOptions, allLegendItems, theme, measure) {
1955
+ if (panel.type === "text")
1956
+ return {
1957
+ panel,
1958
+ placement,
1959
+ slot,
1960
+ margin: {},
1961
+ geometry: layoutTextPanel(panel, slot, theme, measure)
1962
+ };
1963
+ if (panel.type === "legend") {
1964
+ let parsed = parseGridLegendPanelData(panel.data), allow = parsed.from ? new Set(parsed.from) : void 0, items = allow ? collectGridLegendItems(
1965
+ panels.filter((candidate) => allow.has(candidate.id)),
1966
+ parentOptions,
1967
+ measure
1968
+ ) : allLegendItems;
1969
+ return {
1970
+ panel,
1971
+ placement,
1972
+ slot,
1973
+ margin: {},
1974
+ geometry: layoutLegendPanel(panel, slot, items, theme, measure, parentOptions)
1975
+ };
1976
+ }
1977
+ let definition = getChart(panel.type);
1978
+ if (!definition)
1979
+ throw new NormalizeError(
1980
+ "unknown-type",
1981
+ `panels[${panel.id}].type`,
1982
+ `unknown chart type '${panel.type}'`
1983
+ );
1984
+ let authoredOptions = panel.options ?? {}, compactTiers = parentOptions.sharedAxis === "category" && panels.length > 1, authoredTitle = panel.title ?? (typeof authoredOptions.title == "string" ? authoredOptions.title : void 0), panelOptions = parentOptions.sharedAxis === "category" && panels.indexOf(panel) !== sharedCategoryLabelOwner(panels) ? { ...authoredOptions, labels: withoutCategoryLabels(authoredOptions.labels) } : authoredOptions, authoredMargin = isRecord(panelOptions.margin) ? panelOptions.margin : {}, recordOptions, relayout = (margin2, kpiValueSize) => {
1985
+ let captionPanel = compactTiers ? { ...panel, title: panelOptions.title === !1 ? void 0 : authoredTitle } : panel, captionHeight = () => measureCaptionBand(captionPanel, theme, measure, slot.w, compactTiers), marginTop = numeric(margin2.top ?? authoredMargin.top, 20), resolvedOptions = {
1986
+ ...definition.defaults,
1987
+ ...panelOptions,
1988
+ ...(panelOptions.locale ?? parentOptions.locale) === void 0 ? {} : { locale: panelOptions.locale ?? parentOptions.locale },
1989
+ ...Object.keys(authoredStrings(parentOptions) ?? {}).length ? { strings: { ...authoredStrings(parentOptions), ...panelOptions.strings } } : {},
1990
+ ...compactTiers && panelOptions.title !== !1 && (authoredTitle !== void 0 || panel.type === "variance") ? { title: "" } : {},
1991
+ ...hasKpiFigure(panel.type) && kpiValueSize !== void 0 ? { [KPI_VALUE_SIZE]: kpiValueSize } : {},
1992
+ ...panel.type === "kpi" ? { [KPI_HOST_TEXT]: stringsIn([panel.title, panel.caption, parentOptions.title, parentOptions.subtitle, parentOptions.footnotes, parentOptions.source]) } : {},
1993
+ ...panel.type === "variance" && isAuthoredVarianceStack(panels, parentOptions) ? { [VARIANCE_TIER]: panels.length } : {},
1994
+ ...panel.annotations ? { annotations: panel.annotations } : {},
1995
+ ...parentOptions.palette !== void 0 && panelOptions.palette === void 0 ? { palette: parentOptions.palette } : {},
1996
+ // A status panel resolves its hatch strength in its own layout.
1997
+ ...hatchStrengthFor(panelOptions, parentOptions),
1998
+ theme: panelOptions.theme ?? parentOptions.theme,
1999
+ target: parentOptions.target,
2000
+ size: { width: slot.w, height: slot.h },
2001
+ margin: { ...authoredMargin, ...margin2, top: compactTiers ? Math.max(marginTop, captionHeight()) : marginTop + measureCaptionBand({ ...panel, options: { ...panelOptions, margin: { ...authoredMargin, ...margin2 } } }, theme, measure, slot.w) },
2002
+ measure,
2003
+ typeClass: gridTypeClass(parentOptions)
2004
+ }, geometry = layoutChildChart(panel.data, resolvedOptions, definition.layout);
2005
+ if (geometry.refused) throw new GridChildRefusal(panel.id, geometry);
2006
+ let tierName = geometry.derived.tierName;
2007
+ if (compactTiers && panelOptions.title !== !1 && !captionPanel.title && tierName && (captionPanel.title = tierName, captionHeight() > resolvedOptions.margin.top && (resolvedOptions.margin.top = captionHeight(), geometry = layoutChildChart(panel.data, resolvedOptions, definition.layout), geometry.refused)))
2008
+ throw new GridChildRefusal(panel.id, geometry);
2009
+ let { measure: _measure, ...serializable } = resolvedOptions;
2010
+ recordOptions = serializable;
2011
+ let captionY = compactTiers && isAuthoredVarianceStack(panels, parentOptions) ? authoredOccupiedBounds(geometry).y - resolvedOptions.margin.top - theme.space.labelPad : 0, band = panelCaptionBand({ ...captionPanel, options: resolvedOptions }, theme, measure, { x: 0, y: captionY, w: slot.w, h: slot.h }, new Set(resolveHighlight(parentOptions.highlight)), compactTiers);
2012
+ return pushAll(geometry.scene, band.nodes), pushAll(geometry.debug.occupied, band.claims), geometry;
2013
+ }, margin = { ...authoredMargin };
2014
+ return { panel, placement, slot, geometry: relayout(margin), margin, relayout, recordOptions: () => recordOptions };
2015
+ }
2016
+ function readoutIndents(children, columns) {
2017
+ let indents = /* @__PURE__ */ new Map(), chart = children.find((child) => child.placement.column === 0 && child.placement.columnSpan === columns && child.geometry.axes.find((axis) => axis.axis === "x")?.ticks.length === columns), ticks = chart?.geometry.axes.find((axis) => axis.axis === "x")?.ticks;
2018
+ if (!chart || !ticks || columns < 2) return indents;
2019
+ for (let child of children) {
2020
+ if (child.panel.type !== "text" || child.placement.columnSpan !== 1 || child.panel.readoutLead) continue;
2021
+ let category = ticks[child.placement.column]?.at, lefts = chart.geometry.scene.flatMap((node) => node.t === "rect" && node.part === "bar" && node.owner?.categoryId === category ? [node.rect.x + (node.tx ?? 0)] : []);
2022
+ if (lefts.length === 0) continue;
2023
+ let indent = chart.slot.x + minOf(lefts) - child.slot.x - TEXT_PANEL_PAD;
2024
+ indent > 0.5 && indent < child.slot.w * 2 / 3 && indents.set(child.panel.id, indent);
2025
+ }
2026
+ return indents;
2027
+ }
2028
+ function stackNarrowReadouts(panels, options, theme, measure, width) {
2029
+ let anchored = options.anchors?.categories === "column" || options.anchors?.categories === "all", columns = Array.isArray(options.columns) ? options.columns.length : typeof options.columns == "number" ? options.columns : void 0;
2030
+ if (!anchored || columns === void 0 || columns < 2 || width >= CARD_CLASS_WIDTH) return { panels, options };
2031
+ let chart = panels.find((panel) => panel.type !== "text" && panel.type !== "legend" && (panel.column ?? 0) === 0 && panel.span?.columns === columns && (panel.span?.rows ?? 1) === 1), categories = chart && isRecord(chart.data) && Array.isArray(chart.data.categories) ? chart.data.categories : [];
2032
+ if (!chart || categories.length !== columns) return { panels, options };
2033
+ let readouts = panels.filter((panel) => panel.type === "text" && panel.row !== void 0 && panel.row > (chart.row ?? 0) && panel.column !== void 0 && (panel.span?.columns ?? 1) === 1 && (panel.span?.rows ?? 1) === 1), row = readouts[0]?.row, inRow = readouts.filter((panel) => panel.row === row);
2034
+ if (row === void 0 || inRow.length !== columns || new Set(inRow.map((panel) => panel.column)).size !== columns || panels.some((panel) => panel !== chart && !inRow.includes(panel))) return { panels, options };
2035
+ let weights = options.columns, shares = Array.isArray(weights) ? weights : Array.from({ length: columns }, () => 1), total = shares.reduce((sum2, value) => sum2 + value, 0), margin = canvasMargin(theme, width), gaps = resolveGaps(options.gutters?.columns, columns - 1, theme.space.facetGap, "columns"), inner = width - margin.left - margin.right - gaps.reduce((sum2, gap) => sum2 + gap, 0), titleFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) };
2036
+ if (!inRow.some((panel) => {
2037
+ let title = isRecord(panel.data) && typeof panel.data.title == "string" ? panel.data.title : "";
2038
+ return title !== "" && measure(title, titleFont).width > inner * shares[panel.column] / total - 2 * TEXT_PANEL_PAD;
2039
+ })) return { panels, options };
2040
+ let rows = options.rows?.flatMap((weight, index) => index === row ? inRow.map(() => weight) : [weight]), label = (index) => {
2041
+ let category = categories[index];
2042
+ return isRecord(category) ? String(category.label ?? category.id ?? "") : "";
2043
+ }, authored = options.gutters?.rows, gutters = { ...options.gutters, rows: Array.from({ length: row + columns - 1 }, (_, index) => index >= row ? READOUT_STACK_GAP : typeof authored == "number" ? authored : authored?.[index] ?? theme.space.tierGap) };
2044
+ return {
2045
+ options: { ...options, ...rows ? { rows } : {}, gutters },
2046
+ panels: panels.map((panel) => {
2047
+ if (!inRow.includes(panel)) return panel.row !== void 0 && panel.row > row ? { ...panel, row: panel.row + columns - 1 } : panel;
2048
+ let lead = label(panel.column);
2049
+ return { ...panel, row: row + panel.column, column: 0, span: { ...panel.span, columns }, ...lead ? { readoutLead: lead } : {} };
2050
+ })
2051
+ };
2052
+ }
2053
+ function stackCompactPanels(panels, options, width) {
2054
+ let authored = Array.isArray(options.columns) ? options.columns.length : options.columns ?? (options.rows ? Math.ceil(panels.length / options.rows.length) : Math.ceil(Math.sqrt(panels.length))), columns = Math.max(authored, ...panels.map((panel) => (panel.column ?? 0) + (panel.span?.columns ?? 1)));
2055
+ if (options.mode !== "compact" || panelTypeClass(options) !== void 0 || width >= CARD_CLASS_WIDTH || columns < 2 || options.anchors !== void 0 || options.alignmentRules !== void 0) return { panels, options };
2056
+ let { rows: _rows, columns: _gutterColumns, ...gutters } = options.gutters ?? {};
2057
+ return {
2058
+ options: { ...options, columns: 1, rows: void 0, gutters },
2059
+ // A chart panel takes the card's width as the same chart alone does: the grid's margin, not its own beside it.
2060
+ panels: panels.map((panel, index) => ({
2061
+ ...panel,
2062
+ row: index,
2063
+ column: 0,
2064
+ span: void 0,
2065
+ ...panel.type === "text" || panel.type === "legend" ? {} : { options: { ...panel.options, margin: { left: 0, right: 0, ...isRecord(panel.options?.margin) ? panel.options.margin : {} } } }
2066
+ }))
2067
+ };
2068
+ }
2069
+ var READOUT_PLOT_BASE = 82, READOUT_PLOT_SLOPE = 0.15;
2070
+ function withReadoutPlotHeight(sizing, size, children) {
2071
+ if (!children.some((child) => child.panel.type === "text")) return sizing;
2072
+ let charts = children.filter((child) => child.panel.type !== "text" && child.panel.type !== "legend" && child.geometry.sizing?.fit !== "content");
2073
+ if (charts.length === 0) return sizing;
2074
+ let change = maxOf(charts.map((child) => {
2075
+ let plot = child.geometry.plot;
2076
+ return READOUT_PLOT_BASE + READOUT_PLOT_SLOPE * plot.w - plot.h;
2077
+ })), naturalHeight = Math.max(sizing.minHeight, Math.ceil(size.height + change));
2078
+ return { ...sizing, naturalHeight, comfortableHeight: Math.max(sizing.comfortableHeight, naturalHeight) };
2079
+ }
2080
+ var TEXT_PANEL_PAD = 6, READOUT_STACK_GAP = 6, READOUT_STACK_PAD = 2;
2081
+ function layoutTextPanel(panel, slot, theme, measure) {
2082
+ let data = parseGridTextPanelData(panel.data), occupied = createOccupiedIndex({ x: 0, y: 0, w: slot.w, h: slot.h }), titleFont = { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) }, bodyFont = { family: theme.type.family, ...theme.type.label }, requests = [], pad = TEXT_PANEL_PAD, indent = panel.readoutIndent ?? 0, lead = panel.readoutLead, cap = Math.max(20, slot.w - pad * (lead || indent > 0 ? 1 : 2) - indent), padY = lead ? READOUT_STACK_PAD : pad, y = padY, lastGap = 0, leadGap = measure("\u2002", bodyFont).width, leadWidth = lead && data.title ? measure(lead, bodyFont).width + leadGap : 0, add = (id, text, font, priority, prefix = "", offset = 0) => {
2083
+ let lines = wrapMeasured(`${prefix}${text}`, font, Math.max(20, cap - offset), Number.MAX_SAFE_INTEGER, measure), w = Math.max(1, ...lines.map((line) => measure(line, font).width)), h = lines.length * font.size * (font.lineHeight ?? 1.2);
2084
+ requests.push({
2085
+ id,
2086
+ kind: "annotation",
2087
+ typeRole: font === titleFont ? "axis" : "label",
2088
+ owner: { categoryId: panel.id },
2089
+ text: lines.join(" "),
2090
+ lines,
2091
+ font,
2092
+ priority,
2093
+ candidates: [{ slot: "panelFlow", rect: { x: pad + indent + offset, y, w, h }, penalty: 0 }],
2094
+ // Authored panel prose: a note, never a value label.
2095
+ role: "note"
2096
+ }), lastGap = font === titleFont ? lead || indent > 0 ? 4 : 6 : 4, y += h + lastGap;
2097
+ };
2098
+ if (lead && data.title) {
2099
+ let h = bodyFont.size * (bodyFont.lineHeight ?? 1.2);
2100
+ requests.push({
2101
+ id: `text:${panel.id}:lead`,
2102
+ kind: "annotation",
2103
+ typeRole: "label",
2104
+ owner: { categoryId: panel.id },
2105
+ text: lead,
2106
+ lines: [lead],
2107
+ font: bodyFont,
2108
+ priority: PRIORITY.total,
2109
+ candidates: [{ slot: "panelFlow", rect: { x: pad + indent, y, w: leadWidth - leadGap, h }, penalty: 0 }],
2110
+ role: "note"
2111
+ });
2112
+ }
2113
+ data.title && add(`text:${panel.id}:title`, data.title, titleFont, PRIORITY.total, "", leadWidth), data.body && add(`text:${panel.id}:body`, data.body, bodyFont, PRIORITY.valueLine), (data.bullets ?? []).forEach(
2114
+ (bullet, index) => add(`text:${panel.id}:bullet:${index + 1}`, bullet, bodyFont, PRIORITY.extreme, "\u2022 ")
2115
+ );
2116
+ let solveCtx = labelCtx(theme, { width: slot.w, height: slot.h }, {}, {
2117
+ density: "full",
2118
+ measure,
2119
+ plot: { x: 0, y: 0, w: slot.w, h: slot.h },
2120
+ labelPad: 2
2121
+ }), solved = solveLabels(requests, occupied, solveCtx), nodes = labelsToNodes(
2122
+ theme,
2123
+ solved.placed,
2124
+ (label) => label.id.endsWith(":title") ? titleFont : bodyFont
2125
+ ).map((node) => {
2126
+ let ink = textPanelInk(node.id, data.tone);
2127
+ return ink && node.t === "text" ? { ...node, ink } : node;
2128
+ }), contentHeight = Math.ceil(y - lastGap + padY);
2129
+ return {
2130
+ type: "grid-text",
2131
+ size: { width: slot.w, height: slot.h },
2132
+ plot: { x: 0, y: 0, w: slot.w, h: slot.h },
2133
+ scene: nodes,
2134
+ labels: solved.placed,
2135
+ axes: [],
2136
+ annotations: [],
2137
+ // A text panel is as tall as its prose: an automatic row of text panels
2138
+ // takes that height and leaves the rest of the canvas to the charts.
2139
+ sizing: {
2140
+ aspect: "content",
2141
+ fit: "content",
2142
+ minWidth: 0,
2143
+ minHeight: contentHeight,
2144
+ measuredMinWidth: 0,
2145
+ measuredMinHeight: contentHeight,
2146
+ naturalWidth: slot.w,
2147
+ naturalHeight: contentHeight,
2148
+ comfortableWidth: slot.w,
2149
+ comfortableHeight: contentHeight
2150
+ },
2151
+ frame: { minHeight: y - lastGap + padY },
2152
+ marks: {},
2153
+ derived: {},
2154
+ a11y: {
2155
+ title: data.title ?? panel.title ?? panel.id,
2156
+ desc: [data.body, ...data.bullets ?? []].filter(Boolean).join(" ")
2157
+ },
2158
+ warnings: solved.warnings,
2159
+ debug: { occupied: occupied.snapshot(), decisions: solved.decisions }
2160
+ };
2161
+ }
2162
+ function layoutLegendPanel(panel, slot, items, theme, measure, parentOptions) {
2163
+ let occupied = createOccupiedIndex({ x: 0, y: 0, w: slot.w, h: slot.h }), frame = solveFrame(
2164
+ {
2165
+ size: { width: slot.w, height: slot.h },
2166
+ margin: { top: 4, right: 4, bottom: 4, left: 4 },
2167
+ ...frameTextOptions({ title: panel.title, mode: parentOptions.mode, theme: parentOptions.theme, target: parentOptions.target }),
2168
+ legend: items.length > 0 ? { options: { position: "top" }, items } : void 0,
2169
+ theme,
2170
+ measure
2171
+ },
2172
+ occupied
2173
+ ), warnings = items.length > 0 ? [] : [{
2174
+ code: "grid-legend-empty",
2175
+ severity: "warn",
2176
+ message: `legend panel '${panel.id}' has no contributing chart legend items`
2177
+ }];
2178
+ return frame.legend && (frame.frame.minHeight = frame.legend.rect.y + frame.legend.rect.h + 4), {
2179
+ type: "grid-legend",
2180
+ size: { width: slot.w, height: slot.h },
2181
+ plot: frame.plot,
2182
+ scene: frame.nodes,
2183
+ labels: [],
2184
+ axes: [],
2185
+ annotations: [],
2186
+ legend: frame.legend,
2187
+ frame: frame.frame,
2188
+ marks: {},
2189
+ derived: {},
2190
+ a11y: { title: panel.title ?? chartString(parentOptions, "legendName"), desc: chartString(parentOptions, "legendItemsCount", { v1: items.length }) },
2191
+ warnings,
2192
+ debug: { occupied: occupied.snapshot(), decisions: [] }
2193
+ };
2194
+ }
2195
+ function resolveGaps(authored, count, fallback, axis) {
2196
+ if (count <= 0) return [];
2197
+ if (authored === void 0) return Array.from({ length: count }, () => fallback);
2198
+ if (typeof authored == "number") return Array.from({ length: count }, () => authored);
2199
+ if (authored.length !== count)
2200
+ throw new NormalizeError(
2201
+ "grid-gutter-count",
2202
+ `options.gutters.${axis}`,
2203
+ `${axis} gutters require exactly ${count} value${count === 1 ? "" : "s"} for the authored tracks; received ${authored.length}`
2204
+ );
2205
+ return [...authored];
2206
+ }
2207
+ function trackBands(start, span, weights, gaps, authoredGaps) {
2208
+ let usable = span - gaps.reduce((sum2, gap) => sum2 + gap, 0);
2209
+ if (authoredGaps && usable <= 0)
2210
+ throw new NormalizeError(
2211
+ "grid-gutters-exceed-space",
2212
+ "options.gutters",
2213
+ `authored gutters consume ${span - usable}px of ${span}px available space`,
2214
+ "make options.gutters smaller, or give the grid a larger size: the title, panel heads and gutters share the canvas"
2215
+ );
2216
+ let total = weights.reduce((sum2, weight) => sum2 + weight, 0), cursor = start;
2217
+ return weights.map((weight, index) => {
2218
+ let size = Math.max(0, usable) * weight / total, band = { start: cursor, size };
2219
+ return cursor += size + (gaps[index] ?? 0), band;
2220
+ });
2221
+ }
2222
+ function spanRect(rows, columns, placement) {
2223
+ let firstRow = rows[placement.row], lastRow = rows[placement.row + placement.rowSpan - 1], firstColumn = columns[placement.column], lastColumn = columns[placement.column + placement.columnSpan - 1];
2224
+ return {
2225
+ x: firstColumn.start,
2226
+ y: firstRow.start,
2227
+ w: lastColumn.start + lastColumn.size - firstColumn.start,
2228
+ h: lastRow.start + lastRow.size - firstRow.start
2229
+ };
2230
+ }
2231
+ function alignInside(raw, align) {
2232
+ if (!align) return raw;
2233
+ let horizontal = align.horizontal ?? "stretch", vertical = align.vertical ?? "stretch", w = horizontal === "stretch" ? raw.w : Math.min(raw.w, align.width ?? raw.w), h = vertical === "stretch" ? raw.h : Math.min(raw.h, align.height ?? raw.h), x = horizontal === "end" ? raw.x + raw.w - w : horizontal === "center" ? raw.x + (raw.w - w) / 2 : raw.x, y = vertical === "end" ? raw.y + raw.h - h : vertical === "center" ? raw.y + (raw.h - h) / 2 : raw.y;
2234
+ return { x, y, w, h };
2235
+ }
2236
+ function scopeGroups(children, scope) {
2237
+ if (scope === "all") return [children];
2238
+ let groups = /* @__PURE__ */ new Map();
2239
+ for (let child of children) {
2240
+ let key = scope === "row" ? child.placement.row : child.placement.column, members = groups.get(key) ?? [];
2241
+ members.push(child), groups.set(key, members);
2242
+ }
2243
+ return [...groups.values()];
2244
+ }
2245
+ function categoryColumnBands(children, columnBands, columnGaps, warnings) {
2246
+ let candidates = children.flatMap((child) => {
2247
+ let axis = child.geometry.axes.find((candidate) => candidate.axis === "x");
2248
+ return child.placement.column === 0 && child.placement.columnSpan === columnBands.length && axis?.ticks.length === columnBands.length ? [{ child, axis }] : [];
2249
+ });
2250
+ if (candidates.length === 0 || columnBands.length < 2) return columnBands;
2251
+ let centers = candidates[0].axis.ticks.map(
2252
+ (tick) => candidates[0].child.slot.x + tick.pos
2253
+ );
2254
+ for (let { child, axis } of candidates.slice(1))
2255
+ axis.ticks.map((tick) => child.slot.x + tick.pos).some((value, index) => Math.abs(value - centers[index]) > 1e-6) && warnings.push({
2256
+ code: "grid-anchor-incompatible",
2257
+ severity: "warn",
2258
+ message: `panel '${child.panel.id}' proposes category anchors that conflict with panel '${candidates[0].child.panel.id}'`
2259
+ });
2260
+ let signs = [1], offsets = [0];
2261
+ for (let index = 0; index < centers.length - 1; index += 1) {
2262
+ let available = centers[index + 1] - centers[index] - columnGaps[index];
2263
+ if (!(available > 0))
2264
+ return warnings.push({
2265
+ code: "grid-anchor-incompatible",
2266
+ severity: "warn",
2267
+ message: `category anchors leave no room for authored column gutter ${index + 1}`
2268
+ }), columnBands;
2269
+ signs.push(-signs[index]), offsets.push(2 * available - offsets[index]);
2270
+ }
2271
+ let lower = 1, upper = Number.POSITIVE_INFINITY;
2272
+ for (let index = 0; index < signs.length; index += 1)
2273
+ signs[index] === 1 ? lower = Math.max(lower, 1 - offsets[index]) : upper = Math.min(upper, offsets[index] - 1);
2274
+ upper = Math.min(upper, 2 * (centers[0] - columnBands[0].start));
2275
+ let last = columnBands.length - 1, lastRoom = 2 * (columnBands[last].start + columnBands[last].size - centers[last]);
2276
+ if (signs[last] === 1 ? upper = Math.min(upper, lastRoom - offsets[last]) : lower = Math.max(lower, offsets[last] - lastRoom), lower > upper)
2277
+ return warnings.push({
2278
+ code: "grid-anchor-incompatible",
2279
+ severity: "warn",
2280
+ message: "category anchors cannot form positive column tracks inside the authored grid"
2281
+ }), columnBands;
2282
+ let leastSquares = signs.reduce(
2283
+ (sum2, sign, index) => sum2 + sign * (columnBands[index].size - offsets[index]),
2284
+ 0
2285
+ ) / signs.length, firstWidth = Math.max(lower, Math.min(upper, leastSquares));
2286
+ return centers.map((center, index) => {
2287
+ let size = signs[index] * firstWidth + offsets[index];
2288
+ return { start: center - size / 2, size };
2289
+ });
2290
+ }
2291
+ function recordCategoryColumnAnchors(children, columnBands, derived, warnings) {
2292
+ for (let child of children) {
2293
+ let axis = child.geometry.axes.find((candidate) => candidate.axis === "x");
2294
+ child.placement.column !== 0 || child.placement.columnSpan !== columnBands.length || axis?.ticks.length !== columnBands.length || axis.ticks.forEach((tick, index) => {
2295
+ let target = columnBands[index].start + columnBands[index].size / 2, actual = child.slot.x + tick.pos;
2296
+ if (derived[`category:column:${child.panel.id}:${tick.at}`] = target, Math.abs(actual - target) > 1e-6) {
2297
+ let miss = Math.round(Math.abs(actual - target) * 1e3) / 1e3;
2298
+ warnings.push({
2299
+ code: "grid-anchor-inexact",
2300
+ severity: "warn",
2301
+ message: `panel '${child.panel.id}' category '${tick.at}' missed its authored column anchor by ${miss}px`
2302
+ });
2303
+ }
2304
+ });
2305
+ }
2306
+ }
2307
+ function alignPlotEdges(input, scope, derived, warnings, theme) {
2308
+ let children = [...input];
2309
+ for (let [groupIndex, group] of scopeGroups(children, scope).entries()) {
2310
+ let candidates = group.filter((child) => child.relayout !== void 0);
2311
+ if (candidates.length < 2) continue;
2312
+ let left = maxOf(candidates.map((child) => child.slot.x + child.geometry.plot.x)), right = minOf(candidates.map((child) => child.slot.x + child.geometry.plot.x + child.geometry.plot.w));
2313
+ if (!(right > left)) {
2314
+ warnings.push({
2315
+ code: "grid-anchor-incompatible",
2316
+ severity: "warn",
2317
+ message: `${scope} plot-edge alignment group ${groupIndex + 1} has no shared horizontal span \u2014 plot edges were left unchanged`
2318
+ });
2319
+ continue;
2320
+ }
2321
+ derived[`plotEdges:${scope}:${groupIndex}:left`] = left, derived[`plotEdges:${scope}:${groupIndex}:right`] = right;
2322
+ for (let child of candidates) {
2323
+ let currentLeft = child.slot.x + child.geometry.plot.x, currentRight = currentLeft + child.geometry.plot.w;
2324
+ moveChildPlot(child, left - currentLeft, currentRight - right, theme);
2325
+ }
2326
+ }
2327
+ return children;
2328
+ }
2329
+ function alignBaselines(input, scope, derived) {
2330
+ let children = [...input];
2331
+ for (let [groupIndex, group] of scopeGroups(children, scope).entries()) {
2332
+ let candidates = group.flatMap((child) => {
2333
+ let baseline = baselineY(child.geometry);
2334
+ return baseline === null || !child.relayout ? [] : [{ child, baseline: child.slot.y + baseline }];
2335
+ });
2336
+ if (candidates.length < 2) continue;
2337
+ let target = minOf(candidates.map((entry) => entry.baseline));
2338
+ derived[`baseline:${scope}:${groupIndex}`] = target;
2339
+ for (let entry of candidates) {
2340
+ let delta = entry.baseline - target;
2341
+ delta <= 0 || (entry.child.margin = {
2342
+ ...entry.child.margin,
2343
+ bottom: (entry.child.margin.bottom ?? 16) + delta
2344
+ }, entry.child.geometry = entry.child.relayout(entry.child.margin));
2345
+ }
2346
+ }
2347
+ return children;
2348
+ }
2349
+ function baselineY(geometry) {
2350
+ let axis = geometry.axes.find((candidate) => candidate.axis === "x" && candidate.baselineNodeId), node = axis?.baselineNodeId ? geometry.scene.find((candidate) => candidate.id === axis.baselineNodeId) : void 0;
2351
+ return node?.t === "line" && node.y1 === node.y2 ? node.y1 : null;
2352
+ }
2353
+ function guideRuns(occupied, orientation, at, start, end) {
2354
+ let vertical = orientation === "vertical", blocks = occupied.filter((claim) => claim.part !== "alignmentRule" && claim.rect.w > 2 && claim.rect.h > 2).filter((claim) => vertical ? claim.rect.x < at && claim.rect.x + claim.rect.w > at : claim.rect.y < at && claim.rect.y + claim.rect.h > at).map((claim) => vertical ? [claim.rect.y - 3, claim.rect.y + claim.rect.h + 3] : [claim.rect.x - 3, claim.rect.x + claim.rect.w + 3]).sort((a, b) => a[0] - b[0]), runs = [], from = Math.min(start, end), last = Math.max(start, end);
2355
+ for (let [a, b] of blocks)
2356
+ Math.min(a, last) - from >= 12 && runs.push([from, Math.min(a, last)]), from = Math.max(from, b);
2357
+ return last - from >= 12 && runs.push([from, last]), runs;
2358
+ }
2359
+ function appendAuthoredChild(child, scene, labels, axes, annotations, occupied, decisions, warnings, marks) {
2360
+ let prefix = `${child.panel.id}/`, dx = child.slot.x, dy = child.slot.y, legendItems = new Map((child.geometry.legend?.items ?? []).flatMap((item) => [
2361
+ [item.swatchNodeId, item.id],
2362
+ [item.labelId, item.id]
2363
+ ]));
2364
+ for (let node of child.geometry.scene) {
2365
+ let legendItem = node.origin?.legendItem ?? legendItems.get(node.id);
2366
+ scene.push({
2367
+ ...node,
2368
+ id: prefix + node.id,
2369
+ owner: prefixPanelOwner(node.owner, prefix),
2370
+ tx: (node.tx ?? 0) + dx,
2371
+ ty: (node.ty ?? 0) + dy,
2372
+ origin: {
2373
+ owner: node.origin?.owner ?? node.owner,
2374
+ panels: [child.panel.id, ...node.origin?.panels ?? []],
2375
+ ...legendItem === void 0 ? {} : { legendItem }
2376
+ }
2377
+ });
2378
+ }
2379
+ let noteData = panelNoteData(
2380
+ child.panel.type,
2381
+ child.panel.data,
2382
+ child.panel.options?.locale?.language
2383
+ ), noteTexts = panelNoteTexts(child.geometry, noteData, child.panel.options, child.panel.annotations);
2384
+ for (let label of child.geometry.labels) {
2385
+ let noteText = noteTexts.texts.get(label.id), named = noteText === void 0 ? label : { ...label, noteText };
2386
+ labels.push(translatePlacedLabel(noteTexts.leftOut.has(label.id) ? { ...named, [LEFT_OUT_OF_NOTE]: !0 } : named, prefix, dx, dy));
2387
+ }
2388
+ for (let axis of child.geometry.axes)
2389
+ axes.push({
2390
+ ...axis,
2391
+ baselineNodeId: axis.baselineNodeId ? prefix + axis.baselineNodeId : void 0,
2392
+ ticks: axis.ticks.map((tick) => ({
2393
+ ...tick,
2394
+ pos: tick.pos + (axis.axis === "x" ? dx : dy),
2395
+ labelId: tick.labelId ? prefix + tick.labelId : void 0,
2396
+ gridNodeId: tick.gridNodeId ? prefix + tick.gridNodeId : void 0
2397
+ })),
2398
+ scenarioBands: axis.scenarioBands?.map((band) => ({
2399
+ ...band,
2400
+ rect: { ...band.rect, x: band.rect.x + dx, y: band.rect.y + dy }
2401
+ }))
2402
+ });
2403
+ for (let annotation of child.geometry.annotations)
2404
+ annotations.push({
2405
+ ...annotation,
2406
+ id: prefix + annotation.id,
2407
+ // The event anchor is a child-scene rect: move it with the panel.
2408
+ ...annotation.event?.anchor ? { event: { ...annotation.event, anchor: translateRect(annotation.event.anchor, dx, dy) } } : {},
2409
+ nodeIds: annotation.nodeIds.map((id) => prefix + id),
2410
+ labelId: annotation.labelId ? prefix + annotation.labelId : void 0,
2411
+ labelNodeId: annotation.labelNodeId ? prefix + annotation.labelNodeId : annotation.labelId ? prefix + `label:${annotation.labelId}` : void 0
2412
+ });
2413
+ for (let claim of child.geometry.debug.occupied)
2414
+ occupied.push({
2415
+ ...claim,
2416
+ owner: prefixPanelOwner(claim.owner, prefix),
2417
+ rect: { ...claim.rect, x: claim.rect.x + dx, y: claim.rect.y + dy }
2418
+ });
2419
+ for (let decision of child.geometry.debug.decisions)
2420
+ decisions.push({ ...decision, labelId: prefix + decision.labelId });
2421
+ let warningOffset = warnings.length;
2422
+ pushAll(
2423
+ warnings,
2424
+ child.geometry.warnings.map(({ field: _field, fix: _fix, ...warning }) => ({
2425
+ ...warning,
2426
+ message: `[${child.panel.id}] ${warning.message}`,
2427
+ owner: warning.owner ? prefixPanelOwner(warning.owner, prefix) : void 0
2428
+ }))
2429
+ );
2430
+ let content = authoredOccupiedBounds(child.geometry);
2431
+ marks.panels.push({
2432
+ id: child.panel.id,
2433
+ type: child.panel.type,
2434
+ ...child.recordOptions ? { chart: { options: child.recordOptions(), geometry: child.geometry, offset: { x: dx, y: dy }, warningOffset, warningOwnerPrefix: prefix, ...child.panel.options?.theme ? { theme: child.panel.options.theme } : {} } } : {},
2435
+ plot: {
2436
+ x: child.geometry.plot.x + dx,
2437
+ y: child.geometry.plot.y + dy,
2438
+ w: child.geometry.plot.w,
2439
+ h: child.geometry.plot.h
2440
+ },
2441
+ content: { x: content.x + dx, y: content.y + dy, w: content.w, h: content.h },
2442
+ title: child.panel.title ?? child.geometry.a11y.title ?? child.panel.id,
2443
+ row: child.placement.row,
2444
+ column: child.placement.column,
2445
+ rowSpan: child.placement.rowSpan,
2446
+ columnSpan: child.placement.columnSpan
2447
+ });
2448
+ }
2449
+ var PLACED_LABEL_TRANSLATION_IS_EXHAUSTIVE = !0;
2450
+ function translatePlacedLabel(label, prefix, dx, dy) {
2451
+ return {
2452
+ ...label,
2453
+ id: prefix + label.id,
2454
+ ...label.claimId ? { claimId: prefix + label.claimId } : {},
2455
+ nodeId: label.nodeId ? prefix + label.nodeId : void 0,
2456
+ owner: prefixPanelOwner(label.owner, prefix),
2457
+ rect: translateRect(label.rect, dx, dy),
2458
+ backing: label.backing ? translateRect(label.backing, dx, dy) : void 0,
2459
+ leader: label.leader ? { ...label.leader, d: translateLeaderPath(label.leader.d, dx, dy) } : void 0
2460
+ };
2461
+ }
2462
+ var PANEL_LOCAL_OWNER_FIELDS = [
2463
+ "annotationId",
2464
+ "valueLineId"
2465
+ ];
2466
+ var OWNER_FIELD_CLASSIFICATION_IS_EXHAUSTIVE = !0;
2467
+ function prefixPanelOwner(owner, prefix) {
2468
+ let translated = { ...owner };
2469
+ for (let field of PANEL_LOCAL_OWNER_FIELDS) {
2470
+ let id = owner[field];
2471
+ id !== void 0 && (translated[field] = prefix + id);
2472
+ }
2473
+ return translated;
2474
+ }
2475
+ function translateRect(rect, dx, dy) {
2476
+ return { ...rect, x: rect.x + dx, y: rect.y + dy };
2477
+ }
2478
+ function translateLeaderPath(path, dx, dy) {
2479
+ let coordinateIndex = 0;
2480
+ return path.replace(
2481
+ /-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?/gi,
2482
+ (raw) => String(Number(raw) + (coordinateIndex++ % 2 === 0 ? dx : dy))
2483
+ );
2484
+ }
2485
+ function authoredOccupiedBounds(geometry) {
2486
+ let rects = geometry.debug.occupied.filter((item) => item.kind !== "reserved").map((item) => item.rect);
2487
+ return rects.length > 0 ? boundsOf(rects) : geometry.plot;
2488
+ }
2489
+ function resolveRuleCoordinate(child, anchor, categoryId) {
2490
+ if (anchor === "plotLeft") return { axis: "x", value: child.slot.x + child.geometry.plot.x };
2491
+ if (anchor === "plotRight")
2492
+ return {
2493
+ axis: "x",
2494
+ value: child.slot.x + child.geometry.plot.x + child.geometry.plot.w
2495
+ };
2496
+ if (anchor === "baseline") {
2497
+ let value = baselineY(child.geometry);
2498
+ return value === null ? null : { axis: "y", value: child.slot.y + value };
2499
+ }
2500
+ if (!categoryId) return null;
2501
+ let tick = child.geometry.axes.find((candidate) => candidate.axis === "x")?.ticks.find((candidate) => candidate.at === categoryId);
2502
+ return tick ? { axis: "x", value: child.slot.x + tick.pos } : null;
2503
+ }
2504
+ function textPanelInk(id, tone) {
2505
+ if (tone === "muted") return { token: "inkMuted" };
2506
+ if (tone === "message")
2507
+ return { token: id.endsWith(":title") ? "ink" : "inkMuted" };
2508
+ }
2509
+ function wrapMeasured(text, font, maxWidth, maxLines, measure) {
2510
+ let words = text.split(/\s+/).filter(Boolean), lines = [], current = "";
2511
+ for (let word of words) {
2512
+ let next = current ? `${current} ${word}` : word;
2513
+ if (current && measure(next, font).width > maxWidth) {
2514
+ if (lines.push(current), current = word, lines.length === maxLines - 1) break;
2515
+ } else
2516
+ current = next;
2517
+ }
2518
+ return current && lines.length < maxLines && lines.push(current), lines.length > 0 ? lines : [""];
2519
+ }
2520
+ var DEFAULT_Y_GROUP = "grid:y";
2521
+ function panelScaleSemantics(panel) {
2522
+ return scalePanelSemantics({
2523
+ type: panel.type,
2524
+ data: panel.data,
2525
+ options: panel.options
2526
+ });
2527
+ }
2528
+ function probePanelGeometry(panel, options, valueAxis) {
2529
+ let definition = getChart(panel.type);
2530
+ if (!definition) return null;
2531
+ let panelOptions = panel.options ?? {};
2532
+ return layoutChildChart(panel.data, {
2533
+ ...definition.defaults,
2534
+ ...panelOptions,
2535
+ ...panel.annotations ? { annotations: panel.annotations } : {},
2536
+ theme: panelOptions.theme ?? options.theme,
2537
+ size: { width: 720, height: 405 },
2538
+ valueAxis,
2539
+ measure: options.measure,
2540
+ typeClass: gridTypeClass(options)
2541
+ }, definition.layout);
2542
+ }
2543
+ function panelValueAxisBreak(panel) {
2544
+ let valueAxis = isRecord(panel.options?.valueAxis) ? panel.options.valueAxis : void 0, raw = valueAxis && isRecord(valueAxis.break) ? valueAxis.break : null;
2545
+ if (!raw) return null;
2546
+ let { from, to } = raw;
2547
+ return typeof from != "number" || typeof to != "number" ? null : { from, to };
2548
+ }
2549
+ function sharedBreakForGroup(panels, indexes) {
2550
+ let authored = [];
2551
+ for (let index of indexes) {
2552
+ let axisBreak = panelValueAxisBreak(panels[index]);
2553
+ axisBreak && authored.push(axisBreak);
2554
+ }
2555
+ return authored.length === 0 ? { kind: "none" } : new Set(authored.map((axisBreak) => `${axisBreak.from}|${axisBreak.to}`)).size > 1 ? { kind: "mismatch" } : { kind: "one", axisBreak: authored[0] };
2556
+ }
2557
+ function groupHonorsSharedBreak(panels, indexes, domain, axisBreak, options) {
2558
+ for (let index of indexes) {
2559
+ let panel = panels[index], panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, geometry = null;
2560
+ try {
2561
+ geometry = probePanelGeometry(panel, options, {
2562
+ ...valueAxis,
2563
+ show: !0,
2564
+ min: domain[0],
2565
+ max: domain[1],
2566
+ break: axisBreak
2567
+ });
2568
+ } catch {
2569
+ return !1;
2570
+ }
2571
+ if (!geometry || geometry.refused || !geometry.axes.some((axis) => axis.axis === "y" && axis.break !== void 0)) return !1;
2572
+ }
2573
+ return !0;
2574
+ }
2575
+ function resolveSharedYDomains(panels, options, repeatFacet) {
2576
+ let groups = /* @__PURE__ */ new Map();
2577
+ panels.forEach((panel, index) => {
2578
+ let scaleGroup = isRecord(panel.options?.scaleGroup) ? panel.options.scaleGroup : void 0;
2579
+ if (typeof scaleGroup?.y != "string") return;
2580
+ let members = groups.get(scaleGroup.y) ?? [];
2581
+ members.push(index), groups.set(scaleGroup.y, members);
2582
+ });
2583
+ let panelDomains = panels.map((panel) => {
2584
+ let panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, { break: _ignoredBreak, ...axisWithoutBreak } = valueAxis, probe = probePanelGeometry(panel, options, { ...axisWithoutBreak, show: !0 });
2585
+ return probe && !probe.refused ? inferLinearYDomain(probe) : null;
2586
+ }), authoredGroups = groups.size > 0, semantics = panels.map(panelScaleSemantics), firstSemantics = semantics[0], matchingSemantics = firstSemantics != null && semantics.every(
2587
+ (candidate) => candidate !== null && candidate.unit === firstSemantics.unit && candidate.format === firstSemantics.format
2588
+ ), sameMeasure = options.sharedScale === !0 || repeatFacet || firstSemantics?.unit != null || !!options.unit?.trim(), defaultShareEligible = panels.length > 1 && panelDomains.every((domain) => domain !== null) && matchingSemantics && sameMeasure;
2589
+ options.sharedScale !== !1 && !authoredGroups && defaultShareEligible && groups.set(
2590
+ DEFAULT_Y_GROUP,
2591
+ panels.map((_, index) => index)
2592
+ );
2593
+ let clampWarnings = leaveClampedPanelsOut(groups, panels), groupByIndex = /* @__PURE__ */ new Map();
2594
+ for (let [group, indexes] of groups)
2595
+ for (let index of indexes) groupByIndex.set(index, group);
2596
+ let { domains, breaks, warnings } = unionSharedYGroups(groups, panels, panelDomains, options);
2597
+ return {
2598
+ panels: pinSharedYAxis(panels, groupByIndex, domains, breaks),
2599
+ domains,
2600
+ members: Object.fromEntries([...groups].map(([group, indexes]) => [group, indexes.map((index) => panels[index].id)])),
2601
+ warnings: [...clampWarnings, ...warnings]
2602
+ };
2603
+ }
2604
+ function ownYScale(panel) {
2605
+ let valueAxis = panel.options?.valueAxis;
2606
+ if (!isRecord(valueAxis)) return;
2607
+ if (valueAxis.log === !0 || valueAxis.log === "y" || valueAxis.log === "both") return "log";
2608
+ let clamp = valueAxis.clamp;
2609
+ if (!isRecord(clamp)) return;
2610
+ let y = isRecord(clamp.y) ? clamp.y : {};
2611
+ return [clamp.min, clamp.max, y.min, y.max].some((bound) => typeof bound == "number") ? "clamp" : void 0;
2612
+ }
2613
+ function leaveClampedPanelsOut(groups, panels) {
2614
+ let warnings = [];
2615
+ for (let [group, indexes] of groups) {
2616
+ let own = indexes.filter((index) => ownYScale(panels[index]) !== void 0);
2617
+ if (own.length !== 0 && (groups.set(group, indexes.filter((index) => !own.includes(index))), group !== DEFAULT_Y_GROUP))
2618
+ for (let reason of ["clamp", "log"]) {
2619
+ let names = own.filter((index) => ownYScale(panels[index]) === reason).map((index) => `'${panels[index].id ?? index}'`).join(", ");
2620
+ names && warnings.push({
2621
+ code: `scale-${reason}`,
2622
+ severity: "warn",
2623
+ message: `panel ${names} ${reason === "clamp" ? "caps its vertical axis with valueAxis.clamp" : "draws its vertical axis on a log scale"}, so it keeps its own y scale and leaves y scale group '${group}'`,
2624
+ suggest: `drop valueAxis.${reason} to share the scale, or take the panel out of scaleGroup.y`
2625
+ });
2626
+ }
2627
+ }
2628
+ return warnings;
2629
+ }
2630
+ function unionSharedYGroups(groups, panels, panelDomains, options) {
2631
+ let domains = emptyIdRecord(), breaks = emptyIdRecord(), warnings = [];
2632
+ for (let [group, indexes] of groups) {
2633
+ if (indexes.length < 2) continue;
2634
+ let memberDomains = [];
2635
+ for (let index of indexes) {
2636
+ let domain2 = panelDomains[index];
2637
+ domain2 && memberDomains.push(domain2);
2638
+ }
2639
+ if (memberDomains.length !== indexes.length) {
2640
+ group !== DEFAULT_Y_GROUP && warnings.push({
2641
+ code: "scale-mix",
2642
+ severity: "warn",
2643
+ message: `y scale group '${group}' contains a panel without a numeric linear y scale`
2644
+ });
2645
+ continue;
2646
+ }
2647
+ let domain = [
2648
+ minOf(memberDomains.map((entry) => entry[0])),
2649
+ maxOf(memberDomains.map((entry) => entry[1]))
2650
+ ], agreed = sharedBreakForGroup(panels, indexes);
2651
+ if (agreed.kind === "mismatch") {
2652
+ warnings.push({
2653
+ code: "scale-break-mismatch",
2654
+ severity: "error",
2655
+ message: `y scale group '${group}' has conflicting valueAxis.break spans, so panels keep independent scales`,
2656
+ suggest: "give every panel in the group the same valueAxis.break, or drop the breaks"
2657
+ });
2658
+ continue;
2659
+ }
2660
+ if (agreed.kind === "one" && !groupHonorsSharedBreak(panels, indexes, domain, agreed.axisBreak, options)) {
2661
+ warnings.push({
2662
+ code: "scale-break-incompatible",
2663
+ severity: "error",
2664
+ message: `y scale group '${group}' cannot honour valueAxis.break { from: ${agreed.axisBreak.from}, to: ${agreed.axisBreak.to} } on every panel, so panels keep independent scales`,
2665
+ suggest: "choose a break every panel can honour, or drop valueAxis.break"
2666
+ });
2667
+ continue;
2668
+ }
2669
+ domains[group] = domain, agreed.kind === "one" && (breaks[group] = agreed.axisBreak);
2670
+ }
2671
+ return { domains, breaks, warnings };
2672
+ }
2673
+ function pinSharedYAxis(panels, groupByIndex, domains, breaks) {
2674
+ return panels.map((panel, index) => {
2675
+ let group = groupByIndex.get(index), domain = group === void 0 ? void 0 : domains[group];
2676
+ if (!domain) return panel;
2677
+ let panelOptions = panel.options ?? {}, valueAxis = isRecord(panelOptions.valueAxis) ? panelOptions.valueAxis : {}, axisBreak = group === void 0 ? void 0 : breaks[group];
2678
+ return {
2679
+ ...panel,
2680
+ options: {
2681
+ ...panelOptions,
2682
+ valueAxis: {
2683
+ ...valueAxis,
2684
+ min: domain[0],
2685
+ max: domain[1],
2686
+ ...axisBreak ? { break: axisBreak } : {}
2687
+ }
2688
+ }
2689
+ };
2690
+ });
2691
+ }
2692
+ function measureCaptionBand(panel, theme, measure, slotWidth, compact = !1) {
2693
+ let margin = isRecord(panel.options?.margin) ? panel.options.margin : {}, sides = canvasMargin(theme, slotWidth), width = Math.max(1, slotWidth - numeric(margin.left, sides.left) - numeric(margin.right, sides.right)), heightOf = (text, font) => measuredCaption(text, font, width, measure).height, height = 0;
2694
+ return panel.title && (height += heightOf(panel.title, compact ? { family: theme.type.family, ...theme.type.axis } : { family: theme.type.family, ...theme.type.label, weight: emphasisWeight(theme) })), panel.title && panel.caption && (height += 2), panel.caption && (height += heightOf(panel.caption, { family: theme.type.family, ...theme.type.axis })), height > 0 ? height + 6 : 0;
2695
+ }
2696
+ function numeric(value, fallback) {
2697
+ return typeof value == "number" ? value : fallback;
2698
+ }
2699
+
2700
+ // src/core/charts/grid/core.ts
2701
+ function normalizeGridInput(raw) {
2702
+ return isMetricStackData(raw) ? normalizeMetricStack(raw) : normalizeGridData(raw);
2703
+ }
2704
+ var gridCore = {
2705
+ type: "grid",
2706
+ sizing: { ...chartSizing("grid"), minWidth: CARD_MIN_WIDTH },
2707
+ title: "Grid / multi-tier",
2708
+ summary: "Facets, variance tiers and metric stacks with shared categories and computed readouts",
2709
+ aliases: ["facets"],
2710
+ layout: layoutGrid2,
2711
+ defaults: {},
2712
+ annotationKinds: [],
2713
+ prepare: normalizeGridInput,
2714
+ requiredKey: gridRequiredKey,
2715
+ compactForm: compactStacks
2716
+ };
2717
+
2718
+ export {
2719
+ gridFormOf,
2720
+ gridCore
2721
+ };