@toclocoinc/lattice-grid 1.98.1 → 1.98.2

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 (402) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +27 -17
  5. package/docs/api/adapters.html +1 -1
  6. package/docs/api/ai.html +1 -1
  7. package/docs/api/alarms.html +1 -1
  8. package/docs/api/calendar.html +1 -1
  9. package/docs/api/charts.html +1 -1
  10. package/docs/api/dashboard.html +1 -1
  11. package/docs/api/data-router.html +1 -1
  12. package/docs/api/deckgl.html +1 -1
  13. package/docs/api/designer.html +1 -1
  14. package/docs/api/gantt.html +1 -1
  15. package/docs/api/geometry.html +1 -1
  16. package/docs/api/grid.html +2 -2
  17. package/docs/api/index.html +2 -2
  18. package/docs/api/kanban.html +1 -1
  19. package/docs/api/kpi.html +1 -1
  20. package/docs/api/layout.html +1 -1
  21. package/docs/api/leaflet.html +1 -1
  22. package/docs/api/list.html +1 -1
  23. package/docs/api/mapview.html +1 -1
  24. package/docs/api/mock-socket.html +1 -1
  25. package/docs/api/presets.html +1 -1
  26. package/docs/api/scheduler.html +22 -12
  27. package/docs/api/shell.html +1 -1
  28. package/docs/api/tabs.html +1 -1
  29. package/docs/api/types.html +3 -3
  30. package/docs/api-detail.html +12 -4
  31. package/docs/warnings.json +1 -1
  32. package/lattice-grid.d.ts +1 -1
  33. package/lattice-grid.esm.min.js +2 -2
  34. package/lattice-grid.min.cjs +2 -2
  35. package/lattice-grid.min.js +2 -2
  36. package/locales/all.d.ts +1 -1
  37. package/locales/all.esm.min.js +1 -1
  38. package/locales/all.min.cjs +1 -1
  39. package/locales/all.min.js +1 -1
  40. package/locales/ar.d.ts +1 -1
  41. package/locales/ar.esm.min.js +1 -1
  42. package/locales/ar.min.cjs +1 -1
  43. package/locales/ar.min.js +1 -1
  44. package/locales/cs-CZ.d.ts +1 -1
  45. package/locales/cs-CZ.esm.min.js +1 -1
  46. package/locales/cs-CZ.min.cjs +1 -1
  47. package/locales/cs-CZ.min.js +1 -1
  48. package/locales/da-DK.d.ts +1 -1
  49. package/locales/da-DK.esm.min.js +1 -1
  50. package/locales/da-DK.min.cjs +1 -1
  51. package/locales/da-DK.min.js +1 -1
  52. package/locales/de-DE.d.ts +1 -1
  53. package/locales/de-DE.esm.min.js +1 -1
  54. package/locales/de-DE.min.cjs +1 -1
  55. package/locales/de-DE.min.js +1 -1
  56. package/locales/el-GR.d.ts +1 -1
  57. package/locales/el-GR.esm.min.js +1 -1
  58. package/locales/el-GR.min.cjs +1 -1
  59. package/locales/el-GR.min.js +1 -1
  60. package/locales/en-US.d.ts +1 -1
  61. package/locales/en-US.esm.min.js +1 -1
  62. package/locales/en-US.min.cjs +1 -1
  63. package/locales/en-US.min.js +1 -1
  64. package/locales/es-ES.d.ts +1 -1
  65. package/locales/es-ES.esm.min.js +1 -1
  66. package/locales/es-ES.min.cjs +1 -1
  67. package/locales/es-ES.min.js +1 -1
  68. package/locales/fi-FI.d.ts +1 -1
  69. package/locales/fi-FI.esm.min.js +1 -1
  70. package/locales/fi-FI.min.cjs +1 -1
  71. package/locales/fi-FI.min.js +1 -1
  72. package/locales/fr-CA.d.ts +1 -1
  73. package/locales/fr-CA.esm.min.js +1 -1
  74. package/locales/fr-CA.min.cjs +1 -1
  75. package/locales/fr-CA.min.js +1 -1
  76. package/locales/fr-FR.d.ts +1 -1
  77. package/locales/fr-FR.esm.min.js +1 -1
  78. package/locales/fr-FR.min.cjs +1 -1
  79. package/locales/fr-FR.min.js +1 -1
  80. package/locales/hu-HU.d.ts +1 -1
  81. package/locales/hu-HU.esm.min.js +1 -1
  82. package/locales/hu-HU.min.cjs +1 -1
  83. package/locales/hu-HU.min.js +1 -1
  84. package/locales/it-IT.d.ts +1 -1
  85. package/locales/it-IT.esm.min.js +1 -1
  86. package/locales/it-IT.min.cjs +1 -1
  87. package/locales/it-IT.min.js +1 -1
  88. package/locales/ja-JP.d.ts +1 -1
  89. package/locales/ja-JP.esm.min.js +1 -1
  90. package/locales/ja-JP.min.cjs +1 -1
  91. package/locales/ja-JP.min.js +1 -1
  92. package/locales/nb-NO.d.ts +1 -1
  93. package/locales/nb-NO.esm.min.js +1 -1
  94. package/locales/nb-NO.min.cjs +1 -1
  95. package/locales/nb-NO.min.js +1 -1
  96. package/locales/nl-NL.d.ts +1 -1
  97. package/locales/nl-NL.esm.min.js +1 -1
  98. package/locales/nl-NL.min.cjs +1 -1
  99. package/locales/nl-NL.min.js +1 -1
  100. package/locales/pl-PL.d.ts +1 -1
  101. package/locales/pl-PL.esm.min.js +1 -1
  102. package/locales/pl-PL.min.cjs +1 -1
  103. package/locales/pl-PL.min.js +1 -1
  104. package/locales/pt-BR.d.ts +1 -1
  105. package/locales/pt-BR.esm.min.js +1 -1
  106. package/locales/pt-BR.min.cjs +1 -1
  107. package/locales/pt-BR.min.js +1 -1
  108. package/locales/ro-RO.d.ts +1 -1
  109. package/locales/ro-RO.esm.min.js +1 -1
  110. package/locales/ro-RO.min.cjs +1 -1
  111. package/locales/ro-RO.min.js +1 -1
  112. package/locales/sv-SE.d.ts +1 -1
  113. package/locales/sv-SE.esm.min.js +1 -1
  114. package/locales/sv-SE.min.cjs +1 -1
  115. package/locales/sv-SE.min.js +1 -1
  116. package/locales/uk-UA.d.ts +1 -1
  117. package/locales/uk-UA.esm.min.js +1 -1
  118. package/locales/uk-UA.min.cjs +1 -1
  119. package/locales/uk-UA.min.js +1 -1
  120. package/modules/ai.d.ts +1 -1
  121. package/modules/ai.esm.min.js +1 -1
  122. package/modules/ai.min.cjs +1 -1
  123. package/modules/ai.min.js +1 -1
  124. package/modules/alarms.d.ts +1 -1
  125. package/modules/alarms.esm.min.js +1 -1
  126. package/modules/alarms.min.cjs +1 -1
  127. package/modules/alarms.min.js +1 -1
  128. package/modules/angular.d.ts +1 -1
  129. package/modules/angular.esm.min.js +1 -1
  130. package/modules/angular.min.cjs +1 -1
  131. package/modules/angular.min.js +1 -1
  132. package/modules/calendar.d.ts +1 -1
  133. package/modules/calendar.esm.min.js +1 -1
  134. package/modules/calendar.min.cjs +1 -1
  135. package/modules/calendar.min.js +1 -1
  136. package/modules/chart-alluvial.d.ts +1 -1
  137. package/modules/chart-alluvial.esm.min.js +1 -1
  138. package/modules/chart-alluvial.min.cjs +1 -1
  139. package/modules/chart-alluvial.min.js +1 -1
  140. package/modules/chart-arc.d.ts +1 -1
  141. package/modules/chart-arc.esm.min.js +1 -1
  142. package/modules/chart-arc.min.cjs +1 -1
  143. package/modules/chart-arc.min.js +1 -1
  144. package/modules/chart-barrace.d.ts +1 -1
  145. package/modules/chart-barrace.esm.min.js +1 -1
  146. package/modules/chart-barrace.min.cjs +1 -1
  147. package/modules/chart-barrace.min.js +1 -1
  148. package/modules/chart-bubblemap.d.ts +1 -1
  149. package/modules/chart-bubblemap.esm.min.js +1 -1
  150. package/modules/chart-bubblemap.min.cjs +1 -1
  151. package/modules/chart-bubblemap.min.js +1 -1
  152. package/modules/chart-bump.d.ts +1 -1
  153. package/modules/chart-bump.esm.min.js +1 -1
  154. package/modules/chart-bump.min.cjs +1 -1
  155. package/modules/chart-bump.min.js +1 -1
  156. package/modules/chart-calendar.d.ts +1 -1
  157. package/modules/chart-calendar.esm.min.js +1 -1
  158. package/modules/chart-calendar.min.cjs +1 -1
  159. package/modules/chart-calendar.min.js +1 -1
  160. package/modules/chart-choropleth.d.ts +1 -1
  161. package/modules/chart-choropleth.esm.min.js +1 -1
  162. package/modules/chart-choropleth.min.cjs +1 -1
  163. package/modules/chart-choropleth.min.js +1 -1
  164. package/modules/chart-decomposition.d.ts +1 -1
  165. package/modules/chart-decomposition.esm.min.js +1 -1
  166. package/modules/chart-decomposition.min.cjs +1 -1
  167. package/modules/chart-decomposition.min.js +1 -1
  168. package/modules/chart-diverging.d.ts +1 -1
  169. package/modules/chart-diverging.esm.min.js +1 -1
  170. package/modules/chart-diverging.min.cjs +1 -1
  171. package/modules/chart-diverging.min.js +1 -1
  172. package/modules/chart-dumbbell.d.ts +1 -1
  173. package/modules/chart-dumbbell.esm.min.js +1 -1
  174. package/modules/chart-dumbbell.min.cjs +1 -1
  175. package/modules/chart-dumbbell.min.js +1 -1
  176. package/modules/chart-fan.d.ts +1 -1
  177. package/modules/chart-fan.esm.min.js +1 -1
  178. package/modules/chart-fan.min.cjs +1 -1
  179. package/modules/chart-fan.min.js +1 -1
  180. package/modules/chart-forcetree.d.ts +1 -1
  181. package/modules/chart-forcetree.esm.min.js +1 -1
  182. package/modules/chart-forcetree.min.cjs +1 -1
  183. package/modules/chart-forcetree.min.js +1 -1
  184. package/modules/chart-hexbin.d.ts +1 -1
  185. package/modules/chart-hexbin.esm.min.js +1 -1
  186. package/modules/chart-hexbin.min.cjs +1 -1
  187. package/modules/chart-hexbin.min.js +1 -1
  188. package/modules/chart-hexmap.d.ts +1 -1
  189. package/modules/chart-hexmap.esm.min.js +1 -1
  190. package/modules/chart-hexmap.min.cjs +1 -1
  191. package/modules/chart-hexmap.min.js +1 -1
  192. package/modules/chart-icicle.d.ts +1 -1
  193. package/modules/chart-icicle.esm.min.js +1 -1
  194. package/modules/chart-icicle.min.cjs +1 -1
  195. package/modules/chart-icicle.min.js +1 -1
  196. package/modules/chart-markermap.d.ts +1 -1
  197. package/modules/chart-markermap.esm.min.js +1 -1
  198. package/modules/chart-markermap.min.cjs +1 -1
  199. package/modules/chart-markermap.min.js +1 -1
  200. package/modules/chart-motion.d.ts +1 -1
  201. package/modules/chart-motion.esm.min.js +1 -1
  202. package/modules/chart-motion.min.cjs +1 -1
  203. package/modules/chart-motion.min.js +1 -1
  204. package/modules/chart-pack.d.ts +1 -1
  205. package/modules/chart-pack.esm.min.js +1 -1
  206. package/modules/chart-pack.min.cjs +1 -1
  207. package/modules/chart-pack.min.js +1 -1
  208. package/modules/chart-parallel.d.ts +1 -1
  209. package/modules/chart-parallel.esm.min.js +1 -1
  210. package/modules/chart-parallel.min.cjs +1 -1
  211. package/modules/chart-parallel.min.js +1 -1
  212. package/modules/chart-pictorial.d.ts +1 -1
  213. package/modules/chart-pictorial.esm.min.js +1 -1
  214. package/modules/chart-pictorial.min.cjs +1 -1
  215. package/modules/chart-pictorial.min.js +1 -1
  216. package/modules/chart-polararea.d.ts +1 -1
  217. package/modules/chart-polararea.esm.min.js +1 -1
  218. package/modules/chart-polararea.min.cjs +1 -1
  219. package/modules/chart-polararea.min.js +1 -1
  220. package/modules/chart-polarscatter.d.ts +1 -1
  221. package/modules/chart-polarscatter.esm.min.js +1 -1
  222. package/modules/chart-polarscatter.min.cjs +1 -1
  223. package/modules/chart-polarscatter.min.js +1 -1
  224. package/modules/chart-pyramid.d.ts +1 -1
  225. package/modules/chart-pyramid.esm.min.js +1 -1
  226. package/modules/chart-pyramid.min.cjs +1 -1
  227. package/modules/chart-pyramid.min.js +1 -1
  228. package/modules/chart-radialbar.d.ts +1 -1
  229. package/modules/chart-radialbar.esm.min.js +1 -1
  230. package/modules/chart-radialbar.min.cjs +1 -1
  231. package/modules/chart-radialbar.min.js +1 -1
  232. package/modules/chart-ridgeline.d.ts +1 -1
  233. package/modules/chart-ridgeline.esm.min.js +1 -1
  234. package/modules/chart-ridgeline.min.cjs +1 -1
  235. package/modules/chart-ridgeline.min.js +1 -1
  236. package/modules/chart-roc.d.ts +1 -1
  237. package/modules/chart-roc.esm.min.js +1 -1
  238. package/modules/chart-roc.min.cjs +1 -1
  239. package/modules/chart-roc.min.js +1 -1
  240. package/modules/chart-scatter3d.d.ts +1 -1
  241. package/modules/chart-scatter3d.esm.min.js +1 -1
  242. package/modules/chart-scatter3d.min.cjs +1 -1
  243. package/modules/chart-scatter3d.min.js +1 -1
  244. package/modules/chart-serpentine.d.ts +1 -1
  245. package/modules/chart-serpentine.esm.min.js +1 -1
  246. package/modules/chart-serpentine.min.cjs +1 -1
  247. package/modules/chart-serpentine.min.js +1 -1
  248. package/modules/chart-slope.d.ts +1 -1
  249. package/modules/chart-slope.esm.min.js +1 -1
  250. package/modules/chart-slope.min.cjs +1 -1
  251. package/modules/chart-slope.min.js +1 -1
  252. package/modules/chart-spiral.d.ts +1 -1
  253. package/modules/chart-spiral.esm.min.js +1 -1
  254. package/modules/chart-spiral.min.cjs +1 -1
  255. package/modules/chart-spiral.min.js +1 -1
  256. package/modules/chart-splom.d.ts +1 -1
  257. package/modules/chart-splom.esm.min.js +1 -1
  258. package/modules/chart-splom.min.cjs +1 -1
  259. package/modules/chart-splom.min.js +1 -1
  260. package/modules/chart-tree.d.ts +1 -1
  261. package/modules/chart-tree.esm.min.js +1 -1
  262. package/modules/chart-tree.min.cjs +1 -1
  263. package/modules/chart-tree.min.js +1 -1
  264. package/modules/chart-venn.d.ts +1 -1
  265. package/modules/chart-venn.esm.min.js +1 -1
  266. package/modules/chart-venn.min.cjs +1 -1
  267. package/modules/chart-venn.min.js +1 -1
  268. package/modules/chart-voronoi.d.ts +1 -1
  269. package/modules/chart-voronoi.esm.min.js +1 -1
  270. package/modules/chart-voronoi.min.cjs +1 -1
  271. package/modules/chart-voronoi.min.js +1 -1
  272. package/modules/chart-waffle.d.ts +1 -1
  273. package/modules/chart-waffle.esm.min.js +1 -1
  274. package/modules/chart-waffle.min.cjs +1 -1
  275. package/modules/chart-waffle.min.js +1 -1
  276. package/modules/chart-wordcloud.d.ts +1 -1
  277. package/modules/chart-wordcloud.esm.min.js +1 -1
  278. package/modules/chart-wordcloud.min.cjs +1 -1
  279. package/modules/chart-wordcloud.min.js +1 -1
  280. package/modules/charts.d.ts +1 -1
  281. package/modules/charts.esm.min.js +1 -1
  282. package/modules/charts.min.cjs +1 -1
  283. package/modules/charts.min.js +1 -1
  284. package/modules/dashboard.d.ts +1 -1
  285. package/modules/dashboard.esm.min.js +1 -1
  286. package/modules/dashboard.min.cjs +1 -1
  287. package/modules/dashboard.min.js +1 -1
  288. package/modules/data-router.d.ts +1 -1
  289. package/modules/data-router.esm.min.js +1 -1
  290. package/modules/data-router.min.cjs +1 -1
  291. package/modules/data-router.min.js +1 -1
  292. package/modules/deckgl.d.ts +1 -1
  293. package/modules/deckgl.esm.min.js +1 -1
  294. package/modules/deckgl.min.cjs +1 -1
  295. package/modules/deckgl.min.js +1 -1
  296. package/modules/designer.d.ts +1 -1
  297. package/modules/designer.esm.min.js +1 -1
  298. package/modules/designer.min.cjs +1 -1
  299. package/modules/designer.min.js +1 -1
  300. package/modules/devtools.d.ts +1 -1
  301. package/modules/devtools.esm.min.js +1 -1
  302. package/modules/devtools.min.cjs +1 -1
  303. package/modules/devtools.min.js +1 -1
  304. package/modules/dhtmlx-compat.d.ts +1 -1
  305. package/modules/dhtmlx-compat.esm.min.js +1 -1
  306. package/modules/dhtmlx-compat.min.cjs +1 -1
  307. package/modules/dhtmlx-compat.min.js +1 -1
  308. package/modules/gantt.d.ts +1 -1
  309. package/modules/gantt.esm.min.js +1 -1
  310. package/modules/gantt.min.cjs +1 -1
  311. package/modules/gantt.min.js +1 -1
  312. package/modules/geo-europe-nuts.d.ts +1 -1
  313. package/modules/geo-europe-nuts.esm.min.js +1 -1
  314. package/modules/geo-europe-nuts.min.cjs +1 -1
  315. package/modules/geo-europe-nuts.min.js +1 -1
  316. package/modules/geo-uk.d.ts +1 -1
  317. package/modules/geo-uk.esm.min.js +1 -1
  318. package/modules/geo-uk.min.cjs +1 -1
  319. package/modules/geo-uk.min.js +1 -1
  320. package/modules/geo-us-states.d.ts +1 -1
  321. package/modules/geo-us-states.esm.min.js +1 -1
  322. package/modules/geo-us-states.min.cjs +1 -1
  323. package/modules/geo-us-states.min.js +1 -1
  324. package/modules/geo-world-110m.d.ts +1 -1
  325. package/modules/geo-world-110m.esm.min.js +1 -1
  326. package/modules/geo-world-110m.min.cjs +1 -1
  327. package/modules/geo-world-110m.min.js +1 -1
  328. package/modules/geo-world-50m.d.ts +1 -1
  329. package/modules/geo-world-50m.esm.min.js +1 -1
  330. package/modules/geo-world-50m.min.cjs +1 -1
  331. package/modules/geo-world-50m.min.js +1 -1
  332. package/modules/geometry.d.ts +1 -1
  333. package/modules/geometry.esm.min.js +1 -1
  334. package/modules/geometry.min.cjs +1 -1
  335. package/modules/geometry.min.js +1 -1
  336. package/modules/htmx.d.ts +1 -1
  337. package/modules/htmx.esm.min.js +2 -2
  338. package/modules/htmx.min.cjs +2 -2
  339. package/modules/htmx.min.js +2 -2
  340. package/modules/kanban.d.ts +1 -1
  341. package/modules/kanban.esm.min.js +1 -1
  342. package/modules/kanban.min.cjs +1 -1
  343. package/modules/kanban.min.js +1 -1
  344. package/modules/kpi.d.ts +1 -1
  345. package/modules/kpi.esm.min.js +1 -1
  346. package/modules/kpi.min.cjs +1 -1
  347. package/modules/kpi.min.js +1 -1
  348. package/modules/layout.d.ts +1 -1
  349. package/modules/layout.esm.min.js +1 -1
  350. package/modules/layout.min.cjs +1 -1
  351. package/modules/layout.min.js +1 -1
  352. package/modules/leaflet.d.ts +1 -1
  353. package/modules/leaflet.esm.min.js +1 -1
  354. package/modules/leaflet.min.cjs +1 -1
  355. package/modules/leaflet.min.js +1 -1
  356. package/modules/list.d.ts +1 -1
  357. package/modules/list.esm.min.js +1 -1
  358. package/modules/list.min.cjs +1 -1
  359. package/modules/list.min.js +1 -1
  360. package/modules/mapview.d.ts +1 -1
  361. package/modules/mapview.esm.min.js +1 -1
  362. package/modules/mapview.min.cjs +1 -1
  363. package/modules/mapview.min.js +1 -1
  364. package/modules/mock-socket.d.ts +1 -1
  365. package/modules/mock-socket.esm.min.js +1 -1
  366. package/modules/mock-socket.min.cjs +1 -1
  367. package/modules/mock-socket.min.js +1 -1
  368. package/modules/presets.d.ts +1 -1
  369. package/modules/presets.esm.min.js +1 -1
  370. package/modules/presets.min.cjs +1 -1
  371. package/modules/presets.min.js +1 -1
  372. package/modules/react.d.ts +1 -1
  373. package/modules/react.esm.min.js +1 -1
  374. package/modules/react.min.cjs +1 -1
  375. package/modules/react.min.js +1 -1
  376. package/modules/scheduler.d.ts +12 -8
  377. package/modules/scheduler.esm.min.js +90 -78
  378. package/modules/scheduler.esm.min.js.map +2 -2
  379. package/modules/scheduler.min.cjs +90 -78
  380. package/modules/scheduler.min.js +90 -78
  381. package/modules/scheduler.min.js.map +2 -2
  382. package/modules/shell.d.ts +1 -1
  383. package/modules/shell.esm.min.js +1 -1
  384. package/modules/shell.min.cjs +1 -1
  385. package/modules/shell.min.js +1 -1
  386. package/modules/svelte.d.ts +1 -1
  387. package/modules/svelte.esm.min.js +1 -1
  388. package/modules/svelte.min.cjs +1 -1
  389. package/modules/svelte.min.js +1 -1
  390. package/modules/tabs.d.ts +1 -1
  391. package/modules/tabs.esm.min.js +1 -1
  392. package/modules/tabs.min.cjs +1 -1
  393. package/modules/tabs.min.js +1 -1
  394. package/modules/vue.d.ts +1 -1
  395. package/modules/vue.esm.min.js +1 -1
  396. package/modules/vue.min.cjs +1 -1
  397. package/modules/vue.min.js +1 -1
  398. package/modules/webcomponent.d.ts +1 -1
  399. package/modules/webcomponent.esm.min.js +2 -2
  400. package/modules/webcomponent.min.cjs +2 -2
  401. package/modules/webcomponent.min.js +2 -2
  402. package/package.json +1 -1
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * Lattice Grid 1.98.1, webcomponent module
2
+ * Lattice Grid 1.98.2, webcomponent module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
6
  var pr=Object.create(null),mr=Object.create(null);function Be(e,H){pr[e]=H}function Kn(e){var H=mr[e];if(H)return H;var te=Object.create(null);mr[e]=te;var L=pr[e];if(!L)throw new Error("[lattice] missing module: "+e);return L(te,Kn),te}Be("packages/core/src/internal/predicates.js",function(e,H){"use strict";Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return F}});function te(Z){return Z!==null&&typeof Z=="object"&&!Array.isArray(Z)}function L(Z){return typeof Z=="function"}function X(Z){return Z==null}function D(Z){return Z==null||Z===""}function F(Z){return typeof Z!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(Z))?!0:!!(Z.prototype&&Object.getOwnPropertyNames(Z.prototype).length>1)}}),Be("packages/core/src/internal/warn.js",function(e,H){"use strict";Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"infoOnce",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"resetWarnings",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"fail",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return d}});const te=new Set,L=2e3;function X(l){if(te.add(l),te.size>L){const r=te.values().next().value;r!==void 0&&te.delete(r)}}const D=[],F=500;function Z(l,r,t){D.push({key:l,level:r,message:t.map(i=>typeof i=="string"?i:Y(i)).join(" "),at:Date.now()}),D.length>F&&D.shift()}function Y(l){if(l instanceof Error)return l.message;try{return JSON.stringify(l)}catch{return String(l)}}function B(){return D.map(l=>({...l}))}function z(l){if(l.length===0||typeof l[0]!="string")return l;const r=l[0].replace(/^\[lattice\]\s*/,"");return r===l[0]?l:[r,...l.slice(1)]}function G(l,...r){if(te.has(l))return;X(l);const t=z(r);Z(l,"warn",t),console.warn("[lattice]",...t)}function P(l,...r){if(te.has(l))return;X(l);const t=z(r);Z(l,"info",t),console.info("[lattice]",...t)}function O(){te.clear(),D.length=0}function b(l,r){const t=new Error(`[lattice] ${l}`);throw r!==void 0&&(t.cause=r),t}function c(l,r){l||b(r)}const d=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})()}),Be("packages/core/src/formatting/rules.js",function(e,H){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DISTRIBUTION_OPS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DISTRIBUTION_LABELS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"testRule",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return T}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),Z=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Y=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function B(j,N){const W=Number(j),R=Number(N);if(j!==null&&j!==""&&N!==null&&N!==""&&Number.isFinite(W)&&Number.isFinite(R))return W<R?-1:W>R?1:0;const A=String(j??"").toLowerCase(),$=String(N??"").toLowerCase();return A<$?-1:A>$?1:0}function z(j){return j==null||j===""}function G(j,N){if(!N||typeof N!="object")return!1;const{op:W}=N,R=N.value,x=N.value2;switch(W){case"blank":return z(j);case"notBlank":return!z(j);case"true":return j===!0;case"false":return j===!1;default:break}if(z(j))return!1;switch(W){case"eq":return B(j,R)===0;case"ne":return B(j,R)!==0;case"gt":return B(j,R)>0;case"gte":return B(j,R)>=0;case"lt":return B(j,R)<0;case"lte":return B(j,R)<=0;case"between":return B(j,R)>=0&&B(j,x)<=0;case"outside":return B(j,R)<0||B(j,x)>0;case"contains":return String(j).toLowerCase().includes(String(R??"").toLowerCase());case"notContains":return!String(j).toLowerCase().includes(String(R??"").toLowerCase());case"startsWith":return String(j).toLowerCase().startsWith(String(R??"").toLowerCase());case"endsWith":return String(j).toLowerCase().endsWith(String(R??"").toLowerCase());default:return!1}}function P(j,N,W){const R=K=>{const q=String(K).replace("#",""),_=q.length===3?q.split("").map(J=>J+J).join(""):q;return[0,2,4].map(J=>parseInt(_.slice(J,J+2),16)||0)},[x,A,$]=R(j),[I,M,S]=R(N),E=Math.max(0,Math.min(1,W)),U=(K,q)=>Math.round(K+(q-K)*E);return`#${[U(x,I),U(A,M),U($,S)].map(K=>K.toString(16).padStart(2,"0")).join("")}`}function O(j){const N=[];for(const I of j||[]){if(I==null||I==="")continue;const M=I instanceof Date?I.getTime():Number(I);Number.isFinite(M)&&N.push(M)}if(!N.length)return null;N.sort((I,M)=>I-M);let W=0,R=0,x=0;for(const I of N){W++;const M=I-R;R+=M/W,x+=M*(I-R)}const A=b(N,.25),$=b(N,.75);return{n:N.length,min:N[0],max:N[N.length-1],mean:R,stddev:N.length>1?Math.sqrt(x/(N.length-1)):0,median:b(N,.5),q1:A,q3:$,iqr:$-A,sorted:N}}function b(j,N){if(!j.length)return 0;const W=(j.length-1)*Math.max(0,Math.min(1,N)),R=Math.floor(W),x=Math.ceil(W);return R===x?j[R]:j[R]+(W-R)*(j[x]-j[R])}function c(j){for(const N of Array.isArray(j)?j:[])if(!(!N||typeof N!="object")&&(N.when&&Z.includes(N.when.op)||N.scale&&N.scale.from||N.dataBar&&!(Number.isFinite(Number(N.dataBar.min))&&Number.isFinite(Number(N.dataBar.max)))||N.iconSet&&!Array.isArray(N.iconSet.thresholds)))return!0;return!1}function d(j,N){const W=Number(j.value),R=x=>b(N.sorted,x);switch(j.op){case"topPercent":{const x=l(W,10);return{op:"gte",value:R(1-x)}}case"bottomPercent":{const x=l(W,10);return{op:"lte",value:R(x)}}case"topN":{const x=Math.max(1,Math.floor(W)||1),A=Math.max(0,N.sorted.length-x);return{op:"gte",value:N.sorted[A]}}case"bottomN":{const x=Math.max(1,Math.floor(W)||1),A=Math.min(N.sorted.length-1,x-1);return{op:"lte",value:N.sorted[A]}}case"aboveMean":return{op:"gt",value:N.mean};case"belowMean":return{op:"lt",value:N.mean};case"aboveMedian":return{op:"gt",value:N.median};case"belowMedian":return{op:"lt",value:N.median};case"zAbove":return N.stddev?{op:"gte",value:N.mean+(Number.isFinite(W)?W:2)*N.stddev}:null;case"zBelow":return N.stddev?{op:"lte",value:N.mean-(Number.isFinite(W)?W:2)*N.stddev}:null;case"outlier":{const x=(Number.isFinite(W)&&W>0?W:1.5)*N.iqr;return N.iqr?{op:"outside",value:N.q1-x,value2:N.q3+x}:null}default:return null}}function l(j,N){const W=Number.isFinite(j)?j:N,R=W>1?W/100:W;return Math.max(0,Math.min(1,R))}function r(j,N){if(j.from==="minmax")return{...j,min:N.min,max:N.max};if(j.from==="quantile")return{...j,min:b(N.sorted,l(Number(j.low),5)),max:b(N.sorted,l(Number(j.high),95))};if(j.from==="stddev"){const W=Number.isFinite(Number(j.deviations))?Number(j.deviations):2;return{...j,min:N.mean-W*N.stddev,max:N.mean+W*N.stddev}}return j}function t(j,N){const W=Array.isArray(j)?j:[];return!N||!N.n?W.map(R=>R&&c([R])?{...R,enabled:!1}:R):W.map(R=>{if(!R||typeof R!="object")return R;if(R.scale&&R.scale.from)return{...R,scale:r(R.scale,N)};if(R.dataBar)return{...R,dataBar:i(R.dataBar,N)};if(R.iconSet)return{...R,iconSet:s(R.iconSet,N)};if(!R.when||!Z.includes(R.when.op))return R;const x=d(R.when,N);return x?{...R,when:x}:{...R,enabled:!1}})}function i(j,N){const W=Number.isFinite(Number(j.min))?Number(j.min):void 0,R=Number.isFinite(Number(j.max))?Number(j.max):void 0;if(W!==void 0&&R!==void 0)return{...j,min:W,max:R};if(j.from==="quantile")return{...j,min:W??b(N.sorted,l(Number(j.low),5)),max:R??b(N.sorted,l(Number(j.high),95))};if(j.from==="stddev"){const x=Number.isFinite(Number(j.deviations))?Number(j.deviations):2;return{...j,min:W??N.mean-x*N.stddev,max:R??N.mean+x*N.stddev}}return{...j,min:W??N.min,max:R??N.max}}function s(j,N){if(Array.isArray(j.thresholds))return j;const W=n(j),R=[];for(let x=1;x<W;x++)R.push(b(N.sorted,x/W));return{...j,thresholds:R}}function n(j){if(Array.isArray(j.icons)&&j.icons.length>=2)return j.icons.length;if(Number.isFinite(Number(j.count))&&Number(j.count)>=2)return Math.floor(Number(j.count));const N=v[j.set];return N?N.length:3}function u(j){return`url("data:image/svg+xml,${encodeURIComponent(j)}")`}function o(j){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${j}"/></svg>`}function a(j,N){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${N==="up"?"8,2 14,13 2,13":N==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${j}"/></svg>`}function f(j,N){const W="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let R=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${N*16} 16">`;for(let x=0;x<N;x++){const A=x<j?"#f5a623":"#d0d0d0";R+=`<path transform="translate(${x*16},0)" d="${W}" fill="${A}"/>`}return`${R}</svg>`}const w=Object.freeze([a("#c0392b","down"),a("#e0a800","right"),a("#2e7d32","up")]),m=Object.freeze([o("#d13438"),o("#f5a623"),o("#2e9e44")]),v=Object.freeze({arrows:w,trafficLights:m,ratings:Object.freeze([1,2,3,4,5].map(j=>f(j,5)))}),h=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function p(j){if(Array.isArray(j.icons)&&j.icons.length>=2)return j.icons.map(R=>/^\s*(url\(|data:|<)/.test(String(R))&&String(R).trim().startsWith("<")?u(String(R)):String(R));const N=j.set||"arrows";if(N==="ratings"){const R=n(j),x=[];for(let A=1;A<=R;A++)x.push(u(f(A,R)));return x}const W=v[N];return W?W.map(u):(D(`iconSet:${N}`,`unknown icon set '${N}'; falling back to arrows.`),w.map(u))}function g(j){const N=Number(j.min),R=Number(j.max)-N,x=j.colour||j.color||"#5b9bd5",A=j.negativeColour||j.negativeColor||"#d13438",$=j.direction==="rtl"?"left":"right",I=S=>Math.max(0,Math.min(1,(S-N)/R))*100,M=R?Math.max(0,Math.min(100,(0-N)/R*100)):0;return S=>{if(z(S))return null;const E=Number(S);if(!Number.isFinite(E)||!R)return null;const U=I(E),K=Math.min(U,M),q=Math.max(U,M),_=E>=0?x:A;return{backgroundImage:`linear-gradient(to ${$}, transparent ${K}%, ${_} ${K}%, ${_} ${q}%, transparent ${q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function k(j){const N=p(j),W=j.reverse?[...N].reverse():N,R=(Array.isArray(j.thresholds)?j.thresholds:[]).map(Number).filter(Number.isFinite),x=Number.isFinite(Number(j.size))?Number(j.size):16,A=j.set==="ratings"?x*n(j):x;return $=>{if(z($))return null;const I=Number($);if(!Number.isFinite(I))return null;let M=0;for(const E of R)I>=E&&M++;const S=W[Math.min(M,W.length-1)];return S?{backgroundImage:S,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${A}px ${x}px`,paddingLeft:`${A+4}px`}:null}}function y(j){const N=Array.isArray(j.colours)&&j.colours.length>=2?j.colours:["#f8f9fa","#1a6bc7"],W=Number(j.min),R=Number(j.max),x=R-W,A=N.length-1,$=[];for(let M=0;M<=A;M++)$.push(A?M/A:0);const I=Number(j.mid);if(j.mid!==void 0&&j.mid!==null)if(N.length%2===0)D("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${N.length} were given, so "mid" was ignored.`);else if(Number.isFinite(I)&&x&&I>Math.min(W,R)&&I<Math.max(W,R)){const M=A/2,S=Math.max(0,Math.min(1,(I-W)/x));for(let E=0;E<=A;E++)$[E]=E<=M?M?E/M*S:S:S+(E-M)/(A-M)*(1-S)}else Number.isFinite(I)&&D("formatting.scale.mid.range",`a scale's "mid" (${I}) is outside its min..max range, so it was ignored.`);return M=>{const S=Number(M);if(!Number.isFinite(S)||!x)return null;const E=Math.max(0,Math.min(1,(S-W)/x));let U=0;for(;U<A-1&&E>$[U+1];)U++;const K=$[U+1]-$[U],q=K>0?(E-$[U])/K:0;return{background:P(N[U],N[U+1],Math.max(0,Math.min(1,q)))}}}function T(j,N=null){const W=c(j)?t(j,N):j,R=(Array.isArray(W)?W:[]).filter(A=>A&&typeof A=="object");if(!R.length)return()=>null;const x=R.map(A=>A.scale?{scale:y(A.scale),enabled:A.enabled!==!1}:A.dataBar?{scale:g(A.dataBar),enabled:A.enabled!==!1}:A.iconSet?{scale:k(A.iconSet),enabled:A.enabled!==!1}:{when:A.when,style:A.style,stop:A.stopIfTrue!==!1,enabled:A.enabled!==!1});return A=>{const $=A?A.value:void 0;let I=null;for(const M of x){if(!M.enabled)continue;if(M.scale){const E=M.scale($);E&&(I={...I||{},...E});continue}if(!G($,M.when))continue;const S=L(M.style)?M.style(A):M.style;if(S&&(I={...I||{},...S}),M.stop)break}return I}}}),Be("packages/core/src/formula/parse.js",function(e,H){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return t}});const te="num",L="str",X="ref",D="name",F="op",Z="end",Y=["<=",">=","<>","!="],B="+-*/^%(),<>=";class z extends Error{constructor(s,n){super(s),this.name="FormulaError",this.at=n}}function G(i){const s=[];let n=0;for(;n<i.length;){const u=i[n];if(u===" "||u===" "||u===`
7
- `||u==="\r"){n++;continue}if(u>="0"&&u<="9"){n=O(i,n,s);continue}if(u==="."&&i[n+1]>="0"&&i[n+1]<="9"){n=O(i,n,s);continue}if(u==='"'||u==="'"){n=b(i,n,s);continue}if(u==="["){const a=i.indexOf("]",n+1);if(a<0)throw new z("a [column reference] was opened and never closed",n);s.push({kind:X,value:i.slice(n+1,a).trim(),at:n}),n=a+1;continue}if(P(u)){n=c(i,n,s);continue}const o=i.slice(n,n+2);if(Y.includes(o)){s.push({kind:F,value:o==="!="?"<>":o,at:n}),n+=2;continue}if(B.includes(u)){s.push({kind:F,value:u,at:n}),n++;continue}throw new z(`unexpected character ${JSON.stringify(u)}`,n)}return s.push({kind:Z,value:null,at:i.length}),s}function P(i){return/[A-Za-z_À-￿]/.test(i)}function O(i,s,n){let u=s,o=!1;for(;u<i.length;){const a=i[u];if(a>="0"&&a<="9"){u++;continue}if(a==="."&&!o){o=!0,u++;continue}if((a==="e"||a==="E")&&/[0-9+-]/.test(i[u+1]||"")){for(u+=2;u<i.length&&i[u]>="0"&&i[u]<="9";)u++;break}break}return n.push({kind:te,value:Number(i.slice(s,u)),at:s}),u}function b(i,s,n){const u=i[s];let o=s+1,a="";for(;o<i.length;){if(i[o]===u){if(i[o+1]===u){a+=u,o+=2;continue}return n.push({kind:L,value:a,at:s}),o+1}a+=i[o],o++}throw new z("a string was opened and never closed",s)}function c(i,s,n){let u=s;for(;u<i.length&&/[A-Za-z0-9_.À-￿]/.test(i[u]);)u++;const o=i.slice(s,u);let a=u;for(;a<i.length&&i[a]===" ";)a++;return n.push({kind:i[a]==="("?D:X,value:o,at:s}),u}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function l(i){const s=String(i??"").replace(/^\s*=/,"");if(!s.trim())throw new z("the formula is empty");const n=G(s);let u=0;const o=()=>n[u],a=()=>n[u++],f=k=>{const y=o();if(y.kind!==F||y.value!==k)throw new z(`expected ${JSON.stringify(k)}`,y.at);u++},w=k=>{let y=m();for(;;){const T=o();if(T.kind!==F)break;const j=d[T.value];if(!j||j<k)break;u++;const N=w(T.value==="^"?j:j+1);y={kind:"bin",op:T.value,left:y,right:N}}return y},m=()=>{const k=o();return k.kind===F&&(k.value==="-"||k.value==="+")?(u++,{kind:"unary",op:k.value,arg:m()}):v()},v=()=>{let k=h();for(;o().kind===F&&o().value==="%";)u++,k={kind:"unary",op:"%",arg:k};return k},h=()=>{const k=a();if(k.kind===te)return{kind:"num",value:k.value};if(k.kind===L)return{kind:"str",value:k.value};if(k.kind===X)return{kind:"ref",name:k.value};if(k.kind===D){f("(");const y=[];if(!(o().kind===F&&o().value===")"))for(;;){if(y.push(w(1)),o().kind===F&&o().value===","){u++;continue}break}return f(")"),{kind:"call",name:String(k.value).toUpperCase(),args:y}}if(k.kind===F&&k.value==="("){const y=w(1);return f(")"),y}throw k.kind===Z?new z("the formula ends unexpectedly",k.at):new z(`unexpected ${JSON.stringify(k.value)}`,k.at)},p=w(1),g=o();if(g.kind!==Z)throw new z(`unexpected ${JSON.stringify(g.value)}: is an operator missing?`,g.at);return p}function r(i){const s=new Set,n=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){s.add(String(u.name));return}if(u.kind==="bin"){n(u.left),n(u.right);return}if(u.kind==="unary"){n(u.arg);return}if(u.kind==="call")for(const o of u.args)n(o)}};return n(i),[...s]}function t(i){return typeof i=="string"&&/^\s*=/.test(i)&&i.trim()!=="="}}),Be("packages/core/src/formula/evaluate.js",function(e,H){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const L=H("packages/core/src/formula/parse.js").FormulaError;function X(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const c=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(c))throw new L(`${JSON.stringify(b)} is not a number`);return c}function D(b){return b==null?"":String(b)}function F(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const c=String(b).trim().toLowerCase();return c==="false"||c==="no"||c==="0"?!1:c!==""}function Z(b){const c=[];for(const d of b){if(Array.isArray(d)){for(const l of d)l!=null&&l!==""&&c.push(X(l));continue}d==null||d===""||c.push(X(d))}return c}function Y(b,c){const d=10**c,l=b*d;return Math.sign(l)*Math.round(Math.abs(l)+Number.EPSILON*Math.abs(l))/d}function B(b,c){if(!b.length)return 0;const d=b.slice().sort((i,s)=>i-s),l=(d.length-1)*Math.min(1,Math.max(0,c)),r=Math.floor(l),t=Math.ceil(l);return r===t?d[r]:d[r]+(l-r)*(d[t]-d[r])}function z(b,c){let d=0,l=0,r=0;for(const i of b){d++;const s=i-l;l+=s/d,r+=s*(i-l)}const t=c?d-1:d;return t>0?Math.sqrt(r/t):0}const G={SUM:b=>Z(b).reduce((c,d)=>c+d,0),AVERAGE:b=>{const c=Z(b);return c.length?c.reduce((d,l)=>d+l,0)/c.length:0},MIN:b=>{const c=Z(b);return c.length?Math.min(...c):0},MAX:b=>{const c=Z(b);return c.length?Math.max(...c):0},COUNT:b=>Z(b).length,PRODUCT:b=>Z(b).reduce((c,d)=>c*d,1),ROUND:b=>Y(X(b[0]),b.length>1?X(b[1]):0),ROUNDDOWN:b=>{const c=10**(b.length>1?X(b[1]):0),d=X(b[0])*c;return(d<0?Math.ceil(d):Math.floor(d))/c},ROUNDUP:b=>{const c=10**(b.length>1?X(b[1]):0),d=X(b[0])*c;return(d<0?Math.floor(d):Math.ceil(d))/c},ABS:b=>Math.abs(X(b[0])),FLOOR:b=>Math.floor(X(b[0])),CEILING:b=>Math.ceil(X(b[0])),SQRT:b=>Math.sqrt(X(b[0])),POWER:b=>X(b[0])**X(b[1]),MOD:b=>{const c=X(b[1]);if(c===0)throw new L("MOD by zero");return(X(b[0])%c+c)%c},IF:b=>F(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(F),OR:b=>b.some(F),NOT:b=>!F(b[0]),COALESCE:b=>b.find(c=>c!=null&&c!=="")??null,CONCAT:b=>b.map(D).join(""),LEN:b=>D(b[0]).length,UPPER:b=>D(b[0]).toUpperCase(),LOWER:b=>D(b[0]).toLowerCase(),TRIM:b=>D(b[0]).trim(),LEFT:b=>D(b[0]).slice(0,b.length>1?X(b[1]):1),RIGHT:b=>{const c=b.length>1?X(b[1]):1;return c<=0?"":D(b[0]).slice(-c)},MEDIAN:b=>B(Z(b),.5),PERCENTILE:b=>{const c=X(b[b.length-1]);return B(Z(b.slice(0,-1)),c>1?c/100:c)},QUARTILE1:b=>B(Z(b),.25),QUARTILE3:b=>B(Z(b),.75),STDEV:b=>z(Z(b),!0),STDEVP:b=>z(Z(b),!1),VAR:b=>{const c=z(Z(b),!0);return c*c},VARP:b=>{const c=z(Z(b),!1);return c*c},COUNTDISTINCT:b=>{const c=new Set;for(const d of b){const l=Array.isArray(d)?d:[d];for(const r of l)r!=null&&r!==""&&c.add(r)}return c.size},IQR:b=>{const c=Z(b);return B(c,.75)-B(c,.25)}};G.AVG=G.AVERAGE,G.CEIL=G.CEILING,G.POW=G.POWER,G.STDEVS=G.STDEV,G.PERCENTILEINC=G.PERCENTILE;function P(b,c){const d=Number(b),l=Number(c);if(b!==null&&b!==""&&c!==null&&c!==""&&Number.isFinite(d)&&Number.isFinite(l))return d<l?-1:d>l?1:0;const t=D(b).toLowerCase(),i=D(c).toLowerCase();return t<i?-1:t>i?1:0}function O(b,c={}){const d=typeof c.lookup=="function"?c.lookup:null,l=c.functions?{...G,...c.functions}:G,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new L(`there is no column called ${JSON.stringify(t.name)} here`);const i=d(String(t.name));if(i===void 0)throw new L(`there is no column called ${JSON.stringify(t.name)}`);return i}case"unary":{if(t.op==="%")return X(r(t.arg))/100;const i=X(r(t.arg));return t.op==="-"?-i:i}case"bin":{const i=t.op;if(i==="=")return P(r(t.left),r(t.right))===0;if(i==="<>")return P(r(t.left),r(t.right))!==0;if(i==="<")return P(r(t.left),r(t.right))<0;if(i==="<=")return P(r(t.left),r(t.right))<=0;if(i===">")return P(r(t.left),r(t.right))>0;if(i===">=")return P(r(t.left),r(t.right))>=0;const s=X(r(t.left)),n=X(r(t.right));if(i==="+")return s+n;if(i==="-")return s-n;if(i==="*")return s*n;if(i==="^")return s**n;if(i==="/"){if(n===0)throw new L("division by zero");return s/n}throw new L(`unknown operator ${JSON.stringify(i)}`)}case"call":{const i=c.lazy&&c.lazy[t.name];if(typeof i=="function")return i(t.args,r,c);const s=l[t.name];if(typeof s!="function")throw new L(`there is no function called ${t.name}`);return s(t.args.map(r),c)}default:throw new L("the formula could not be read")}};return r(b)}}),Be("packages/core/src/formula/index.js",function(e,H){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/formula/parse.js"),L=te.parseFormula,X=te.referencesOf,D=te.looksLikeFormula,F=te.FormulaError,Z=te.tokenise,Y=H("packages/core/src/formula/evaluate.js"),B=Y.evaluateAst,z=Y.FUNCTIONS;function G(O){const{grid:b,row:c,data:d}=O||{},l=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],t=b&&b.permissions,i=t&&typeof t.isReadable=="function"?n=>t.isReadable(n):()=>!0,s=new Set;for(const n of r)i(n)||(s.add(l(n.id)),n.field&&s.add(l(n.field)),n.title&&s.add(l(n.title)));return n=>{const u=l(n);if(s.has(u))throw new F(`"${n}" cannot be read`);for(const o of r)if(l(o.id)===u||o.field&&l(o.field)===u||o.title&&l(o.title)===u)return c&&b.rows&&typeof b.rows.value=="function"?b.rows.value(c.key,o.id):d?d[o.field||o.id]:void 0;if(d&&typeof d=="object"){for(const o of Object.keys(d))if(l(o)===u){if(!i(o))throw new F(`"${n}" cannot be read`);return d[o]}}}}function P(O,b={}){try{const c=L(O);return{ok:!0,value:B(c,{lookup:G(b),functions:b.formulaFunctions}),references:X(c)}}catch(c){return{ok:!1,error:c instanceof F?c.message:"the formula could not be read",at:c instanceof F?c.at:void 0}}}}),Be("packages/core/src/internal/version.js",function(e,H){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return X}});const te="1.98.1";async function L(){return te}const X="1.98.1"}),Be("packages/core/src/internal/merge.js",function(e,H){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/predicates.js").isObject;function X(B,z,G){if(B!==void 0)return B===!0?{enabled:!0,...G}:B===!1?{enabled:!1}:L(B)?B:{[z]:B,enabled:!0}}function D(B){return B==null?[]:Array.isArray(B)?B:[B]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(B,z){if(!L(B))return L(z)?{...z}:z;if(!L(z))return z===void 0?B:z;const G={...B};for(const P of Object.keys(z)){if(F.has(P))continue;const O=z[P];O!==void 0&&(G[P]=L(O)&&L(G[P])?Z(G[P],O):O)}return G}function Y(B,z){if(!L(B)||!L(z)||B===z)return z;const G=Object.create(Object.getPrototypeOf(B));return Object.assign(G,B,z),G}}),Be("packages/core/src/internal/schedule.js",function(e,H){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}});function te(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const L=typeof requestAnimationFrame=="function";function X(B){return L?requestAnimationFrame(B):setTimeout(()=>B(te()),16)}function D(B){B!=null&&(L?cancelAnimationFrame(B):clearTimeout(B))}function F(B){let z=null,G=null;const P=()=>{z=null;const b=G;G=null,B(...b||[])},O=(...b)=>{G=b,z===null&&(z=X(P))};return O.cancel=()=>{D(z),z=null,G=null},O.flush=()=>{z!==null&&(D(z),P())},O}function Z(B,z){let G=null,P=null;const O=()=>{if(G=null,P===null)return;const d=P;P=null,B(...d),b()},b=()=>{G=setTimeout(O,z),typeof G?.unref=="function"&&G.unref()},c=(...d)=>{G===null?(B(...d),b()):(P=d,clearTimeout(G),b())};return c.flush=()=>{if(G!==null&&clearTimeout(G),G=null,P===null)return;const d=P;P=null,B(...d)},c.cancel=()=>{G!==null&&clearTimeout(G),G=null,P=null},c.pending=()=>G!==null||P!==null,c}function Y(B,z=50){return typeof requestIdleCallback=="function"?requestIdleCallback(B,{timeout:z}):setTimeout(()=>B({timeRemaining:()=>0,didTimeout:!0}),1)}}),Be("packages/core/src/internal/paths.js",function(e,H){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const te=new Map;function L(Y){let B=te.get(Y);if(B)return B;if(!Y.includes("."))B=z=>z?.[Y];else{const z=Y.split("."),G=z.length;B=P=>{let O=P;for(let b=0;b<G;b++){if(O==null)return;O=O[z[b]]}return O}}return te.set(Y,B),B}const X=new Map;function D(Y){let B=X.get(Y);if(B)return B;if(!Y.includes("."))B=(z,G)=>{z!=null&&(z[Y]=G)};else{const z=Y.split("."),G=z.length-1;B=(P,O)=>{let b=P;for(let c=0;c<G;c++){if(b==null)return;const d=z[c];b[d]==null&&(b[d]={}),b=b[d]}b!=null&&(b[z[G]]=O)}}return X.set(Y,B),B}function F(Y,B){return L(B)(Y)}function Z(Y,B,z){D(B)(Y,z)}}),Be("packages/core/src/internal/compare.js",function(e,H){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return X}});const te=new Map;function L(D,F){const Z=`${D||""}|${F?JSON.stringify(F):""}`;let Y=te.get(Z);return Y||(Y=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...F}),te.set(Z,Y)),Y}function X(D,F){if(D===F)return 0;if(D==null)return 1;if(F==null)return-1;if(typeof D=="number"&&typeof F=="number")return Number.isNaN(D)?Number.isNaN(F)?0:1:Number.isNaN(F)||D<F?-1:D>F?1:0;const Z=String(D),Y=String(F);return Z<Y?-1:Z>Y?1:0}}),Be("packages/core/src/defaults.js",function(e,H){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return P}});const L=H("packages/core/src/internal/predicates.js").isObject,D=H("packages/core/src/internal/merge.js").merge,Z=H("packages/core/src/internal/warn.js").warnOnce;let Y=null;class B extends Error{}function z(O,b=new Set){if(Array.isArray(O)){if(b.has(O))throw new B;b.add(O);const d=O.map(l=>z(l,b));return b.delete(O),d}if(!L(O)||Object.getPrototypeOf(O)!==Object.prototype&&Object.getPrototypeOf(O)!==null)return O;if(b.has(O))throw new B;b.add(O);const c={};for(const[d,l]of Object.entries(O))c[d]=z(l,b);return b.delete(O),c}function G(O){if(O===void 0)return z(Y??{});if(O===null)return Y=null,{};if(!L(O))return Z("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(O)?"an array":typeof O}. The call was ignored and the defaults are unchanged.`),z(Y??{});try{Y=z(O)}catch(b){if(!(b instanceof B))throw b;return Z("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),z(Y??{})}return z(Y)}function P(O){return Y===null?O:D(z(Y),O)}}),Be("packages/core/src/internal/uid.js",function(e,H){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return L}});let te=0;function L(X="l"){return`${X}${(++te).toString(36)}`}}),Be("packages/core/src/events/names.js",function(e,H){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return X}});const te=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),L=new Set(te);function X(D){return D==="*"||L.has(D)}}),Be("packages/core/src/events/bus.js",function(e,H){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return d}});const te=H("packages/core/src/internal/warn.js"),L=te.warnOnce,X=te.DEV,F=H("packages/core/src/internal/uid.js").uid,Y=H("packages/core/src/events/names.js").isKnownEvent,B="*";function z(l,r){!X||Y(r)||L(`bus.unknown:${r}`,`${l}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const G=new Set(["api","user","init","ai"]),P=new WeakMap;function O(l){let r=P.get(l);return r||(r=F("h"),P.set(l,r)),r}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function c(l){if(!l||typeof l!="object")return{};const r={};for(const[t,i]of Object.entries(l))t!=="grid"&&(i==null?r[t]=String(i):Array.isArray(i)?r[t]=`[${i.length}]`:typeof i=="object"?r[t]=i.key?`row ${i.key}`:"{…}":typeof i=="function"?r[t]="[function]":r[t]=String(i).slice(0,60));return r}class d{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#o=!1;#l=0;constructor(r=null){this.#i=r}attach(r){this.#i=r}get grid(){return this.#i}get destroyed(){return this.#o}on(r,t){if(typeof t!="function")return L(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};z("on",r);let i=this.#e.get(r);return i||(i=[],this.#e.set(r,i)),i.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return L(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};z("once",r);const i=s=>{this.off(r,t),t(s)};return this.#s.set(t,i),this.on(r,i)}off(r,t){if(t===void 0){this.#e.delete(r);return}const i=this.#e.get(r);if(!i)return;const s=this.#s.get(t),n=s&&i.includes(s)?s:t,u=i.indexOf(n);u>=0&&i.splice(u,1),s&&n===s&&this.#s.delete(t),i.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),i=r===B?null:this.#e.get(B);return(t?t.length:0)+(i?i.length:0)}#a(r,t,i,s,n){this.#n.push({type:r,origin:t,listeners:(s?s.length:0)+(n?n.length:0),payload:c(i),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,i]of this.#e)r[t]=i.length;return r}emit(r,t,i){const s=i??(t&&t.origin),n=G.has(s)?s:"api",u={...t||null,type:r,origin:n,grid:this.#i};if(this.#o)return u;const o=this.#e.get(r),a=r===B?void 0:this.#e.get(B);if(this.#t&&this.#a(r,n,t,o,a),!o&&!a)return u;const f=this.#t?b():0;this.#l++;try{o&&this.#c(o.slice(),u,r),a&&this.#c(a.slice(),u,B)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-f)}return u}emitBefore(r,t,i){const s=i??(t&&t.origin),n=G.has(s)?s:"user";let u=!1,o=null;const a=p=>{u=!0,p!=null&&o===null&&(o=String(p))},f={...t||null,type:r,origin:n,grid:this.#i,get defaultPrevented(){return u},get reason(){return o},preventDefault(p){a(p)}};if(this.#o)return!0;const w=this.#e.get(r);this.#t&&this.#a(r,n,t,w,void 0);const m=w?w.slice():[];if(m.length===0)return!0;const v=()=>(u&&o===null&&(o="prevented"),u&&t&&typeof t=="object"&&(t.reason=o),!u),h=[];for(const p of m)try{const g=p(f);g&&typeof g.then=="function"?h.push(g):g===!1&&a("prevented")}catch(g){a("error"),L(`bus.beforeThrow:${r}:${O(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,g)}return h.length===0?v():Promise.allSettled(h).then(p=>{for(const g of p)g.status==="rejected"?(a("error"),L(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,g.reason)):g.value===!1&&a("prevented");return v()})}#c(r,t,i){for(let s=0;s<r.length;s++)try{r[s](t)}catch(n){L(`bus.throw:${i}:${O(r[s])}`,`a '${i}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#o=!0,this.#i=null}}}),Be("packages/core/src/registry/free-tier-notice.js",function(e,H){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return te}});const te="Free for non-commercial use: latticegrid.dev/free"}),Be("packages/core/src/registry/licence.js",function(e,H){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return R}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=H("packages/core/src/registry/free-tier-notice.js"),D=X.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return X.FREE_TIER_NOTICE}});const F="lattice-grid",Z=1,Y="LG1",B=64,z="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",P=(()=>{const x=new Int16Array(128).fill(-1);for(let A=0;A<G.length;A++)x[G.charCodeAt(A)]=A;return x[43]=62,x[47]=63,x})();function O(x){if(typeof x!="string")return null;let A="";for(let U=0;U<x.length;U++){const K=x.charCodeAt(U);if(K!==61){if(K>127||P[K]<0)return null;A+=x[U]}}const $=A.length;if($%4===1)return null;const I=new Uint8Array(Math.floor($*3/4));let M=0,S=0,E=0;for(let U=0;U<$;U++)M=M<<6|P[A.charCodeAt(U)],S+=6,S>=8&&(S-=8,I[E++]=M>>S&255);return E===I.length?I:I.subarray(0,E)}function b(x){let A="",$=0;for(;$+2<x.length;$+=3){const M=x[$]<<16|x[$+1]<<8|x[$+2];A+=G[M>>18&63]+G[M>>12&63]+G[M>>6&63]+G[M&63]}const I=x.length-$;if(I===1){const M=x[$]<<16;A+=G[M>>18&63]+G[M>>12&63]}else if(I===2){const M=x[$]<<16|x[$+1]<<8;A+=G[M>>18&63]+G[M>>12&63]+G[M>>6&63]}return A}function c(x){const A=new Uint8Array(x.length);for(let $=0;$<x.length;$++)A[$]=x.charCodeAt($)&127;return A}function d(x){if(typeof TextDecoder=="function")return new TextDecoder().decode(x);let A="";for(let $=0;$<x.length;$++)A+=String.fromCharCode(x[$]);return A}function l(x){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof x=="string"?x:""};if(typeof x!="string"||x.length===0)return{...A,reason:"missing"};const $=x.trim(),I=$.split(".");if(I.length!==3)return A;const[M,S,E]=I;if(M!==Y)return{...A,reason:"prefix"};const U=O(S),K=O(E);if(!U||!K)return A;let q;try{q=JSON.parse(d(U))}catch{return A}return q===null||typeof q!="object"?A:{ok:!0,reason:null,product:typeof q.p=="string"?q.p:null,issuedTo:typeof q.t=="string"?q.t:null,expires:typeof q.e=="string"?q.e:null,terms:typeof q.terms=="string"?q.terms:null,features:Array.isArray(q.f)?q.f.slice():[],deployments:Array.isArray(q.d)?q.d.slice():[],version:typeof q.v=="number"?q.v:0,message:c(S),signature:K,raw:$}}function r(x,A){if(!x)return!1;const $=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(x)?`${x}T23:59:59.999Z`:x);return Number.isNaN($)?!0:A>$}function t(x){return x==="non-commercial"?"non-commercial":"commercial"}let i=null,s=null,n=null;function u(){const x=globalThis.crypto;return x&&x.subtle?x.subtle:null}async function o(x){if(i&&s===x)return i;const A=u();if(!A)return null;const $=O(x);if(!$)return null;try{const I=await A.importKey("raw",$,{name:"Ed25519"},!1,["verify"]);return i=I,s=x,I}catch{return null}}async function a(){return n!==null||(n=await o(z)!==null),n}async function f(x,A={}){const $=A.warn!==!1,I=A.product||F,M=A.publicKey||z,S=A.now??Date.now(),E=A.host??m(),U=w(E)?"":` ${D}`,K=l(x);if(!K.ok){const ne=K.reason==="missing"?"missing":"malformed";return $&&L(`licence.${ne}`,ne==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${U}`:`licence key could not be read. The grid will render with a watermark.${U}`),{valid:!1,reason:ne,terms:"commercial"}}const q={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0,terms:t(K.terms)};if(K.product!==I)return $&&L("licence.product",`licence key is for '${K.product}', not '${I}'. The grid will render with a watermark.`),{valid:!1,...q,reason:"product"};if(r(K.expires,S))return $&&L("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...q,reason:"expired"};const _=K.deployments||[];if(_.length&&E&&!w(E)&&!v(E,_))return $&&L("licence.domain",`licence key is not valid for ${E}; it covers ${_.join(", ")}. The grid will render with a watermark.`),{valid:!1,...q,reason:"domain"};const J=await o(M);if(!J){const ne=!!K.signature&&K.signature.length===B;return $&&L("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ne?{valid:!0,...q,reason:"unverified"}:{valid:!1,...q,reason:"signature"}}let ee=!1;try{ee=await u().verify({name:"Ed25519"},J,K.signature,K.message)}catch{ee=!1}return ee?{valid:!0,...q}:($&&L("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...q,reason:"signature"})}function w(x){const A=String(x??m()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function m(){const x=globalThis.location;return x&&typeof x.hostname=="string"?x.hostname:null}function v(x,A){const $=h(x);return!$||!Array.isArray(A)?!1:A.some(I=>{const M=h(I);if(!M)return!1;if(M==="*")return!0;if(M.startsWith("*.")){const S=M.slice(2);return $===S||$.endsWith(`.${S}`)}return $===M})}function h(x){return String(x??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(A={}){this.#s=A}set(A){this.#e=typeof A=="string"?A.trim():"";const $=l(this.#e);return this.#t=$.ok?{valid:!r($.expires,Date.now())&&$.product===(this.#s.product||F),product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0,terms:t($.terms),reason:"pending"}:{valid:!1,reason:$.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=f(A,this.#s).then($=>{if(this.#e===A){this.#t=$;for(const I of this.#i)I($)}return $}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!w(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":w(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const g=Symbol.for("lattice-grid/licence/holder");function k(){const x=globalThis,A=x&&x[g];if(A&&typeof A.set=="function"&&typeof A.watermark=="function")return A;const $=new p;if(x)try{x[g]=$}catch{}return $}const y=k();function T(x){return y.set(x)}function j(){return y.info()}function N(){return y.watermark()}function W(){return y.state()}function R(){return y}}),Be("packages/core/src/registry/registry.js",function(e,H){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return i}});const te=H("packages/core/src/internal/warn.js"),L=te.warnOnce,X=te.DEV,F=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/registry/licence.js"),Y=Z.LicenceHolder,B=Z.sharedLicence,z=["renderer","editor","filter","dataType","totalFn","pipe","component"],G=["all","header","body","totals","panels"];class P{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#o=null;#l=new Set;#a=new Map;constructor(n={}){for(const u of z)this.#t.set(u,new Map);this.#s=n.holder||B(),this.#o=n.grid??null,this.#i=this.#s.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,u={}){u.licence&&this.setLicence(u.licence),u.grid!==void 0&&(this.#o=u.grid);const o=Array.isArray(n)?n:[n],a=[];for(const f of o){if(!f||typeof f!="object"||typeof f.name!="string"||!f.name){L("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(f.name)){X&&this.#u(this.#e.get(f.name),f);continue}if(!F(f.install)){L(`registry.module.install:${f.name}`,`module '${f.name}' has no install() and was ignored.`);continue}const w={registry:this,grid:this.#o};try{f.install(w)}catch(m){L(`registry.module.throw:${f.name}`,`module '${f.name}' threw during install; it was not registered.`,m);continue}this.#e.set(f.name,f);for(const m of O(f))this.#n.add(m);a.push(f.name),this.#f({reason:"module",name:f.name,capabilities:this.capabilities(),regions:d(f)})}return a}unregisterModule(n){const u=this.#e.get(n);if(!u)return!1;if(F(u.uninstall))try{u.uninstall({registry:this,grid:this.#o})}catch(o){L(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,o)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:d(u)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const u of O(n))this.#n.add(u)}#u(n,u){!n||n===u||b(n,u)||L(`registry.module.reconfigure:${u.name}`,`module '${u.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return F(n)?(this.#r.add(n),this.#a.set(n,this.#o),()=>{this.#r.delete(n),this.#a.delete(n)}):()=>{}}#f(n){for(const u of[...this.#r])try{u(n)}catch(o){L("registry.onChange.throw","a registry change handler threw.",o)}}register(n,u,o){const a=this.#t.get(n);if(!a){L(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${z.join(", ")}.`);return}if(!u||typeof u!="string"){L(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}a.has(u)&&a.get(u)!==o&&L(`registry.replace:${n}:${u}`,`'${u}' was already registered as a ${n} and has been replaced.`),a.set(u,o),this.#f({reason:"register",name:u,kind:n,capabilities:this.capabilities(),regions:l(n)})}registerAll(n,u){if(u)for(const o of Object.keys(u))this.register(n,o,u[o])}get(n,u){const o=this.#t.get(n);return o?o.get(u):void 0}names(n){const u=this.#t.get(n);return u?[...u.keys()]:[]}#d(n,u){const o=this.#t.get(n).get(u);return o!==void 0?o:this.#t.get("component").get(u)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#s.set(n)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#o=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[u,o]of[...this.#a])o===n&&(this.#r.delete(u),this.#a.delete(u));if(this.#o===n){const u=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=u}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const u of[...this.#e.keys()])this.unregisterModule(u);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#o=null}}function O(s){const n=s.capabilities,u=Array.isArray(n)?n.filter(o=>typeof o=="string"):[];return[s.name,...u]}function b(s,n){return s.install!==n.install||s.uninstall!==n.uninstall||(s.version||"")!==(n.version||"")?!1:c(O(s),O(n))&&c(d(s),d(n))}function c(s,n){const u=new Set(s),o=new Set(n);if(u.size!==o.size)return!1;for(const a of u)if(!o.has(a))return!1;return!0}function d(s){const n=s.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(u=>G.includes(u))}function l(s){switch(s){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new P;function t(){return r}function i(s,n={}){return r.registerModules(s,n)}}),Be("packages/core/src/internal/text.js",function(e,H){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return D}});function te(F){return F?(F.includes(".")?F.slice(F.lastIndexOf(".")+1):F).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,Y=>Y.toUpperCase()):""}const L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function X(F){const Z=F==null?"":String(F);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,Y=>L[Y]):Z}function D(F){return String(F).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),Be("packages/core/src/format/number.js",function(e,H){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return X}});const L=H("packages/core/src/internal/predicates.js").isNil;function X(D,F){const Z=D||{},Y=Z.locale||F||void 0,B=Z.style||"decimal",z=typeof Z.scale=="number"?Z.scale:1,G=Z.nullDisplay??"",P=Z.zeroDisplay,O=Z.prefix||"",b=Z.suffix||"",c=Z.negative||"minus",d=Z.signed===!0,l={style:B,notation:Z.notation||"standard"};B==="currency"&&(l.currency=Z.currency||"USD",Z.currencyDisplay&&(l.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(l.minimumFractionDigits=Z.decimals,l.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(l.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(l.maximumFractionDigits=Z.maxDecimals),l.minimumFractionDigits>(l.maximumFractionDigits??20)&&(l.maximumFractionDigits=l.minimumFractionDigits)),Z.thousandsSeparator===!1&&(l.useGrouping=!1),l.notation==="compact"&&(l.compactDisplay=Z.compactDisplay||"short");const r=new Intl.NumberFormat(Y,l),t=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,i=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let s=",",n=".";if(t||i)for(const m of r.formatToParts(12345.6))m.type==="group"?s=m.value:m.type==="decimal"&&(n=m.value);const u=m=>{let v=m;return t&&(v=v.split(s).join("")),i&&(v=v.split(n).join("")),t&&(v=v.split("").join(t)),i&&(v=v.split("").join(i)),v},o=!!(t||i),a=O!==""&&B==="currency",f=m=>{let v;if(a){const h=r.formatToParts(m);let p=!1;v="";for(const g of h)v+=g.value,!p&&g.type==="currency"&&(v+=O,p=!0);p||(v=O+v)}else v=O+r.format(m);return o&&(v=u(v)),v+b},w=m=>{if(L(m)||m==="")return G;const v=typeof m=="number"?m:Number(m);if(Number.isNaN(v))return G;const h=z===1?v:v*z;return h===0&&P!==void 0?P:h<0?c==="parentheses"?`(${f(-h)})`:c==="suffix"?`${f(-h)}-`:f(h):d&&h>0?`+${f(h)}`:f(h)};return w.negativeClass=Z.negativeClass||null,w.spec=Z,w}}),Be("packages/core/src/format/date.js",function(e,H){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(i){const s=[];let n=0,u="";const o=()=>{u&&(s.push({token:null,text:u}),u="")};for(;n<i.length;){const a=i[n];if(a==="'"){if(i[n+1]==="'"){u+="'",n+=2;continue}const w=i.indexOf("'",n+1);if(w===-1){u+=i.slice(n+1),n=i.length;continue}u+=i.slice(n+1,w),n=w+1;continue}const f=F.find(w=>i.startsWith(w,n));if(f){o(),s.push({token:f,text:f}),n+=f.length;continue}/[A-Za-z]/.test(a)&&D(`date.pattern.token:${a}`,`the date pattern "${i}" contains '${a}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),u+=a,n+=1}return o(),s}const Y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function B(i){if(L(i)||i==="")return null;if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isNaN(i)?null:new Date(i);if(typeof i=="string"){const s=Y.exec(i.trim());if(s){const[,u,o,a,f="0",w="0",m="0"]=s;return new Date(+u,+o-1,+a,+f,+w,+m)}const n=new Date(i);return Number.isNaN(n.getTime())?null:n}return null}function z(i,s){return String(i).padStart(s,"0")}function G(i){if(!i)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const s=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const o={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const a of s.formatToParts(u))switch(a.type){case"year":o.year=Number(a.value);break;case"month":o.month=Number(a.value);break;case"day":o.day=Number(a.value);break;case"hour":o.hour=Number(a.value)%24;break;case"minute":o.minute=Number(a.value);break;case"second":o.second=Number(a.value);break;case"weekday":o.weekday=n[a.value]??0;break;default:break}return o}}function P(i,s,n){const u=Z(i),o=G(n),a=new Set(u.filter(h=>h.token).map(h=>h.token)),f=a.has("MMM")?new Intl.DateTimeFormat(s,{month:"short",timeZone:n}):null,w=a.has("MMMM")?new Intl.DateTimeFormat(s,{month:"long",timeZone:n}):null,m=a.has("EEE")?new Intl.DateTimeFormat(s,{weekday:"short",timeZone:n}):null,v=a.has("EEEE")?new Intl.DateTimeFormat(s,{weekday:"long",timeZone:n}):null;return h=>{const p=o(h);let g="";for(const k of u){if(!k.token){g+=k.text;continue}switch(k.token){case"yyyy":g+=z(p.year,4);break;case"yy":g+=z(p.year%100,2);break;case"MMMM":g+=w.format(h);break;case"MMM":g+=f.format(h);break;case"MM":g+=z(p.month,2);break;case"M":g+=String(p.month);break;case"dd":g+=z(p.day,2);break;case"d":g+=String(p.day);break;case"EEEE":g+=v.format(h);break;case"EEE":g+=m.format(h);break;case"HH":g+=z(p.hour,2);break;case"H":g+=String(p.hour);break;case"hh":g+=z(p.hour%12===0?12:p.hour%12,2);break;case"h":g+=String(p.hour%12===0?12:p.hour%12);break;case"mm":g+=z(p.minute,2);break;case"m":g+=String(p.minute);break;case"ss":g+=z(p.second,2);break;case"s":g+=String(p.second);break;case"SSS":g+=z(p.ms,3);break;case"a":g+=p.hour<12?"AM":"PM";break;default:g+=k.text;break}}return g}}const O=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(i,s){const n=i||{},u=n.locale||s||void 0,o=n.nullDisplay??"",a=n.timeZone;let f;if(n.pattern)f=P(n.pattern,u,a);else if(n.dateStyle||n.timeStyle){const p={timeZone:a};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const g=new Intl.DateTimeFormat(u,p);f=k=>g.format(k)}else{const p=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:a});f=g=>p.format(g)}const w=n.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,v=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,h=(p,g)=>{const k=B(p);if(!k)return o;if(w){const y=g&&typeof g.now=="number"?g.now:Date.now(),T=k.getTime()-y;if(Math.abs(T)<v){for(const[j,N]of O)if(Math.abs(T)>=N||j==="second")return w.format(Math.round(T/N),j)}}return f(k)};return h.spec=n,h}function c(i){if(L(i)||i==="")return null;if(typeof i=="string"){const u=/^(\d{4}-\d{2}-\d{2})/.exec(i.trim());if(u)return u[1];const o=B(i);return o?c(o):null}const s=B(i);if(!s)return null;const n=u=>String(u).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}`}function d(i,s){if(L(i)||i==="")return null;if(typeof i=="string"){const u=i.trim();if(l.test(u)){const f=B(u);return f?r(f,s):null}const o=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(u);if(o){const[,f,w,m,v]=o;return`${f}T${w}:${m}${v&&v!=="00"?`:${v}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(u))return`${u}T00:00`;const a=B(u);return a?d(a):null}const n=B(i);return n?r(n,s):null}const l=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(i,s){const n=f=>String(f).padStart(2,"0");if(s)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(i).reduce((v,h)=>(h.type!=="literal"&&(v[h.type]=h.value),v),{}),w=f.hour==="24"?"00":f.hour,m=Number(f.second);return`${f.year}-${f.month}-${f.day}T${w}:${f.minute}`+(m?`:${f.second}`:"")}catch{}const u=`${i.getFullYear()}-${n(i.getMonth()+1)}-${n(i.getDate())}`,o=i.getSeconds(),a=`${n(i.getHours())}:${n(i.getMinutes())}${o?`:${n(o)}`:""}`;return`${u}T${a}`}function t(i,s){const n=L(i)||i===""?null:String(i),u=L(s)||s===""?null:String(s);return n===null?u===null?0:1:u===null||n<u?-1:n>u?1:0}}),Be("packages/core/src/format/boolean.js",function(e,H){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isNil,X={true:"☑",false:"☐",null:""},D={true:"◉",false:"◯",null:""};function F(Y){if(L(Y)||Y==="")return null;if(typeof Y=="boolean")return Y;if(typeof Y=="number")return Y!==0;const B=String(Y).trim().toLowerCase();return B==="true"||B==="yes"||B==="y"||B==="1"?!0:B==="false"||B==="no"||B==="n"||B==="0"?!1:null}function Z(Y,B){const z=Y||{},G=z.display||"text",P=z.trueLabel??"Yes",O=z.falseLabel??"No",b=z.nullLabel??"";let c=P,d=O;const l=b;G==="checkbox"?(c=X.true,d=X.false):G==="switch"?(c=D.true,d=D.false):G==="icon"&&(c=z.trueIcon??P,d=z.falseIcon??O);const r=t=>{const i=F(t);return i===null?l:i?c:d};return r.display=G,r.labels={true:P,false:O,null:b},r.locale=B,r.spec=z,r}}),Be("packages/core/src/format/text.js",function(e,H){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/text.js").titleCase;function F(Z,Y){const B=Z||{},z=B.locale||Y||void 0,G=B.nullDisplay??"",P=B.emptyDisplay??"",O=B.transform||"none",b=typeof B.truncate=="number"?{chars:B.truncate}:B.truncate||null,c=b?b.chars:0,d=b?b.ellipsis??"…":"",l=t=>{switch(O){case"upper":return z?t.toLocaleUpperCase(z):t.toUpperCase();case"lower":return z?t.toLocaleLowerCase(z):t.toLowerCase();case"title":return D(t);default:return t}},r=t=>{if(L(t))return G;let i=typeof t=="string"?t:String(t);return i===""?P:(O!=="none"&&(i=l(i)),c>0&&i.length>c&&(i=i.slice(0,c)+d),i)};return r.spec=B,r}}),Be("packages/core/src/format/mask.js",function(e,H){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const te=new Set(["0","#","?",",","."]),L="\0";function X(B){const z=[];let G="",P=!1;for(let O=0;O<B.length;O++){const b=B[O];if(b==="\\"){G+=b+(B[O+1]??""),O+=1;continue}if(b==='"'){P=!P,G+=b;continue}if(b===";"&&!P){z.push(G),G="";continue}G+=b}return z.push(G),z}function D(B){let z="",G="",P="",O=1,b=!1,c=!1;const d=a=>{c?G+=a:z+=a};for(let a=0;a<B.length;a++){const f=B[a];if(f==="\\"){d(B[a+1]??""),a+=1;continue}if(f==='"'){const w=B.indexOf('"',a+1);d(w===-1?B.slice(a+1):B.slice(a+1,w)),a=w===-1?B.length:w;continue}if(f==="%"){O*=100,d("%");continue}if(f==="@"){b=!0,d("\0");continue}if(te.has(f)){P+=f,c=!0;continue}d(f)}let l=-1;for(let a=P.length-1;a>=0;a--){const f=P[a];if(f==="0"||f==="#"||f==="?"){l=a;break}}let r=!1,t="";for(let a=0;a<P.length;a++){const f=P[a];if(f===","){a>l?O/=1e3:r=!0;continue}t+=f}const i=t.indexOf("."),s=i===-1?t:t.slice(0,i),n=i===-1?"":t.slice(i+1);let u=0;for(const a of s)a==="0"&&(u+=1);let o=0;for(const a of n)a==="0"&&(o+=1);return{prefix:z,suffix:G,minInt:u,minDec:o,maxDec:n.length,grouping:r,scale:O,hasNumber:l!==-1,isText:b}}function F(B,z){const G=new Intl.NumberFormat(z,{minimumIntegerDigits:Math.max(B.minInt,1),minimumFractionDigits:B.minDec,maximumFractionDigits:Math.max(B.maxDec,B.minDec),useGrouping:B.grouping}),{prefix:P,suffix:O,scale:b,hasNumber:c}=B;return d=>{if(!c)return P+O;const l=b===1?d:d*b;return P+G.format(l)+O}}function Z(B,z){const P=X(String(B)).map(D),O=P.map(t=>F(t,z)),b=0,c=P.length>1?1:-1,d=P.length>2?2:-1,l=P.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const i=Number(t);if(Number.isNaN(i))return l===-1?String(t):(P[l].prefix+P[l].suffix).split("\0").join(String(t));t=i}return t===0&&d!==-1?O[d](0):t<0&&c!==-1?O[c](-t):O[b](t)};return r.spec={mask:B},{format:r,ooxml:Y(String(B))}}function Y(B){return B.trim()}}),Be("packages/core/src/format/shorthand.js",function(e,H){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return Y}});const te=["currency","number","percent","date","boolean","text","relative"],L=/[#0?@;"\\]/,X=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function D(B){return typeof B!="string"||B===""||Z(B)?!1:L.test(B)}function F(B){return typeof B!="string"||B===""||Z(B)?!1:X.test(B)}function Z(B){const z=B.indexOf(":"),G=z===-1?B:B.slice(0,z);return te.includes(G)?G:null}function Y(B){const z=Z(B);if(!z)return null;const G=B.indexOf(":"),P=G===-1?"":B.slice(G+1),O=P===""?[]:P.split(":");switch(z){case"currency":{const b={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(b.decimals=Number(O[1])),b}case"number":{const b={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"percent":{const b={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"date":return{type:"date",pattern:P||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=P.split("/"),c={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(c.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(c.falseLabel=b[1]),b[2]!==void 0&&(c.nullLabel=b[2]),c}case"text":{const b={type:"text"};return O[0]&&(b.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(b.truncate=Number(O[1])),b}default:return null}}}),Be("packages/core/src/format/index.js",function(e,H){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return g}});const te=H("packages/core/src/internal/predicates.js"),L=te.isFunction,X=te.isObject,F=H("packages/core/src/internal/warn.js").warnOnce,Z=H("packages/core/src/format/number.js"),Y=Z.compileNumber,B=H("packages/core/src/format/date.js"),z=B.compileDate,G=B.scanPattern,P=H("packages/core/src/format/boolean.js"),O=P.compileBoolean,b=H("packages/core/src/format/text.js"),c=b.compileText,d=H("packages/core/src/format/mask.js"),l=d.compileMask,r=H("packages/core/src/format/shorthand.js"),t=r.parseShorthand,i=r.looksLikeMask,s=r.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return Z.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return B.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return B.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return B.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return B.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return P.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return P.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return d.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return d.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return d.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const n=new Set(["decimal","currency","percent","unit"]),u=new Set(["type","locale"]),o={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},a=new Set(["number","date","boolean","text"]);function f(j,N){const W=j.type;if(W===void 0||a.has(W)||!n.has(String(W)))return;const R=N?`"${N}"`:"with no id";F(`format:unknown-style-key:${N||""}:${W}`,`column ${R} has format: { type: "${W}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${W}" instead?`)}function w(j,N,W){const R=o[N],x=W?`"${W}"`:"with no id";for(const A of j){if(u.has(A)||R.has(A))continue;const $=Object.keys(o).find(I=>I!==N&&o[I].has(A));$?F(`format:inapplicable:${W||""}:${A}`,`column ${x} has format key "${A}", which applies to a ${$} column, not the ${N} column it was applied to; it is ignored.`):F(`format:unknown:${W||""}:${A}`,`column ${x} has an unrecognised format key "${A}" for its ${N} format; it is ignored.`)}}function m(j){if(j.type==="number"||j.type==="date"||j.type==="boolean"||j.type==="text")return!0;const N=n.has(String(j.style));return!!(j.pattern||j.dateStyle||j.timeStyle||j.relative||j.timeZone||j.trueLabel||j.falseLabel||j.display||j.trueIcon||j.falseIcon||j.transform||j.truncate||j.emptyDisplay||N||j.currency||j.decimals!==void 0||j.minDecimals!==void 0||j.maxDecimals!==void 0||j.notation||j.negative||j.scale!==void 0||j.prefix||j.suffix||j.zeroDisplay!==void 0)}function v(j,N){if(j.type==="number"||j.type==="date"||j.type==="boolean"||j.type==="text")return j.type;if(j.pattern||j.dateStyle||j.timeStyle||j.relative||j.timeZone)return"date";if(j.trueLabel||j.falseLabel||j.display||j.trueIcon||j.falseIcon)return"boolean";if(j.transform||j.truncate||j.emptyDisplay)return"text";if(j.style||j.currency||j.decimals!==void 0||j.minDecimals!==void 0||j.maxDecimals!==void 0||j.notation||j.negative||j.scale!==void 0||j.prefix||j.suffix||j.zeroDisplay!==void 0)return"number";const W=N&&N.base;return W==="number"?"number":W==="date"||W==="dateString"?"date":W==="boolean"?"boolean":"text"}function h(j,N=null,W=void 0,R=void 0,x=void 0){if(j==null||j==="")return null;const A=X(j)?Object.keys(j):null;if(typeof j=="function"){const M=(S,E)=>String(j({...E||{},value:S,locale:W})??"");return M.ooxml=N&&N.excel||"General",M}if(typeof j=="string"){if(i(j)){const{format:S,ooxml:E}=l(j,W);return S.ooxml=E,S}const M=t(j)||(s(j)?{type:"date",pattern:j}:null);return M?h(M,N,W,R,x):(F(`format:${j}`,`unrecognised format string "${j}"; the value will be stringified`),null)}if(!X(j))return F("format:shape","format must be a spec object or a string; ignoring",j),null;if(N&&L(N.format)&&!m(j)||N&&L(N.format)&&Array.isArray(N.formatPatterns)&&j.type===void 0)return null;const $=v(j,N);$==="date"&&R&&j.timeZone===void 0&&(j={...j,timeZone:R}),f(j,x),w(A||Object.keys(j),$,x);let I;switch($){case"number":I=Y(j,W);break;case"date":I=z(j,W);break;case"boolean":I=O(j,W);break;default:I=c(j,W);break}return I.ooxml=g(j,$,W,N),I.kind=$,I}const p={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function g(j,N,W=void 0,R=null){if(N==="date"){if(j.pattern){let M="";for(const S of G(j.pattern))M+=S.token?p[S.token]??S.text:S.text;return M}return R&&R.excel||"yyyy-mm-dd"}if(N==="boolean")return"General";if(N==="text")return"@";if(j.notation==="compact"||j.notation==="scientific")return"General";const x=typeof j.decimals=="number"?j.decimals:typeof j.minDecimals=="number"?j.minDecimals:j.style==="currency"?2:0;let $=`${j.thousandsSeparator===!1?"":"#,#"}#0${x>0?`.${"0".repeat(x)}`:""}`,I="";return j.style==="currency"&&(I+=k(T(j.currency||"USD",W))),j.prefix&&(I+=k(j.prefix)),$=I+$,j.style==="percent"&&($=`${$}%`),j.suffix&&($+=k(j.suffix)),j.negative==="parentheses"?`${$};(${$})`:j.negative==="suffix"?`${$};${$}-`:$}function k(j){return`"${String(j).split('"').join("")}"`}const y=new Map;function T(j,N){const W=`${j}|${N||""}`;let R=y.get(W);if(R!==void 0)return R;R=j;try{const A=new Intl.NumberFormat(N,{style:"currency",currency:j}).formatToParts(0).find($=>$.type==="currency");A&&(R=A.value)}catch{}return y.set(W,R),R}}),Be("packages/core/src/columns/types/temporal.js",function(e,H){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ie}});const te=H("packages/core/src/internal/predicates.js"),L=te.isNil,X=te.isFunction,D=H("packages/core/src/format/date.js"),F=D.toDate,Z=D.compilePattern,Y=D.compileDate,B=D.toIsoDateTime,z=D.compareIso,G=864e5,P=Object.freeze({}),O=1e3,b=60*O,c=60*b,d=24*c,l=7*d,r=new WeakMap;function t(we,Fe){const He=we&&we.locale||"",Ke=we&&we.column;if(!Ke)return He?{locale:He}:P;const nt=r.get(Ke);if(nt&&nt.locale===He)return nt.bag;const it=Ke.typeOptions||Ke[Fe]||(i(Ke.format)?Ke.format:null),mt={...it||P,locale:it&&it.locale||He||void 0};return r.set(Ke,{locale:He,bag:mt}),mt}function i(we){return we!==null&&typeof we=="object"&&!Array.isArray(we)&&!(we instanceof Date)}function s(we,Fe){const He=we===null||Number.isNaN(we)?null:we,Ke=Fe===null||Number.isNaN(Fe)?null:Fe;return He===null?Ke===null?0:1:Ke===null||He<Ke?-1:He>Ke?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function o(we,Fe,He,Ke){return!(we>=0&&we<=23)||!(Fe>=0&&Fe<=59)||!(He>=0&&He<=59)||!(Ke>=0&&Ke<=999)?null:we*c+Fe*b+He*O+Ke}function a(we){if(L(we))return null;const Fe=String(we).trim();if(Fe==="")return null;const He=u.exec(Fe);if(He){const Pt=He[1];if(Pt.length===5)return null;const Nt=Pt.length===3?1:2;return o(Number(Pt.slice(0,Nt)),Number(Pt.slice(Nt,Nt+2)),Number(Pt.slice(Nt+2,Nt+4)||0),0)}const Ke=n.exec(Fe);if(!Ke)return null;let nt=Number(Ke[1]);const it=Number(Ke[2]||0),mt=Number(Ke[3]||0),kt=Ke[4]?Number(Ke[4].padEnd(3,"0")):0,St=Ke[5]?Ke[5][0].toLowerCase():null;if(St){if(nt<1||nt>12)return null;nt=nt%12,St==="p"&&(nt+=12)}return o(nt,it,mt,kt)}function f(we){return L(we)||we===""?null:typeof we=="number"?Number.isFinite(we)?(we%d+d)%d:null:we instanceof Date?Number.isNaN(we.getTime())?null:we.getHours()*c+we.getMinutes()*b+we.getSeconds()*O+we.getMilliseconds():a(we)}const w=new Map;function m(we){const Fe=we.pattern||"",He=we.timeStyle||(we.seconds?"medium":"short"),Ke=`${we.locale||""}|${Fe}|${He}`;let nt=w.get(Ke);if(nt)return nt;if(Fe)nt=Z(Fe,we.locale||void 0,"UTC");else{const it=new Intl.DateTimeFormat(we.locale||void 0,{timeStyle:He,timeZone:"UTC"});nt=mt=>it.format(mt)}return w.set(Ke,nt),nt}function v(we,Fe){const He=Fe||P;if(we==null||typeof we!="number"||!Number.isFinite(we))return He.nullDisplay??"";const Ke=(we%d+d)%d;return m(He)(new Date(Ke))}function h(we){return we instanceof Date?!Number.isNaN(we.getTime()):typeof we=="number"?Number.isFinite(we)&&we>=0&&we<d:typeof we!="string"||!we.includes(":")?!1:a(we)!==null}function p(we){const Fe=f(we);return Fe==null?"":v(Fe,{pattern:Fe%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const g=new Map;function k(we){const Fe=we||"";let He=g.get(Fe);return He||(He=new Intl.DateTimeFormat("en-GB",{timeZone:we||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),g.set(Fe,He)),He}function y(we,Fe){const He={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ke of k(Fe).formatToParts(new Date(we)))Ke.type==="year"?He.year=Number(Ke.value):Ke.type==="month"?He.month=Number(Ke.value):Ke.type==="day"?He.day=Number(Ke.value):Ke.type==="hour"?He.hour=Number(Ke.value)%24:Ke.type==="minute"?He.minute=Number(Ke.value):Ke.type==="second"&&(He.second=Number(Ke.value));return He}function T(we,Fe){const He=y(we,Fe);return Date.UTC(He.year,He.month-1,He.day,He.hour,He.minute,He.second,0)-Math.floor(we/1e3)*1e3}function j(we,Fe){const He=we.hour||0,Ke=we.minute||0,nt=we.second||0,it=we.ms||0;if(!Fe)return new Date(we.year,we.month-1,we.day,He,Ke,nt,it).getTime();const mt=Date.UTC(we.year,we.month-1,we.day,He,Ke,nt,it);let kt=mt-T(mt,Fe);return kt=mt-T(kt,Fe),kt}const N=/(?:Z|[+-]\d{2}:?\d{2})$/i,W=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function R(we,Fe){if(L(we))return null;const He=String(we).trim();if(He==="")return null;const Ke=Fe&&Fe.timeZone||void 0;if(!N.test(He)){const nt=W.exec(He);if(nt){const it=(nt[4]||"").trim(),mt=it===""?0:a(it);if(mt===null)return null;const kt=j({year:Number(nt[1]),month:Number(nt[2]),day:Number(nt[3]),hour:Math.floor(mt/c),minute:Math.floor(mt/b)%60,second:Math.floor(mt/O)%60,ms:mt%O},Ke);return Number.isNaN(kt)?null:new Date(kt)}}return F(He)}function x(we){if(typeof we=="number")return Number.isFinite(we)?we:null;const Fe=F(we);return Fe?Fe.getTime():null}const A=new Map;function $(we){const Fe=[we.locale||"",we.pattern||"",we.dateStyle||"",we.timeStyle||"",we.timeZone||"",we.seconds?"1":""].join("|");let He=A.get(Fe);if(He)return He;const Ke=we.pattern?{type:"date",pattern:we.pattern,timeZone:we.timeZone}:{type:"date",dateStyle:we.dateStyle||"medium",timeStyle:we.timeStyle||(we.seconds?"medium":"short"),timeZone:we.timeZone};return He=Y(Ke,we.locale||void 0),A.set(Fe,He),He}function I(we,Fe){const He=Fe||P,Ke=x(we);return Ke==null?He.nullDisplay??"":$(He)(Ke)}function M(we){return we instanceof Date?!Number.isNaN(we.getTime()):typeof we!="string"||!W.test(we.trim())?!1:R(we)!==null}const S=Object.freeze([{key:"w",ms:l,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:c,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),E=new Map;for(const we of S)for(const Fe of we.names)E.set(Fe,we);const U=Object.freeze(S.filter(we=>we.key!=="w")),K=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,q=/^\d+(?:\.\d+)?$/,_=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(we){const Fe=we&&we.defaultUnit?E.get(String(we.defaultUnit).toLowerCase()):null;return Fe?Fe.ms:b}function ee(we){return(we&&we.defaultUnit?E.get(String(we.defaultUnit).toLowerCase()):null)||E.get("m")}function ne(we,Fe){if(L(we))return null;let He=String(we).trim().toLowerCase();if(He==="")return null;let Ke=1;if(He[0]==="-"?(Ke=-1,He=He.slice(1).trim()):He[0]==="+"&&(He=He.slice(1).trim()),He==="")return null;const nt=_.exec(He);if(nt){const St=nt[3]!==void 0,Pt=Number(nt[1])*c+Number(nt[2])*b+(St?Number(nt[3])*O:0)+(nt[4]?Number(nt[4].padEnd(3,"0")):0);return Ke*Pt}if(q.test(He))return Math.round(Ke*Number(He)*J(Fe||P));let it=He,mt=0,kt=0;for(;it!=="";){const St=K.exec(it);if(!St)return null;const Pt=E.get(St[2]);if(!Pt)return null;mt+=Number(St[1])*Pt.ms,it=it.slice(St[0].length),kt++}return kt===0?null:Math.round(Ke*mt)}function oe(we){return L(we)||we===""?null:typeof we=="number"?Number.isFinite(we)?we:null:ne(we)}const ie=new Map;function ae(we,Fe,He){const Ke=`${He||""}|${Fe.intl}`;let nt=ie.get(Ke);if(nt===void 0){try{nt=new Intl.NumberFormat(He||void 0,{style:"unit",unit:Fe.intl,unitDisplay:"long"})}catch{nt=null}ie.set(Ke,nt)}return nt?nt.format(we):`${we} ${we===1?Fe.long[0]:Fe.long[1]}`}function ce(we,Fe){return String(we).padStart(Fe,"0")}function de(we,Fe){const He=Fe||P;if(we==null||typeof we!="number"||!Number.isFinite(we))return He.nullDisplay??"";const Ke=He.style||"short",nt=we<0;let it=Math.round(Math.abs(we));const mt=nt?"-":"";if(it===0&&He.zeroDisplay!=null)return He.zeroDisplay;if(Ke==="clock"){const Nt=Math.floor(it/c),Ft=Math.floor(it/b)%60,Lt=Math.floor(it/O)%60;return`${mt}${ce(Nt,2)}:${ce(Ft,2)}:${ce(Lt,2)}`}if(it===0){const Nt=ee(He);return Ke==="long"?ae(0,Nt,He.locale):`0${Nt.key}`}const kt=He.weeks===!0?S:U,St=typeof He.maxUnits=="number"&&He.maxUnits>0?He.maxUnits:He.maxUnits===void 0?2:1/0,Pt=[];for(const Nt of kt){if(Pt.length>=St)break;const Ft=Math.floor(it/Nt.ms);Ft!==0&&(it-=Ft*Nt.ms,Pt.push(Ke==="long"?ae(Ft,Nt,He.locale):`${Ft}${Nt.key}`))}return mt+Pt.join(" ")}function Ae(we){if(typeof we!="string")return!1;const Fe=we.trim();return Fe===""||_.test(Fe)||!/[a-z]/i.test(Fe)?!1:ne(Fe)!==null}const je=Date.UTC(1899,11,30),be=new Map;function re(we,Fe){const He=we||"";let Ke=be.get(He);Ke||(Ke=new Intl.DateTimeFormat("en-GB",{timeZone:we||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),be.set(He,Ke));const nt=typeof Fe=="number"?Fe:Date.now();for(const it of Ke.formatToParts(new Date(nt)))if(it.type==="timeZoneName")return it.value;return""}function fe(we){if(we)return we;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function pe(we,Fe){const He=fe(we),Ke=re(we,Fe);return Ke?`${He} (${Ke})`:He}function Oe(we,Fe){if(we&&we.timeZone)return we.timeZone;const He=Fe&&Fe.grid;return(He&&X(He.get)?He.get("timeZone"):void 0)||void 0}function ve(we,Fe){const He=Fe||P,Ke=x(we);if(Ke==null)return He.nullDisplay??"";const nt=$(He)(Ke);if(!He.showOrigin)return nt;const it=He.originZone;return it?it===(He.timeZone||fe(He.timeZone))?nt:`${nt} (${pe(it,Ke)})`:`${nt} (no origin recorded)`}function $e(we,Fe,He,Ke){if(Fe==="instant"||!Fe)return we;const nt=y(we,He);if(Fe==="month")return j({year:nt.year,month:nt.month,day:1},He);if(Fe==="week"){const it=Ke>=1&&Ke<=7?Ke:1,kt=((new Date(Date.UTC(nt.year,nt.month-1,nt.day)).getUTCDay()+6)%7+1-it+7)%7,St=new Date(Date.UTC(nt.year,nt.month-1,nt.day-kt));return j({year:St.getUTCFullYear(),month:St.getUTCMonth()+1,day:St.getUTCDate()},He)}return j({year:nt.year,month:nt.month,day:nt.day},He)}function he(we,Fe){const He=we&&we.group,Ke=He&&He.granularity||"day";if(Ke==="instant")return null;const nt=He&&He.weekStart;return it=>typeof it=="number"?$e(it,Ke,Fe,nt):it}const ye={time:{base:"number",storage:"float64",matches:h,format:we=>v(f(we.value),t(we,"time")),parse:we=>a(we.text),compare:(we,Fe)=>s(f(we),f(Fe)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:we=>{const Fe=f(we);return Fe===null?null:Fe/G},toStorage:we=>f(we),toClipboard:p,fromClipboard:a},datetime:{base:"dateString",storage:"dictionary",matches:M,format:we=>I(we.value,t(we,"datetime")),parse:we=>B(R(we.text,t(we,"datetime"))??we.text),compare:z,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(we,Fe)=>B(we,Fe&&Fe.timeZone),toClipboard:we=>L(we)?"":String(we),fromClipboard:we=>B(we)},duration:{base:"number",storage:"float64",matches:Ae,format:we=>de(oe(we.value),t(we,"duration")),parse:we=>ne(we.text,t(we,"duration")),compare:(we,Fe)=>s(oe(we),oe(Fe)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:we=>{const Fe=oe(we);return Fe===null?null:Fe/G},toStorage:we=>oe(we),toClipboard:we=>de(oe(we),{style:"short",maxUnits:-1}),fromClipboard:we=>ne(we)},timestamp:{base:"number",storage:"float64",format:we=>{const Fe=t(we,"timestamp");return ve(we.value,{...Fe,timeZone:Oe(Fe,we)})},parse:we=>{const Fe=t(we,"timestamp"),He=R(we.text,{timeZone:Oe(Fe,we)});return He?He.getTime():null},compare:(we,Fe)=>s(x(we),x(Fe)),groupProjector:(we,Fe)=>he(we,Fe),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(we,Fe)=>{const He=x(we);if(He==null)return null;const Ke=y(He,Fe&&Fe.timeZone||void 0);return(Date.UTC(Ke.year,Ke.month-1,Ke.day,Ke.hour,Ke.minute,Ke.second)-je)/G},toStorage:we=>x(we),toClipboard:we=>{const Fe=x(we);return Fe==null?"":new Date(Fe).toISOString()},fromClipboard:we=>x(we)}},Se=["datetime","time","duration"],Ie=ye}),Be("packages/core/src/internal/lru.js",function(e,H){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return te}});class te{#e;#t=new Map;#n;constructor(X=256,D=null){this.#e=X,this.#n=D}get size(){return this.#t.size}get max(){return this.#e}set max(X){this.#e=X,this.#r()}has(X){return this.#t.has(X)}get(X){const D=this.#t;if(!D.has(X))return;const F=D.get(X);return D.delete(X),D.set(X,F),F}peek(X){return this.#t.get(X)}set(X,D){const F=this.#t;return F.has(X)&&F.delete(X),F.set(X,D),this.#r(),D}delete(X){const D=this.#t.get(X);return this.#t.delete(X)&&this.#n&&this.#n(D,X),D}clear(){if(this.#n)for(const[X,D]of this.#t)this.#n(D,X);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const X=this.#t;for(;X.size>this.#e;){const D=X.keys().next().value,F=X.get(D);X.delete(D),this.#n&&this.#n(F,D)}}}}),Be("packages/core/src/columns/types/network.js",function(e,H){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/lru.js").Lru,F=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Y(A){if(L(A))return null;if(typeof A=="string")return B(A);const $=Number(A);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>F?null:Math.trunc($)>>>0:null}function B(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const I=Z.exec($);if(!I)return null;let M=0;for(let S=1;S<=4;S++){const E=I[S];if(E.length>1&&E.charCodeAt(0)===48)return null;const U=Number(E);if(U>255)return null;M=M*256+U}return M}function z(A){const $=Y(A);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function G(A){return typeof A=="string"&&B(A)!==null}function P(A,$){const I=Y(A),M=Y($);return I===null?M===null?0:1:M===null||I<M?-1:I>M?1:0}const O=64,b=F*O+32,c=/^(?:0|[1-9]\d?)$/;function d(A,$){return A*O+$}function l(A){if(L(A))return null;if(typeof A=="string"){const M=r(A);return M===null?null:l(M)}if(typeof A=="object"){const M=Y(A.address),S=Number(A.prefix);return M===null||!Number.isInteger(S)||S<0||S>32?null:{address:M,prefix:S}}const $=Number(A);if(!Number.isInteger($)||$<0||$>b)return null;const I=$%O;return I>32?null:{address:($-I)/O,prefix:I}}function r(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const I=$.indexOf("/");if(I<0)return null;const M=B($.slice(0,I));if(M===null)return null;const S=$.slice(I+1).trim();if(!c.test(S))return null;const E=Number(S);return E>32?null:d(M,E)}function t(A){const $=l(A);return $?`${z($.address)}/${$.prefix}`:""}function i(A){return typeof A=="string"&&r(A)!==null}function s(A,$){const I=l(A),M=l($);return I?M?I.address!==M.address?I.address<M.address?-1:1:I.prefix-M.prefix:-1:M?1:0}function n(A){return A===0?0:4294967295<<32-A>>>0}function u(A){const $=l(A);return $?($.address&n($.prefix))>>>0:null}function o(A){const $=l(A);return $?($.address&n($.prefix)|~n($.prefix)>>>0)>>>0:null}function a(A){const $=l(A);return $?2**(32-$.prefix):null}function f(A){const $=l(A);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function w(A,$){const I=l(A);if(!I)return!1;const M=Y($);if(M===null)return!1;const S=n(I.prefix);return(M&S)>>>0===(I.address&S)>>>0}function m(A,$){const I=u(A),M=u($);return I===null||M===null?!1:I<=o($)&&M<=o(A)}const v=/^[0-9a-fA-F]{1,4}$/,h=new D(512);function p(A){if(L(A))return null;let $=String(A).trim();if($==="")return null;const I=$.indexOf("%");if(I>=0&&($=$.slice(0,I)),$==="")return null;if($.indexOf(".")>=0){const q=$.lastIndexOf(":");if(q<0)return null;const _=B($.slice(q+1));if(_===null)return null;$=`${$.slice(0,q+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const M=$.split("::");if(M.length>2)return null;const S=g(M[0]);if(S===null)return null;if(M.length===1)return S.length===8?S:null;const E=g(M[1]);if(E===null)return null;const U=8-S.length-E.length;if(U<1)return null;const K=S.slice();for(let q=0;q<U;q++)K.push(0);for(const q of E)K.push(q);return K}function g(A){if(A==="")return[];const $=[];for(const I of A.split(":")){if(!v.test(I))return null;$.push(parseInt(I,16))}return $}function k(A){if(typeof A!="string")return p(A);if(h.has(A))return h.get(A);const $=p(A);return h.set(A,$),$}function y(A){if(A[0]===0&&A[1]===0&&A[2]===0&&A[3]===0&&A[4]===0&&A[5]===65535)return`::ffff:${z((A[6]<<16|A[7])>>>0)}`;let $=-1,I=0,M=-1,S=0;for(let K=0;K<8;K++)A[K]===0?(M<0?(M=K,S=1):S++,S>I&&(I=S,$=M)):(M=-1,S=0);if(I<2)return A.map(K=>K.toString(16)).join(":");const E=A.slice(0,$).map(K=>K.toString(16)).join(":"),U=A.slice($+I).map(K=>K.toString(16)).join(":");return`${E}::${U}`}function T(A){const $=p(A);return $===null?null:y($)}function j(A){return T(A)??""}function N(A){return typeof A=="string"&&A.indexOf(":")>=0&&p(A)!==null}function W(A,$){const I=k(A),M=k($);if(!I)return M?1:0;if(!M)return-1;for(let S=0;S<8;S++)if(I[S]!==M[S])return I[S]<M[S]?-1:1;return 0}const R=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:G,parse:A=>B(A.text),compare:P,format:A=>z(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>Y(A),toClipboard:A=>z(A),fromClipboard:A=>B(A)},cidr:{base:"number",storage:"float64",matches:i,parse:A=>r(A.text),compare:s,format:A=>t(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>{const $=l(A);return $===null?null:d($.address,$.prefix)},toClipboard:A=>t(A),fromClipboard:A=>r(A)},ipv6:{base:"text",storage:"dictionary",matches:N,parse:A=>T(A.text),compare:W,format:A=>j(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:A=>T(A),toClipboard:A=>j(A),fromClipboard:A=>T(A)}}),x=R}),Be("packages/core/src/i18n/catalogue.js",function(e,H){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return D}});const L=H("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","licence.watermark.free":L,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),D=Object.freeze(Object.keys(X))}),Be("packages/core/src/i18n/format.js",function(e,H){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const L=H("packages/core/src/internal/predicates.js").isFunction,X=/\{(\w+)\}/g,D=new Map,F=new Map;function Z(b){const c=b||"";if(D.has(c))return D.get(c);let d=null;try{d=new Intl.PluralRules(b||void 0)}catch{d=null}return D.set(c,d),d}function Y(b,c,d="conjunction"){const l=Array.isArray(b)?b.filter(i=>i!=null&&i!==""):[];if(l.length===0)return"";if(l.length===1)return String(l[0]);const r=`${c||""}|${d}`;let t=F.get(r);if(t===void 0){try{t=new Intl.ListFormat(c||void 0,{style:"long",type:d})}catch{t=null}F.set(r,t)}return t?t.format(l.map(String)):l.map(String).join(", ")}function B(b,c){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(c||void 0,{maximumFractionDigits:20}):"":String(b)}function z(b,c,d){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const l=c&&typeof c.count=="number"?c.count:null;if(l===null)return b.other??"";const r=Z(d),t=r?r.select(l):l===1?"one":"other";return b[t]??b.other??""}function G(b,c={},d){const l=z(b,c,d);return l?l.replace(X,(r,t)=>Object.prototype.hasOwnProperty.call(c,t)?B(c[t],d):r):""}function P(b,c,d="en-GB"){return typeof b=="string"&&b?b:typeof c=="string"&&c?c:d}function O(b,c){const d=b?b[c]:void 0;return d==null||L(d)?c:d}}),Be("packages/core/src/i18n/registry.js",function(e,H){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/i18n/catalogue.js").EN_GB,X=new Map([["en-gb",L]]);function D(Y,B){const z=typeof Y=="string"?Y.toLowerCase():"";return!z||!B||typeof B!="object"?!1:(X.set(z,B),!0)}function F(Y){if(typeof Y!="string"||!Y)return null;const B=Y.toLowerCase(),z=X.get(B);if(z)return z;const G=B.split("-")[0],P=X.get(G);if(P)return P;for(const[O,b]of X)if(O.split("-")[0]===G)return b;return null}function Z(){return[...X.keys()]}}),Be("packages/core/src/i18n/index.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return s}});const te=H("packages/core/src/i18n/catalogue.js"),L=te.EN_GB,X=te.MESSAGE_KEYS,D=H("packages/core/src/i18n/format.js"),F=D.formatMessage,Z=D.formatList,Y=D.lookup,B=D.resolveLocale,G=H("packages/core/src/internal/predicates.js").isFunction,O=H("packages/core/src/internal/warn.js").warnOnce,b=H("packages/core/src/i18n/registry.js"),c=b.registerLocale,d=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return te.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return te.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const l="en-GB";class r{#e=l;#t=L;constructor(u={}){this.configure(u)}configure(u={}){this.#e=B(u.locale,u.declared,l);const o=u.messages,a=d(this.#e);if(!a&&this.#e.toLowerCase()!=="en-gb"&&(!o||typeof o!="object")&&O(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!o||typeof o!="object"){this.#t=a?{...L,...a}:L;return}const w=Object.keys(o).filter(m=>!(m in L));w.length&&O(`i18n:unknown:${w[0]}`,`message keys not in the catalogue and so ignored: ${w.slice(0,5).join(", ")}${w.length>5?`, and ${w.length-5} more`:""}`),this.#t={...L,...a||{},...o}}get locale(){return this.#e}t(u,o){return F(Y(this.#t,u),o||{},this.#e)}list(u,o){return Z(u,this.#e,o)}number(u,o){const a=Number(u);return Number.isFinite(a)?a.toLocaleString(this.#e,o||{maximumFractionDigits:20}):""}}const t=new r;function i(n){return n instanceof r?n:new r(n||{})}function s(n){const u=n&&typeof n=="object"?n:{},o=X.filter(f=>{const w=u[f];return w==null||w===""||G(w)}),a=Object.keys(u).filter(f=>!(f in L));return{missing:o,unknown:a}}}),Be("packages/core/src/columns/types/structured.js",function(e,H){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const te=H("packages/core/src/internal/predicates.js"),L=te.isNil,X=te.isObject,F=H("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function Y(r,t){const i=t||{},s=i.emptyDisplay??Z.emptyDisplay;if(L(r)||r==="")return s;const u=[...typeof i.char=="string"&&i.char!==""?i.char:Z.char][0]||Z.char,o=i.fixedLength??Z.fixedLength,a=Number.isFinite(i.length)&&Number(i.length)>0?Math.floor(Number(i.length)):Z.length,f=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let w=0;if(f!==null){const m=Number.isFinite(i.lastVisible)?Math.floor(Number(i.lastVisible)):Z.lastVisible,v=[...f];if(w=m>0&&m<v.length?m:0,w>0){const h=v.slice(v.length-w).join(""),p=Math.max(1,(o?a:v.length)-w);return u.repeat(p)+h}return u.repeat(o?a:Math.max(1,v.length))}return u.repeat(a)}const B=48;function z(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function G(r,t){if(L(r))return"";const i=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):B;if(typeof r=="string")return r.length>i?`${r.slice(0,i-1)}…`:r;if(typeof r!="object")return String(r);const s=z(r);if(s!==null&&s.length<=i)return s;if(Array.isArray(r)){const u=r.length;return`[${F.t("count.items",{count:u})}]`}const n=Object.keys(r).length;return`{${F.t("count.keys",{count:n})}}`}function P(r,t){if(r==null)return"null";const i=typeof r;if(i==="number"||i==="boolean"||i==="bigint")return String(r);if(i==="string")return JSON.stringify(r);if(i!=="object")return JSON.stringify(String(r));const s=t||new WeakSet;return s.has(r)?'"[circular]"':(s.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(o=>P(o,s)).join(",")}]`:`{${Object.keys(r).sort().map(o=>`${JSON.stringify(o)}:${P(r[o],s)}`).join(",")}}`)}function O(r,t){if(L(r))return L(t)?0:1;if(L(t))return-1;const i=P(r),s=P(t);return i<s?-1:i>s?1:0}function b(r){if(L(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function c(r){const t=r&&r.cell&&r.cell.props;return X(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:r=>G(r&&r.value,c(r&&r.column)),parse:r=>b(r&&r.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(L(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>b(r)},secret:{base:"text",storage:"object",format:r=>Y(r&&r.value,c(r&&r.column)),parse:r=>{const t=r&&r.text;return L(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const i=L(r)||r==="",s=L(t)||t==="";return i===s?0:i?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>Y(r),fromClipboard:r=>L(r)||String(r)===""?null:String(r)}}),l=d}),Be("packages/core/src/columns/types/unit.js",function(e,H){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce;function F(S,E,U,K){return Object.freeze({symbol:S,factor:E,aliases:Object.freeze(U||[]),binary:!!(K&&K.binary),prefix:K&&K.prefix||null,auto:!(K&&K.auto===!1)})}function Z(S,E,U,K){return F(S,E,U,K)}const Y=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),B=Symbol("ambiguous"),z=new Map,G=new Map;function P(S,E){const U=String(S||"").trim();if(!U)throw new Error("[lattice] a unit system needs a name");if(Y[U]||G.has(U))throw new Error(`[lattice] unit system "${U}" already exists`);const K=[...E||[]];if(!K.length)throw new Error(`[lattice] unit system "${U}" has no units`);if(!K.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${U}" has no base unit (none with factor 1)`);const q=new Set;for(const _ of K){if(q.has(_.symbol))throw new Error(`[lattice] unit system "${U}" declares "${_.symbol}" twice`);q.add(_.symbol)}return G.set(U,Object.freeze(K)),z.delete(U),U}function O(){return[...Object.keys(Y),...G.keys()]}function b(S){const E=c(S);return E?E.units:[]}function c(S){const E=String(S||""),U=z.get(E);if(U!==void 0)return U;const K=Y[E]||G.get(E);if(!K)return z.set(E,null),null;const q=Object.freeze([...K].sort((oe,ie)=>oe.factor-ie.factor)),_=new Map,J=new Map,ee=(oe,ie)=>{const ae=_.get(oe);ae===void 0?_.set(oe,ie):ae!==ie&&_.set(oe,B)};for(const oe of q){ee(oe.symbol.toLowerCase(),oe);for(const ie of oe.aliases)ee(ie.toLowerCase(),oe);if(oe.prefix){const ie=J.get(oe.prefix)||[];ie.push(oe),J.set(oe.prefix,ie)}}const ne={units:q,byToken:_,byPrefix:J,decimal:q.filter(oe=>!oe.binary&&oe.auto),binary:q.some(oe=>oe.binary)?q.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return z.set(E,ne),ne}function d(S,E){return E&&S.binary||S.decimal}function l(S,E){const U=c(S);if(!U||L(E))return null;const K=U.units.find(_=>_.symbol===String(E));if(K)return K;const q=U.byToken.get(String(E).trim().toLowerCase());return q&&q!==B?q:null}const r=new WeakMap;function t(S){const E=S||{};if(typeof E=="object"&&E!==null){const _=r.get(E);if(_!==void 0)return _}const U=E.system||"data",K=c(U);let q=null;if(!K)D(`unit:system:${U}`,`unknown unit system "${U}"; known systems are ${O().join(", ")}`);else{let _=E.unit?l(U,E.unit):null;_||(E.unit&&D(`unit:unit:${U}:${E.unit}`,`unknown unit "${E.unit}" in system "${U}"; falling back to ${K.units[0].symbol}`),_=K.units.find(J=>J.factor===1)||K.units[0]),q={index:K,base:_,binary:E.binary===!0}}return typeof E=="object"&&E!==null&&r.set(E,q),q}const i=new WeakMap;function s(S,E){if(!S||!E||!Array.isArray(S.compound)||S.compound.length===0)return null;const U=i.get(S);if(U!==void 0)return U;const K=new Set,q=[];for(const J of S.compound){const ee=l(S.system||"data",J);if(!ee){D(`unit:compound:${S.system}:${J}`,`unknown compound unit "${J}" in system "${S.system||"data"}"; ignoring it`);continue}K.has(ee.symbol)||(K.add(ee.symbol),q.push(ee))}q.sort((J,ee)=>ee.factor-J.factor);const _=q.length>=2?q:null;return i.set(S,_),_}function n(S,E,U){return E===U||E.factor===U.factor?S:S*E.factor/U.factor}const u=new Map;function o(S){const E=S||"",U=u.get(E);if(U)return U;const K={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(S||void 0).formatToParts(12345.6))q.type==="group"?K.group=q.value:q.type==="decimal"&&(K.decimal=q.value)}catch{}return u.set(E,K),K}const a=/[\s   ]/g,f=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,w=/^[^\d+\-(.,\s]+\s*/,m=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function v(S,E){const{group:U,decimal:K}=o(E);let q=String(S).replace(a,"");if(q==="")return null;const _=K?q.indexOf(K):-1;if(U&&U!==K){if(_>=0&&q.indexOf(U,_+K.length)>=0)return null;q=q.split(U).join("")}if(K&&K!=="."&&(q=q.split(K).join(".")),!m.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function h(S,E,U){const K=String(S).trim().replace(/\.$/,"");if(K==="")return null;const q=E.units.find(ie=>ie.symbol===K);if(q)return q;const _=K.toLowerCase(),J=E.byToken.get(_);if(J===B)return null;if(J)return J;const ee=E.byPrefix.get(_);if(!ee||!ee.length)return null;const ne=d(E,U),oe=ee.filter(ie=>ne.includes(ie));return oe.length===1?oe[0]:null}function p(S,E,U,K){let q=S,_=0,J=!1,ee=!1;for(;q!=="";){const ne=f.exec(q)[0];if(ne==="")return null;const oe=v(ne,K&&K.locale);if(oe===null)return null;q=q.slice(ne.length).trim();const ie=q.search(/[+-]?[\d]/),ae=(ie>=0?q.slice(0,ie):q).trim();if(q=ie>=0?q.slice(ie).trim():"",ae===""){if(J)return null;ee=!0,_+=n(oe,U[0],E.base)}else{const ce=h(ae,E.index,E.binary);if(!ce)return null;_+=n(oe,ce,E.base)}if(J=!0,ee&&q!=="")return null}return J?_:null}function g(S,E){if(L(S))return null;if(typeof S=="number")return Number.isFinite(S)?S:null;const U=t(E);if(!U)return null;let K=String(S).trim();if(K==="")return null;let q=!1;K.startsWith("(")&&K.endsWith(")")&&(q=!0,K=K.slice(1,-1).trim());const _=s(E,U);if(_){K.startsWith("-")&&(q=!0,K=K.slice(1).trim());const de=p(K,U,_,E);return de===null?null:q?-de:de}let J=null;const ee=w.exec(K);if(ee&&ee[0]){const de=h(ee[0].trim(),U.index,U.binary);de&&(J=de,K=K.slice(ee[0].length).trim())}const ne=f.exec(K)[0],oe=v(ne,E&&E.locale);if(oe===null)return null;const ie=K.slice(ne.length).trim();if(J&&ie!=="")return null;const ae=J||(ie===""?U.base:h(ie,U.index,U.binary));if(!ae)return null;const ce=n(oe,ae,U.base);return q?-ce:ce}const k=new Map;function y(S,E,U,K){const q=`${S||""}|${E}|${U}|${K?1:0}`;let _=k.get(q);return _||(_=new Intl.NumberFormat(S||void 0,{minimumFractionDigits:E,maximumFractionDigits:U,useGrouping:K}),k.set(q,_)),_}function T(S,E){if(!Number.isFinite(S)||S===0)return Math.max(0,E-1);const U=Math.floor(Math.log10(Math.abs(S)));return Math.min(20,Math.max(0,E-1-U))}function j(S,E){if(!Number.isFinite(S)||S===0)return S;const U=Math.ceil(Math.log10(Math.abs(S))),K=10**(E-U);return Math.round(S*K)/K}function N(S,E,U){if(!U||U===E.base.symbol)return E.base;if(U!=="auto")return W(E,U);if(S===0||!Number.isFinite(S))return E.base;const K=Math.abs(S)*E.base.factor,q=d(E.index,E.binary);let _=q[0];for(const ne of q)K>=ne.factor&&(_=ne);if(K>=_.factor)return _;let J=_;for(const ne of E.index.units)ne.binary!==E.binary&&ne.factor!==1||ne.factor<=K&&ne.factor>(J===_?0:J.factor)&&(J=ne);if(J!==_)return J;let ee=_;for(const ne of E.index.units)ne.binary!==E.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<E.base.factor?ee:E.base}function W(S,E){const U=S.index.units.find(q=>q.symbol===E);if(U)return U;const K=S.index.byToken.get(String(E).toLowerCase());return K&&K!==B?K:(D(`unit:display:${E}`,`unknown display unit "${E}"; rendering in ${S.base.symbol}`),S.base)}function R(S,E,U,K){const q=S<0;let _=Math.abs(S)*E.base.factor;const J=typeof K.decimals=="number"?K.decimals:K.minDecimals??0,ee=typeof K.decimals=="number"?K.decimals:K.maxDecimals??Math.max(J,2),ne=K.space??" ",oe=[];for(let ae=0;ae<U.length;ae++){const ce=U[ae],de=ae===U.length-1;let Ae=de?_/ce.factor:Math.floor(_/ce.factor);if(_-=Ae*ce.factor,de){const be=10**ee;Ae=Math.round(Ae*be)/be+0}const je=de?y(K.locale,J,ee,K.group!==!1):y(K.locale,0,0,K.group!==!1);oe.push(`${je.format(Ae)}${ne}${ce.symbol}`)}const ie=oe.join(" ");return q?`-${ie}`:ie}function x(S,E){const U=E||{},K=U.nullDisplay??"";if(L(S)||S==="")return K;const q=typeof S=="number"?S:Number(S);if(!Number.isFinite(q))return K;const _=t(U);if(!_)return String(q);const J=s(U,_);if(J)return R(q,_,J,U);const ee=typeof U.significantFigures=="number"&&U.significantFigures>0?U.significantFigures:0,ne=ee?j(q,ee):q,oe=N(ne,_,U.display),ie=n(ne,_.base,oe);let ae=typeof U.decimals=="number"?U.decimals:U.minDecimals??0,ce=typeof U.decimals=="number"?U.decimals:U.maxDecimals??Math.max(ae,2);ee&&(ae=T(ie,ee),ce=ae);const de=y(U.locale,ae,ce,U.group!==!1).format(ie),Ae=U.space??" ";return U.placement==="prefix"?`${oe.symbol}${U.space??""}${de}`:`${de}${Ae}${oe.symbol}`}function A(S,E){const U=L(S)||Number.isNaN(S)?null:Number(S),K=L(E)||Number.isNaN(E)?null:Number(E);return U===null||Number.isNaN(U)?K===null||Number.isNaN(K)?0:1:K===null||Number.isNaN(K)||U<K?-1:U>K?1:0}function $(S){const E=typeof S.decimals=="number"&&S.decimals>0?`.${"0".repeat(S.decimals)}`:"";return`${typeof S.decimals=="number"?`#,##0${E}`:"#,##0.##"}" ${S.symbol}"`}function I(S){const E={system:"data",...S||{}},U=t(E),K=U?U.base.symbol:String(E.unit||""),q=Object.freeze({...E,unit:K}),_=Object.freeze({...q,display:K,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),ee=ne=>{const oe=ne||"";let ie=J.get(oe);return ie||(ie=Object.freeze({...q,locale:ne||void 0}),J.set(oe,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>x(ne.value,ne.locale?ee(ne.locale):q),parse:ne=>g(ne.text,ne.locale?ee(ne.locale):q),compare:A,defaults:{filter:"number",editor:"unit",align:"end",total:E.total||"sum"},...E.totals?{totals:E.totals}:{},excel:E.excel||$({decimals:E.decimals,symbol:K}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?g(ne,q):L(ne)?null:g(String(ne),q),toClipboard:ne=>x(ne,_),fromClipboard:ne=>g(ne,q)}}const M=I}),Be("packages/core/src/columns/types/engineering.js",function(e,H){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/columns/types/unit.js").createUnitType;function F(B){const z=2*Math.PI/B;return G=>{let P=0,O=0,b=0;for(const d of G||[]){if(L(d))continue;const l=Number(d);Number.isFinite(l)&&(P+=Math.cos(l*z),O+=Math.sin(l*z),b+=1)}return!b||Math.hypot(P,O)/b<1e-12?null:(Math.atan2(O,P)/z%B+B)%B}}function Z(B){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:F(B)}}}const Y=Object.freeze({metres:D({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:D({system:"length",unit:"mm",maxDecimals:2}),kilometres:D({system:"length",unit:"km",maxDecimals:3}),grams:D({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:D({system:"mass",unit:"kg",maxDecimals:3}),tonnes:D({system:"mass",unit:"t",maxDecimals:3}),seconds:D({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:D({system:"duration",unit:"ms",maxDecimals:3}),hours:D({system:"duration",unit:"h",maxDecimals:2}),speed:D({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:D({system:"speed",unit:"km/h",maxDecimals:1}),mph:D({system:"speed",unit:"mph",maxDecimals:1}),knots:D({system:"speed",unit:"kn",maxDecimals:1}),acceleration:D({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:D({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:D({system:"area",unit:"ha",maxDecimals:4}),volume:D({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:D({system:"volume",unit:"m³",maxDecimals:3}),energy:D({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:D({system:"energy",unit:"kWh",maxDecimals:2}),power:D({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:D({system:"power",unit:"kW",maxDecimals:2}),force:D({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:D({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:D({system:"pressure",unit:"bar",maxDecimals:3}),psi:D({system:"pressure",unit:"psi",maxDecimals:1}),torque:D({system:"torque",unit:"N·m",maxDecimals:2}),density:D({system:"density",unit:"kg/m³",maxDecimals:2}),flow:D({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:D({system:"flow",unit:"L/min",maxDecimals:1}),radians:D({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:D({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:D({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:D({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:D({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:D({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:D({system:"fraction",unit:"bp",maxDecimals:1}),molarity:D({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:D({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:D({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:D({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:D({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:D({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:D({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:D({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Be("packages/core/src/columns/types/si.js",function(e,H){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/columns/types/unit.js"),L=te.defineUnit,X=te.registerUnitSystem,D=te.createUnitType,F=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function Y(O){const b=String(O.base),c=new Set([...O.prefixes||Z,""]),d=[];for(const l of F){if(!c.has(l.symbol))continue;const r=`${l.symbol}${b}`,t=[];if(O.name){t.push(`${l.name}${O.name}`,`${l.name}${O.name}s`);const i=l.name.slice(-1);if(i&&O.name.startsWith(i)){const s=`${l.name.slice(0,-1)}${O.name}`;t.push(s,`${s}s`)}}l.symbol==="µ"&&t.push(`u${b}`),l.factor===1&&O.aliases&&t.push(...O.aliases),d.push(L(r,l.factor,t))}for(const l of O.extra||[])d.push(l);return d}function B(O,b){const c=Y(b);return X(O,c)}function z(O,b,c){return B(O,b),D({system:O,unit:b.base,display:"auto",maxDecimals:3,...c||{}})}const G=Object.freeze({voltage:z("voltage",{base:"V",name:"volt"}),current:z("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:z("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:z("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:z("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:z("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[L("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),L("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:z("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:z("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[L("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:z("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:z("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:z("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:z("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:z("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:z("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:z("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[L("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:z("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),P=z}),Be("packages/core/src/columns/types/temperature.js",function(e,H){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=H("packages/core/src/internal/predicates.js").isNil,X=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function D(d){if(L(d))return null;const l=String(d).trim();if(l==="")return null;for(const[t,i]of Object.entries(X))if(l===t||l===i.symbol)return{key:t,scale:i};const r=l.toLowerCase();for(const[t,i]of Object.entries(X))if(i.aliases.includes(r))return{key:t,scale:i};return null}function F(d,l,r){const t=D(l),i=D(r);return!t||!i||!Number.isFinite(Number(d))?null:t.key===i.key?Number(d):i.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const Z=new Map;function Y(d,l,r){const t=`${d||""}|${l}|${r}`;let i=Z.get(t);return i||(i=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:l,maximumFractionDigits:r}),Z.set(t,i)),i}function B(d,l){const r=l||{},t=r.nullDisplay??"";if(L(d)||d==="")return t;const i=Number(d);if(!Number.isFinite(i))return t;const s=D(r.scale||"C");if(!s)return String(i);const n=D(r.display||r.scale||"C")||s,u=n.key===s.key?i:n.scale.fromKelvin(s.scale.toKelvin(i)),o=typeof r.decimals=="number"?r.decimals:null,a=o??r.minDecimals??0,f=o??r.maxDecimals??1;return`${Y(r.locale,a,f).format(u)}${r.space??" "}${n.scale.symbol}`}const z=/^[+-]?[\d\s.,  ]*\d/;function G(d,l){const r=String(d).trim();if(r==="")return null;const t=new Intl.NumberFormat(l||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",i=t===","?".":",",s=r.split(i).join("").split(/[\s  ]/).join("").replace(t,"."),n=Number(s);return Number.isFinite(n)?n:null}function P(d,l){if(L(d))return null;const r=l||{},t=D(r.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let i=String(d).trim();if(i==="")return null;let s=!1;i.startsWith("(")&&i.endsWith(")")&&(s=!0,i=i.slice(1,-1).trim());const n=z.exec(i);if(!n)return null;const u=G(n[0],r.locale);if(u===null)return null;const o=i.slice(n[0].length).trim();if(o==="")return s?-u:u;const a=D(o);if(!a)return null;const f=a.key===t.key?u:t.scale.fromKelvin(a.scale.toKelvin(u));return s?-f:f}function O(d){const l=Object.freeze({scale:"C",...d||{}}),t=(D(l.scale)||D("C")).scale.symbol,i=Object.freeze({...l,display:l.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[l.locale||"",l]]),n=u=>{const o=u||"";let a=s.get(o);return a||(a=Object.freeze({...l,locale:u||void 0}),s.set(o,a)),a};return{base:"number",extends:"number",storage:"float64",temperatureConfig:l,format:u=>B(u.value,u.locale?n(u.locale):l),parse:u=>P(u.text,u.locale?n(u.locale):l),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:l.excel||`#,##0${typeof l.decimals=="number"&&l.decimals>0?`.${"0".repeat(l.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?P(u,l):L(u)?null:P(String(u),l),toClipboard:u=>B(u,i),fromClipboard:u=>P(u,l)}}const b=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),c=O}),Be("packages/core/src/columns/types/radix.js",function(e,H){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return R}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce,F=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),Y=Object.freeze({2:"0b",8:"0o",16:"0x"}),B=Object.freeze({2:4,8:3,16:2}),z=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),G=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),P=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),O=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,c=Object.freeze([8,16,32,53]),d=new WeakSet,l=new WeakMap,r=new Map,t=new WeakMap,i=new WeakMap,s=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(x){if(x==null)return 16;const A=typeof x=="string"?x.toLowerCase():x,$=F[A];return $||(D(`radix:base:${String(x)}`,`unsupported radix ${String(x)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function u(x,A){return Math.ceil(x/Z[A])}function o(x,A){if(!x)return A?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!A)return{min:0,max:2**x-1};const $=2**(x-1);return{min:-$,max:$-1}}function a(x){return G[x]||"hexadecimal"}function f(x){if(typeof x=="string"){const A=s[x];return A||D(`radix:preset:${x}`,`unknown radix preset "${x}"; known presets are ${Object.keys(s).join(", ")}`),{...A||{}}}if(x&&typeof x.preset=="string"){const A=s[x.preset];return A||D(`radix:preset:${x.preset}`,`unknown radix preset "${x.preset}"; known presets are ${Object.keys(s).join(", ")}`),{...A||{},...x}}return x||{}}function w(x){const A=f(x),$=n(A.radix),I=Z[$];let M=null;if(A.bitWidth!==void 0&&A.bitWidth!==null&&A.bitWidth!==!1){const ne=Number(A.bitWidth);c.includes(ne)?M=ne:D(`radix:width:${String(A.bitWidth)}`,`unsupported bitWidth ${String(A.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let S=A.signed!==!1;!S&&M===null&&(D("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const E=A.prefix===void 0||A.prefix===!0?Y[$]:A.prefix===!1?"":String(A.prefix);let U=0;A.pad===!0?U=M?u(M,$):0:typeof A.pad=="number"&&A.pad>0&&(U=Math.floor(A.pad));let K=0;A.group===!0?K=B[$]:typeof A.group=="number"&&A.group>0&&(K=Math.floor(A.group));const q=o(M,S),_=typeof A.min=="number"?Math.max(q.min,A.min):q.min,J=typeof A.max=="number"?Math.min(q.max,A.max):q.max,ee=Object.freeze({radix:$,bits:I,prefix:E,uppercase:A.uppercase!==!1,pad:U,group:K,groupSeparator:typeof A.groupSeparator=="string"?A.groupSeparator:" ",bitWidth:M,signed:S,min:_,max:J<_?_:J,nullDisplay:typeof A.nullDisplay=="string"?A.nullDisplay:"",name:a($)});return d.add(ee),ee}function m(x){if(x&&d.has(x))return x;if(typeof x=="string"){let A=r.get(x);return A||(A=w(x),r.set(x,A)),A}if(x&&typeof x=="object"){let A=l.get(x);return A||(A=w(x),l.set(x,A)),A}return m("hex")}function v(x){return x<0?-Math.round(-x):Math.round(x)}function h(x,A,$){if(A<=0||x.length<=A)return x;const I=x.length%A||A,M=[x.slice(0,I)];for(let S=I;S<x.length;S+=A)M.push(x.slice(S,S+A));return M.join($)}function p(x){const A=m(x),{radix:$,prefix:I,uppercase:M,pad:S,group:E,groupSeparator:U,signed:K,bitWidth:q,nullDisplay:_}=A,J=q?2**q:0,ee=ne=>{if(L(ne)||ne==="")return _;const oe=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(oe))return _;const ie=v(oe);let ae="",ce=ie;ie<0&&(K?(ae="-",ce=-ie):ce=(ie%J+J)%J);let de=ce.toString($);return de=M?de.toUpperCase():de.toLowerCase(),S>0&&de.length<S&&(de=de.padStart(S,"0")),E>0&&(de=h(de,E,U)),ae+I+de};return ee.options=A,ee}function g(x,A){const $=m(A);let I=t.get($);return I||(I=p($),t.set($,I)),I(x)}function k(x){const A=m(x),{radix:$,groupSeparator:I,signed:M,min:S,max:E}=A,U=z[$],K=q=>{if(L(q))return{ok:!0,value:null,reason:"blank"};let _=String(q);if(I&&I!==""&&(_=_.split(I).join("")),_=_.replace(O,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[oe,ie]of P){const ae=oe.exec(_);if(!ae)continue;const ce=_.slice(ae[0].length);if(ce==="")break;if(!z[ie].test(ce))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ce,ie);break}if(ee===null)if(U.test(_))ee=parseInt(_,$);else if(b.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=v(J?-ee:ee);return!M&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<S||ne>E?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return K.options=A,K}function y(x,A){const $=m(A);let I=i.get($);return I||(I=k($),i.set($,I)),I(x)}function T(x,A){const $=y(x,A);return $.ok?$.value:null}function j(x,A){const $=L(x)||Number.isNaN(x)?null:Number(x),I=L(A)||Number.isNaN(A)?null:Number(A);return $===null?I===null?0:1:I===null||$<I?-1:$>I?1:0}function N(x){const A=x.min>=-2147483648&&x.max<=2147483647;return x.bitWidth&&A?"int32":"float64"}function W(x){const A=w(x),$=p(A),I=k(A);return{base:"number",extends:"number",storage:N(A),matches:null,format:M=>$(M.value),parse:M=>{const S=I(M.text);return S.ok?S.value:null},compare:j,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>$(M),fromClipboard:M=>{const S=I(M);return S.ok?S.value:null},radix:A,formatValue:$,parseText:I}}const R=W}),Be("packages/core/src/columns/types/aggregable.js",function(e,H){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil;function X(G){const P=[];for(const O of G||[]){if(L(O))continue;const b=Number(O);Number.isFinite(b)&&P.push(b)}return P}function D(G){return P=>{const O=X(P);if(!O.length)return null;let b=0;for(const c of O)b+=10**(c/G);return G*Math.log10(b)}}function F(G){return P=>{const O=X(P);if(!O.length)return null;let b=0;for(const c of O)b+=10**(c/G);return G*Math.log10(b/O.length)}}function Z(G,P){const O=P&&P.column,c=(O&&O.typeOptions||{}).weight,d=P&&P.valueAt;if(!c||typeof d!="function")return null;let l=0,r=0;for(let t=0;t<G.length;t++){if(L(G[t]))continue;const i=Number(G[t]);if(!Number.isFinite(i))continue;const s=d(c,t);if(L(s))continue;const n=Number(s);!Number.isFinite(n)||n<=0||(l+=i*n,r+=n)}return r===0?null:l/r}function Y(G={}){const P=G.factor===20?20:10,O=typeof G.suffix=="string"?G.suffix:"",b=Number.isInteger(G.decimals)?G.decimals:1;return{base:"number",storage:"float64",name:G.name||"logarithmic",format:c=>{const d=c&&c.value;return L(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(b)}${O}`},parse:c=>{const d=String((c&&c.text)??"").replace(O,"").trim();if(!d)return null;const l=Number(d);return Number.isFinite(l)?l:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:D(P),avg:F(P)}}}}function B(G={}){const P=Number.isInteger(G.decimals)?G.decimals:1,O=G.percent===!0;return{base:"number",storage:"float64",name:G.name||"ratio",format:b=>{const c=b&&b.value;return L(c)||!Number.isFinite(Number(c))?"":O?`${Number(c).toFixed(P)}%`:Number(c).toFixed(P)},parse:b=>{const c=String((b&&b.text)??"").replace("%","").trim();if(!c)return null;const d=Number(c);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const z=Object.freeze({decibel:Y({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:Y({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:B({name:"ratio"}),percentRate:B({name:"percentRate",percent:!0})})}),Be("packages/core/src/columns/types/currency.js",function(e,H){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const L=H("packages/core/src/internal/predicates.js").isNil,X="⚠ no rate";function D(u){if(L(u))return null;const o=String(u).trim().toUpperCase();return o===""?null:o}function F(u){if(L(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const o=Number(u.amount),a=D(u.code);return!a||!Number.isFinite(o)?null:{amount:o,code:a}}if(Array.isArray(u)&&u.length===2){const o=Number(u[0]),a=D(u[1]);return!a||!Number.isFinite(o)?null:{amount:o,code:a}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),Y=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),B=/[+-]?[\d\s., ]*\d/;function z(u,o){const a=String(u).trim();if(a==="")return null;const f=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(h=>h.type==="decimal")?.value||".",w=f===","?".":",",m=a.split(w).join("").split(/[\s ]/).join("").replace(f,"."),v=Number(m);return Number.isFinite(v)?v:null}function G(u,o){const a=o||{},f=D(a.code);if(L(u))return null;const w=F(u);if(w)return w;if(typeof u=="number")return Number.isFinite(u)&&f?{amount:u,code:f}:null;let m=String(u).trim();if(m==="")return null;let v=!1;m.startsWith("(")&&m.endsWith(")")&&(v=!0,m=m.slice(1,-1).trim());let h=null;for(const[j,N]of Object.entries(Z)){if(m.startsWith(j)){h=N,m=m.slice(j.length).trim();break}if(m.endsWith(j)){h=N,m=m.slice(0,-j.length).trim();break}}const p=B.exec(m);if(!p)return null;const g=z(p[0],a.locale);if(g===null)return null;const k=(m.slice(0,p.index)+" "+m.slice(p.index+p[0].length)).trim();!h&&k!==""&&(h=D(k));const y=h||f;return y?{amount:v?-g:g,code:y}:null}function P(u,o){if(typeof u=="function")return(a,f)=>{if(a===f)return 1;const w=u(a,f);return typeof w=="number"&&Number.isFinite(w)&&w>0?w:null};if(u&&typeof u=="object"){const a=u;return(f,w)=>{if(f===w)return 1;const m=Number(a[f]),v=Number(a[w]);return!Number.isFinite(m)||!Number.isFinite(v)||m<=0||v<=0?null:v/m}}return(a,f)=>a===f?1:null}function O(u,o,a){if(!u)return null;if(u.code===o)return u.amount;const f=a(u.code,o);return f===null?null:u.amount*f}const b=new Map;function c(u,o,a){const f=`${u||""}|${o}|${a??""}`;let w=b.get(f);if(!w){const m={style:"currency",currency:o};typeof a=="number"&&(m.minimumFractionDigits=a,m.maximumFractionDigits=a);try{w={fmt:new Intl.NumberFormat(u||void 0,m),currency:!0}}catch{w={fmt:new Intl.NumberFormat(u||void 0,typeof a=="number"?{minimumFractionDigits:a,maximumFractionDigits:a}:{}),currency:!1}}b.set(f,w)}return w}function d(u,o){const a=o||{},f=a.nullDisplay??"",w=F(u);if(!w)return f;const m=D(a.display)||w.code;let v=w.amount,h=w.code;if(m!==w.code){const k=a.rateFn||P(a.rates,a.rateBase),y=O(w,m,k);if(y===null)return`${a.missingRate??X} ${w.code}→${m}`;v=y,h=m}const{fmt:p,currency:g}=c(a.locale,h,a.decimals);return g?p.format(v):`${p.format(v)} ${h}`}function l(u){const o=F(u);return o?`${o.amount} ${o.code}`:""}function r(u){const o=u||{},a=D(o.display),f=o.rateFn||P(o.rates,o.rateBase);return(w,m)=>{const v=F(w),h=F(m);if(!v&&!h)return 0;if(!v)return 1;if(!h)return-1;if(a){const p=O(v,a,f),g=O(h,a,f);if(p!==null&&g!==null)return p===g?0:p<g?-1:1}return v.code===h.code?v.amount===h.amount?0:v.amount<h.amount?-1:1:v.code<h.code?-1:1}}function t(u){const o=u||{},a=(w,m)=>{const v=[];for(const y of w||[]){const T=F(y);T&&v.push(T)}if(!v.length)return null;if(new Set(v.map(y=>y.code)).size===1){const y=v[0].code;return{amount:m(v.map(T=>T.amount)),code:y}}const p=D(o.display);if(!p)return`${o.missingRate??X}: mixed currencies, no display currency set`;const g=o.rateFn||P(o.rates,o.rateBase),k=[];for(const y of v){const T=O(y,p,g);if(T===null)return`${o.missingRate??X}: ${y.code}→${p}`;k.push(T)}return{amount:m(k),code:p}},f=w=>w.reduce((m,v)=>m+v,0);return{sum:w=>a(w,f),avg:w=>a(w,m=>f(m)/m.length),min:w=>a(w,m=>Math.min(...m)),max:w=>a(w,m=>Math.max(...m))}}function i(u){const o=Object.freeze({code:"USD",...u||{}}),a=P(o.rates,o.rateBase),f=Object.freeze({...o,rateFn:a}),w=t(f),m=r(f),v=new Map([[o.locale||"",f]]),h=k=>{const y=k||"";let T=v.get(y);return T||(T=Object.freeze({...f,locale:k||void 0}),v.set(y,T)),T},p=Y[D(o.display||o.code)]||"",g=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:f,format:k=>d(k.value,k.locale?h(k.locale):f),parse:k=>G(k.text,k.locale?h(k.locale):f),compare:m,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:w},excel:o.excel||(p?`"${p}"#,##0${g}`:`#,##0${g}`),toStorage:k=>{const y=F(k);return y||(typeof k=="string"||typeof k=="number"?G(k,f):null)},toClipboard:k=>l(k),fromClipboard:k=>G(k,f)}}const s=Object.freeze({currency:i({code:"USD"}),usd:i({code:"USD"}),eur:i({code:"EUR"}),gbp:i({code:"GBP"}),jpy:i({code:"JPY",decimals:0})}),n=i}),Be("packages/core/src/columns/types/index.js",function(e,H){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return j}});const te=H("packages/core/src/columns/types/temporal.js"),L=te.TEMPORAL_TYPES,X=H("packages/core/src/columns/types/network.js"),D=X.NETWORK_TYPES,F=H("packages/core/src/columns/types/structured.js"),Z=F.STRUCTURED_TYPES,Y=H("packages/core/src/columns/types/unit.js"),B=Y.createUnitType,z=Y.UNIT_SYSTEMS,G=Y.parseUnit,P=Y.formatUnit,O=Y.registerUnitSystem,b=Y.unitSystemNames,c=Y.unitsOf,d=Y.defineUnit,l=H("packages/core/src/columns/types/engineering.js"),r=l.ENGINEERING_TYPES,t=H("packages/core/src/columns/types/si.js"),i=t.SI_TYPES,s=t.createSiType,n=t.createSiSystem,u=t.siUnits,o=t.SI_PREFIXES,a=H("packages/core/src/columns/types/temperature.js"),f=a.TEMPERATURE_TYPES,w=a.createTemperatureType,m=a.convertTemperature,v=a.formatTemperature,h=a.parseTemperature,p=a.TEMPERATURE_SCALES,g=H("packages/core/src/columns/types/radix.js"),k=g.createRadixType,y=g.RADIX_PRESETS,T=g.parseRadix,j=g.formatRadix,N=H("packages/core/src/columns/types/aggregable.js"),W=N.AGGREGABLE_TYPES,R=H("packages/core/src/columns/types/currency.js"),x=R.CURRENCY_TYPES,A=R.createCurrencyType,$=R.parseMoney,I=R.formatMoney,M=R.convertMoney,S=R.toMoney,E=R.rateFunction,U=R.moneyComparator,K=R.normaliseCode,q=R.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return Y.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return l.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return l.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return a.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return a.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return a.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return a.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return a.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return a.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return a.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return R.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return R.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return R.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return R.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return R.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return R.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return R.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return R.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return R.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return R.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return te.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return X.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return F.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return N.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return N.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return N.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return te.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return te.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return te.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return te.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return te.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return te.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return X.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return X.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return X.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return X.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return X.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return X.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return X.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return X.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return X.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return F.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return F.summariseJson}});const _=Object.freeze({...L,...D,...Z,...W,hex:k(y.hex),hex8:k(y.hex8),hex16:k(y.hex16),hex32:k(y.hex32),binary:k(y.binary),binary8:k(y.binary8),octal:k(y.octal),bytes:B({system:"data",unit:"B",display:"auto"}),megabytes:B({system:"data",unit:"MB"}),gigabytes:B({system:"data",unit:"GB"}),bitrate:B({system:"bitrate",unit:"Mbps"}),gigabits:B({system:"bitrate",unit:"Gbps"}),...r,...i,...f,...x});{const J=new Set;for(const ee of[L,D,Z,W,r,i,f,x])for(const ne of Object.keys(ee)){if(J.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);J.add(ne)}}}),Be("packages/core/src/compute/handle.js",function(e,H){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return i}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,F=H("packages/core/src/internal/warn.js").warnOnce;function Z(s){const n=new Uint32Array(s);for(let u=0;u<s;u++)n[u]=u;return n}function Y(s,n){if(n&&typeof n.count=="number")return n.count;if(!s)return 0;if(typeof s.count=="number")return s.count;if(typeof s.length=="number")return s.length;const u=s.values;return s.kind==="multi"&&s.offsets?Math.max(0,s.offsets.length-1):u?s.kind==="bitset"?typeof u.size=="number"?u.size:s.presence&&typeof s.presence.size=="number"?s.presence.size:(F(`count:${s.id}`,`column "${s.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:s.presence&&typeof s.presence.size=="number"?s.presence.size:0}const B=new WeakMap;function z(s){const n=s.constructor;if(!n)return"unknown";const u=B.get(n);if(u)return u;let o="unknown";try{let a=null;typeof n.from=="function"?a=n.from([!1,!0]):(a=new n(8),a.set(1));const f=a&&a.words;f&&f.length&&(f[0]===2?o="lsb":f[0]===64&&(o="msb"))}catch{o="unknown"}return B.set(n,o),o}function G(s){if(!s)return()=>0;const n=s instanceof Uint8Array?s:s.words;if(n instanceof Uint8Array){const u=s instanceof Uint8Array?"lsb":z(s);if(u==="lsb")return o=>n[o>>>3]>>>(o&7)&1;if(u==="msb")return o=>n[o>>>3]>>>7-(o&7)&1}return typeof s.get=="function"?u=>s.get(u)?1:0:()=>0}function P(s){return!s||!s.presence?null:G(s.presence)}function O(s){return s?typeof s.size=="number"?s.size:typeof s.values=="function"?s.values().length:0:0}function b(s,n){return s?typeof s.valueOf=="function"?s.valueOf(n):typeof s.values=="function"?s.values()[n]:null:null}function c(s,n){const u=s.offsets,o=s.values;if(!u||!o)return[];const a=u[n],f=u[n+1];if(!(f>a))return[];const w=s.dict,m=new Array(f-a);for(let v=a;v<f;v++)m[v-a]=w?b(w,o[v]):o[v];return m}function d(s){if(!s)return()=>{};const n=s.values,u=P(s),o=s.kind;if(o==="dictionary"){const a=s.dict;return u?f=>u(f)?b(a,n[f]):null:f=>b(a,n[f])}if(o==="bitset"){const a=G(n);return u?f=>u(f)?a(f)===1:null:f=>a(f)===1}if(o==="multi")return u?a=>u(a)?c(s,a):null:a=>c(s,a);if(!n&&typeof s.get=="function"){const a=s.get.bind(s);return f=>{const w=a(f);return w===void 0?null:w}}return u?a=>{if(!u(a))return null;const f=n[a];return f===void 0?null:f}:a=>{const f=n[a];return f===void 0?null:f}}function l(s,n){if(s<n)return-1;if(s>n)return 1;if(s===n){const a=Object.is(s,-0),f=Object.is(n,-0);return a===f?0:a?-1:1}const u=Number.isNaN(s),o=Number.isNaN(n);return u&&o?0:u?1:-1}function r(s){const n=L(s);return(u,o)=>{if(u===o)return 0;const a=typeof u,f=typeof o;if(a==="string"&&f==="string")return n.compare(u,o);if(a==="number"&&f==="number")return l(u,o);if(a==="boolean"&&f==="boolean")return u===o?0:u?1:-1;if(u instanceof Date||o instanceof Date){const w=u instanceof Date?u.getTime():Number(u),m=o instanceof Date?o.getTime():Number(o);return l(w,m)}return X(u,o)}}function t(s,n){if(s&&typeof s.ranks=="function")return s.ranks(n);const u=s&&typeof s.values=="function"?s.values():[],o=u.length,a=r(n),f=new Array(o);for(let m=0;m<o;m++)f[m]=m;f.sort((m,v)=>a(u[m],u[v])||m-v);const w=new Uint32Array(o);for(let m=0;m<o;m++)w[f[m]]=m;return w}function i(s){return s==null||typeof s=="number"&&Number.isNaN(s)}}),Be("packages/core/src/compute/filter.js",function(e,H){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ce}});const L=H("packages/core/src/internal/predicates.js").isBlank,D=H("packages/core/src/internal/merge.js").toArray,Z=H("packages/core/src/internal/warn.js").warnOnce,Y=H("packages/core/src/format/date.js"),B=Y.toDate,z=Y.toIsoDate,G=H("packages/core/src/compute/handle.js"),P=G.bitReader,O=G.dictSize,b=G.dictValue,c=G.presenceReader,d=G.valueComparator,l=G.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,t="\0null\0";function i(de,Ae){const je=de&&de.pool;if(je){const be=je.mask||je.acquireMask||je.acquire||je.take;if(typeof be=="function"){const re=be.call(je,Ae);if(re&&re.length>=Ae)return re}}return new Uint8Array(Ae)}function s(de,Ae){const je=de&&de.pool;if(!je||!Ae)return;const be=je.release||je.releaseMask||je.free||je.recycle;typeof be=="function"&&be.call(je,Ae)}function n(de,Ae,je){return de.fill(je,0,Ae),de}function u(de){return de==null||typeof de=="number"&&Number.isNaN(de)}function o(de,Ae){if(de==null)return de;if(Ae==="number")return typeof de=="number"?de:Number(de);if(Ae==="date"||Ae==="dateString"){const je=z(de);return je===null?a(de):je}return Ae==="boolean"?typeof de=="boolean"?de:de==="true"||de===1?!0:de==="false"||de===0?!1:!!de:de}function a(de){return de instanceof Date?de.getTime():typeof de=="number"?de:Date.parse(String(de))}function f(de){return typeof de=="number"?de:de instanceof Date?de.getTime():de==null||de===""?NaN:Number(de)}function w(de,Ae){const je=typeof de=="string"?de:String(de);return Ae?je:je.toLowerCase()}function m(de,Ae){return de==null?t:typeof de=="string"?Ae?de:de.toLowerCase():de instanceof Date?de.getTime():de}function v(de,Ae,je){const be=new Set;for(const re of D(de)){const fe=o(re,je);be.add(m(fe,Ae)),typeof fe=="string"&&fe!==""&&Number.isFinite(Number(fe))?be.add(Number(fe)):typeof fe=="number"&&Number.isFinite(fe)&&be.add(m(String(fe),Ae))}return be}function h(de,Ae,je){if(de==null||Ae===null||Ae===void 0)return de==null&&Ae==null;const be=typeof de,re=typeof Ae;return be==="string"&&re==="string"?je?de===Ae:de.toLowerCase()===Ae.toLowerCase():de instanceof Date||Ae instanceof Date?a(de)===a(Ae):be==="number"&&re==="number"?de===Ae||Number.isNaN(de)&&Number.isNaN(Ae):be==="number"&&re==="string"?de===Number(Ae):be==="string"&&re==="number"?Number(de)===Ae:be==="boolean"||re==="boolean"?de===Ae:Array.isArray(de)&&Array.isArray(Ae)?de.length===Ae.length&&de.every((fe,pe)=>h(fe,Ae[pe],je)):de===Ae}function p(de,Ae){try{if(de instanceof RegExp){const je=de.flags.replace(/[gy]/g,"");return new RegExp(de.source,Ae||je.includes("i")?je:`${je}i`)}return new RegExp(String(de),Ae?"":"i")}catch(je){return Z(`regex:${String(de)}`,`filter operator "matches" received an invalid pattern: ${String(de)}`,je),null}}function g(de,Ae){if(de&&de.type==="datetime"&&k.has(de.op))return W(de,Ae);const je=R(de,Ae),be=de&&de.type;return be!=="date"&&be!=="dateString"?je:re=>je(typeof re=="string"&&r.test(re)?re:z(re)??re)}const k=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,T=new Map;function j(de,Ae){let je=T.get(Ae);if(je===void 0){try{je=new Intl.DateTimeFormat("en-CA",{timeZone:Ae,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{je=null}T.set(Ae,je)}if(!je)return null;const be={};for(const re of je.formatToParts(de))re.type!=="literal"&&(be[re.type]=re.value);return be}function N(de,Ae){if(de==null||de==="")return null;if(typeof de=="string"){const fe=y.exec(de.trim());if(fe)return Date.UTC(+fe[1],+fe[2]-1,+fe[3],+(fe[4]||0),+(fe[5]||0),+(fe[6]||0),+(fe[7]||"0").padEnd(3,"0"))}const je=B(de);if(!je)return null;const be=je.getUTCMilliseconds(),re=Ae?j(je,Ae):null;return re?Date.UTC(+re.year,+re.month-1,+re.day,re.hour==="24"?0:+re.hour,+re.minute,+re.second,be):Date.UTC(je.getFullYear(),je.getMonth(),je.getDate(),je.getHours(),je.getMinutes(),je.getSeconds(),be)}function W(de,Ae){const je=typeof de.timeZone=="string"&&de.timeZone?de.timeZone:void 0,be=pe=>N(pe,je),re=Array.isArray(de.value)?de.value.map(be):be(de.value),fe=R({...de,type:"number",value:re},Ae);return pe=>fe(N(pe))}function R(de,Ae){const je=de&&de.op,be=!!(de&&de.caseSensitive),re=de&&de.type,fe=d(Ae),pe=Oe=>ve=>!Oe(ve);switch(je){case"eq":{const Oe=o(de.value,re);return ve=>h(ve,Oe,be)}case"ne":{const Oe=o(de.value,re);return ve=>!h(ve,Oe,be)}case"lt":case"lte":case"gt":case"gte":{const Oe=o(de.value,re);if(u(Oe))return()=>!1;const ve=je==="lt"?-1:je==="lte"?0:je==="gt"?1:2;return $e=>{if(u($e))return!1;const he=fe($e,Oe);return ve===-1?he<0:ve===0?he<=0:ve===1?he>0:he>=0}}case"between":case"notBetween":{const Oe=D(de.value),ve=o(Oe[0],re),$e=o(Oe[1],re),he=de.bounds||"[]",ye=he.charAt(0)!=="(",Se=he.charAt(1)!==")";if(u(ve)||u($e))return je==="between"?()=>!1:()=>!0;const Ie=we=>{if(u(we))return!1;const Fe=fe(we,ve),He=fe(we,$e);return(ye?Fe>=0:Fe>0)&&(Se?He<=0:He<0)};return je==="between"?Ie:pe(Ie)}case"in":case"notIn":{const Oe=v(de.value,be,re),ve=$e=>Oe.has(m($e,be));return je==="in"?ve:pe(ve)}case"contains":case"notContains":{const Oe=w(o(de.value,re),be),ve=$e=>$e==null?!1:w($e,be).includes(Oe);return je==="contains"?ve:pe(ve)}case"startsWith":{const Oe=w(o(de.value,re),be);return ve=>ve==null?!1:w(ve,be).startsWith(Oe)}case"endsWith":{const Oe=w(o(de.value,re),be);return ve=>ve==null?!1:w(ve,be).endsWith(Oe)}case"matches":{const Oe=p(de.value,be);return Oe?ve=>ve==null?!1:Oe.test(String(ve)):()=>!1}case"blank":return Oe=>L(Oe)||Array.isArray(Oe)&&Oe.length===0;case"notBlank":return Oe=>!(L(Oe)||Array.isArray(Oe)&&Oe.length===0);case"containsAny":case"containsNone":{const Oe=v(de.value,be,re),ve=$e=>{const he=$e==null?[]:D($e);for(let ye=0;ye<he.length;ye++)if(Oe.has(m(he[ye],be)))return!0;return!1};return je==="containsAny"?ve:pe(ve)}case"containsAll":{const Oe=D(de.value).map(ve=>m(o(ve,re),be));return ve=>{const $e=ve==null?[]:D(ve);if(Oe.length===0)return!0;const he=new Set($e.map(ye=>m(ye,be)));for(let ye=0;ye<Oe.length;ye++)if(!he.has(Oe[ye]))return!1;return!0}}default:{const Oe=ce(je);return Oe?Oe.compile(de.value):(Z(`op:${String(je)}`,`unknown filter operator "${String(je)}"; the condition is refused rather than matching every row`),()=>!1)}}}function x(de,Ae,je){return g(Ae,je)(de)}const A=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),$=new Set(["containsAny","containsAll","containsNone"]);function I(de,Ae,je){const be=de&&de.op,re=A[be]||be,fe=g({...de,op:re,type:Ae.type},je),pe=Ae.items,Oe=ve=>{const $e=pe(ve);if(!$e)return!1;for(let he=0;he<$e.length;he++)if(fe($e[he]))return!0;return!1};return A[be]?ve=>!Oe(ve):Oe}function M(de,Ae,je,be){const re=c(de);if(re){const Oe=Ae?1:0;for(let ve=0;ve<be;ve++)je[ve]=re(ve)===Oe?1:0;return je}const fe=de.kind;if(fe==="float64"||fe==="int32"||fe==="bitset")return n(je,be,Ae?1:0);const pe=l(de);for(let Oe=0;Oe<be;Oe++){const ve=pe(Oe),$e=L(ve)||Array.isArray(ve)&&ve.length===0;je[Oe]=$e===Ae?0:1}return je}function S(de,Ae,je,be){const re=de.dict,fe=O(re),pe=new Uint8Array(fe);for(let he=0;he<fe;he++)pe[he]=Ae(b(re,he))?1:0;const Oe=de.values,ve=c(de);if(!ve){for(let he=0;he<be;he++)je[he]=pe[Oe[he]];return je}const $e=Ae(null)?1:0;for(let he=0;he<be;he++)je[he]=ve(he)===1?pe[Oe[he]]:$e;return je}function E(de,Ae,je,be){const re=P(de.values),fe=Ae(!0)?1:0,pe=Ae(!1)?1:0,Oe=c(de);if(!Oe){for(let $e=0;$e<be;$e++)je[$e]=re($e)===1?fe:pe;return je}const ve=Ae(null)?1:0;for(let $e=0;$e<be;$e++)je[$e]=Oe($e)===0?ve:re($e)===1?fe:pe;return je}function U(de,Ae,je,be,re){const fe=de.values,pe=Ae.type,Oe=Ae.op;let ve=!0;switch(Oe){case"eq":case"ne":{const he=f(o(Ae.value,pe)),ye=typeof Ae.value=="number"&&Number.isNaN(Ae.value),Se=Oe==="ne"?1:0;if(ye)for(let Ie=0;Ie<re;Ie++)be[Ie]=(Number.isNaN(fe[Ie])?1:0)^Se;else for(let Ie=0;Ie<re;Ie++)be[Ie]=(fe[Ie]===he?1:0)^Se;break}case"lt":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]<he?1:0;break}case"lte":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]<=he?1:0;break}case"gt":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]>he?1:0;break}case"gte":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]>=he?1:0;break}case"between":case"notBetween":{const he=D(Ae.value),ye=f(o(he[0],pe)),Se=f(o(he[1],pe)),Ie=Ae.bounds||"[]",we=Ie.charAt(0)!=="(",Fe=Ie.charAt(1)!==")",He=Oe==="notBetween"?1:0;if(we&&Fe)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>=ye&fe[Ke]<=Se?1:0)^He;else if(we)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>=ye&fe[Ke]<Se?1:0)^He;else if(Fe)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>ye&fe[Ke]<=Se?1:0)^He;else for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>ye&fe[Ke]<Se?1:0)^He;break}case"in":case"notIn":{const he=new Set;for(const Se of D(Ae.value)){const Ie=f(o(Se,pe));Number.isNaN(Ie)||he.add(Ie)}const ye=Oe==="notIn"?1:0;for(let Se=0;Se<re;Se++)be[Se]=(he.has(fe[Se])?1:0)^ye;break}default:ve=!1;break}if(!ve)return!1;const $e=c(de);if($e){const he=je(null)?1:0;for(let ye=0;ye<re;ye++)$e(ye)===0&&(be[ye]=he)}return!0}function K(de,Ae,je,be){const re=l(de);for(let fe=0;fe<be;fe++)je[fe]=Ae(re(fe))?1:0;return je}function q(de,Ae,je){const be=Ae.count|0,re=je||i(Ae,be);if(!de)return n(re,be,1);const fe=typeof Ae.handle=="function"?Ae.handle(de.col):void 0,pe=typeof Ae.custom=="function"?Ae.custom:null;if(!fe){if(pe){for(let he=0;he<be;he++)re[he]=pe(de,he)?1:0;return re}return Z(`filter:col:${String(de.col)}`,`filter references unknown column "${String(de.col)}"; the condition is refused rather than matching every row`),n(re,be,0)}const Oe=de.op;if(Oe==="blank"||Oe==="notBlank")return M(fe,Oe==="notBlank",re,be);const ve=typeof Ae.itemwise=="function"?Ae.itemwise(de.col):null;if(ve&&!ce(Oe)&&!$.has(Oe))return K(fe,I(de,ve,Ae.locale),re,be);const $e=g(de,Ae.locale);switch(fe.kind){case"dictionary":return S(fe,$e,re,be);case"bitset":return E(fe,$e,re,be);case"float64":case"int32":return U(fe,de,$e,re,be)?re:K(fe,$e,re,be);default:return K(fe,$e,re,be)}}function _(de,Ae,je){if(!de)return n(i(Ae,je),je,1);if(Array.isArray(de.conditions)){const be=de.conditions.filter(pe=>pe!=null),re=de.op==="or"?"or":de.op==="not"?"not":"and";if(be.length===0)return n(i(Ae,je),je,1);const fe=_(be[0],Ae,je);for(let pe=1;pe<be.length;pe++){const Oe=_(be[pe],Ae,je);if(re==="or")for(let ve=0;ve<je;ve++)fe[ve]|=Oe[ve];else for(let ve=0;ve<je;ve++)fe[ve]&=Oe[ve];s(Ae,Oe)}if(re==="not")for(let pe=0;pe<je;pe++)fe[pe]^=1;return fe}return q(de,Ae,i(Ae,je))}function J(de,Ae){return _(de,Ae,Ae.count|0)}function ee(de,Ae){if(!de||!Ae)return de||null;const je=de;if(Array.isArray(je.conditions)){if((je.op==="or"?"or":je.op==="not"?"not":"and")!=="and")return ne(je,Ae)?null:de;const re=[];for(const fe of je.conditions){const pe=ee(fe,Ae);pe&&re.push(pe)}return re.length?{...je,op:"and",conditions:re}:null}return je.col===Ae?null:de}function ne(de,Ae){if(!de||typeof de!="object")return!1;const je=de;if(je.col===Ae)return!0;if(Array.isArray(je.conditions)){for(const be of je.conditions)if(ne(be,Ae))return!0}return!1}function oe(de,Ae,je){if(je&&je.length>=Ae){let pe=0;for(let Oe=0;Oe<Ae;Oe++)de[Oe]&&(je[pe++]=Oe);return je.subarray(0,pe)}let be=0;for(let pe=0;pe<Ae;pe++)be+=de[pe]?1:0;const re=new Uint32Array(be);let fe=0;for(let pe=0;pe<Ae;pe++)de[pe]&&(re[fe++]=pe);return re}const ie=new Map;function ae(de){if(!(!de||typeof de!="object"))for(const[Ae,je]of Object.entries(de))je&&typeof je.compile=="function"&&ie.set(Ae,je)}function ce(de){return typeof de=="string"?ie.get(de):void 0}}),Be("packages/core/src/columns/datatypes.js",function(e,H){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return I}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,D=H("packages/core/src/internal/predicates.js"),F=D.isNil,Z=D.isObject,Y=D.isFunction,z=H("packages/core/src/internal/warn.js").fail,P=H("packages/core/src/internal/text.js").titleCase,O=H("packages/core/src/format/date.js"),b=O.toDate,c=O.toIsoDate,d=O.compareIso,r=H("packages/core/src/format/boolean.js").toTriState,i=H("packages/core/src/columns/types/index.js").EXTENDED_TYPES,s=H("packages/core/src/formula/index.js"),n=s.evaluateFormula,u=s.looksLikeFormula,a=H("packages/core/src/compute/filter.js").declareOperators,f=/^\d{4}-\d{2}-\d{2}$/;function w(M){return M.getHours()===0&&M.getMinutes()===0&&M.getSeconds()===0&&M.getMilliseconds()===0}const m=new Map;function v(M){const S=M||"",E=m.get(S);if(E)return E;const U={group:",",decimal:"."};try{for(const K of new Intl.NumberFormat(M||void 0).formatToParts(12345.6))K.type==="group"?U.group=K.value:K.type==="decimal"&&(U.decimal=K.value)}catch{}return m.set(S,U),U}const h=/\d\s*[*/^]\s*[\d.(]/;function p(M,S){if(F(M))return null;let E=String(M).trim();if(E===""||E.startsWith("=")||h.test(E))return null;let U=1;E.startsWith("(")&&E.endsWith(")")&&(U=-1,E=E.slice(1,-1));const K=E.endsWith("%"),{group:q,decimal:_}=v(S);if(E=E.replace(/[\s\u00a0\u202f\u2009']/g,""),q&&q!=="."&&q!==","&&(E=E.split(q).join("")),E=E.replace(/[^0-9eE+\-.,]/g,""),_===","?E=E.split(".").join("").replace(",","."):E=E.split(",").join(""),E===""||E==="-"||E==="+")return null;const J=Number(E);return Number.isNaN(J)?null:U*(K?J/100:J)}function g(M,S){const E=F(M)||Number.isNaN(M)?null:Number(M),U=F(S)||Number.isNaN(S)?null:Number(S);return E===null?U===null?0:1:U===null||E<U?-1:E>U?1:0}function k(M,S){const E=r(M),U=r(S);return E===null?U===null?0:1:U===null?-1:E===U?0:E?1:-1}function y(M,S){const E=b(M),U=b(S);if(!E)return U?1:0;if(!U)return-1;const K=E.getTime(),q=U.getTime();return K<q?-1:K>q?1:0}const T=new Map;function j(M){const S=b(M.value);if(!S)return"";const E=M.locale||"";let U=T.get(E);return U||(U=new Intl.DateTimeFormat(M.locale||void 0,{dateStyle:"medium"}),T.set(E,U)),U.format(S)}const N={boolean:{base:"boolean",storage:"bitset",matches:M=>typeof M=="boolean",parse:M=>r(M.text),compare:k,format:M=>r(M.value)===null?"":r(M.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:M=>r(M)===null?"":String(r(M)),fromClipboard:M=>r(M)},number:{base:"number",storage:"float64",matches:M=>typeof M=="number"&&!Number.isNaN(M),parse:M=>{if(u(M.text)){const S=n(M.text,M);if(!S.ok)return null;const E=Number(S.value);return Number.isFinite(E)?E:null}return p(M.text,M.locale)},compare:g,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:M=>F(M)?"":String(M),fromClipboard:(M,S)=>p(M,S&&S.locale)},date:{base:"dateString",storage:"dictionary",matches:M=>typeof M=="string"&&f.test(M)&&!Number.isNaN(Date.parse(M))||M instanceof Date&&!Number.isNaN(M.getTime())&&w(M),parse:M=>c(M.text),compare:d,format:j,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:M=>c(M),toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>c(M)},dateString:{base:"dateString",storage:"dictionary",matches:M=>typeof M=="string"&&f.test(M)&&!Number.isNaN(Date.parse(M)),parse:M=>c(M.text),compare:d,format:j,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:M=>c(M),toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>c(M)},text:{base:"text",storage:"dictionary",matches:M=>typeof M=="string",parse:M=>M.text===""?null:String(M.text),compare:(M,S)=>F(M)?F(S)?0:1:F(S)?-1:L().compare(String(M),String(S)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},image:{base:"text",storage:"dictionary",parse:M=>M.text===""||M.text==null?null:String(M.text).trim(),compare:(M,S)=>F(M)?F(S)?0:1:F(S)?-1:L().compare(String(M),String(S)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},lookup:{base:"text",storage:"dictionary",parse:M=>{if(M.text===""||M.text==null)return null;const S=M.column&&M.column.lookup,E=S&&Y(S.options)?S.options():null;if(!E)return M.text;const U=String(M.text),K=E.find(J=>String(J.id)===U);if(K)return K.id;const q=U.trim().toLowerCase(),_=E.find(J=>String(J.label).toLowerCase()===q);return _?_.id:M.text},compare:X,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},object:{base:"object",storage:"object",matches:M=>M!==null&&typeof M=="object"&&!(M instanceof Date),parse:M=>{try{return M.text===""?null:JSON.parse(M.text)}catch{return M.text}},compare:(M,S)=>X(M,S),format:M=>{const S=M.value;if(F(S))return"";if(typeof S=="string")return S;try{return JSON.stringify(S)}catch{return String(S)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:M=>F(M)?"":typeof M=="string"?M:JSON.stringify(M),fromClipboard:M=>M}},W=["boolean","number","date","dateString","datetime","text","object"];function R(M,S,E,U){const K=E.get(M);if(K)return K;U.includes(M)&&z(`circular data type extends chain: ${[...U,M].join(" → ")}`);const q=S[M];q||z(`unknown data type "${M}"`);let _=null;q.extends&&(_=R(q.extends,S,E,[...U,M]));const J={..._||{},...q,name:M,defaults:{..._&&_.defaults||{},...q.defaults||{}}};return J.base||(J.base=_&&_.base||"text"),J.storage||(J.storage=_&&_.storage||"object"),E.set(M,J),J}function x(M,S){const E={...N,...i};if(S&&typeof S.dataType=="function"&&typeof S.names=="function")for(const K of S.names("dataType")){const q=S.dataType(K);q&&(E[K]=q)}if(Z(M))for(const[K,q]of Object.entries(M))E[K]=q;const U=new Map;for(const K of W)R(K,E,U,[]);R("lookup",E,U,[]);for(const K of Object.keys(E))R(K,E,U,[]);for(const K of U.values())a(K.operators);return U}function A(M,S){if(M.base==="text"&&(!M.compare||M.compare===N.text.compare)){const E=L(S);return(U,K)=>F(U)?F(K)?0:1:F(K)?-1:E.compare(String(U),String(K))}return M.compare||X}function $(M,S){return S?M.multiStorage||"multi":M.storage||"object"}function I(M){return P(String(M).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Be("packages/core/src/columns/infer.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/warn.js").infoOnce,D=H("packages/core/src/internal/predicates.js").isNil,F=100;function Z(B,z,G={}){const P=G.sampleSize??F,O=[];for(let b=0;b<B.length&&O.length<P;b++){const c=B[b];D(c)||typeof c=="number"&&Number.isNaN(c)||O.push(c)}if(O.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,c]of z){if(typeof c.matches!="function")continue;let d=!0;for(let l=0;l<O.length;l++)if(!c.matches(O[l])){d=!1;break}if(d)return{type:b,unanimous:!0,sampled:O.length}}return G.quiet||L(`infer:${G.colId||"?"}`,`column "${G.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:O.length}}function Y(B,z,G,P,O={}){const b=O.sampleSize??F,c=[];for(let d=0;d<z.length&&c.length<b;d++){const l=G(z[d]);D(l)||typeof l=="number"&&Number.isNaN(l)||c.push(l)}return Z(c,P,{...O,colId:B}).type}}),Be("packages/core/src/columns/graph.js",function(e,H){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/internal/warn.js"),L=te.DEV,X=te.fail,D=te.warnOnce,Z=H("packages/core/src/internal/predicates.js").isFunction,Y="*";function B(O){const b=O.value||{};if(!Z(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const d=b.pure!==!1;return b.deps===Y?{computed:!0,wholeRow:!0,deps:[],pure:d}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:d}:(D(`deps:missing:${O.id}`,`computed column "${O.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:d})}function z(O){const b=new Map;for(const f of O)b.set(f.id,f);const c=new Map,d=new Map,l=new Set,r=new Set,t=new Set,i=new Set;for(const f of O){const w=B(f);if(!w.computed){c.set(f.id,[]);continue}r.add(f.id),(w.pure?t:i).add(f.id),w.wholeRow&&l.add(f.id);const m=[],v=[];for(const h of w.deps)(b.has(h)?m:v).push(h);c.set(f.id,m),v.length&&d.set(f.id,v)}for(const f of t)for(const w of c.get(f))i.has(w)&&X(`pure computed column "${f}" depends on impure column "${w}". Mark it \`value.pure: false\` or make the dependency pure.`);const s=[],n=new Map,u=[],o=f=>{const w=n.get(f);if(w!=="done"){if(w==="open"){const m=u.indexOf(f);X(`circular column dependency: ${[...u.slice(m),f].join(" → ")}`)}n.set(f,"open"),u.push(f);for(const m of c.get(f)||[])b.has(m)&&o(m);u.pop(),n.set(f,"done"),s.push(f)}};for(const f of O)o(f.id);const a=new Map;for(const f of O)a.set(f.id,[]);for(const f of O)for(const w of c.get(f.id)||[]){const m=a.get(w);m&&!m.includes(f.id)&&m.push(f.id)}if(l.size)for(const f of O){if(r.has(f.id))continue;const w=a.get(f.id);for(const m of l)w.includes(m)||w.push(m)}return{order:s,dependents:a,pure:t,impure:i,computed:r,deps:c,wholeRow:l,external:d,index:b}}function G(O,b){const c=Array.isArray(b)?b:[b],d=new Set,l=[...c];for(;l.length;){const r=l.shift();for(const t of O.dependents.get(r)||[])d.has(t)||(d.add(t),l.push(t))}for(const r of c)d.delete(r);return O.order.filter(r=>d.has(r))}function P(O,b,c){if(!L)return O;const d=b instanceof Set?b:new Set(b);return new Proxy(O,{get(l,r){return typeof r=="string"&&!d.has(r)&&!Object.hasOwn(l,r)&&D(`undeclared:${c}:${r}`,`computed column "${c}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),l[r]}})}}),Be("packages/core/src/model/rowkey.js",function(e,H){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/paths.js").pathGetter,F=H("packages/core/src/internal/predicates.js"),Z=F.isFunction,Y=F.isBlank,B=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],z="";function G(t){if(t===null)return"\0n";if(t===void 0)return"\0u";const i=typeof t;if(i==="string")return t;if(i==="number"||i==="bigint"||i==="boolean")return String(t);if(t instanceof Date)return`\0d${t.getTime()}`;try{return`\0o${JSON.stringify(t)}`}catch{return"\0o?"}}function P(t){if(t.length===1)return G(t[0]);let i="";for(let s=0;s<t.length;s++)s&&(i+=z),i+=G(t[s]);return i}function O(t,i={}){const s=i.warn!==!1;if(Z(t)){const n=t;return{stable:!0,fields:[],disabled:[],key(u,o){try{const a=n(u);return Array.isArray(a)?P(a):G(a)}catch(a){return L("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",a),`#${o??-1}`}},keyEmpty(u){try{const o=n(u);return Array.isArray(o)?o.length===0||o.some(Y):Y(o)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(t)&&t.length>0){const n=t.filter(a=>typeof a=="string"),u=n.map(a=>D(a)),o=u.length;return{stable:!0,fields:n,disabled:[],key(a){const f=new Array(o);for(let w=0;w<o;w++)f[w]=u[w](a);return P(f)},keyEmpty(a){for(let f=0;f<o;f++)if(Y(u[f](a)))return!0;return!1},missingFields(a){const f=[];for(let w=0;w<o;w++)Y(u[w](a))&&f.push(n[w]);return f}}}if(typeof t=="string"&&t.length>0){const n=D(t);return{stable:!0,fields:[t],disabled:[],key(u){return G(n(u))},keyEmpty(u){return Y(n(u))},missingFields(u){return Y(n(u))?[t]:[]}}}return s&&L("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${B.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:B.slice(),key(n,u){if(n===null||typeof n!="object")return`#${u??0}:${String(n)}`;let o=b.get(n);return o===void 0&&(o=`#${c++}`,b.set(n,o)),o}}}const b=new WeakMap;let c=0;function d(t,i){if(!t||t.stable===!1||!Z(t.keyEmpty)||!Array.isArray(i)||i.length===0)return;let s=0,n=null,u;for(let w=0;w<i.length;w++){const m=i[w];t.keyEmpty(m)&&(s++,n===null&&(n=Z(t.missingFields)?t.missingFields(m):[],u=m))}if(s===0)return;const o=t.fields.length?t.fields.join(","):"(function)",a=n&&n.length?n.join(", "):t.fields.length?t.fields.join(", "):"the rowKey function",f=u!==null&&typeof u=="object"?Object.keys(u).join(", ")||"(no fields)":String(u);L(`rowKey.emptyValue:${o}`,`rowKey ${a} is missing on ${s} of ${i.length} rows; the first such row has: ${f}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function l(t){return P(t)}function r(t){return t.split(z)}}),Be("packages/core/src/columns/lookup.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return t}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,D=H("packages/core/src/internal/predicates.js"),F=D.isFunction,Z=D.isNil,B=H("packages/core/src/internal/warn.js").warnOnce,G=H("packages/core/src/model/rowkey.js").compositeKey,P=", ",O="";function b(i,s,n,u){if(i===null||typeof i!="object")return{id:i,label:i==null?"":String(i)};const o=i[s],a=i[n],f={id:o,label:a==null?String(o??""):String(a)};i.disabled&&(f.disabled=!0),i.variant&&(f.variant=i.variant),i.icon&&(f.icon=i.icon);const w=u?i[u]:i.group;return w!==void 0&&(f.group=w),f}function c(i,s,n=0,u=[],o=[]){for(const a of i||[]){const f=a&&typeof a=="object"?a[s]:null;if(o.push({raw:a,depth:n,path:u}),Array.isArray(f)&&f.length){const w=String(a&&typeof a=="object"?a.label??a.name??a.id??"":a);c(f,s,n+1,[...u,w],o)}}return o}function d(i){return!!i&&typeof i=="object"&&!Array.isArray(i)&&F(i.router&&i.router.subscribe)}class l{#e;#t;#n;#r;#s=[];#i=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#f=null;#d=new Map;constructor(s,n={}){this.#e=s||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=L(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??P}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#s}setLocale(s){this.#n=s,this.#u=L(s)}#h(s){const n=this.#e,u=n.valueKey||"id",o=n.labelKey||"label",a=n.childrenKey||"children";this.#s=c(s,a).map(f=>{const w=b(f.raw,u,o,n.groupKey);return f.depth&&(w.depth=f.depth,w.path=f.path),w}),this.#i=new Map,this.#o=new Map,this.#s.forEach((f,w)=>{this.#i.set(f.id,f),this.#o.set(f.id,w)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const s=this.#e.options;if(Array.isArray(s)||s===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(d(s))return this.#c=this.#p(s),this.#c;if(!F(s))return B(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#c=Promise.resolve([]),this.#c;this.#a="loading";let n;try{n=s()}catch(u){return this.#a="error",B(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,u),this.#c=Promise.resolve([]),this.#c}return!n||!F(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=n.then(u=>(this.#h(u),this.#r&&this.#r(this),this.#s),u=>(this.#a="error",B(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,u),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(s){if(this.#f)return Promise.resolve(this.#s);const n=this.#e,u=n.valueKey||"id",o=n.labelKey||"label",a=n.groupKey,f=F(s.map)?s.map:null,w=v=>b(f?f(v):v,u,o,a).id,m=v=>this.#m(v,f,u,o,a);return s.router.subscribe(s.predicate,m,{rowKey:w}),this.#f=()=>{F(s.router.detach)&&s.router.detach(m)},this.#a="ready",Promise.resolve(this.#s)}#m(s,n,u,o,a){const f=s&&s.add||[],w=s&&s.update||[],m=s&&s.remove||[];if(!(!f.length&&!w.length&&!m.length)){for(const v of f)this.#g(v,n,u,o,a);for(const v of w)this.#g(v,n,u,o,a);for(const v of m){if(!this.#d.has(v))continue;const h=this.#d.get(v);this.#d.delete(v),this.#i.delete(h);const p=this.#s.findIndex(g=>g.id===h);p>=0&&this.#s.splice(p,1)}this.#o=new Map(this.#s.map((v,h)=>[v.id,h])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(s,n,u,o,a){const f=b(n?n(s):s,u,o,a);this.#d.set(G([f.id]),f.id);const w=this.#s.findIndex(m=>m.id===f.id);w>=0?this.#s[w]=f:this.#s.push(f),this.#i.set(f.id,f)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(s,n){const u=this.#e;if(!F(u.search)){const f=String(s||"").toLowerCase();return Promise.resolve(f===""?this.#s:this.#s.filter(w=>w.label.toLowerCase().includes(f)))}const o=u.valueKey||"id",a=u.labelKey||"label";return Promise.resolve(u.search(s,n)).then(f=>(f||[]).map(w=>b(w,o,a,u.groupKey)))}option(s){return this.#i.get(s)}has(s){return this.#i.has(s)}label(s){if(Z(s)||s==="")return"";const n=this.#i.get(s);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||B(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(s)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const u=this.#e.unknownLabel;return F(u)?String(u(s)??""):typeof u=="string"?u:String(s)}text(s){if(this.multiple){const n=r(s);return n.length===0?"":n.map(u=>this.label(u)).join(this.separator)}return this.label(s)}dictionary(){return this.#s.map(s=>s.id)}sorted(){const s=this.sortBy;if(s==="optionOrder"||s==="count")return this.#s.slice();if(s==="value")return this.#s.slice().sort((u,o)=>X(u.id,o.id));const n=this.#u;return this.#s.slice().sort((u,o)=>n.compare(u.label,o.label))}comparator(){const s=this.sortBy,n=this.multiple,u=this.#u,o=this.#o;if(n&&s==="count")return(f,w)=>r(f).length-r(w).length;const a=n?f=>r(f)[0]:f=>f;return s==="value"?(f,w)=>X(a(f),a(w)):s==="optionOrder"?(f,w)=>{const m=o.has(a(f))?o.get(a(f)):Number.MAX_SAFE_INTEGER,v=o.has(a(w))?o.get(a(w)):Number.MAX_SAFE_INTEGER;return m-v}:(f,w)=>{const m=a(f),v=a(w);return Z(m)?Z(v)?0:1:Z(v)?-1:u.compare(this.label(m),this.label(v))}}groupKey(s){return this.multiple?r(s).map(u=>String(u)).sort().join(O):Z(s)?"":String(s)}countValues(s){return this.multiple?r(s).length:Z(s)?0:1}contains(s,n,u){const o=this.multiple?r(s):Z(s)?[]:[s],a=Array.isArray(n)?n:[n];switch(u){case"containsAll":return a.every(f=>o.includes(f));case"containsNone":return!a.some(f=>o.includes(f));default:return a.some(f=>o.includes(f))}}exportText(s,n="label"){return n==="value"?this.multiple?r(s).join(this.separator):Z(s)?"":String(s):this.text(s)}exportColumns(){const s=this.multiple;return this.#s.map(n=>({id:n.id,label:n.label,has:u=>s?r(u).includes(n.id):u===n.id}))}}function r(i){return Array.isArray(i)?i:Z(i)||i===""?[]:[i]}function t(i,s={}){const n=i.lookup;if(!n)return null;const u=new l(n,{colId:i.id,locale:s.locale,onChange:s.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&u.load(),u}}),Be("packages/core/src/columns/value.js",function(e,H){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return l}});const L=H("packages/core/src/internal/paths.js").getPath,X=H("packages/core/src/internal/predicates.js"),D=X.isFunction,F=X.isNil,Y=H("packages/core/src/internal/lru.js").Lru,z=H("packages/core/src/internal/warn.js").warnOnce,P=H("packages/core/src/columns/graph.js").depsProxy,O="\0";function b(s,n={}){const u=n.locale,o=n.grid??null,a=n.context,f=s.value&&s.value.format,w=s.formatter||null,m=s.dataType&&s.dataType.format,v=s.lookup||null,h=(p,g,k)=>({value:p,data:k,row:g,column:s,colId:s.id,grid:o,context:a,locale:u});if(D(f))return(p,g,k)=>{const y=f(h(p,g,k));return y==null?"":String(y)};if(w){if(v){const p=w.kind==="text";return(g,k,y)=>w(p?v.text(g):g,h(g,k,y))}return(p,g,k)=>w(p,h(p,g,k))}return D(m)?(p,g,k)=>{const y=m(h(p,g,k));return y==null?"":String(y)}:v?p=>v.text(p):p=>F(p)?"":typeof p=="string"?p:String(p)}function c(s,n){!s||!s.value||s.value.pure!==!1||z(`impure:${n}:${s.id}`,`column "${s.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class d{#e;#t;#n;#r;#s;#i;#o=new Y(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(u=>[u.id,u])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#s=n.rowKey||l}get graph(){return this.#t}setGraph(n){this.#t=n,this.#o.clear()}beginPass(){this.#o.clear()}endPass(){this.#o.clear()}invalidate(n){if(this.#o.size===0)return;const u=n&&n.rows?new Set([...n.rows].map(String)):null,o=n&&n.columns?[...n.columns]:null;if(!u&&!o){this.#o.clear();return}const a=o?this.#l(o):null;for(const f of[...this.#o.keys()]){const w=String(f).split(O);w.length===3&&(u&&!u.has(w[0])||a&&!a.has(w[2])||this.#o.delete(f))}}#l(n){const u=new Set,o=this.#t,a=[...n];for(;a.length;){const f=a.pop();if(!u.has(f)){u.add(f);for(const w of o?o.dependents.get(f)||[]:[])a.push(w)}}return u}value(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return;if(!a.computed)return this.#c(a,u,o);if(a.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(a.id))return this.#i.get(a.id,o.physical);if(a.volatile)return this.compute(a,u,o);if(a.value.pure===!1)return this.compute(a,u,o);const f=`${this.#a(u,o)}${O}${a.id}`;if(this.#o.has(f))return this.#o.get(f);const w=this.compute(a,u,o);return this.#o.set(f,w),w}#a(n,u){return`${this.#s(n,u)}${O}${r(n)}`}#c(n,u,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,o.physical);if(n.field)return n.read?n.read(u):L(u,n.field)}compute(n,u,o){const a=this.#t,f=a&&a.wholeRow.has(n.id);let w;if(f)w=u??{};else{w={};const v=a&&a.deps.get(n.id)||[];for(const p of v)w[p]=this.value(p,u,o);const h=a&&a.external.get(n.id)||[];for(const p of h)w[p]=L(u,p);w=P(w,[...v,...h],n.id)}const m={data:u,row:o,column:n,grid:this.#n,context:this.#r};return n.value.compute(w,m)}values(n,u){const o={},a=this.#t?this.#t.order:[...this.#e.keys()];for(const f of a)o[f]=this.value(f,n,u);return o}text(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;return a?a.formatValue(this.value(a,u,o),o,u):""}key(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return"";const f=this.value(a,u,o);return D(a.value.key)?String(a.value.key(this.#u(a,f,u,o))):a.lookup?a.lookup.groupKey(f):F(f)?"":String(f)}quickFilterText(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return"";if(D(a.value.quickFilterText)){const f=this.value(a,u,o);return String(a.value.quickFilterText(this.#u(a,f,u,o))??"")}return this.text(a,u,o)}#u(n,u,o,a){return{value:u,data:o,row:a,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return u;const w={text:u,value:this.value(f,o,a),data:o,row:a,column:f,grid:this.#n,context:this.#r,locale:this.#n&&D(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&D(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return D(f.value.parse)?f.value.parse(w):f.dataType&&D(f.dataType.parse)?f.dataType.parse(w):u}validate(n,u,o,a,f){const w=typeof n=="string"?this.#e.get(n):n;if(!w||!D(w.edit.validate))return!0;const m=w.edit.validate({value:u,oldValue:o,data:a,row:f,column:w,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return!1;const w=this.value(f,o,a);if(D(f.value.apply)){const m=f.value.apply({value:u,oldValue:w,data:o,row:a,column:f,grid:this.#n,context:this.#r});return this.#f(f,o,a),m!==!1}return f.field?w===u?!1:(f.write(o,u),this.#f(f,o,a),!0):(z(`apply:${f.id}`,`column "${f.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const w=this.value(f,o,a),m=this.parse(f,u,o,a),v=this.validate(f,m,w,o,a);if(v!==!0)return{ok:!1,value:m,oldValue:w,changed:!1,error:v};const h=this.apply(f,m,o,a);return{ok:!0,value:m,oldValue:w,changed:h}}#f(n,u,o){if(this.#o.size===0)return;const a=this.#a(u,o);this.#o.delete(`${a}${O}${n.id}`);for(const f of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${a}${O}${f}`)}}function l(s,n){return n&&n.key!=null?String(n.key):r(s)}function r(s){if(s&&typeof s=="object"){let n=t.get(s);return n===void 0&&(n=`#${i++}`,t.set(s,n)),n}return String(s)}const t=new WeakMap;let i=0}),Be("packages/core/src/model/shadow.js",function(e,H){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return o}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=2e5,D=20,F=1e3,Z=50;function Y(a){return Math.min(F,Math.max(Z,Math.floor(a)))}const B=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),z=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),G=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),P=.6745,O=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),c=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function l(a,f){if(!f)return null;const w=Number.isFinite(Number(f.lower))?Number(f.lower):null,m=Number.isFinite(Number(f.upper))?Number(f.upper):null;if(w===null&&m===null||!Number.isFinite(a))return null;if(w!==null&&a<w||m!==null&&a>m)return b.FAIL;const v=Number.isFinite(Number(f.warnLower))?Number(f.warnLower):null,h=Number.isFinite(Number(f.warnUpper))?Number(f.warnUpper):null;return v!==null&&a<v||h!==null&&a>h?b.WARN:b.PASS}function r(a,f,w){if(!f||typeof f!="object")return null;if(f.kind!=="time")return f.kind!==void 0&&L(`shadow.history.window.kind:${a}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${f.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const m=f.minutes!=null?Number(f.minutes)*6e4:Number(f.span);if(!(m>0))return L(`shadow.history.window.span:${a}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const v=Math.max(2,Math.floor(w)||D);return{span:m,bucketMs:Math.max(1,Math.floor(m/v))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#o=new Map;#l=0;#a;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(f){this.#e=f.colId,this.#a=Math.max(2,f.depth||D),this.#c=Math.max(1,f.max||X),this.#u=f.now||(()=>Date.now()),this.#f=r(this.#e,f.historyWindow,this.#a),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(f,w){const m=u(w);if(m===null)return;if(!this.#n.has(f)){this.#p=null,this.#m=null,this.#g(),this.#t.set(f,m),this.#n.set(f,m),this.#r.set(f,0),this.#s.set(f,this.#u()),this.#i.set(f,[m]),this.#f&&this.#d.set(f,[m]),this.#o.set(f,0);return}const v=this.#n.get(f);if(v===m)return;this.#p=null,this.#m=null,this.#n.set(f,m),this.#r.set(f,(this.#r.get(f)||0)+1),this.#s.set(f,this.#u());const h=this.#i.get(f)||[];h.push(m),h.length>this.#a&&h.splice(0,h.length-this.#a),this.#i.set(f,h);const p=Math.sign(m-v),g=this.#o.get(f)||0;this.#o.set(f,Math.sign(g)===p?g+p:p)}#g(){if(this.#n.size<this.#c)return;const f=this.#n.keys().next().value;f!==void 0&&(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#s.delete(f),this.#i.delete(f),this.#d.delete(f),this.#o.delete(f),this.#l++)}rebase(){for(const[f,w]of this.#n)this.#t.set(f,w);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#d.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(f){const w=f instanceof Set?f:new Set(f);let m=0;for(const v of[...this.#n.keys()])w.has(v)||(this.#t.delete(v),this.#n.delete(v),this.#r.delete(v),this.#s.delete(v),this.#i.delete(v),this.#d.delete(v),this.#o.delete(v),m++);return m&&(this.#p=null,this.#m=null),m}advanceHistoryWindow(f=this.#u()){const w=this.#f;if(!w)return 0;const m=Math.floor(f/w.bucketMs),v=m-this.#h;if(!(v>0))return 0;const h=Math.min(v,this.#a);for(const[p,g]of this.#d){const k=this.#n.get(p);for(let y=0;y<h;y++)g.push(k);g.length>this.#a&&g.splice(0,g.length-this.#a)}return this.#h=m,v}read(f,w,m,v){switch(f){case"updates":return this.#r.has(w)?this.#r.get(w):0;case"updatedAt":{const h=this.#s.get(w);return h===void 0?null:new Date(h)}case"sinceUpdate":{const h=this.#s.get(w);return h===void 0?null:this.#u()-h}case"firstValue":return this.#t.has(w)?this.#t.get(w):null;case"delta":return this.#n.has(w)?this.#n.get(w)-this.#t.get(w):null;case"deltaPercent":{if(!this.#n.has(w))return null;const h=this.#t.get(w);return h?(this.#n.get(w)-h)/Math.abs(h)*100:null}case"rate":{const h=this.#i.get(w),p=this.#s.get(w);if(!h||h.length<2||p===void 0)return null;const g=this.#u()-p,k=h[h.length-1]-h[h.length-2];return g>0?k/g*1e3:k}case"history":return this.#f?this.#d.has(w)?[...this.#d.get(w)]:null:this.#i.has(w)?[...this.#i.get(w)]:null;case"streak":return this.#o.has(w)?this.#o.get(w):0;case"specStatus":return this.#n.has(w)?l(this.#n.get(w),v):null;default:return c.includes(f)?this.#j(f,w,m,v):null}}#b(f){if(f){if(this.#m&&this.#m.only===f)return this.#m.view;const w=this.#y(f);return this.#m={only:f,view:w},w}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(f){const w=[];for(const[N,W]of this.#n)f&&!f.has(N)||w.push(W);const m=w.sort((N,W)=>N-W);let v=0,h=0,p=0,g=0;for(const N of m){g+=N,v++;const W=N-h;h+=W/v,p+=W*(N-h)}const k=[];for(const[N,W]of this.#t)f&&!f.has(N)||k.push(W);const y=v?i(m):0,T=m.map(N=>Math.abs(N-y)).sort((N,W)=>N-W),j=v?i(T):0;return{sorted:m,baseline:k.sort((N,W)=>N-W),sum:g,mean:v?h:0,sd:v>1?Math.sqrt(p/(v-1)):0,median:y,mad:j}}#j(f,w,m,v){if(!this.#n.has(w)||m&&!m.has(w))return null;const h=this.#n.get(w),p=this.#b(m),g=p.sorted.length;if(!g)return null;switch(f){case"rank":return g-n(p.sorted,h)+1;case"rankAsc":return s(p.sorted,h)+1;case"rankChange":{if(!this.#t.has(w)||!p.baseline.length)return null;const k=p.baseline.length-n(p.baseline,this.#t.get(w))+1,y=g-n(p.sorted,h)+1;return k-y}case"percentile":return n(p.sorted,h)/g*100;case"quartile":{const k=n(p.sorted,h)/g;return Math.min(4,Math.max(1,Math.ceil(k*4)))}case"zScore":return p.sd?(h-p.mean)/p.sd:null;case"anomalyScore":return p.mad?P*(h-p.median)/p.mad:null;case"anomalyFlag":{if(!p.mad)return null;const k=v&&Number.isFinite(Number(v.threshold))?Number(v.threshold):O;return Math.abs(P*(h-p.median)/p.mad)>k}case"shareOfTotal":return p.sum?h/p.sum*100:null;default:return null}}}function i(a){const f=a.length;if(!f)return 0;const w=(f-1)*.5,m=Math.floor(w),v=Math.ceil(w);return m===v?a[m]:a[m]+(w-m)*(a[v]-a[m])}function s(a,f){let w=0,m=a.length;for(;w<m;){const v=w+m>>1;a[v]<f?w=v+1:m=v}return w}function n(a,f){let w=0,m=a.length;for(;w<m;){const v=w+m>>1;a[v]<=f?w=v+1:m=v}return w}function u(a){if(a==null||a==="")return null;if(a instanceof Date){const w=a.getTime();return Number.isFinite(w)?w:null}const f=typeof a=="number"?a:Number(a);return Number.isFinite(f)?f:null}function o(a){const f=[];for(const w of a||[]){const m=w.shadow;if(!m)continue;const v=typeof m=="string"?{kind:m}:m,h=v.kind;B.includes(h)&&(z.includes(h)||G.includes(h)||f.push({colId:w.id||w.field,of:v.of||w.field||w.id,kind:h,depth:v.depth,historyWindow:h==="history"?v.window:void 0}))}return f}}),Be("packages/core/src/columns/model.js",function(e,H){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Ae}});const te=H("packages/core/src/internal/merge.js"),L=te.expand,X=te.merge,D=te.toArray,F=H("packages/core/src/internal/warn.js"),Z=F.fail,Y=F.warnOnce,B=H("packages/core/src/internal/paths.js"),z=B.getPath,G=B.pathGetter,P=B.pathSetter,b=H("packages/core/src/internal/text.js").humanise,c=H("packages/core/src/internal/predicates.js"),d=c.isFunction,l=c.isObject,t=H("packages/core/src/internal/uid.js").uid,s=H("packages/core/src/format/index.js").compileFormat,n=H("packages/core/src/columns/datatypes.js"),u=n.comparatorFor,o=n.createTypeRegistry,a=n.storageKind,f=H("packages/core/src/columns/infer.js"),w=f.inferColumnType,m=f.DEFAULT_SAMPLE,v=H("packages/core/src/columns/graph.js"),h=v.buildGraph,p=v.affectedBy,k=H("packages/core/src/columns/lookup.js").createLookup,y=H("packages/core/src/columns/value.js"),T=y.compileDisplay,j=y.ValuePipeline,N=y.warnImpureUse,R=H("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,x=Object.freeze({geometry:"geometry",list:"list"}),A={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},$={centre:"center"},I=new Set(["start","center","end","left","right"]);function M(be){if(typeof be!="string")return;const re=be.toLowerCase();return $[re]?$[re]:I.has(re)?re:void 0}function S(be){if(typeof be!="string")return;const re=be.toLowerCase();return re==="center"||re==="centre"?"middle":re==="top"||re==="middle"||re==="bottom"?re:void 0}const E=["cell","layout","header"];function U(be){if(!l(be))return{};const re={...be},fe=(pe,Oe)=>{if(be[pe]===void 0)return;const ve=L(be[pe],Oe);ve&&E.includes(pe)&&!l(be[pe])&&delete ve.enabled,re[pe]=ve};return fe("sort","direction"),fe("filter","type"),fe("cell","render"),fe("edit","editor"),fe("layout","width"),fe("group","index"),fe("pivot","index"),fe("header","render"),fe("facet","strategy"),re}function K(be,re){const fe={...be||{}},pe=l(re)&&l(re.layout)&&re.layout.width!==void 0;return fe.fit==="content"&&!pe&&delete fe.width,fe}const q=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),_=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(be,re,fe,pe){const Oe=fe==="columnGroup"?"column group":"column";for(const ve of Object.keys(be))if(!re.has(ve)){if(ve==="timeZone"&&fe==="column"){Y("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${pe}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}Y(`${fe}.unknown:${ve}`,`'${ve}' is not a configuration key this grid recognises, so it had no effect on ${Oe} "${pe}". Check the spelling against the reference.`)}}function ee(be){l(be.cell)&&be.cell.autoHeight!==void 0&&Y("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${be.id||be.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(be,re){const fe=re&&d(be.defaultsFor)?be.defaultsFor(re):null,pe={...be.defaults||{},...l(fe)?fe:{}},Oe={};return pe.align&&(Oe.align=pe.align,Oe.cell={align:pe.align},Oe.header={align:pe.align}),pe.filter&&(Oe.filter=pe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:pe.filter}),pe.editor&&(Oe.edit=pe.editor==="none"?{editor:null}:{editor:pe.editor}),pe.total&&(Oe.total=pe.total),pe.render&&(Oe.cell={...Oe.cell||{},render:pe.render}),be.export&&(Oe.export={...be.export}),Oe}function oe(be){if(typeof be=="string")return be.trim()?[be.trim()]:[];if(!Array.isArray(be))return[];const re=[];for(const fe of be){if(typeof fe!="string")continue;const pe=fe.trim();pe&&!re.includes(pe)&&re.push(pe)}return re}class ie{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#o;#l;#a;#c;#u(re,fe,pe){const Oe=this.#f(re,fe,pe);if(typeof Oe!="string"||!this.#d)return Oe??null;const ve=fe&&fe.totals&&fe.totals.implement;if(ve&&d(ve[Oe])){const he=ve[Oe];return he.totalName=Oe,he}const $e=this.#d.totalFn?.(Oe);return d($e)?$e:Oe}#f(re,fe,pe){if(typeof re!="string")return re;const Oe=fe&&fe.totals&&fe.totals.supported;if(!Array.isArray(Oe)||Oe.includes(re))return re;const ve=Oe.length?Oe.join(", "):"none";return Z(`column "${pe}" is typed ${fe.name||"a type"}, for which the total "${re}" is not meaningful. Supported: ${ve}. Aggregating it anyway would produce a confident wrong number.`),re}#d;#h;#p;#m;#g;#b;#y=!1;#j;#w;constructor(re={}){this.#i=U(re.columnDefaults||{}),this.#o=re.columnPresets||{},this.#a=re.locale,this.#l=re.timeZone,this.#c=S(re.verticalAlign),this.#d=re.registry||null,this.#h=re.grid||null,this.#p=re.context,this.#j=re.sampleSize??m,this.#w=re.onChange||null,this.#b=d(re.rowKey)?re.rowKey:void 0,this.#s=o(re.dataTypes,this.#d);const{leaves:fe,groups:pe}=Ae(re.columns||[]);this.#n=pe;for(const Oe of fe){Oe.facet!==void 0&&this.#r.set(Oe.def,Oe.facet);const ve=this.#O(Oe.def,null);if(ve.groupPath=Oe.path,this.#e.has(ve.id)){Y(`columns.duplicate:${ve.id}`,`two columns resolve to the id '${ve.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}Oe.column=ve,this.#e.set(ve.id,ve),this.#t.push(ve.id)}this.#E(re.stored||null)}#O(re,fe){J(re,q,"column",re.id||re.field||"(unnamed)"),ee(re);const pe=U(re),Oe=D(re.preset),ve=Oe.map(it=>{const mt=this.#o[it];return mt?U(mt):(Y(`preset:${it}`,`unknown column preset "${it}"; ignoring`),{})}),$e=this.#S(pe,ve,fe),he=this.#s.get($e)||this.#s.get("text");if(!this.#s.has($e)&&re.type){const it=x[$e];Y(`type:${$e}`,`unknown data type "${$e}"; falling back to "text"`+(it?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${it}'.`:""))}const ye=d(he.items)?this.#T(pe,ve,re.id||re.field||"(unnamed)"):null;let Se=A;Se=X(Se,this.#i),re.type!==!1&&(Se=X(Se,ne(he,ye)));for(const it of ve)Se=X(Se,it);this.#r.has(re)&&(Se=X(Se,U({facet:this.#r.get(re)}))),Se=X(Se,pe);const Ie=Se.edit;Ie&&Ie.editor&&Ie.enabled!==!0&&!d(Ie.enabled)&&(re.edit||{}).editor&&Y(`column.editor-not-enabled:${re.id||re.field}`,`column '${re.id||re.field}' names the editor '${Ie.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const we=re.id||re.field||t("col");if(re.shadow&&!d(Se.value&&Se.value.compute)){const it=typeof re.shadow=="string"?{kind:re.shadow}:re.shadow,mt=it.of||re.field||we,kt=R.includes(it.kind),St=kt?it.model||it:null,Pt=kt&&St?[...Array.isArray(St.predictors)?St.predictors:[],St.response].filter(Boolean):null;Se.value={...Se.value||{},deps:Pt&&Pt.length?Pt:it.orderBy&&it.orderBy!==mt?[mt,it.orderBy]:[mt],pure:!1,compute:(Nt,Ft)=>{const Lt=Ft.grid&&Ft.grid.statistics;if(!Lt)return null;const Ut=Ft.row&&Ft.row.key||Lt.keyOf(Ft.data);if(!Ut)return null;if(kt){if(!d(Lt.fitShadow))return null;const ft=it.model?{...it.model,threshold:it.threshold}:it;return Lt.fitShadow(it.kind,Ut,ft)}return Lt.shadow(mt,it.kind,Ut,it.scope,it)}}}if(re.running&&!d(Se.value&&Se.value.compute)){const it=typeof re.running=="string"?{kind:re.running}:re.running,mt=it.of||re.field||we;Se.value={...Se.value||{},deps:[mt],pure:!1,compute:(kt,St)=>{const Pt=St.grid&&St.grid.statistics;if(!Pt||!d(Pt.running))return null;const Nt=St.row&&St.row.key||Pt.keyOf(St.data);return Nt?Pt.running(mt,it.kind||"total",Nt):null}},re.sort===void 0&&(Se.sort={...Se.sort||{},enabled:!1})}const Fe=re.field??(d(Se.value&&Se.value.compute)?null:re.id??null),He=d(Se.value&&Se.value.compute),Ke={id:we,field:Fe,shadow:re.shadow||null,running:re.running||null,spec:re.spec||null,validation:re.validation||null,volatile:!!(re.shadow||re.running),title:Se.title??b(Fe||we),type:he.name,dataType:he,itemType:ye,nullable:Se.nullable!==!1,align:M(pe.cell&&pe.cell.align||pe.align||Se.cell&&Se.cell.align||Se.align||he.defaults&&he.defaults.align)||"start",verticalAlign:S(pe.cell&&pe.cell.verticalAlign||pe.verticalAlign||Se.cell&&Se.cell.verticalAlign||Se.verticalAlign)||this.#c,rowSpan:d(Se.rowSpan)?Se.rowSpan:null,colSpan:d(Se.colSpan)?Se.colSpan:null,value:{pure:!0,...Se.value||{}},cell:{...Se.cell||{}},edit:{...Se.edit||{}},sort:{...Se.sort||{}},filter:{...Se.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Se.group||{}},pivot:{enabled:!1,index:-1,...Se.pivot||{}},total:this.#u(Se.total,he,re.id||re.field||"(unnamed)"),groupTotal:Se.groupTotal===void 0?null:this.#u(Se.groupTotal,he,re.id||re.field||"(unnamed)"),grandTotal:Se.grandTotal===void 0?null:this.#u(Se.grandTotal,he,re.id||re.field||"(unnamed)"),tags:oe(Se.tags),typeOptions:Se.typeOptions??null,...l(Se[$e])?{[$e]:Se[$e]}:{},layout:K(Se.layout,pe),header:{...Se.header||{}},contextMenu:Se.contextMenu===void 0?null:Se.contextMenu,facet:{...Se.facet||{}},export:{...Se.export||{}},allowGroup:Se.allowGroup!==!1,allowPivot:Se.allowPivot!==!1,allowTotal:Se.allowTotal!==!1,quickFilter:Se.quickFilter!==!1,def:re,format:Se.format,presets:Oe,inferred:fe!=null&&!re.type,computed:He,diff:re.diff===void 0?void 0:!!re.diff,read:Fe?G(Fe):null,write:Fe?P(Fe):null};Ke.cell.align=M(pe.cell&&pe.cell.align)||Ke.align,Ke.header.align=M(pe.header&&pe.header.align)||Ke.align;const nt=Se.lookup||null;return Ke.lookup=nt?k({id:we,lookup:nt},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:we})}}):null,Ke.group.explode&&Ke.lookup&&Ke.lookup.multiple&&Y(`explode:${we}`,`column "${we}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ke),Ke}#v(re){re.formatter=s(re.format,re.dataType,this.#a,this.#l,re.id),re.formatValue=T(re,{locale:this.#a,grid:this.#h,context:this.#p}),re.itemCompare=re.itemType?u(re.itemType,this.#a):null,re.compare=d(re.value.compare)?re.value.compare:re.lookup?re.lookup.comparator():d(re.dataType.compareFor)?re.dataType.compareFor(re):u(re.dataType,this.#a),re.excel=re.formatter&&re.formatter.ooxml||re.dataType&&re.dataType.excel||"General",re.storeKind=a(re.dataType,!!(re.lookup&&re.lookup.multiple))}#T(re,fe,pe){let Oe=l(re.typeOptions)?re.typeOptions:null;for(let ye=fe.length-1;!Oe&&ye>=0;ye--)l(fe[ye].typeOptions)&&(Oe=fe[ye].typeOptions);!Oe&&l(this.#i.typeOptions)&&(Oe=this.#i.typeOptions);const ve=Oe&&Oe.of!==void 0?Oe.of:"text",$e=typeof ve=="string"?this.#s.get(ve):void 0;return $e&&!d($e.items)&&$e.storage!=="object"?$e:(Y(`type:of:${String(ve)}`,`column "${pe}" names "${String(ve)}" as its item type (typeOptions.of), which is not ${$e?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#S(re,fe,pe){if(re.type===!1)return"text";if(re.type)return re.type;for(let Oe=fe.length-1;Oe>=0;Oe--)if(fe[Oe].type)return fe[Oe].type;if(this.#i.type)return this.#i.type;if(re.shadow){const Oe=typeof re.shadow=="string"?re.shadow:re.shadow.kind;if(Oe==="fitInfluence")return"boolean";if(Oe==="fitPredicted"||Oe==="fitResidual"||Oe==="fitStdResidual"||Oe==="fitLeverage"||Oe==="fitCooksD"||Oe==="tsTrend"||Oe==="tsSeasonal"||Oe==="tsResidual"||Oe==="tsCoverage"||Oe==="tsSmoothed"||Oe==="tsSmoothingAlpha"||Oe==="tsSmoothingBeta")return"number"}return pe||(re.lookup?"lookup":"text")}#E(re){const fe=this.all();this.#m=h(fe),this.#g?this.#g.setGraph(this.#m):this.#g=new j({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:re||null,rowKey:this.#b});const pe=this.#g;for(const Oe of fe)Oe.getValue=(ve,$e)=>pe.value(Oe,ve,$e)}all(){return this.#t.map(re=>this.#e.get(re))}visible(){return this.all().filter(re=>!re.layout.hidden)}get(re){return this.#e.get(re)}groups(){const re=fe=>{const pe=[];for(const Oe of fe)Array.isArray(Oe.columns)?pe.push({...Oe,columns:re(Oe.columns)}):Oe.column&&pe.push(Oe.column);return pe};return re(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(re){return p(this.#m,re)}value(re,fe,pe){return this.#g.value(re,fe,pe)}text(re,fe,pe){return this.#g.text(re,fe,pe)}checkImpure(re,fe){N(this.#e.get(re),fe)}setLocale(re){this.#a=re;for(const fe of this.all())fe.lookup&&fe.lookup.setLocale(re),this.#v(fe);this.#w&&this.#w("locale",{locale:re})}infer(re){const fe={};if(this.#y||!Array.isArray(re)||re.length===0)return fe;this.#y=!0;let pe=!1;for(const Oe of this.all()){const ve=Oe.def;if(ve.type!==void 0||!Oe.field||Oe.computed||Oe.lookup||this.#M(Oe))continue;const $e=Oe.read||(Se=>z(Se,Oe.field)),he=w(Oe.id,re,$e,this.#s,{sampleSize:this.#j});if(he===Oe.type)continue;fe[Oe.id]=he;const ye=this.#O(ve,he);ye.groupPath=Oe.groupPath,ye.layout={...ye.layout,...ae(Oe.layout)},this.#e.set(Oe.id,ye),je(this.#n,Oe.id,ye),pe=!0}return pe&&this.#E(null),fe}redecorate(re,fe,pe={}){const Oe=this.#e.get(re);if(!Oe){Y(`redecorate:${re}`,`columns.decorate('${re}', …): no column with id '${re}'.`);return}const ve=Oe.def||{},$e={...l(ve.cell)?ve.cell:{}};$e.decoration=fe??void 0,pe&&"variant"in pe&&($e.variant=pe.variant);const he={...ve,cell:$e};this.#r.has(ve)&&this.#r.set(he,this.#r.get(ve));const ye=this.#O(he,Oe.type);return ye.groupPath=Oe.groupPath,ye.layout={...ye.layout,...ae(Oe.layout)},Oe.lookup&&Oe.lookup!==ye.lookup&&d(Oe.lookup.destroy)&&Oe.lookup.destroy(),this.#e.set(re,ye),je(this.#n,re,ye),this.#E(null),this.#w&&this.#w("decorate",{colId:re}),ye}destroy(){for(const re of this.#e.values())re.lookup&&d(re.lookup.destroy)&&re.lookup.destroy()}#M(re){for(const fe of re.presets){const pe=this.#o[fe];if(pe&&pe.type)return!0}return!!this.#i.type}#P(re){return!re.computed&&d(re.dataType&&re.dataType.toStorage)}storeReader(re){if(re.computed)return fe=>this.#g.value(re,fe,null);if(this.#P(re)){const fe=re.dataType.toStorage,pe={timeZone:this.#l,colId:re.id,itemType:re.itemType||null};return Oe=>fe(re.read(Oe),pe)}return re.read}storeValue(re,fe){if(!(!re||re.computed)&&d(re.read))return this.storeReader(re)(fe)}storeSchema(){const re=[];for(const fe of this.all()){if(fe.computed&&fe.value.pure===!1||!fe.computed&&!fe.field)continue;const pe=this.storeReader(fe);let Oe=null;!fe.computed&&!this.#P(fe)&&typeof fe.field=="string"&&!fe.lookup&&(Oe=fe.field);const ve={id:fe.id,kind:fe.storeKind,nullable:fe.nullable,read:pe};Oe!==null&&(ve.field=Oe),fe.lookup&&(ve.dictionary=fe.lookup.dictionary()),re.push(ve)}return re}state(){return this.all().map(re=>({id:re.id,width:re.layout.width,flex:re.layout.flex||void 0,hidden:!!re.layout.hidden,headerWrap:re.header?.wrap===!0?!0:void 0,headerOrientation:re.header?.orientation==="vertical"?"vertical":void 0,pin:re.layout.pin??null,sort:re.sort.direction??null,sortIndex:re.sort.direction?re.sort.order??0:null,groupIndex:re.group.enabled?re.group.index??0:null,pivotIndex:re.pivot.enabled?re.pivot.index??0:null,total:typeof re.total=="string"?re.total:null,groupTotal:typeof re.groupTotal=="string"?re.groupTotal:void 0,grandTotal:typeof re.grandTotal=="string"?re.grandTotal:void 0,decoration:re.cell&&re.cell.decoration!=null?ce(re.cell.decoration):void 0,variant:re.cell&&re.cell.variant!=null?ce(re.cell.variant):void 0}))}applyState(re,fe={}){const pe={applied:[],skipped:[]},Oe=Array.isArray(re)?re:re&&re.columns||[],ve=!Array.isArray(re)&&re&&re.columnOrder||null;for(const he of Oe){if(!he||!he.id){pe.skipped.push({key:"?",reason:"no id"});continue}let ye=this.#e.get(he.id);if(!ye){pe.skipped.push({key:he.id,reason:"unknown column"});continue}if(Object.hasOwn(he,"decoration")||Object.hasOwn(he,"variant")){const Se=ye.cell?ye.cell.decoration:void 0,Ie=he.decoration??null,we=Object.hasOwn(he,"variant"),Fe=we&&!de(ye.cell?ye.cell.variant:void 0,he.variant);(!de(Se,Ie)||Fe)&&(this.redecorate(he.id,Ie,we?{variant:he.variant??void 0}:{}),ye=this.#e.get(he.id)||ye)}he.width!=null&&(ye.layout.width=he.width),he.flex!=null&&(ye.layout.flex=he.flex),he.hidden!=null&&(ye.layout.hidden=!!he.hidden),he.headerWrap!==void 0&&(ye.header.wrap=!!he.headerWrap),he.headerOrientation!==void 0&&(ye.header.orientation=he.headerOrientation==="vertical"?"vertical":"horizontal"),he.pin!==void 0&&(ye.layout.pin=he.pin),he.sort!==void 0&&(ye.sort.direction=he.sort),he.sortIndex!=null&&(ye.sort.order=he.sortIndex),he.groupIndex!=null&&(ye.group.enabled=!0,ye.group.index=he.groupIndex),he.pivotIndex!=null&&(ye.pivot.enabled=!0,ye.pivot.index=he.pivotIndex),he.total!==void 0&&(ye.total=he.total),he.groupTotal!==void 0&&(ye.groupTotal=he.groupTotal),he.grandTotal!==void 0&&(ye.grandTotal=he.grandTotal),pe.applied.push(he.id)}const $e=ve||(fe&&fe.keepOrder?[]:Oe.map(he=>he&&he.id).filter(Boolean));if($e.length){const he=$e.filter(Se=>this.#e.has(Se)),ye=this.#t.filter(Se=>!he.includes(Se));this.#t=[...he,...ye]}return this.#w&&this.#w("state",pe),pe}move(re,fe){this.#N(re,fe)&&(this.#L(),this.#w&&this.#w("move",{id:re,to:fe}))}reorder(re){const fe={applied:[],skipped:[]},pe=[];let Oe=0;for(const ve of Array.isArray(re)?re:[]){const $e=Oe++;this.#N(ve,$e)&&(fe.applied.push(ve),pe.push({id:ve,to:$e}))}if(!pe.length)return fe;if(this.#L(),this.#w)for(const ve of pe)this.#w("move",ve);return fe}#N(re,fe){const pe=this.#t.indexOf(re);if(pe===-1||Math.max(0,Math.min(Number(fe)||0,this.#t.length-1))===pe)return!1;const ve=this.#e.get(re);if(ve.layout.movable===!1||ve.layout.lockPosition)return Y(`move:${re}`,`column "${re}" is not movable; the move was ignored`),!1;const $e=this.#R(re,fe);return $e?(Y(`move.married:${$e}`,`band "${$e}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(pe,1),this.#t.splice(Math.max(0,Math.min(fe,this.#t.length)),0,re),!0)}#R(re,fe){if(!this.#n||!this.#n.length)return null;const pe=this.#t.filter(he=>he!==re),Oe=Math.max(0,Math.min(fe,pe.length)),ve=(he,ye)=>{if(Array.isArray(he.columns)){for(const Ie of he.columns)ve(Ie,ye);return ye}const Se=he.column?he.column.id:he.id;return Se&&ye.push(Se),ye},$e=he=>{for(const ye of he){if(!Array.isArray(ye.columns))continue;if(ye.marryChildren===!0){const Ie=ve(ye,[]),we=Ie.includes(re),Fe=Ie.map(He=>pe.indexOf(He)).filter(He=>He>=0);if(Fe.length){const He=Math.min(...Fe),Ke=Math.max(...Fe);if(we?Oe<He||Oe>Ke+1:Oe>He&&Oe<=Ke)return ye.id}}const Se=$e(ye.columns);if(Se)return Se}return null};return $e(this.#n)}#L(){const re=new Map(this.#t.map((Oe,ve)=>[Oe,ve])),fe=Oe=>{if(!Array.isArray(Oe.columns)){const $e=Oe.column?Oe.column.id:Oe.id;return re.has($e)?re.get($e):1/0}let ve=1/0;for(const $e of Oe.columns)ve=Math.min(ve,fe($e));return ve},pe=Oe=>{Oe.sort((ve,$e)=>fe(ve)-fe($e));for(const ve of Oe)Array.isArray(ve.columns)&&pe(ve.columns)};pe(this.#n)}#U(re){const fe=pe=>{for(let Oe=0;Oe<pe.length;Oe++){const ve=pe[Oe];if(Array.isArray(ve.columns)){const $e=fe(ve.columns);if($e)return $e}else if(ve.column&&ve.column.id===re)return pe.splice(Oe,1)[0]}return null};return fe(this.#n)}#G(re){const fe=[];for(let pe=re.length-1;pe>=0;pe--){const Oe=re[pe];Array.isArray(Oe.columns)&&(fe.push(...this.#G(Oe.columns)),Oe.columns.length===0&&(fe.push(Oe.id),re.splice(pe,1)))}return fe}#x(){const re=(fe,pe,Oe)=>{for(const ve of fe)Array.isArray(ve.columns)?re(ve.columns,[...pe,ve.id]):ve.column&&(ve.column.groupPath=pe)};re(this.#n,[])}#F(re){const fe=new Set(re),pe=this.#t.filter(he=>fe.has(he));if(!pe.length)return;const Oe=Math.min(...pe.map(he=>this.#t.indexOf(he))),ve=this.#t.slice(0,Oe).filter(he=>!fe.has(he)),$e=this.#t.slice(Oe).filter(he=>!fe.has(he));this.#t=[...ve,...pe,...$e]}#Y(re){const fe=[],pe=Oe=>{if(Array.isArray(Oe.columns))for(const ve of Oe.columns)pe(ve);else Oe.column&&fe.push(Oe.column.id)};return pe(re),fe}#I(re){const fe=pe=>{for(const Oe of pe){if(!Array.isArray(Oe.columns))continue;if(Oe.id===re)return{node:Oe,parent:pe};const ve=fe(Oe.columns);if(ve)return ve}return null};return fe(this.#n)}groupColumns(re,fe={}){const pe=D(re).filter(ye=>this.#e.has(ye));if(!pe.length)return Y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const ye of pe)if(this.#e.get(ye).layout.lockPosition)return Y(`columns.group.locked:${ye}`,`column "${ye}" is position-locked and cannot be grouped.`),null;const Oe=fe.groupId?this.#I(fe.groupId):null;if(fe.groupId&&!Oe)return Y(`columns.group.unknown:${fe.groupId}`,`no band "${fe.groupId}" to add to; nothing was grouped.`),null;let ve=null;if(!Oe&&fe.id!=null&&(ve=String(fe.id),this.#I(ve)||this.#e.has(ve)))return Y(`columns.group.idtaken:${ve}`,`band id "${ve}" is already in use; nothing was grouped.`),null;const $e=pe.map(ye=>this.#U(ye)).filter(Boolean);if(!$e.length)return null;let he;if(Oe)Oe.node.columns.push(...$e),he=Oe.node.id;else{const ye={id:ve||t("grp"),title:fe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:$e},Se=Number.isInteger(fe.at)?Math.max(0,Math.min(fe.at,this.#n.length)):this.#n.length;this.#n.splice(Se,0,ye),he=ye.id}return this.#G(this.#n),this.#F(pe),this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"formed",groupId:he,ids:pe}),he}ungroupColumn(re){const fe=this.#e.get(re);if(!fe){Y(`columns.ungroup.unknown:${re}`,`no column "${re}" to ungroup.`);return}const pe=fe.groupPath||[];if(!pe.length)return;const Oe=pe[pe.length-1],ve=this.#I(Oe);if(!ve)return;const $e=this.#U(re);if(!$e)return;const he=ve.parent.indexOf(ve.node);ve.parent.splice(he+1,0,$e);const ye=this.#G(this.#n),Se=this.#Y(ve.node);if(Se.length){this.#F(Se);const Ie=Math.max(...Se.map(Fe=>this.#t.indexOf(Fe))),we=this.#t.filter(Fe=>Fe!==re);we.splice(Ie+1,0,re),this.#t=we}this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"removed",id:re,dissolved:ye})}renameGroup(re,fe){const pe=this.#I(re);if(!pe){Y(`columns.group.rename:${re}`,`no band "${re}" to rename.`);return}pe.node.title=String(fe??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:re,title:pe.node.title})}dissolveGroup(re){const fe=this.#I(re);if(!fe){Y(`columns.group.dissolve:${re}`,`no band "${re}" to dissolve.`);return}const pe=fe.parent.indexOf(fe.node);fe.parent.splice(pe,1,...fe.node.columns),this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:re})}moveGroup(re,fe){const pe=this.#I(re);if(!pe){Y(`columns.group.move:${re}`,`no band "${re}" to move.`);return}const Oe=pe.parent,ve=Oe.indexOf(pe.node);ve!==-1&&(Oe.splice(ve,1),Oe.splice(Math.max(0,Math.min(fe,Oe.length)),0,pe.node),this.#K(),this.#x(),this.#w&&this.#w("columngroup",{action:"moved",groupId:re,to:fe}))}#K(){const re=[],fe=Oe=>{for(const ve of Oe)Array.isArray(ve.columns)?fe(ve.columns):ve.column&&re.push(ve.column.id)};fe(this.#n);const pe=new Set(re);this.#t=[...re,...this.#t.filter(Oe=>!pe.has(Oe))]}groupTree(){const re=pe=>pe.map(Oe=>Array.isArray(Oe.columns)?{id:Oe.id,title:Oe.title||"",collapsible:!!Oe.collapsible,openByDefault:Oe.openByDefault!==!1,columns:re(Oe.columns)}:Oe.column?Oe.column.id:null).filter(Oe=>Oe!==null),fe=re(this.#n);return fe.some(pe=>pe&&typeof pe=="object")?fe:[]}applyGroupTree(re){if(!Array.isArray(re))return;const fe=new Set,pe=ve=>{const $e=[];for(const he of ve)if(he&&typeof he=="object"&&Array.isArray(he.columns)){const ye=pe(he.columns);if(!ye.length)continue;$e.push({id:he.id||t("grp"),title:he.title||"",collapsible:he.collapsible===!0,openByDefault:he.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:ye})}else if(typeof he=="string"){const ye=this.#e.get(he);ye&&!fe.has(he)&&(fe.add(he),$e.push({column:ye,path:[]}))}return $e},Oe=pe(re);for(const ve of this.#t){if(fe.has(ve))continue;const $e=this.#e.get(ve);$e&&Oe.push({column:$e,path:[]})}this.#n=Oe,this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"applied"})}show(re){this.#H(re,!1)}hide(re){this.#H(re,!0)}#H(re,fe){const pe=[];for(const Oe of D(re)){const ve=this.#e.get(Oe);if(ve){if(fe&&ve.layout.lockVisible){Y(`lockVisible:${Oe}`,`column "${Oe}" is \`layout.lockVisible\` and cannot be hidden`);continue}ve.layout.hidden!==fe&&(ve.layout.hidden=fe,pe.push(Oe))}}pe.length&&this.#w&&this.#w("visible",{ids:pe,hidden:fe})}pin(re,fe){const pe=this.#e.get(re);pe&&(pe.layout.pin=fe??null,this.#w&&this.#w("pin",{id:re,side:pe.layout.pin}))}pinMany(re){const fe={};for(const[Oe,ve]of re){const $e=this.#e.get(Oe);$e&&($e.layout.pin=ve??null,fe[Oe]=$e.layout.pin)}const pe=Object.keys(fe);pe.length&&this.#w&&this.#w("pin",{ids:pe,pins:fe})}#z(re,fe){const pe=re.layout.min??0,Oe=re.layout.max;let ve=Math.max(pe,fe);return Oe!=null&&(ve=Math.min(Oe,ve)),re.layout.width=ve,re.layout.flex=0,ve}resize(re,fe){const pe=this.#e.get(re);if(!pe)return;if(pe.layout.resizable===!1){Y(`resize:${re}`,`column "${re}" is not resizable; the resize was ignored`);return}const Oe=this.#z(pe,fe);this.#w&&this.#w("resize",{id:re,width:Oe})}resizeMany(re){const fe={};for(const[Oe,ve]of re){const $e=this.#e.get(Oe);if($e){if($e.layout.resizable===!1){Y(`resize:${Oe}`,`column "${Oe}" is not resizable; the resize was ignored`);continue}fe[Oe]=this.#z($e,ve)}}const pe=Object.keys(fe);pe.length&&this.#w&&this.#w("resize",{ids:pe,widths:fe})}}function ae(be){const re={};return be.width!=null&&(re.width=be.width),be.hidden!=null&&(re.hidden=be.hidden),be.pin!==void 0&&(re.pin=be.pin),re}function ce(be){if(be===null||typeof be!="object")return be;try{return structuredClone(be)}catch{}try{return JSON.parse(JSON.stringify(be))}catch{return be}}function de(be,re){const fe=be??null,pe=re??null;if(fe===pe)return!0;if(fe===null||pe===null)return!1;if(typeof fe!="object"||typeof pe!="object")return fe===pe;try{return JSON.stringify(fe)===JSON.stringify(pe)}catch{return!1}}function Ae(be){const re=[],fe=(Oe,ve,$e)=>{const he=[];for(const ye of Oe){if(!l(ye)){Z("a column definition must be an object");continue}if(Array.isArray(ye.columns)){J(ye,_,"columnGroup",ye.title||ye.id||"(unnamed)");const Se={id:ye.id||t("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:ye.showWhen||"always",marryChildren:ye.marryChildren===!0,header:ye.header||{},def:ye,columns:[]};Se.columns=fe(ye.columns,[...ve,Se.id],ye.facet!==void 0?ye.facet:$e),he.push(Se)}else{const Se={def:ye,path:ve,facet:$e};re.push(Se),he.push(Se)}}return he},pe=fe(be,[],void 0);return{leaves:re,groups:pe}}function je(be,re,fe){for(const pe of be){if(pe.columns){if(je(pe.columns,re,fe))return!0;continue}if(pe.column&&pe.column.id===re)return pe.column=fe,!0}return!1}}),Be("packages/core/src/columns/autogroup.js",function(e,H){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="__lattice_group",D=240,F=.5;function Z(B){const{columns:z,groupBy:G}=B,P=G.map(c=>z.get(c)).filter(Boolean),O=P.length?P.map(c=>c.title||c.id).join(" > "):"Group",b=B.config&&B.config.autoGroupColumnWidth||D;return{id:X,field:null,title:O,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:G.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:B.config&&B.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,d){return d&&d.group?d.groupValue:null},formatValue(c,d){if(!d||!d.group)return"";if(d.grandTotal)return B.config&&B.config.grandTotalLabel||"Total";const l=P[Math.min(d.level||0,P.length-1)];return l&&typeof l.formatValue=="function"?l.formatValue(c,d):c==null?"":String(c)}}}function Y(B,z,G){!B.length||G<100||z<G*F||L(`grouping.cardinality:${B.join(",")}`,`grouping by ${B.join(", ")} produced ${z} groups for ${G} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),Be("packages/core/src/columns/selectcolumn.js",function(e,H){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const te="__lattice_select",L=44;function X(F){const Z=F.selection||{},Y=F.config&&F.config.selectionColumnWidth||L;return{id:te,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Y,min:Y,max:Y,pin:F.config&&F.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(B,z){return z?z.selected:!1},formatValue(){return""}}}const D=X}),Be("packages/core/src/columns/rownumbercolumn.js",function(e,H){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/internal/predicates.js").isFunction,X="__lattice_rownumber",D=40,F=9,Z=22;function Y(G){const P=String(Math.max(1,Math.trunc(Math.abs(G))||1)).length;return Math.max(D,P*F+Z)}function B(G){const P=G.rowNumbers,O=P&&typeof P=="object"?P:{},b=Number.isFinite(O.start)?O.start:1,c=Number.isFinite(O.width)?O.width:Y((G.maxNumber||0)+b),d=L(G.rank)?G.rank:()=>null;return{id:X,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:c,min:c,max:c,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,r){const t=d(r);return t==null?null:t-1+b},formatValue(l){return l==null?"":String(l)}}}const z=B}),Be("packages/core/src/model/detail.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F=240,Z=10;function Y(G){if(!G)return null;const P=G===!0?{}:G;return P.enabled===!1?null:!L(P.rows)&&!P.render?(D("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:P.render||null,config:P.config||null,rows:L(P.rows)?P.rows:null,height:P.height??F,cacheLimit:Number.isFinite(P.cacheLimit)?Math.max(0,P.cacheLimit):Z,isMaster:L(P.isMaster)?P.isMaster:null,target:P.target||null,onCreate:L(P.onCreate)?P.onCreate:null,path:typeof P.path=="string"?P.path:null}}class B{#e;#t=new Set;#n;#r=0;constructor(P){this.#e=P.config,this.#n=L(P.onChange)?P.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(P){if(!P||P.group||P.detail)return!1;const O=this.#e.isMaster;return O?!!O(P.data,P):!0}isOpen(P){return this.#t.has(P)}keys(){return[...this.#t]}activeKey(){for(const P of this.#t)return P;return null}heightOf(P){const O=this.#e.height;return L(O)?Number(O(P))||F:O==="auto"?F:Number(O)||F}open(P){return this.#t.has(P)?!1:(this.inline||this.#t.clear(),this.#t.add(P),this.#s(),!0)}close(P){return this.#t.delete(P)?(this.#s(),!0):!1}toggle(P){return this.#t.has(P)?(this.close(P),!1):(this.open(P),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#s())}prune(P){if(!this.#t.size||!L(P))return;let O=!1;for(const b of[...this.#t])P(b)||(this.#t.delete(b),O=!0);O&&this.#s()}signature(){return`${this.#r}`}set(P){this.#t.clear();const O=Array.isArray(P)?P:[];for(const b of this.inline?O:O.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const z=B}),Be("packages/core/src/compute/special.js",function(e,H){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return l}});const te=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),L=3e-12,X=1e-300;function D(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-D(1-r);const t=r-1;let i=.9999999999998099;const s=t+7.5;for(let n=0;n<te.length;n++)i+=te[n]/(t+n+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(s)-s+Math.log(i)}function F(r,t,i){const s=r+t,n=r+1,u=r-1;let o=1,a=1-s*i/n;Math.abs(a)<X&&(a=X),a=1/a;let f=a;for(let w=1;w<=300;w++){const m=2*w;let v=w*(t-w)*i/((u+m)*(r+m));a=1+v*a,Math.abs(a)<X&&(a=X),o=1+v/o,Math.abs(o)<X&&(o=X),a=1/a,f*=a*o,v=-(r+w)*(s+w)*i/((r+m)*(n+m)),a=1+v*a,Math.abs(a)<X&&(a=X),o=1+v/o,Math.abs(o)<X&&(o=X),a=1/a;const h=a*o;if(f*=h,Math.abs(h-1)<L)break}return f}function Z(r,t,i){if(!(r>0)||!(t>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(D(r+t)-D(r)-D(t)+r*Math.log(i)+t*Math.log(1-i));return i<(r+1)/(r+t+2)?s*F(r,t,i)/r:1-s*F(t,r,1-i)/t}function Y(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let o,a,f;r<u?(o=Math.sqrt(-2*Math.log(r)),f=(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1)):r<=1-u?(o=r-.5,a=o*o,f=(((((t[0]*a+t[1])*a+t[2])*a+t[3])*a+t[4])*a+t[5])*o/(((((i[0]*a+i[1])*a+i[2])*a+i[3])*a+i[4])*a+1)):(o=Math.sqrt(-2*Math.log(1-r)),f=-(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1));const m=(.5*B(-f/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(f*f/2);return f-m/(1+f*m/2)}function B(r){const t=Math.abs(r),i=2/(2+t),s=4*i-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,o=0,a;for(let w=n.length-1;w>0;w--)a=o,o=s*o-u+n[w],u=a;const f=i*Math.exp(-t*t+.5*(n[0]+s*o)-u);return r>=0?f:2-f}function z(r){return .5*B(-r/Math.SQRT2)}function G(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const i=.5*Z(t/2,.5,t/(t+r*r));return r>0?1-i:i}function P(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return Y(r);let i=-1e4,s=1e4,n=Y(r);const u=D(t/2)+D(.5)-D((t+1)/2);for(let o=0;o<60;o++){const a=G(n,t);a<r?i=n:s=n;const f=Math.exp(-((t+1)/2)*Math.log(1+n*n/t)-u)/Math.sqrt(t),w=f>0?(a-r)/f:0;if(Math.abs(w)<1e-12)break;const m=n-w;if(n=m>i&&m<s&&Number.isFinite(m)?m:(i+s)/2,s-i<1e-12)break}return n}function O(r,t){let i=r,s=1/r,n=s;for(let u=0;u<300&&(i+=1,n*=t/i,s+=n,!(Math.abs(n)<Math.abs(s)*L));u++);return s*Math.exp(-t+r*Math.log(t)-D(r))}function b(r,t){let i=t+1-r,s=1/X,n=1/i,u=n;for(let o=1;o<=300;o++){const a=-o*(o-r);i+=2,n=a*n+i,Math.abs(n)<X&&(n=X),s=i+a/s,Math.abs(s)<X&&(s=X),n=1/n;const f=n*s;if(u*=f,Math.abs(f-1)<L)break}return Math.exp(-t+r*Math.log(t)-D(r))*u}function c(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?O(r,t):1-b(r,t)}function d(r,t){return t>0?c(t/2,r/2):Number.NaN}function l(r,t){const i=d(r,t);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Be("packages/core/src/compute/linalg.js",function(e,H){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function te(Y){const B=Y.length,z=Array.from({length:B},()=>new Array(B).fill(0));for(let G=0;G<B;G++)for(let P=0;P<=G;P++){let O=Y[G][P];for(let b=0;b<P;b++)O-=z[G][b]*z[P][b];if(G===P){if(!(O>0))return null;z[G][P]=Math.sqrt(O)}else z[G][P]=O/z[P][P]}return z}function L(Y,B){const z=Y.length,G=new Array(z).fill(0);for(let O=0;O<z;O++){let b=B[O];for(let c=0;c<O;c++)b-=Y[O][c]*G[c];G[O]=b/Y[O][O]}const P=new Array(z).fill(0);for(let O=z-1;O>=0;O--){let b=G[O];for(let c=O+1;c<z;c++)b-=Y[c][O]*P[c];P[O]=b/Y[O][O]}return P}function X(Y){const B=Y.length,z=Array.from({length:B},()=>new Array(B).fill(0));for(let G=0;G<B;G++){const P=new Array(B).fill(0);P[G]=1;const O=L(Y,P);for(let b=0;b<B;b++)z[b][G]=O[b]}return z}function D(Y,B,z){const G=Y.length,P=G?Y[0].length:0,O=Array.from({length:P},()=>new Array(P).fill(0)),b=new Array(P).fill(0);for(let c=0;c<G;c++){const d=z?z[c]:1,l=Y[c];for(let r=0;r<P;r++){const t=d*l[r];b[r]+=t*B[c];for(let i=r;i<P;i++)O[r][i]+=t*l[i]}}for(let c=0;c<P;c++)for(let d=0;d<c;d++)O[c][d]=O[d][c];return{xtwx:O,xtwy:b}}function F(Y,B){return Y.map(z=>z.reduce((G,P,O)=>G+P*B[O],0))}function Z(Y,B){let z=0;for(let G=0;G<Y.length;G++){let P=0;for(let O=0;O<Y.length;O++)P+=B[G][O]*Y[O];z+=Y[G]*P}return z}}),Be("packages/core/src/compute/sketch.js",function(e,H){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class te{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(c){if(!Number.isFinite(c))return;this.#e++;const d=c-this.#t;this.#t+=d/this.#e,this.#n+=d*(c-this.#t)}merge(c){if(c.#e===0)return;if(this.#e===0){this.#e=c.#e,this.#t=c.#t,this.#n=c.#n;return}const d=this.#e+c.#e,l=c.#t-this.#t;this.#t+=l*(c.#e/d),this.#n+=c.#n+l*l*(this.#e*c.#e/d),this.#e=d}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const c=this.variance();return c===null?null:Math.sqrt(c)}stddevP(){const c=this.varianceP();return c===null?null:Math.sqrt(c)}}class L{#e=[];#t=0;#n;#r;constructor(c,d=Math.random){if(!(c>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(c),this.#r=d}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(c){if(!Number.isFinite(c))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(c);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=c)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let c=0;for(const d of this.#e)c+=d;return c/this.#e.length}quantile(c){const d=this.#e.length;if(!d)return null;const l=this.#e.slice().sort((s,n)=>s-n);if(d===1)return l[0];const r=(d-1)*Math.min(1,Math.max(0,c)),t=Math.floor(r),i=Math.ceil(r);return t===i?l[t]:l[t]+(r-t)*(l[i]-l[t])}}function X(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function D(b){if(typeof b=="number"){const l=new DataView(new ArrayBuffer(8));return l.setFloat64(0,b===0?0:b),X(l.getUint32(0)^l.getUint32(4))}const c=typeof b=="string"?b:String(b);let d=2166136261;for(let l=0;l<c.length;l++)d^=c.charCodeAt(l),d=Math.imul(d,16777619);return X(d)}class F{#e;#t;#n;constructor(c=14){const d=Math.floor(c);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(c=14){const d=1<<Math.floor(c),l=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:l,statement:`distinct count within ~${(l*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return F.errorBoundFor(this.#e)}add(c){const d=D(c),l=d&this.#t-1,r=d>>>this.#e|1<<32-this.#e;let t=1,i=r;for(;(i&1)===0;)t++,i>>>=1;t>this.#n[l]&&(this.#n[l]=t)}count(){const c=this.#t,d=32-this.#e,l=new Float64Array(d+2);for(let i=0;i<c;i++)l[this.#n[i]]++;let r=c*B(1-l[d+1]/c);for(let i=d;i>=1;i--)r=.5*(r+l[i]);r+=c*Y(l[0]/c);const t=Z*c*c/r;return Math.round(t)}}const Z=.5/Math.log(2);function Y(b){if(b===1)return 1/0;let c=1,d=b,l;do b*=b,l=d,d+=b*c,c+=c;while(d!==l);return d}function B(b){if(b===0||b===1)return 0;let c=1,d=1-b,l;do b=Math.sqrt(b),l=d,c*=.5,d-=(1-b)**2*c;while(d!==l);return d/3}class z{#e=new Map;#t;#n=0;constructor(c){if(!(c>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(c)}errorBoundFor(c){const d=c/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${c}, m=${this.#t})`})}get seen(){return this.#n}add(c){this.#n++;const d=this.#e.get(c);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(c,{count:1,error:0});return}let l,r=1/0;for(const[t,i]of this.#e)i.count<r&&(r=i.count,l=t);this.#e.delete(l),this.#e.set(c,{count:r+1,error:r})}top(c=this.#t){return[...this.#e.entries()].map(([l,r])=>({item:l,count:r.count,error:r.error})).sort((l,r)=>r.count-l.count).slice(0,Math.max(0,Math.floor(c)))}}class G{#e;#t=[[]];#n=0;#r;#s;constructor(c=200,d=Math.random){this.#e=Math.max(8,Math.floor(c)),this.#r=d,this.#s=2/3}static errorBoundFor(c=200){const d=1/Math.max(8,Math.floor(c));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${c})`})}errorBound(){return G.errorBoundFor(this.#e)}get count(){return this.#n}#i(c){const l=this.#t.length-1-c,r=Math.ceil(this.#e*this.#s**l);return Math.max(2,r)}add(c){Number.isFinite(c)&&(this.#n++,this.#t[0].push(c),this.#t[0].length>=this.#i(0)&&this.#o(0))}#o(c){const d=this.#t[c];d.sort((t,i)=>t-i),c+1>=this.#t.length&&this.#t.push([]);const l=this.#t[c+1],r=this.#r()<.5?0:1;for(let t=r;t<d.length;t+=2)l.push(d[t]);this.#t[c]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#o(t);return}}#l(){const c=[];for(let d=0;d<this.#t.length;d++){const l=1<<d;for(const r of this.#t[d])c.push({v:r,w:l})}return c}quantile(c){const d=this.#l();if(!d.length)return null;d.sort((i,s)=>i.v-s.v);let l=0;for(const i of d)l+=i.w;const r=Math.min(1,Math.max(0,c))*l;let t=0;for(const i of d)if(t+=i.w,t>=r)return i.v;return d[d.length-1].v}rank(c){let d=0;for(let l=0;l<this.#t.length;l++){const r=1<<l;for(const t of this.#t[l])t<=c&&(d+=r)}return d}}const P=Object.freeze({distinct:F.errorBoundFor(14),median:G.errorBoundFor(200),p25:G.errorBoundFor(200),p75:G.errorBoundFor(200),p90:G.errorBoundFor(200),p95:G.errorBoundFor(200),p99:G.errorBoundFor(200),iqr:G.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),O={Welford:te,Reservoir:L,HyperLogLog:F,SpaceSaving:z,KLL:G,hash32:D,SKETCH_BOUNDS:P}}),Be("packages/core/src/compute/statistics.js",function(e,H){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Ue}});const te=H("packages/core/src/compute/handle.js"),L=te.presenceReader,X=te.valueReader,D=H("packages/core/src/compute/special.js"),F=D.studentTQuantile,Z=D.studentT,Y=D.normalQuantile,B=D.normalCdf,z=D.chiSquareUpperTail,G=H("packages/core/src/compute/linalg.js"),P=G.cholesky,O=G.choleskySolve,b=G.choleskyInverse,c=G.normalEquations,d=G.quadForm,r=H("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function n(ge){const Pe=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,ge)?i[ge]:null,ke=Object.prototype.hasOwnProperty.call(s,ge)?s[ge]:null;return{stat:ge,exact:Pe,approximate:ke}}function u(ge,Pe){const ke=Pe.length,Ee=new Float64Array(ke);let Ce=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const ze=ge.values,Ve=L(ge);for(let Qe=0;Qe<ke;Qe++){const Ne=Pe[Qe];if(Ve&&Ve(Ne)!==1)continue;const Ge=ze[Ne];Number.isNaN(Ge)||(Ee[Ce++]=Ge)}return Ee.subarray(0,Ce)}const xe=X(ge);for(let ze=0;ze<ke;ze++){const Ve=xe(Pe[ze]);if(Ve==null||Ve==="")continue;const Qe=typeof Ve=="number"?Ve:Number(Ve);Number.isFinite(Qe)&&(Ee[Ce++]=Qe)}return Ee.subarray(0,Ce)}function o(ge,Pe){const ke=new Map,Ee=X(ge);let Ce=0;for(let xe=0;xe<Pe.length;xe++){const ze=Ee(Pe[xe]);if(ze==null||ze===""||typeof ze=="number"&&Number.isNaN(ze))continue;const Ve=typeof ze=="object"?String(ze):ze;ke.set(Ve,(ke.get(Ve)||0)+1),Ce++}const Re=[...ke.values()].sort((xe,ze)=>ze-xe);return{counts:Re,total:Ce,distinct:Re.length}}function a(ge){return ge.total>0?ge.counts.map(Pe=>Pe/ge.total):[]}function f(ge,Pe){const ke=o(ge,Pe);if(!ke.total)return null;let Ee=0;for(const Ce of a(ke))Ee+=Ce*Ce;return Ee}function w(ge,Pe){const ke=o(ge,Pe);if(!ke.total)return null;let Ee=0;for(const Ce of a(ke))Ce>0&&(Ee-=Ce*Math.log2(Ce));return Ee}function m(ge,Pe){const ke=o(ge,Pe);if(!ke.total||ke.distinct<2)return ke.total?1:null;let Ee=0;for(const Ce of a(ke))Ce>0&&(Ee-=Ce*Math.log2(Ce));return Ee/Math.log2(ke.distinct)}function v(ge,Pe,ke=3){const Ee=o(ge,Pe);if(!Ee.total)return null;const Ce=Math.max(1,Math.floor(ke));let Re=0;for(let xe=0;xe<Math.min(Ce,Ee.counts.length);xe++)Re+=Ee.counts[xe];return Re/Ee.total}function h(ge,Pe){const ke=u(ge,Pe),Ee=ke.length;if(!Ee)return null;const Ce=ke.slice().sort();if(Ce[0]<0)return null;let Re=0,xe=0;for(let ze=0;ze<Ee;ze++)Re+=Ce[ze],xe+=(ze+1)*Ce[ze];return Re===0?0:2*xe/(Ee*Re)-(Ee+1)/Ee}function p(ge){let Pe=0,ke=0,Ee=0;for(let Ce=0;Ce<ge.length;Ce++){const Re=ge[Ce];Pe++;const xe=Re-ke;ke+=xe/Pe,Ee+=xe*(Re-ke)}return{n:Pe,mean:ke,m2:Ee}}function g(ge,Pe){const ke=ge.length;if(!ke)return NaN;if(ke===1)return ge[0];const Ee=(ke-1)*Math.min(1,Math.max(0,Pe)),Ce=Math.floor(Ee),Re=Math.ceil(Ee);return Ce===Re?ge[Ce]:ge[Ce]+(Ee-Ce)*(ge[Re]-ge[Ce])}function k(ge,Pe){if(!ge.length)return NaN;const ke=ge.slice().sort();return g(ke,Pe)}function y(ge,Pe){const ke=X(ge);let Ee=0,Ce=0,Re=0;for(let xe=0;xe<Pe.length;xe++){const ze=ke(Pe[xe]);if(ze==null||ze==="")continue;const Ve=String(ze).toUpperCase();Ve==="PASS"?Ee++:Ve==="FAIL"?Ce++:Ve==="WARN"&&Re++}return{pass:Ee+Re,fail:Ce,warn:Re,judged:Ee+Re+Ce}}const T=Object.freeze({hhi:(ge,Pe)=>f(ge,Pe),entropy:(ge,Pe)=>w(ge,Pe),evenness:(ge,Pe)=>m(ge,Pe),top3Share:(ge,Pe)=>v(ge,Pe,3),top10Share:(ge,Pe)=>v(ge,Pe,10),gini:(ge,Pe)=>h(ge,Pe),trimmedMean:(ge,Pe)=>x(u(ge,Pe),.1),winsorizedMean:(ge,Pe)=>A(u(ge,Pe),.1),robustOutliers:(ge,Pe)=>$(u(ge,Pe),3.5),jarqueBera:(ge,Pe)=>I(u(ge,Pe)),variance:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>1?Ee/(ke-1):null},varianceP:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>0?Ee/ke:null},stddev:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>1?Math.sqrt(Ee/(ke-1)):null},stddevP:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>0?Math.sqrt(Ee/ke):null},median:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.5):null},p25:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.25):null},p75:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.75):null},p90:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.9):null},p95:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.95):null},p99:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.99):null},iqr:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;const Ee=ke.slice().sort();return g(Ee,.75)-g(Ee,.25)},mad:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;const Ee=k(ke,.5),Ce=new Float64Array(ke.length);for(let Re=0;Re<ke.length;Re++)Ce[Re]=Math.abs(ke[Re]-Ee);return k(Ce,.5)},range:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=1/0,Ce=-1/0;for(let Re=0;Re<ke.length;Re++)ke[Re]<Ee&&(Ee=ke[Re]),ke[Re]>Ce&&(Ce=ke[Re]);return Ce-Ee},distinct:(ge,Pe)=>{const ke=X(ge),Ee=new Set;for(let Ce=0;Ce<Pe.length;Ce++){const Re=ke(Pe[Ce]);Re==null||Re===""||Ee.add(Re instanceof Date?Re.getTime():Re)}return Ee.size},mode:(ge,Pe)=>{const ke=X(ge),Ee=new Map;for(let xe=0;xe<Pe.length;xe++){const ze=ke(Pe[xe]);if(ze==null||ze==="")continue;const Ve=ze instanceof Date?ze.getTime():ze;Ee.set(Ve,(Ee.get(Ve)||0)+1)}let Ce=null,Re=1;for(const[xe,ze]of Ee)ze>Re&&(Re=ze,Ce=xe);return Ce},skewness:(ge,Pe)=>{const ke=u(ge,Pe),{n:Ee,mean:Ce,m2:Re}=p(ke);if(Ee<3||Re<=0)return null;const xe=Math.sqrt(Re/(Ee-1));let ze=0;for(let Ve=0;Ve<ke.length;Ve++)ze+=((ke[Ve]-Ce)/xe)**3;return Ee/((Ee-1)*(Ee-2))*ze},kurtosis:(ge,Pe)=>{const ke=u(ge,Pe),{n:Ee,mean:Ce,m2:Re}=p(ke);if(Ee<4||Re<=0)return null;const xe=Math.sqrt(Re/(Ee-1));let ze=0;for(let Ne=0;Ne<ke.length;Ne++)ze+=((ke[Ne]-Ce)/xe)**4;const Ve=Ee*(Ee+1)/((Ee-1)*(Ee-2)*(Ee-3)),Qe=3*(Ee-1)**2/((Ee-2)*(Ee-3));return Ve*ze-Qe},geomean:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=0;for(let Ce=0;Ce<ke.length;Ce++){if(ke[Ce]<=0)return null;Ee+=Math.log(ke[Ce])}return Math.exp(Ee/ke.length)},harmean:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=0;for(let Ce=0;Ce<ke.length;Ce++){if(ke[Ce]===0)return null;Ee+=1/ke[Ce]}return ke.length/Ee},sumSquares:(ge,Pe)=>{const ke=u(ge,Pe);let Ee=0;for(let Ce=0;Ce<ke.length;Ce++)Ee+=ke[Ce]*ke[Ce];return Ee},passRate:(ge,Pe)=>{const{pass:ke,judged:Ee}=y(ge,Pe);return Ee?ke/Ee:null},failureCount:(ge,Pe)=>y(ge,Pe).fail}),j=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function N(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe);let Re=0,xe=0;for(let ze=0;ze<ke.length;ze++){const Ve=ke[ze],Qe=Number(Ee(Ve)),Ne=Number(Ce(Ve));!Number.isFinite(Qe)||!Number.isFinite(Ne)||(Re+=Qe*Ne,xe+=Ne)}return xe===0?null:Re/xe}function W(ge,Pe,ke){const Ee=X(ge);let Ce=null,Re=ke?-1/0:1/0;for(let xe=0;xe<Pe.length;xe++){const ze=Pe[xe],Ve=Number(Ee(ze));Number.isFinite(Ve)&&(ke?Ve>Re:Ve<Re)&&(Re=Ve,Ce=ze)}return Ce}function R(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe);let Re=0,xe=0,ze=0,Ve=0,Qe=0,Ne=0;for(let Ze=0;Ze<ke.length;Ze++){const lt=ke[Ze],ot=Number(Ee(lt)),st=Number(Ce(lt));!Number.isFinite(ot)||!Number.isFinite(st)||(Re++,xe+=ot,ze+=st,Ve+=ot*ot,Qe+=st*st,Ne+=ot*st)}if(Re<2)return null;const Ge=Re*Ne-xe*ze,qe=Math.sqrt((Re*Ve-xe*xe)*(Re*Qe-ze*ze));if(qe===0)return null;const Je=Ge/qe;return Math.max(-1,Math.min(1,Je))}function x(ge,Pe=.1){const ke=ge.length;if(!ke)return null;const Ee=Array.from(ge).sort((ze,Ve)=>ze-Ve),Ce=Math.floor(ke*Math.min(.49,Math.max(0,Pe))),Re=Ee.slice(Ce,ke-Ce);if(!Re.length)return g(Ee,.5);let xe=0;for(const ze of Re)xe+=ze;return xe/Re.length}function A(ge,Pe=.1){const ke=ge.length;if(!ke)return null;const Ee=Array.from(ge).sort((Ve,Qe)=>Ve-Qe),Ce=Math.floor(ke*Math.min(.49,Math.max(0,Pe))),Re=Ee[Ce],xe=Ee[ke-1-Ce];let ze=0;for(const Ve of Ee)ze+=Math.min(xe,Math.max(Re,Ve));return ze/ke}function $(ge,Pe=3.5){if(!ge.length)return null;const Ee=Array.from(ge).sort((Ve,Qe)=>Ve-Qe),Ce=g(Ee,.5),Re=Ee.map(Ve=>Math.abs(Ve-Ce)).sort((Ve,Qe)=>Ve-Qe),xe=g(Re,.5);if(xe===0)return null;let ze=0;for(const Ve of Ee)Math.abs(.6745*(Ve-Ce)/xe)>Pe&&ze++;return ze}function I(ge){const Pe=ge.length;if(Pe<8)return null;let ke=0;for(const Ve of ge)ke+=Ve;ke/=Pe;let Ee=0,Ce=0,Re=0;for(const Ve of ge){const Qe=Ve-ke;Ee+=Qe*Qe,Ce+=Qe*Qe*Qe,Re+=Qe*Qe*Qe*Qe}if(Ee/=Pe,Ce/=Pe,Re/=Pe,Ee===0)return null;const xe=Ce/Ee**1.5,ze=Re/(Ee*Ee)-3;return Pe/6*(xe*xe+ze*ze/4)}function M(ge,Pe,ke){const Ee=[];let Ce=0;for(let Ve=0;Ve<ge.length;Ve++){const Qe=Number(ge[Ve]),Ne=Number(Pe[Ve]);!Number.isFinite(Qe)||!Number.isFinite(Ne)||Ne<=0||(Ee.push([Qe,Ne]),Ce+=Ne)}if(!Ee.length||Ce<=0)return null;if(Ee.sort((Ve,Qe)=>Ve[0]-Qe[0]),Ee.length===1)return Ee[0][0];const Re=[];let xe=0;for(const[,Ve]of Ee)Re.push((xe+Ve/2)/Ce),xe+=Ve;const ze=Math.max(0,Math.min(1,ke));if(ze<=Re[0])return Ee[0][0];if(ze>=Re[Re.length-1])return Ee[Ee.length-1][0];for(let Ve=1;Ve<Re.length;Ve++){if(ze>Re[Ve])continue;const Qe=Re[Ve]-Re[Ve-1],Ne=Qe>0?(ze-Re[Ve-1])/Qe:0;return Ee[Ve-1][0]+(Ee[Ve][0]-Ee[Ve-1][0])*Ne}return Ee[Ee.length-1][0]}function S(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe),Re=new Float64Array(ke.length),xe=new Float64Array(ke.length);let ze=0;for(let Ve=0;Ve<ke.length;Ve++){const Qe=ke[Ve],Ne=Number(Ee(Qe)),Ge=Number(Ce(Qe));!Number.isFinite(Ne)||!Number.isFinite(Ge)||(Re[ze]=Ne,xe[ze]=Ge,ze++)}return{xs:Re.subarray(0,ze),ys:xe.subarray(0,ze),n:ze}}function E(ge,Pe,ke,Ee=!1){const{xs:Ce,ys:Re,n:xe}=S(ge,Pe,ke);if(xe<2)return null;let ze=0,Ve=0;for(let Ne=0;Ne<xe;Ne++)ze+=Ce[Ne],Ve+=Re[Ne];ze/=xe,Ve/=xe;let Qe=0;for(let Ne=0;Ne<xe;Ne++)Qe+=(Ce[Ne]-ze)*(Re[Ne]-Ve);return Qe/(Ee?xe:xe-1)}function U(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2)return null;let xe=0,ze=0;for(let ot=0;ot<Re;ot++)xe+=Ee[ot],ze+=Ce[ot];xe/=Re,ze/=Re;let Ve=0,Qe=0,Ne=0;for(let ot=0;ot<Re;ot++){const st=Ee[ot]-xe,Ot=Ce[ot]-ze;Ve+=st*st,Qe+=st*Ot,Ne+=Ot*Ot}if(Ve===0)return null;const Ge=Qe/Ve,qe=ze-Ge*xe,Je=Ne===0?1:Math.max(0,Math.min(1,Qe*Qe/(Ve*Ne))),Ze=Math.max(0,Ne-Ge*Qe),lt=Re>2?Math.sqrt(Ze/(Re-2)/Ve):0;return{slope:Ge,intercept:qe,r2:Je,stdError:lt,n:Re}}const K=new Set(["ols","wls","robust"]),q=new Set(["quantile"]),_=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function ee(ge,Pe,ke){const{xtwx:Ee,xtwy:Ce}=c(ge,Pe,ke),Re=P(Ee);if(!Re)return null;const xe=O(Re,Ce),ze=b(Re),Ve=ne(ge,xe),Qe=Pe.map((Ne,Ge)=>Ne-Ve[Ge]);return{beta:xe,cov:ze,fitted:Ve,residuals:Qe}}function ne(ge,Pe){return ge.map(ke=>ke.reduce((Ee,Ce,Re)=>Ee+Ce*Pe[Re],0))}function oe(ge,Pe){const ke=ge.length,Ee=ge.map(Qe=>Qe[Pe]),Ce=ge.map(Qe=>[1,...Qe.filter((Ne,Ge)=>Ge!==Pe)]),Re=ee(Ce,Ee,null);if(!Re)return 1;const xe=Ee.reduce((Qe,Ne)=>Qe+Ne,0)/ke;let ze=0,Ve=0;for(let Qe=0;Qe<ke;Qe++)ze+=Re.residuals[Qe]**2,Ve+=(Ee[Qe]-xe)**2;return Ve===0?1:Math.max(0,Math.min(1,1-ze/Ve))}function ie(ge){const Pe=[...ge].sort((Ce,Re)=>Ce-Re),ke=ae(Pe),Ee=ge.map(Ce=>Math.abs(Ce-ke)).sort((Ce,Re)=>Ce-Re);return ae(Ee)/.6745}function ae(ge){const Pe=ge.length;if(!Pe)return 0;const ke=Math.floor(Pe/2);return Pe%2?ge[ke]:(ge[ke-1]+ge[ke])/2}function ce(ge,Pe,ke={}){const Ee=ke.method||"ols";if(_.has(Ee))throw new Error(`[lattice] regression method "${Ee}" is out of scope; use ols, wls or robust.`);if(q.has(Ee))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(Ee))throw new Error(`[lattice] unknown regression method "${Ee}"; use ols, wls or robust.`);const Ce=Array.isArray(Pe)?Pe.length:0,Re=Ce&&Array.isArray(ge[0])?ge[0].length:0,xe=Re+1;if(!(Ce>xe))return null;for(let Mt=0;Mt<Ce;Mt++){if(!Number.isFinite(Pe[Mt])||!Array.isArray(ge[Mt])||ge[Mt].length!==Re)return null;for(let xt=0;xt<Re;xt++)if(!Number.isFinite(ge[Mt][xt]))return null}let ze=null;if(Ee==="wls"){if(ze=ke.weights,!Array.isArray(ze)||ze.length!==Ce)return null;for(let Mt=0;Mt<Ce;Mt++)if(!(ze[Mt]>0)||!Number.isFinite(ze[Mt]))return null}const Ve=ge.map(Mt=>[1,...Mt]);let Qe,Ne=null;if(Ee==="robust"){if(Qe=ee(Ve,Pe,null),!Qe)return null;for(let Mt=0;Mt<50;Mt++){const xt=ie(Qe.residuals);if(!(xt>0))break;const _t=Qe.residuals.map(Jt=>{const qt=Math.abs(Jt/xt);return qt<=J?1:J/qt}),Yt=ee(Ve,Pe,_t);if(!Yt)return null;const Qt=Yt.beta.reduce((Jt,qt,sn)=>Math.max(Jt,Math.abs(qt-Qe.beta[sn])),0);if(Qe=Yt,Ne=_t,Qt<1e-10)break}}else if(Qe=ee(Ve,Pe,ze),!Qe)return null;const Ge=Ee==="robust"?Ne:ze,{beta:qe,cov:Je,fitted:Ze,residuals:lt}=Qe;let ot=0,st=0,Ot=0;for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1;ot+=xt*lt[Mt]**2,st+=xt,Ot+=xt*Pe[Mt]}const At=Ot/st;let Rt=0;for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1;Rt+=xt*(Pe[Mt]-At)**2}const We=Ce-xe,gt=ot/We,ct=Rt===0?1:Math.max(0,Math.min(1,1-ot/Rt)),bt=1-(1-ct)*(Ce-1)/We,Et=Array.isArray(ke.names)&&ke.names.length===Re?ke.names:ge[0].map((Mt,xt)=>`x${xt+1}`),ht=St(ke.confidence),ut=We>0?F(1-(1-ht)/2,We):1/0,Tt=qe.map((Mt,xt)=>{const _t=Math.sqrt(Math.max(0,gt*Je[xt][xt])),Yt=_t>0?Mt/_t:Mt===0?0:1/0,Qt=Number.isFinite(Yt)?2*(1-Z(Math.abs(Yt),We)):0,Jt=Number.isFinite(ut)?ut*_t:null;return{name:xt===0?"(intercept)":Et[xt-1],estimate:Mt,stdError:_t,t:Yt,p:Math.max(0,Math.min(1,Qt)),lower:Jt===null?null:Mt-Jt,upper:Jt===null?null:Mt+Jt}}),Ht=new Array(Ce),Xt=new Array(Ce);for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1,_t=Math.max(0,Math.min(1,xt*d(Ve[Mt],Je)));Ht[Mt]=_t;const Yt=(1-_t)**2;Xt[Mt]=Yt>0&&gt>0?lt[Mt]**2/(xe*gt)*(_t/Yt):null}const mn=ge[0].map((Mt,xt)=>{if(Re<2)return 1;const _t=oe(ge,xt);return _t>=1?1/0:1/(1-_t)});let fn=null;{const Mt=lt.map(_t=>_t*_t),xt=ee(Ve,Mt,null);if(xt){const _t=Mt.reduce((en,gn)=>en+gn,0)/Ce;let Yt=0,Qt=0;for(let en=0;en<Ce;en++)Yt+=xt.residuals[en]**2,Qt+=(Mt[en]-_t)**2;const Jt=Qt===0?0:Math.max(0,Math.min(1,1-Yt/Qt)),qt=Ce*Jt,sn=z(qt,Re);fn={statistic:qt,df:Re,p:sn,heteroscedastic:sn<.05}}}let ln=null;if(Re===1){const Mt=ge.map((xt,_t)=>_t).sort((xt,_t)=>ge[xt][0]-ge[_t][0]);ln={confidence:ht,points:Mt.map(xt=>{const _t=Ve[xt],Yt=Math.sqrt(Math.max(0,gt*d(_t,Je)));return{x:ge[xt][0],yhat:Ze[xt],lower:Ze[xt]-ut*Yt,upper:Ze[xt]+ut*Yt}})}}return{method:Ee,coefficients:Tt,r2:ct,adjR2:bt,n:Ce,df:We,sigma2:gt,fitted:Ze,residuals:lt,leverage:Ht,cooksD:Xt,vif:mn,heteroscedasticity:fn,band:ln,weights:Ge?[...Ge]:null}}function de(ge){const Pe=ge.length,ke=Array.from({length:Pe},(Re,xe)=>xe).sort((Re,xe)=>ge[Re]-ge[xe]),Ee=new Float64Array(Pe);let Ce=0;for(;Ce<Pe;){let Re=Ce;for(;Re+1<Pe&&ge[ke[Re+1]]===ge[ke[Ce]];)Re++;const xe=(Ce+Re)/2+1;for(let ze=Ce;ze<=Re;ze++)Ee[ke[ze]]=xe;Ce=Re+1}return Ee}const Ae=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(ge){const Pe=[.01,.05,.1],ke=[Ae["1%"],Ae["5%"],Ae["10%"]];if(ge<=ke[0]){const Re=(Math.log(Pe[1])-Math.log(Pe[0]))/(ke[1]-ke[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Pe[0])+Re*(ge-ke[0]))))}if(ge>=ke[2]){const Re=(Math.log(Pe[2])-Math.log(Pe[1]))/(ke[2]-ke[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Pe[2])+Re*(ge-ke[2]))))}const Ee=ge<ke[1]?0:1,Ce=(ge-ke[Ee])/(ke[Ee+1]-ke[Ee]);return Math.exp(Math.log(Pe[Ee])+Ce*(Math.log(Pe[Ee+1])-Math.log(Pe[Ee])))}function be(ge,Pe,ke,Ee){const Ce=ke-Ee,Re=Ee+3,xe=new Array(Ce),ze=new Array(Ce);let Ve=!0,Qe=Ee;for(let Ze=0;Ze<Ce;Ze++){const lt=Ee+Ze,ot=new Float64Array(Re);ot[0]=1,ot[1]=Ze+1,ot[2]=ge[lt];for(let st=1;st<=Ee;st++)ot[2+st]=Pe[lt-st];for(let st=1;st<Re;st++)Number.isFinite(ot[st])||(Qe=Math.min(Qe,st-3));xe[Ze]=ot,ze[Ze]=Pe[lt],Number.isFinite(ze[Ze])||(Ve=!1)}if(!Ve)return 0;const{xtwx:Ne,xtwy:Ge}=c(xe,ze,null);let qe=0,Je=1/0;for(let Ze=0;Ze<=Qe;Ze++){const lt=Ze+3;if(!(Ce>lt))continue;const ot=new Array(lt);for(let ct=0;ct<lt;ct++)ot[ct]=Ne[ct].slice(0,lt);const st=P(ot);if(!st)continue;const Ot=O(st,Ge.slice(0,lt));let At=0;for(let ct=0;ct<Ce;ct++){const bt=xe[ct];let Et=0;for(let ht=0;ht<lt;ht++)Et+=bt[ht]*Ot[ht];At+=(ze[ct]-Et)**2}const We=At/(Ce-lt)*(Ce-lt);if(!(We>0))continue;const gt=Ce*Math.log(We/Ce)+2*lt;gt<Je&&(Je=gt,qe=Ze)}return qe}function re(ge,Pe={}){const ke=[];for(let Je=0;Je<ge.length;Je++){const Ze=Number(ge[Je]);Number.isFinite(Ze)&&ke.push(Ze)}const Ee=ke.length,Ce=Ee-1;if(Ee<8||Ce<6)return null;const Re=new Array(Ce);for(let Je=0;Je<Ce;Je++)Re[Je]=ke[Je+1]-ke[Je];let xe=Number.isFinite(Pe.maxlag)?Math.floor(Pe.maxlag):Math.ceil(12*(Ee/100)**.25);xe=Math.max(0,Math.min(xe,Math.floor((Ce-5)/2)));const ze=(Je,Ze)=>{const lt=[],ot=[];for(let st=Ze;st<Ce;st++){const Ot=[st-Ze+1,ke[st]];for(let At=1;At<=Je;At++)Ot.push(Re[st-At]);lt.push(Ot),ot.push(Re[st])}return ce(lt,ot,{method:"ols"})},Ve=be(ke,Re,Ce,xe),Qe=ze(Ve,Ve);if(!Qe||!Qe.coefficients[2])return null;const Ne=Qe.coefficients[2].t,Ge=je(Ne),qe=Ne<Ae["5%"];return{statistic:Ne,usedLag:Ve,nobs:Ce-Ve,criticalValues:{...Ae},pValue:Ge,pApproximate:!0,stationary:qe,verdict:qe?"stationary":"non-stationary",regression:"ct"}}function fe(ge,Pe={}){const ke=[];for(let qe=0;qe<ge.length;qe++){const Je=Number(ge[qe]);Number.isFinite(Je)&&ke.push(Je)}const Ee=ke.length;if(Ee<3)return null;let Ce=Number.isFinite(Pe.maxlag)?Math.floor(Pe.maxlag):Math.min(10,Ee-1);Ce=Math.max(1,Math.min(Ce,Ee-1));let Re=0;for(const qe of ke)Re+=qe;Re/=Ee;const xe=ke.map(qe=>qe-Re);let ze=0;for(const qe of xe)ze+=qe*qe;ze/=Ee;const Ve=new Array(Ce+1).fill(0);Ve[0]=1;for(let qe=1;qe<=Ce;qe++){let Je=0;for(let Ze=qe;Ze<Ee;Ze++)Je+=xe[Ze]*xe[Ze-qe];Ve[qe]=ze>0?Je/Ee/ze:0}const Qe=new Array(Ce+1).fill(0);Qe[0]=1;let Ne=[];for(let qe=1;qe<=Ce;qe++){let Je=Ve[qe];for(let st=1;st<qe;st++)Je-=Ne[st-1]*Ve[qe-st];let Ze=1;for(let st=1;st<qe;st++)Ze-=Ne[st-1]*Ve[st];const lt=Ze!==0?Je/Ze:0,ot=new Array(qe);for(let st=1;st<qe;st++)ot[st-1]=Ne[st-1]-lt*Ne[qe-1-st];ot[qe-1]=lt,Qe[qe]=lt,Ne=ot}const Ge=1.96/Math.sqrt(Ee);return{acf:Ve,pacf:Qe,bounds:{upper:Ge,lower:-Ge},n:Ee,nlags:Ce,approximate:!0}}function pe(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2)return null;const xe=de(Ee),ze=de(Ce);let Ve=0,Qe=0;for(let Je=0;Je<Re;Je++)Ve+=xe[Je],Qe+=ze[Je];Ve/=Re,Qe/=Re;let Ne=0,Ge=0,qe=0;for(let Je=0;Je<Re;Je++){const Ze=xe[Je]-Ve,lt=ze[Je]-Qe;Ne+=Ze*lt,Ge+=Ze*Ze,qe+=lt*lt}return Ge===0||qe===0?null:Math.max(-1,Math.min(1,Ne/Math.sqrt(Ge*qe)))}function Oe(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2||Re>t)return null;let xe=0,ze=0,Ve=0,Qe=0;for(let qe=0;qe<Re;qe++)for(let Je=qe+1;Je<Re;Je++){const Ze=Math.sign(Ee[qe]-Ee[Je]),lt=Math.sign(Ce[qe]-Ce[Je]),ot=Ze*lt;ot>0?xe++:ot<0?ze++:Ze===0&&lt===0||(Ze===0?Ve++:Qe++)}const Ne=xe+ze+Qe,Ge=xe+ze+Ve;return Ne===0||Ge===0?null:(xe-ze)/Math.sqrt(Ne*Ge)}function ve(ge,Pe={}){const ke=ge.length;if(ke<2)return null;const Ee=ge[0],Ce=ge[ke-1],Re=[];for(let st=1;st<ke;st++){const Ot=ge[st-1];Ot!==0&&Re.push((ge[st]-Ot)/Math.abs(Ot))}let xe=null;if(Re.length>1){let st=0;for(const At of Re)st+=At;st/=Re.length;let Ot=0;for(const At of Re)Ot+=(At-st)**2;xe=Math.sqrt(Ot/(Re.length-1))}const ze=Number(Pe.periodsPerYear)>0?Number(Pe.periodsPerYear):null;let Ve=ge[0],Qe=0,Ne=0,Ge=0,qe=0;for(let st=1;st<ke;st++){if(ge[st]>Ve){Ve=ge[st],Qe=st;continue}if(Ve<=0)continue;const Ot=(Ve-ge[st])/Ve;Ot>Ne&&(Ne=Ot,Ge=Qe,qe=st)}let Je=null;if(ke>2){let st=0;for(let Rt=0;Rt<ke;Rt++)st+=ge[Rt];st/=ke;let Ot=0,At=0;for(let Rt=0;Rt<ke;Rt++){const We=ge[Rt]-st;At+=We*We,Rt>0&&(Ot+=We*(ge[Rt-1]-st))}Je=At>0?Ot/At:null}let Ze=0,lt=0;for(const st of Re)st>0?Ze++:st<0&&lt++;let ot=null;if(Ee>0&&Ce>0){const st=(Ce/Ee)**(1/(ke-1))-1;ot=ze?(1+st)**ze-1:st}return{n:ke,first:Ee,last:Ce,change:Ce-Ee,changePercent:Ee===0?null:(Ce-Ee)/Math.abs(Ee)*100,volatility:xe,annualisedVolatility:xe!==null&&ze?xe*Math.sqrt(ze):null,growth:ot,maxDrawdown:Ne,maxDrawdownFrom:Ge,maxDrawdownTo:qe,autocorrelation:Je,upDays:Ze,downDays:lt}}const $e=1.128,he=3.267;function ye(ge){const Pe=ge.length;if(Pe<2)return null;const ke=[];for(let Ce=1;Ce<Pe;Ce++)ke.push(Math.abs(ge[Ce]-ge[Ce-1]));const Ee=ke.reduce((Ce,Re)=>Ce+Re,0)/ke.length;return{ranges:ke,centre:Ee,upper:he*Ee,lower:0}}function Se(ge){const Pe=ge.length;if(Pe<2)return null;let ke=0;for(let Ce=1;Ce<Pe;Ce++)ke+=Math.abs(ge[Ce]-ge[Ce-1]);const Ee=ke/(Pe-1);return{sigma:Ee/$e,meanRange:Ee}}function Ie(ge,Pe){const ke=ge.length;if(ke<2||!Pe)return null;const Ee=Number.isFinite(Number(Pe.lower))?Number(Pe.lower):null,Ce=Number.isFinite(Number(Pe.upper))?Number(Pe.upper):null;if(Ee===null&&Ce===null)return null;let Re=0;for(let Ze=0;Ze<ke;Ze++)Re+=ge[Ze];Re/=ke;let xe=0;for(let Ze=0;Ze<ke;Ze++)xe+=(ge[Ze]-Re)**2;const ze=Math.sqrt(xe/(ke-1)),Ve=Se(ge),Qe=Ve?Ve.sigma:null,Ne=Ze=>{if(!Ze||Ze<=0)return{index:null,k:null};const ot=Ee!==null&&Ce!==null?(Ce-Ee)/(6*Ze):null,st=Ce!==null?(Ce-Re)/(3*Ze):1/0,Ot=Ee!==null?(Re-Ee)/(3*Ze):1/0;return{index:ot,k:Math.min(st,Ot)}},Ge=Ne(Qe),qe=Ne(ze);let Je=0;for(let Ze=0;Ze<ke;Ze++){if(Ee!==null&&ge[Ze]<Ee){Je++;continue}Ce!==null&&ge[Ze]>Ce&&Je++}return{n:ke,mean:Re,lower:Ee,upper:Ce,target:Number.isFinite(Number(Pe.target))?Number(Pe.target):null,sigmaWithin:Qe,sigmaOverall:ze,cp:Ge.index,cpk:Ge.k,pp:qe.index,ppk:qe.k,outOfSpec:Je,defectRate:ke?Je/ke:null}}function we(ge){const Pe=ge.length;if(Pe<2)return null;const ke=Se(ge);if(!ke||!(ke.sigma>0))return null;let Ee=0;for(let Ce=0;Ce<Pe;Ce++)Ee+=ge[Ce];return Ee/=Pe,{centre:Ee,sigma:ke.sigma,upper:Ee+3*ke.sigma,lower:Ee-3*ke.sigma}}function Fe(ge,Pe){if(!Pe||!(Pe.sigma>0))return[];const ke=ge.length,{centre:Ee,sigma:Ce}=Pe,Re=ze=>(ge[ze]-Ee)/Ce,xe=[];for(let ze=0;ze<ke;ze++){if(Math.abs(Re(ze))>3&&xe.push({index:ze,rule:1,description:"beyond three sigma"}),ze>=2)for(const Ve of[1,-1]){let Qe=0;for(let Ne=ze-2;Ne<=ze;Ne++)Re(Ne)*Ve>2&&Qe++;if(Qe>=2){xe.push({index:ze,rule:2,description:"two of three past two sigma"});break}}if(ze>=4)for(const Ve of[1,-1]){let Qe=0;for(let Ne=ze-4;Ne<=ze;Ne++)Re(Ne)*Ve>1&&Qe++;if(Qe>=4){xe.push({index:ze,rule:3,description:"four of five past one sigma"});break}}if(ze>=7)for(const Ve of[1,-1]){let Qe=!0;for(let Ne=ze-7;Ne<=ze;Ne++)if(Re(Ne)*Ve<=0){Qe=!1;break}if(Qe){xe.push({index:ze,rule:4,description:"eight in a row on one side"});break}}}return xe}function He(ge,Pe){if(!Pe||!(Pe.sigma>0))return[];const ke=ge.length,{centre:Ee,sigma:Ce}=Pe,Re=Ve=>(ge[Ve]-Ee)/Ce,xe=(Ve,Qe,Ne,Ge)=>{for(const qe of[1,-1]){let Je=0;for(let Ze=Ve;Ze<=Qe;Ze++)Re(Ze)*qe>Ne&&Je++;if(Je>=Ge)return!0}return!1},ze=[];for(let Ve=0;Ve<ke;Ve++){if(Math.abs(Re(Ve))>3&&ze.push({index:Ve,rule:1,description:"beyond three sigma"}),Ve>=8)for(const Qe of[1,-1]){let Ne=!0;for(let Ge=Ve-8;Ge<=Ve;Ge++)if(Re(Ge)*Qe<=0){Ne=!1;break}if(Ne){ze.push({index:Ve,rule:2,description:"nine in a row on one side"});break}}if(Ve>=5)for(const Qe of[1,-1]){let Ne=!0;for(let Ge=Ve-4;Ge<=Ve;Ge++)if((ge[Ge]-ge[Ge-1])*Qe<=0){Ne=!1;break}if(Ne){ze.push({index:Ve,rule:3,description:Qe>0?"six rising":"six falling"});break}}if(Ve>=13){let Qe=!0;for(let Ne=Ve-12;Ne<=Ve;Ne++){const Ge=ge[Ne]-ge[Ne-1],qe=ge[Ne+1<=Ve?Ne+1:Ne]-ge[Ne];if(Ne+1>Ve)break;if(Ge===0||qe===0||Ge>0==qe>0){Qe=!1;break}}Qe&&ze.push({index:Ve,rule:4,description:"fourteen alternating"})}if(Ve>=2&&xe(Ve-2,Ve,2,2)&&ze.push({index:Ve,rule:5,description:"two of three past two sigma"}),Ve>=4&&xe(Ve-4,Ve,1,4)&&ze.push({index:Ve,rule:6,description:"four of five past one sigma"}),Ve>=14){let Qe=!0;for(let Ne=Ve-14;Ne<=Ve;Ne++)if(Math.abs(Re(Ne))>=1){Qe=!1;break}Qe&&ze.push({index:Ve,rule:7,description:"fifteen within one sigma"})}if(Ve>=7){let Qe=!0;for(let Ne=Ve-7;Ne<=Ve;Ne++)if(Math.abs(Re(Ne))<=1){Qe=!1;break}Qe&&ze.push({index:Ve,rule:8,description:"eight beyond one sigma"})}}return ze}const Ke=Object.freeze(["westernElectric","nelson"]);function nt(ge,Pe,ke="westernElectric"){return String(ke)==="nelson"?He(ge,Pe):Fe(ge,Pe)}function it(ge,Pe,ke){let Ee=0;for(let Ce=0;Ce<ge.length;Ce++)(ge[Ce]<Pe||ge[Ce]>ke)&&Ee++;return Ee}function mt(ge,Pe,ke,Ee=20){const Ce=ge.length;if(!Ce)return[];const Re=ge[0],xe=ge[Ce-1];if(xe===Re)return[{from:Re,to:xe,count:Ce}];const ze=ke-Pe,Ve=1.5*ze;let Qe=ze>0?Math.max(Re,Pe-Ve):Re,Ne=ze>0?Math.min(xe,ke+Ve):xe;Ne>Qe||(Qe=Re,Ne=xe);const Ge=ze>0?2*ze/Math.cbrt(Ce):(Ne-Qe)/(Math.ceil(Math.log2(Ce))+1),qe=Ge>0?Math.min(Ee,Math.max(1,Math.ceil((Ne-Qe)/Ge))):1,Je=(Ne-Qe)/qe,Ze=[];for(let lt=0;lt<qe;lt++)Ze.push({from:Qe+lt*Je,to:Qe+(lt+1)*Je,count:0});for(let lt=0;lt<Ce;lt++){const ot=Math.min(qe-1,Math.max(0,Math.floor((ge[lt]-Qe)/Je)));Ze[ot].count++}return Ze[0].from=Re,Ze[qe-1].to=xe,Ze}const kt=.95;function St(ge){const Pe=Number(ge);return Number.isFinite(Pe)&&Pe>0&&Pe<1?Pe:kt}function Pt(ge,Pe=kt){const ke=ge.length;if(ke<2)return null;let Ee=0;for(let Ne=0;Ne<ke;Ne++)Ee+=ge[Ne];const Ce=Ee/ke;let Re=0;for(let Ne=0;Ne<ke;Ne++){const Ge=ge[Ne]-Ce;Re+=Ge*Ge}const xe=Math.sqrt(Re/(ke-1)),ze=St(Pe),Qe=F(1-(1-ze)/2,ke-1)*xe/Math.sqrt(ke);return{mean:Ce,lower:Ce-Qe,upper:Ce+Qe,margin:Qe,n:ke,confidence:ze}}function Nt(ge,Pe,ke=kt){const Ee=Number(ge),Ce=Number(Pe);if(!(Ce>0)||!(Ee>=0)||Ee>Ce)return null;const Re=St(ke),xe=Y(1-(1-Re)/2),ze=Ee/Ce,Ve=xe*xe,Qe=1+Ve/Ce,Ne=(ze+Ve/(2*Ce))/Qe,Ge=xe/Qe*Math.sqrt(ze*(1-ze)/Ce+Ve/(4*Ce*Ce));return{proportion:ze,lower:Math.max(0,Ne-Ge),upper:Math.min(1,Ne+Ge),n:Ce,confidence:Re}}function Ft(ge,Pe=kt){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const ke=St(Pe),Ce=F(1-(1-ke)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-Ce,upper:ge.slope+Ce,margin:Ce,confidence:ke}}function Lt(ge,Pe,ke=kt){const Ee=Number(ge),Ce=Number(Pe);if(!Number.isFinite(Ee)||!(Ce>1))return null;const Re=St(ke),ze=Y(1-(1-Re)/2)*Math.sqrt(1/(9*Ce)+Ee*Ee/(2*(Ce-1)));return{index:Ee,lower:Ee-ze,upper:Ee+ze,margin:ze,n:Ce,confidence:Re}}function Ut(ge,Pe){return!ge||!(ge.sd>0)||!Number.isFinite(Pe)||!Number.isFinite(ge.mean)?null:(Pe-ge.mean)/ge.sd}function ft(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*B(Math.abs(ge)/2)-1)):0}function dt(ge,Pe){const ke=new Map,Ee=X(ge);let Ce=0;for(let Re=0;Re<Pe.length;Re++){const xe=Ee(Pe[Re]);if(xe==null||xe===""||typeof xe=="number"&&Number.isNaN(xe))continue;const ze=xe instanceof Date?xe.getTime():typeof xe=="object"?String(xe):xe;ke.set(ze,(ke.get(ze)||0)+1),Ce++}return{map:ke,total:Ce}}function wt(ge,Pe,ke,Ee){if(!(Pe>0)||!(Ee>0))return null;let Ce=0;const Re=new Set(ge.keys());for(const xe of ke.keys())Re.add(xe);for(const xe of Re){const ze=(ge.get(xe)||0)/Pe,Ve=(ke.get(xe)||0)/Ee;Ce+=Math.abs(ze-Ve)}return Ce/2}const rt=10;function me(ge,Pe,ke){if(ke&&ke.numeric){const ze=u(ge,Pe),{n:Ve,mean:Qe}=p(ze),Ne=Ve>0?Ut({mean:ke.mean,sd:ke.sd},Qe):null;return{measure:"standardizedMeanDifference",magnitude:Ne,distance:Ne===null?0:ft(Ne),direction:Ne===null?0:Math.sign(Ne),subsetN:Ve,populationN:ke.n||0,reliable:Ve>=rt}}const{map:Ce,total:Re}=dt(ge,Pe),xe=wt(Ce,Re,ke.map,ke.total);return{measure:"categoricalTotalVariation",magnitude:xe,distance:xe===null?0:xe,direction:0,subsetN:Re,populationN:ke.total||0,reliable:Re>=rt}}function Te(ge,Pe){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const ke=X(ge);let Ee=0,Ce=0;for(let Re=0;Re<Pe.length&&Ee<200;Re++){const xe=ke(Pe[Re]);if(xe==null||xe==="")continue;if(xe instanceof Date)return!1;Ee++;const ze=typeof xe=="number"?xe:Number(xe);Number.isFinite(ze)&&Ce++}return Ee===0?!1:Ce/Ee>=.9}function Ue(ge,Pe){if(Te(ge,Pe)){const Ce=u(ge,Pe),{n:Re,mean:xe,m2:ze}=p(Ce);return{numeric:!0,mean:xe,sd:Re>0?Math.sqrt(ze/Re):0,n:Re}}const{map:ke,total:Ee}=dt(ge,Pe);return{numeric:!1,map:ke,total:Ee}}}),Be("packages/core/src/compute/total.js",function(e,H){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F=H("packages/core/src/compute/handle.js"),Z=F.presenceReader,Y=F.valueComparator,B=F.valueReader,z=H("packages/core/src/compute/statistics.js"),G=z.STAT_FNS,P=z.STAT_LABELS;function O(g){return!!g&&(g.kind==="float64"||g.kind==="int32")}function b(g,k){const y=k.length;let T=0;if(O(g)){const N=g.values,W=Z(g);if(!W){for(let R=0;R<y;R++){const x=N[k[R]];Number.isNaN(x)||(T+=x)}return T}for(let R=0;R<y;R++){const x=k[R];if(W(x)===1){const A=N[x];Number.isNaN(A)||(T+=A)}}return T}const j=B(g);for(let N=0;N<y;N++){const W=u(j(k[N]));W!==null&&(T+=W)}return T}b.kernel=!0;function c(g,k){const y=k.length;let T=0;if(O(g)){const N=g.values,W=Z(g);if(!W){for(let R=0;R<y;R++)Number.isNaN(N[k[R]])||T++;return T}for(let R=0;R<y;R++){const x=k[R];W(x)===1&&!Number.isNaN(N[x])&&T++}return T}const j=B(g);for(let N=0;N<y;N++){const W=j(k[N]);W!=null&&!(typeof W=="number"&&Number.isNaN(W))&&T++}return T}c.kernel=!0;function d(g,k){return k.length}d.kernel=!0;function l(g,k){const y=c(g,k);return y===0?null:b(g,k)/y}l.kernel=!0;function r(g,k,y,T){const j=k.length;if(O(g)){const x=g.values,A=Z(g);let $=null;if(!A){for(let I=0;I<j;I++){const M=x[k[I]];Number.isNaN(M)||($===null||(y<0?M<$:M>$))&&($=M)}return $}for(let I=0;I<j;I++){const M=k[I];if(A(M)===0)continue;const S=x[M];Number.isNaN(S)||($===null||(y<0?S<$:S>$))&&($=S)}return $}const N=B(g),W=Y(T);let R=null;for(let x=0;x<j;x++){const A=N(k[x]);A==null||typeof A=="number"&&Number.isNaN(A)||(R===null||(y<0?W(A,R)<0:W(A,R)>0))&&(R=A)}return R}function t(g,k,y){return r(g,k,-1,y&&y.locale)}t.kernel=!0;function i(g,k,y){return r(g,k,1,y&&y.locale)}i.kernel=!0;function s(g,k){return k.length===0?null:B(g)(k[0])}s.kernel=!0;function n(g,k){return k.length===0?null:B(g)(k[k.length-1])}n.kernel=!0;function u(g){if(typeof g=="number")return Number.isNaN(g)?null:g;if(g==null||g===""||typeof g=="boolean")return null;if(g instanceof Date)return g.getTime();const k=Number(g);return Number.isNaN(k)?null:k}const o={sum:b,min:t,max:i,avg:l,count:d,first:s,last:n,countValues:c,...G},a=Object.freeze({...P,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function f(g){return g?typeof g=="string"?a[g]||g:"Total":""}const w=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(g){const k=g&&g.dataType&&g.dataType.totals&&g.dataType.totals.supported;if(Array.isArray(k))return k.slice();const y=w.filter(T=>T in o);for(const T of Object.keys(o))y.includes(T)||y.push(T);return y}function v(g,k){return typeof k!="string"?!0:m(g).includes(k)}function h(g,k){const y=B(g),T=[];for(let j=0;j<k.length;j++){const N=y(k[j]);N!=null&&T.push(N)}return T}function p(g,k,y,T){const j=k||[];if(typeof y=="string"){const N=o[y];return N?N(g,j,T):(D(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return L(y)?y.kernel===!0?y(g,j,T):y(h(g,j),T||{}):null}}),Be("packages/core/src/compute/windowed.js",function(e,H){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/compute/sketch.js").Welford;class X{#e;#t;#n=[];#r;#s;constructor(B,z=0,G=Date.now){if(B!=="count"&&B!=="time"&&B!=="session")throw new RangeError(`unknown window kind: ${B}`);if((B==="count"||B==="time")&&!(z>0))throw new RangeError(`a ${B} window needs a positive span`);this.#e=B,this.#t=Math.floor(z),this.#r=G,this.#s=G()}get size(){return this.#n.length}push(B,z=this.#r()){Number.isFinite(B)&&(this.#n.push({t:z,v:B}),this.#i(z))}#i(B){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const z=B-this.#t;for(;this.#n.length&&this.#n[0].t<z;)this.#n.shift()}}spec(){const B=this.#e==="session"?this.#r()-this.#s:this.#t;return{kind:this.#e,span:B,size:this.#n.length}}values(){return this.#n.map(B=>B.v)}aggregate(){const B=this.spec();if(!this.#n.length)return{over:B,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const z=new L;let G=0,P=1/0,O=-1/0;for(const{v:b}of this.#n)G+=b,b<P&&(P=b),b>O&&(O=b),z.add(b);return{over:B,count:this.#n.length,sum:G,mean:z.mean(),min:P,max:O,variance:z.variance(),stddev:z.stddev()}}reduce(B){const z=this.aggregate(),G={sum:z.sum,avg:z.mean,mean:z.mean,min:z.min,max:z.max,count:z.count,variance:z.variance,stddev:z.stddev};if(!(B in G))throw new RangeError(`unknown windowed aggregate: ${B}`);return{value:G[B],over:z.over}}}const D=Object.freeze(["count","time","session"]);function F(Y,B=Date.now){const z=Y.kind==="time"&&Y.minutes!=null?Y.minutes*6e4:Y.span??0;return new X(Y.kind,z,B)}const Z={Window:X,WINDOW_KINDS:D,openWindow:F}}),Be("packages/core/src/compute/rolling.js",function(e,H){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const L=H("packages/core/src/compute/windowed.js").openWindow,D=H("packages/core/src/compute/sketch.js").KLL,F=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(o,a,f,w){if(o.kind==="count"){const m=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,a/m),partial:a<m}}if(o.kind==="time"){const m=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(m>0))return{coverage:1,partial:!1};const v=f-w;return{coverage:Math.min(1,v/m),partial:v<m}}return{coverage:null,partial:!1}}function Y(o,a){const f=L(a),w=new Map,m=o.length?o[0].at:0;for(let v=0;v<o.length;v++){const{key:h,at:p,value:g}=o[v];Number.isFinite(g)&&f.push(g,p);const k=f.aggregate(),y=Z(a,k.count,p,m);h!=null&&w.set(String(h),{sum:k.sum,avg:k.mean,min:k.min,max:k.max,count:k.count,coverage:y.coverage,partial:y.partial})}return w}function B(o){const a=new Map;let f=0;for(const{key:w,value:m}of o)Number.isFinite(m)&&(f+=m),w!=null&&a.set(String(w),f);return a}function z(o,a=1){const f=new Map,w=Math.max(1,Math.floor(a));for(let m=0;m<o.length;m++){const{key:v,value:h}=o[m];if(v==null)continue;const p=m>=w?o[m-w].value:null,g=Number.isFinite(h)?h:null,k=Number.isFinite(p)?p:null;f.set(String(v),g!==null&&k!==null?g-k:null)}return f}const G=4096;function P(o){let a=o>>>0;return()=>{a+=1831565813;let f=a;return f=Math.imul(f^f>>>15,f|1),f^=f+Math.imul(f^f>>>7,f|61),((f^f>>>14)>>>0)/4294967296}}function O(o,a){const f=o.length;if(f===1)return o[0];const w=(f-1)*a,m=Math.floor(w),v=Math.ceil(w);return m===v?o[m]:o[m]+(w-m)*(o[v]-o[m])}function b(o,a,f={}){const w=Math.min(1,Math.max(0,f.q==null?.5:f.q)),m=Math.max(1,Math.floor(f.cap==null?G:f.cap)),v=P(f.seed==null?2654435769:f.seed),h=new Map,p=o.length?o[0].at:0;if(a.kind==="session"){const k=new D(200,v);let y=0;for(const{key:T,value:j}of o)Number.isFinite(j)&&(k.add(j),y++),T!=null&&h.set(String(T),{value:y?k.quantile(w):null,approx:y>0,count:y,coverage:null,partial:!1});return h}const g=L(a);for(const{key:k,at:y,value:T}of o){Number.isFinite(T)&&g.push(T,y);const j=g.values(),N=j.length;let W=null,R=!1;if(N)if(N<=m)W=O([...j].sort((A,$)=>A-$),w);else{const A=new D(200,v);for(const $ of j)A.add($);W=A.quantile(w),R=!0}const x=Z(a,N,y,p);k!=null&&h.set(String(k),{value:W,approx:R,count:N,coverage:x.coverage,partial:x.partial})}return h}function c(o,a){const f=o.length,w=new Array(f).fill(null),m=Math.floor(a/2),v=a%2===0;for(let h=0;h<f;h++){if(h-m<0||h+m>=f)continue;let p=0,g=!0;if(v)for(let k=-m;k<=m;k++){const y=o[h+k];if(!Number.isFinite(y)){g=!1;break}p+=k===-m||k===m?y*.5:y}else for(let k=-m;k<=m;k++){const y=o[h+k];if(!Number.isFinite(y)){g=!1;break}p+=y}g&&(w[h]=p/a)}return w}function d(o,a){const f=new Map,w=Math.floor(Number(a&&a.period));if(!(w>=2))return f;const m=a&&a.model==="multiplicative",v=o.length,h=o.map(R=>Number.isFinite(R.value)?R.value:null),p=c(h,w),g=new Array(v).fill(null);for(let R=0;R<v;R++){const x=p[R],A=h[R];x===null||A===null||(m?x!==0&&(g[R]=A/x):g[R]=A-x)}const k=new Array(w).fill(0),y=new Array(w).fill(0);for(let R=0;R<v;R++){if(g[R]===null)continue;const x=R%w;k[x]+=g[R],y[x]+=1}const T=m?1:0,j=k.map((R,x)=>y[x]?R/y[x]:T),N=j.reduce((R,x)=>R+x,0)/w,W=m?j.map(R=>N!==0?R/N:1):j.map(R=>R-N);for(let R=0;R<v;R++){const{key:x}=o[R];if(x==null)continue;const A=p[R],$=W[R%w],I=h[R];let M=null;A!==null&&I!==null&&(M=m?A*$!==0?I/(A*$):null:I-A-$),f.set(String(x),{trend:A,seasonal:I===null?null:$,residual:M,coverage:A===null?0:1,partial:A===null})}return f}function l(o,a,f,w=80){const m=(Math.sqrt(5)-1)/2;let v=a,h=f,p=h-m*(h-v),g=v+m*(h-v),k=o(p),y=o(g);for(let T=0;T<w;T++)k<y?(h=g,g=p,y=k,p=h-m*(h-v),k=o(p)):(v=p,p=g,k=y,g=v+m*(h-v),y=o(g));return(v+h)/2}const r=1e-4,t=1-1e-4;function i(o,a){const f=o.length,w=new Array(f).fill(null),m=new Array(f).fill(null);let v=null,h=0;for(let p=0;p<f;p++){const g=o[p];if(!Number.isFinite(g)){v!==null&&(m[p]=v,w[p]=v);continue}if(v===null){v=g,m[p]=g,w[p]=g;continue}m[p]=v,h+=(g-v)**2,v=a*g+(1-a)*v,w[p]=v}return{smoothed:w,fitted:m,sse:h}}function s(o,a,f){const w=o.length,m=new Array(w).fill(null),v=new Array(w).fill(null);let h=null,p=null,g=0;for(let k=0;k<w;k++){const y=o[k];if(!Number.isFinite(y)){h!==null&&(h+=p,m[k]=h);continue}if(h===null){h=y,m[k]=y;continue}if(p===null){p=y-h;const N=h+p;v[k]=N,g+=(y-N)**2;const W=h;h=a*y+(1-a)*(W+p),p=f*(h-W)+(1-f)*p,m[k]=h;continue}const T=h+p;v[k]=T,g+=(y-T)**2;const j=h;h=a*y+(1-a)*(j+p),p=f*(h-j)+(1-f)*p,m[k]=h}return{smoothed:m,fitted:v,sse:g}}function n(o,a={}){const f=new Map,w=a.method==="holt",m=o.map(T=>Number.isFinite(T.value)?T.value:null),v=m.filter(T=>T!==null).length,h=T=>Math.min(t,Math.max(r,T)),p=()=>{for(const{key:T}of o)T!=null&&f.set(String(T),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return f};if(v<(w?2:1))return p();let g=Number.isFinite(a.alpha)?h(a.alpha):null,k=w&&Number.isFinite(a.beta)?h(a.beta):null;if(w){if(g===null||k===null){let T=g===null?.5:g,j=k===null?.5:k;for(let N=0;N<6;N++)g===null&&(T=l(W=>s(m,W,j).sse,r,t)),k===null&&(j=l(W=>s(m,T,W).sse,r,t));g=g===null?T:g,k=k===null?j:k}}else g===null&&(g=l(T=>i(m,T).sse,r,t));const y=w?s(m,g,k):i(m,g);for(let T=0;T<o.length;T++){const{key:j}=o[T];j!=null&&f.set(String(j),{smoothed:y.smoothed[T],fitted:y.fitted[T],alpha:g,beta:w?k:null,sse:y.sse})}return f}const u={ROLLING_WINDOW_FIELDS:F,QUANTILE_SPAN_CAP:G,rollingWindow:Y,rollingQuantile:b,cumulativeToDate:B,periodOverPeriod:z,seasonalDecompose:d,exponentialSmoothing:n}}),Be("packages/core/src/compute/compare.js",function(e,H){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return c}});const te=H("packages/core/src/compute/statistics.js"),L=te.numbers,X=te.moments,D=te.frequencyMap,F=te.categoricalDistance,Z=te.normalTotalVariation,Y=te.isNumericColumn,B=te.SUBSET_RELIABILITY_FLOOR,z=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function G(d,l){if(!d||!l||!(d.n>0)||!(l.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(l.mean))return null;const r=(d.n*d.sd*d.sd+l.n*l.sd*l.sd)/(d.n+l.n);return r>0?(d.mean-l.mean)/Math.sqrt(r):null}function P(d,l){const r=L(d,l),{n:t,mean:i,m2:s}=X(r),n=t>0?Math.sqrt(s/t):0;return{mean:i,sd:n,n:t}}function O(d,l,r,t){return Y(d,l)&&Y(r,t)}function b(d,l,r,t){if(O(d,l,r,t)){const u=P(d,l),o=P(r,t),a=G(u,o);return{measure:z.numeric,magnitude:a,distance:a===null?0:Z(a),direction:a===null?0:Math.sign(a),nA:u.n,nB:o.n,reliable:u.n>=B&&o.n>=B}}const i=D(d,l),s=D(r,t),n=F(i.map,i.total,s.map,s.total);return{measure:z.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:i.total,nB:s.total,reliable:i.total>=B&&s.total>=B}}function c(d,l,r={}){const t=new Set(d.columns),i=new Set(l.columns),s=d.columns.filter(f=>i.has(f)),n=Array.isArray(r.columns)&&r.columns.length?s.filter(f=>r.columns.includes(f)):s,u=d.indices(),o=l.indices(),a=[];for(const f of n){const w=d.handle(f),m=l.handle(f);if(!w||!m)continue;const v=b(w,u,m,o);a.push({column:f,name:d.name&&d.name(f)||l.name&&l.name(f)||f,measure:v.measure,magnitude:v.magnitude,distance:v.distance,direction:v.direction,nA:v.nA,nB:v.nB,reliable:v.reliable})}return a.sort((f,w)=>w.distance-f.distance||Math.abs(w.magnitude||0)-Math.abs(f.magnitude||0)),{ranked:a,nA:u.length,nB:o.length,unmatched:{onlyA:d.columns.filter(f=>!i.has(f)),onlyB:l.columns.filter(f=>!t.has(f))},measures:z}}}),Be("packages/core/src/compute/anomaly.js",function(e,H){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const L=H("packages/core/src/compute/statistics.js").quantileSorted,D=H("packages/core/src/compute/special.js").logGamma,F=.6745,Z=3.5,Y=1.5,B=.975,z=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function G(o){if(!o.length)return null;const f=Array.from(o,Number).sort((h,p)=>h-p),w=L(f,.5),m=f.map(h=>Math.abs(h-w)).sort((h,p)=>h-p),v=L(m,.5);return{median:w,mad:v}}function P(o,a={}){const f=Number.isFinite(a.threshold)?a.threshold:Z,w=o.length,m=new Array(w).fill(null),v=new Array(w).fill(!1),h=[];for(let k=0;k<w;k++){const y=Number(o[k]);Number.isFinite(y)&&h.push(y)}if(!h.length)return{median:null,mad:null,threshold:f,scores:m,flags:v,flagged:0};const p=G(h);if(p.mad===0)return{median:p.median,mad:0,threshold:f,scores:m,flags:v,flagged:0};let g=0;for(let k=0;k<w;k++){const y=Number(o[k]);if(!Number.isFinite(y))continue;const T=F*(y-p.median)/p.mad;m[k]=T,Math.abs(T)>f&&(v[k]=!0,g++)}return{median:p.median,mad:p.mad,threshold:f,scores:m,flags:v,flagged:g}}function O(o,a={}){const f=Number.isFinite(a.k)?a.k:Y,w=[];for(let g=0;g<o.length;g++){const k=Number(o[g]);Number.isFinite(k)&&w.push(k)}if(!w.length)return null;const m=w.sort((g,k)=>g-k),v=L(m,.25),h=L(m,.75),p=h-v;return{q1:v,q3:h,iqr:p,lower:v-f*p,upper:h+f*p,k:f}}function b(o,a){if(a<=0)return 0;const f=D(o);if(a<o+1){let k=o,y=1/o,T=y;for(let j=0;j<1e3&&(k+=1,T*=a/k,y+=T,!(Math.abs(T)<Math.abs(y)*1e-15));j++);return y*Math.exp(-a+o*Math.log(a)-f)}const w=1e-300;let m=a+1-o,v=1/w,h=1/m,p=h;for(let k=1;k<1e3;k++){const y=-k*(k-o);m+=2,h=y*h+m,Math.abs(h)<w&&(h=w),v=m+y/v,Math.abs(v)<w&&(v=w),h=1/h;const T=h*v;if(p*=T,Math.abs(T-1)<1e-15)break}return 1-Math.exp(-a+o*Math.log(a)-f)*p}function c(o,a){return o<=0?0:b(a/2,o/2)}function d(o,a=B){if(!(a>0)||!(a<1))return NaN;let f=0,w=Math.max(1,o);for(;c(w,o)<a;)w*=2;for(let m=0;m<200;m++){const v=(f+w)/2;if(c(v,o)<a?f=v:w=v,w-f<1e-10)break}return(f+w)/2}function l(o){const a=o.length,f=o.map((w,m)=>{const v=w.slice();for(let h=0;h<a;h++)v.push(m===h?1:0);return v});for(let w=0;w<a;w++){let m=w;for(let h=w+1;h<a;h++)Math.abs(f[h][w])>Math.abs(f[m][w])&&(m=h);if(Math.abs(f[m][w])<1e-12)return null;if(m!==w){const h=f[m];f[m]=f[w],f[w]=h}const v=f[w][w];for(let h=0;h<2*a;h++)f[w][h]/=v;for(let h=0;h<a;h++){if(h===w)continue;const p=f[h][w];if(p!==0)for(let g=0;g<2*a;g++)f[h][g]-=p*f[w][g]}}return f.map(w=>w.slice(a))}function r(o,a){const f=o.length,w=new Array(a).fill(0);for(const h of o)for(let p=0;p<a;p++)w[p]+=h[p];for(let h=0;h<a;h++)w[h]/=f;const m=Array.from({length:a},()=>new Array(a).fill(0));for(const h of o)for(let p=0;p<a;p++){const g=h[p]-w[p];for(let k=p;k<a;k++)m[p][k]+=g*(h[k]-w[k])}const v=f>1?f-1:1;for(let h=0;h<a;h++)for(let p=h;p<a;p++)m[h][p]/=v,m[p][h]=m[h][p];return{mean:w,cov:m}}function t(o,a={}){const f=Number.isFinite(a.p)?a.p:B,w=Number.isFinite(a.ridge)?a.ridge:1e-6,m=o.length;if(!m)return null;const v=o[0].length;if(!v)return null;const h=new Array(m).fill(null),p=new Array(m).fill(null),g=new Array(m).fill(!1),k=[],y=[];for(let $=0;$<m;$++){const I=o[$];let M=I.length===v;const S=new Array(v);for(let E=0;M&&E<v;E++){const U=Number(I[E]);Number.isFinite(U)?S[E]=U:M=!1}M&&(k.push($),y.push(S))}const T=v,j=d(T,f);if(y.length<=v)return{center:[],df:T,cutoff:j,singular:!0,used:y.length,distances:h,squared:p,flags:g,flagged:0};const{mean:N,cov:W}=r(y,v);let R=l(W),x=!1;if(!R){x=!0;let $=0;for(let S=0;S<v;S++)$+=W[S][S];const I=$/v*w||w,M=W.map((S,E)=>S.map((U,K)=>E===K?U+I:U));if(R=l(M),!R)return{center:N,df:T,cutoff:j,singular:!0,used:y.length,distances:h,squared:p,flags:g,flagged:0}}let A=0;for(let $=0;$<y.length;$++){const I=y[$],M=new Array(v);for(let U=0;U<v;U++)M[U]=I[U]-N[U];let S=0;for(let U=0;U<v;U++){let K=0;for(let q=0;q<v;q++)K+=R[U][q]*M[q];S+=M[U]*K}S<0&&(S=0);const E=k[$];p[E]=S,h[E]=Math.sqrt(S),S>j&&(g[E]=!0,A++)}return{center:N,df:T,cutoff:j,singular:x,used:y.length,distances:h,squared:p,flags:g,flagged:A}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(o,a={}){const f=a.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",w=Number.isFinite(a.windowLen)&&a.windowLen>=1?Math.floor(a.windowLen):i,m=Number.isFinite(a.threshold)?a.threshold:Z,v=Number.isFinite(a.k)?a.k:Y,h=Number.isFinite(a.minPeriods)&&a.minPeriods>=1?Math.floor(a.minPeriods):w,p=o.length,g=new Array(p).fill(null),k=new Array(p).fill(!1);let y=0;for(let T=0;T<p;T++){const j=Number(o[T]);if(!Number.isFinite(j))continue;const N=Math.max(0,T-w+1),W=[];for(let R=N;R<=T;R++){const x=Number(o[R]);Number.isFinite(x)&&W.push(x)}if(!(W.length<h))if(f==="rollingIqr"){const R=O(W,{k:v});if(!R)continue;(j<R.lower||j>R.upper)&&(k[T]=!0,y++)}else{const R=G(W);if(!R||R.mad===0)continue;const x=F*(j-R.median)/R.mad;g[T]=x,Math.abs(x)>m&&(k[T]=!0,y++)}}return{method:f,windowLen:w,minPeriods:h,threshold:m,k:v,scores:g,flags:k,flagged:y}}function u(o={}){const a=o||{},f=a.field;if(typeof f!="string"||!f)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const w=a.method||"modifiedZScore";if(!(z.includes(w)||s.includes(w))||w==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${w}'`);const v=typeof a.orderBy=="string"?a.orderBy:null,h=a.latest===!0,p=s.includes(w),g=k=>Number(k==null?NaN:k[f]);return k=>{const y=Array.isArray(k)?k.slice():[...k];v&&y.sort((R,x)=>{const A=R?.[v],$=x?.[v];return A===$?0:A==null?-1:$==null?1:A<$?-1:1});const T=y.map(g);let j,N;if(p)({flags:j,scores:N}=n(T,{method:w,windowLen:a.windowLen,threshold:a.threshold,k:a.k,minPeriods:a.minPeriods}));else if(w==="iqr"){const R=O(T,{k:a.k});j=T.map(x=>R?Number.isFinite(x)&&(x<R.lower||x>R.upper):!1),N=T.map(()=>null)}else({flags:j,scores:N}=P(T,{threshold:a.threshold}));if(h){const R=j.length-1;return R<0||!j[R]?!1:{method:w,field:f,flagged:[{row:y[R],score:N[R]}]}}const W=[];for(let R=0;R<j.length;R++)j[R]&&W.push({row:y[R],score:N[R]});return W.length?{method:w,field:f,flagged:W}:!1}}}),Be("packages/core/src/compute/forecast.js",function(e,H){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const te=H("packages/core/src/compute/special.js"),L=te.normalQuantile,X=te.studentTQuantile,F=H("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),Y=1e-4,B=1-1e-4;function z(a){const f=[];for(let w=0;w<a.length;w++){const m=a[w];if(m!==null&&typeof m=="object"){const v=Number.isFinite(m.at)?m.at:w,h=Number.isFinite(m.value)?m.value:null;f.push({at:v,value:h})}else f.push({at:w,value:Number.isFinite(m)?Number(m):null})}return f}function G(a){const f=a.filter(p=>p.value!==null),w=f[0],m=f[f.length-1],v=m.at-w.at,h=f.length>1&&v>0?v/(f.length-1):1;return{lastAt:m.at,step:h}}function P(a){return Math.min(B,Math.max(Y,a))}function O(a,f=Y,w=B,m=80){const v=(Math.sqrt(5)-1)/2;let h=f,p=w,g=p-v*(p-h),k=h+v*(p-h),y=a(g),T=a(k);for(let j=0;j<m;j++)y<T?(p=k,k=g,T=y,g=p-v*(p-h),y=a(g)):(h=g,g=k,y=T,k=h+v*(p-h),T=a(k));return(h+p)/2}function b(a,f){let w=null,m=0,v=0;for(let h=0;h<a.length;h++){const p=a[h];if(p!==null){if(w===null){w=p;continue}m+=(p-w)**2,v+=1,w=f*p+(1-f)*w}}return{level:w,sse:m,m:v}}function c(a,f,w){let m=null,v=null,h=0,p=0;for(let g=0;g<a.length;g++){const k=a[g];if(k===null){m!==null&&v!==null&&(m+=v);continue}if(m===null){m=k;continue}v===null&&(v=k-m);const y=m+v;h+=(k-y)**2,p+=1;const T=m;m=f*k+(1-f)*(T+v),v=w*(m-T)+(1-w)*v}return{level:m,trend:v,sse:h,m:p}}function d(a,f,w,m,v){const h=a.length;if(h<2*f)return null;const p=x=>{let A=0,$=0;for(let I=x;I<x+f&&I<h;I++)a[I]!==null&&(A+=a[I],$+=1);return $?A/$:null},g=p(0),k=p(f);if(g===null||k===null)return null;let y=g,T=(k-g)/f;const j=new Array(f).fill(0);for(let x=0;x<f;x++)j[x]=a[x]===null?0:a[x]-y;const N=j.reduce((x,A)=>x+A,0)/f;for(let x=0;x<f;x++)j[x]-=N;let W=0,R=0;for(let x=f;x<h;x++){const A=x%f,$=j[A],I=a[x];if(I===null){y+=T;continue}const M=y+T+$;W+=(I-M)**2,R+=1;const S=y;y=w*(I-$)+(1-w)*(y+T),T=m*(y-S)+(1-m)*T,j[A]=v*(I-y)+(1-v)*$}return{level:y,trend:T,season:j,phase:(h-1)%f,sse:W,count:R}}function l(a,f,w){let m=1;for(const h of f)m+=h*h;const v=Math.sqrt(a*m);return{se:v,margin:w*v}}function r(a,f={}){if(!a||typeof a.length!="number"||a.length===0)return null;const w=Z.includes(f.method)?f.method:"linear",m=Math.max(1,Math.floor(Number(f.horizon)||1)),v=Number.isFinite(f.confidence)&&f.confidence>0&&f.confidence<1?f.confidence:.95,h=1-(1-v)/2,p=z(a),g=p.map(W=>W.value),k=g.filter(W=>W!==null),y=k.length,{lastAt:T,step:j}=y?G(p):{lastAt:0,step:1},N=W=>T+W*j;return w==="linear"?t(p,y,m,v,h,N):w==="movingAverage"?i(k,y,m,v,h,f,N):w==="ses"?s(g,y,m,v,h,f,N):w==="holt"?n(g,y,m,v,h,f,N):u(g,y,m,v,h,f,N)}function t(a,f,w,m,v,h){if(f<2)return null;let p=0,g=0;for(const I of a)I.value!==null&&(p+=I.at,g+=I.value);p/=f,g/=f;let k=0,y=0,T=0;for(const I of a){if(I.value===null)continue;const M=I.at-p,S=I.value-g;k+=M*M,y+=M*S,T+=S*S}if(k===0)return null;const j=y/k,N=g-j*p,W=T===0?1:Math.max(0,Math.min(1,y*y/(k*T))),R=Math.max(0,T-j*y),x=f>2?Math.sqrt(R/(f-2)):null,A=f>2?X(v,f-2):null,$=[];for(let I=1;I<=w;I++){const M=h(I),S=N+j*M;let E=null,U=null,K=null,q=null,_=null;if(x!==null){const J=1/f+(M-p)**2/k,ee=x*Math.sqrt(1+J),ne=x*Math.sqrt(J);_=ee,E=S-A*ee,U=S+A*ee,K=S-A*ne,q=S+A*ne}$.push({step:I,at:M,mean:S,lower:E,upper:U,lowerMean:K,upperMean:q,se:_})}return{method:"linear",horizon:w,confidence:m,n:f,sigma:x,r2:W,params:{slope:j,intercept:N},points:$}}function i(a,f,w,m,v,h,p){if(f<1)return null;const g=Math.max(1,Math.min(f,Math.floor(Number(h.windowLen)||f))),k=a.slice(f-g);let y=0;for(const x of k)y+=x;const T=y/g;let j=null,N=null;if(g>1){let x=0;for(const $ of k)x+=($-T)**2;j=Math.sqrt(x/(g-1))*Math.sqrt(1+1/g),N=X(v,g-1)}const W=j===null?null:N*j,R=[];for(let x=1;x<=w;x++)R.push({step:x,at:p(x),mean:T,lower:W===null?null:T-W,upper:W===null?null:T+W,se:j});return{method:"movingAverage",horizon:w,confidence:m,n:f,sigma:j===null?null:j,params:{windowLen:g},points:R}}function s(a,f,w,m,v,h,p){if(f<1)return null;let g=Number.isFinite(h.alpha)?P(h.alpha):null;g===null&&(g=O(N=>b(a,N).sse));const k=b(a,g),y=L(v),T=k.m>0?k.sse/k.m:null,j=[];for(let N=1;N<=w;N++){const W=k.level;let R=null,x=null,A=null;if(T!==null){const $=[];for(let M=1;M<N;M++)$.push(g);const I=l(T,$,y);A=I.se,R=W-I.margin,x=W+I.margin}j.push({step:N,at:p(N),mean:W,lower:R,upper:x,se:A})}return{method:"ses",horizon:w,confidence:m,n:f,sigma:T===null?null:Math.sqrt(T),params:{alpha:g},points:j}}function n(a,f,w,m,v,h,p){if(f<2)return null;let g=Number.isFinite(h.alpha)?P(h.alpha):null,k=Number.isFinite(h.beta)?P(h.beta):null;if(g===null||k===null){let R=g===null?.5:g,x=k===null?.5:k;for(let A=0;A<6;A++)g===null&&(R=O($=>c(a,$,x).sse)),k===null&&(x=O($=>c(a,R,$).sse));g=g===null?R:g,k=k===null?x:k}const y=c(a,g,k),T=L(v),j=y.m>0?y.sse/y.m:null,N=g*k,W=[];for(let R=1;R<=w;R++){const x=y.level+R*y.trend;let A=null,$=null,I=null;if(j!==null){const M=[];for(let E=1;E<R;E++)M.push(g+E*N);const S=l(j,M,T);I=S.se,A=x-S.margin,$=x+S.margin}W.push({step:R,at:p(R),mean:x,lower:A,upper:$,se:I})}return{method:"holt",horizon:w,confidence:m,n:f,sigma:j===null?null:Math.sqrt(j),params:{alpha:g,beta:k},points:W}}function u(a,f,w,m,v,h,p){const g=Math.floor(Number(h.period));if(!(g>=2))return F("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(f<2*g)return null;let k=Number.isFinite(h.alpha)?P(h.alpha):null,y=Number.isFinite(h.beta)?P(h.beta):null,T=Number.isFinite(h.gamma)?P(h.gamma):null;const j=(I,M,S)=>{const E=d(a,g,I,M,S);return E?E.sse:1/0};if(k===null||y===null||T===null){let I=k===null?.5:k,M=y===null?.5:y,S=T===null?.5:T;for(let E=0;E<8;E++)k===null&&(I=O(U=>j(U,M,S))),y===null&&(M=O(U=>j(I,U,S))),T===null&&(S=O(U=>j(I,M,U)));k=k===null?I:k,y=y===null?M:y,T=T===null?S:T}const N=d(a,g,k,y,T);if(!N)return null;const W=L(v),R=N.count>0?N.sse/N.count:null,x=k*y,A=T*(1-k),$=[];for(let I=1;I<=w;I++){const M=N.season[(N.phase+I)%g],S=N.level+I*N.trend+M;let E=null,U=null,K=null;if(R!==null){const q=[];for(let J=1;J<I;J++)q.push(k+J*x+(J%g===0?A:0));const _=l(R,q,W);K=_.se,E=S-_.margin,U=S+_.margin}$.push({step:I,at:p(I),mean:S,lower:E,upper:U,se:K})}return{method:"holtWinters",horizon:w,confidence:m,n:f,sigma:R===null?null:Math.sqrt(R),params:{alpha:k,beta:y,gamma:T,period:g},points:$}}const o={FORECAST_METHODS:Z,forecast:r}}),Be("packages/core/src/compute/hypothesis.js",function(e,H){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return W}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/compute/handle.js").valueReader,F=H("packages/core/src/compute/statistics.js"),Z=F.numbers,Y=F.moments,B=F.frequencyMap,z=F.categoricalDistance,G=F.isNumericColumn,P=F.jarqueBera,O=F.proportionInterval,b=F.SUBSET_RELIABILITY_FLOOR,d=H("packages/core/src/compute/compare.js").pooledStandardMeanDifference,l=H("packages/core/src/compute/special.js"),r=l.studentT,t=l.studentTQuantile,i=l.normalCdf,s=l.normalQuantile,n=l.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,a=2e6;function f(R){const x=Number(R);return Number.isFinite(x)&&x>0&&x<1?x:.95}function w(R){const{n:x,mean:A,m2:$}=Y(R);return{mean:A,sd:x>0?Math.sqrt($/x):0,n:x}}function m(R,x){const A=R.length;if(A<2)return 0;let $=0;for(let I=0;I<A;I++){const M=R[I]-x;$+=M*M}return $/(A-1)}function v(R,x){return{name:"pooledStandardMeanDifference",value:d(w(R),w(x))}}function h(R,x,A){const $=R.length,I=x.length;if($<2||I<2)return null;const M=f(A),{mean:S}=Y(R),{mean:E}=Y(x),U=m(R,S),K=m(x,E),q=U/$+K/I;if(!(q>0))return null;const _=Math.sqrt(q),J=(S-E)/_,ee=U/$*(U/$)/($-1),ne=K/I*(K/I)/(I-1),oe=q*q/(ee+ne),ie=Math.min(1,Math.max(0,2*(1-r(Math.abs(J),oe)))),ae=S-E,ce=t(1-(1-M)/2,oe)*_;return{test:u.WELCH,statistic:J,statisticName:"t",df:oe,pValue:ie,interval:{estimate:ae,lower:ae-ce,upper:ae+ce,confidence:M,method:"welch-t (difference of means)"},effectSize:v(R,x),nA:$,nB:I,reliable:$>=b&&I>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(R){const x=R.length;if(x===0)return Number.NaN;const A=x>>1;return x%2?R[A]:(R[A-1]+R[A])/2}function g(R,x,A){const $=R.length,I=x.length,M=$*I;if(M===0||M>a)return null;const S=new Float64Array(M);let E=0;for(let ee=0;ee<$;ee++)for(let ne=0;ne<I;ne++)S[E++]=R[ee]-x[ne];S.sort();const U=p(S),K=Math.sqrt($*I*($+I+1)/12),q=s(1-(1-A)/2);let _=Math.round(M/2-q*K);_>=0||(_=0);const J=Math.floor((M-1)/2);return _>J&&(_=J),{estimate:U,lower:S[_],upper:S[M-1-_],confidence:A,method:"hodges-lehmann (normal approximation)"}}function k(R,x,A){const $=R.length,I=x.length;if($<1||I<1)return null;const M=f(A),S=$+I,E=new Array(S);for(let ie=0;ie<$;ie++)E[ie]={v:R[ie],g:0};for(let ie=0;ie<I;ie++)E[$+ie]={v:x[ie],g:1};E.sort((ie,ae)=>ie.v-ae.v);let U=0,K=0,q=0;for(;q<S;){let ie=q;for(;ie<S&&E[ie].v===E[q].v;)ie++;const ae=ie-q,ce=(q+1+ie)/2;for(let de=q;de<ie;de++)E[de].g===0&&(U+=ce);K+=ae*ae*ae-ae,q=ie}const _=U-$*($+1)/2,J=$*I/2,ee=$*I/12*(S+1-K/(S*(S-1)));let ne=1;if(ee>0){const ie=Math.max(0,Math.abs(_-J)-.5);ne=Math.min(1,2*i(-ie/Math.sqrt(ee)))}const oe=g(R,x,M);return{test:u.MANN_WHITNEY,statistic:_,statisticName:"U",df:null,pValue:ne,interval:oe,effectSize:v(R,x),nA:$,nB:I,reliable:$>=b&&I>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function y(R,x,A,$,I){const M=O(R,x,I),S=O(A,$,I);if(!M||!S)return null;const E=M.proportion-S.proportion,U=E-Math.sqrt((M.proportion-M.lower)**2+(S.upper-S.proportion)**2),K=E+Math.sqrt((M.upper-M.proportion)**2+(S.proportion-S.lower)**2);return{lower:U,upper:K}}function T(R,x,A,$,I,M={}){if(!(x>0)||!($>0))return null;const S=new Set([...R.keys(),...A.keys()]),E=S.size;if(E<2)return null;const U=x+$;let K=0;for(const ne of S){const oe=R.get(ne)||0,ie=A.get(ne)||0,ae=oe+ie,ce=x*ae/U,de=$*ae/U;ce>0&&(K+=(oe-ce)*(oe-ce)/ce),de>0&&(K+=(ie-de)*(ie-de)/de)}const q=E-1,_=n(K,q);let J=null;M.category!==void 0&&S.has(M.category)?J=M.category:E===2&&([J]=[...S]);let ee=null;if(J!==null){const ne=y(R.get(J)||0,x,A.get(J)||0,$,f(I));ne&&(ee={estimate:(R.get(J)||0)/x-(A.get(J)||0)/$,lower:ne.lower,upper:ne.upper,confidence:f(I),method:"newcombe (difference in this category's share)",category:J})}return{test:u.CHI_SQUARE,statistic:K,statisticName:"chiSquare",df:q,pValue:_,interval:ee,effectSize:{name:"categoricalTotalVariation",value:z(R,x,A,$)},nA:x,nB:$,reliable:x>=b&&$>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function j(R){return R==null||R===""||typeof R=="number"&&Number.isNaN(R)?null:R instanceof Date?R.getTime():typeof R=="object"?String(R):R}function N(R,x,A){if(A===u.WELCH||A===u.MANN_WHITNEY)return{test:A,chosenBy:"override",reason:`caller override: ${A}`};const $=P(R),I=P(x),M=$===null?null:Math.exp(-$/2),S=I===null?null:Math.exp(-I/2);return M!==null&&M<o||S!==null&&S<o?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:u.WELCH,chosenBy:"auto",reason:M!==null||S!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function W(R,x,A,$={}){if(!R||!x)return null;const I=f($.confidence),M=D(x);let S;if(Array.isArray($.groups)&&$.groups.length===2)S=[j($.groups[0]),j($.groups[1])];else{const{map:ie}=B(x,A),ae=[...ie.entries()].sort((ce,de)=>de[1]-ce[1]).slice(0,2).map(ce=>ce[0]);if(ae.length<2)return L("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;S=ae}const[E,U]=S;if(E===null||U===null||E===U)return L("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const K=[],q=[];for(let ie=0;ie<A.length;ie++){const ae=j(M(A[ie]));ae===E?K.push(A[ie]):ae===U&&q.push(A[ie])}if(K.length===0||q.length===0)return L("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const _=$.test&&$.test!=="auto"?String($.test):null,J=G(R,K.concat(q));let ee,ne,oe;if(_===u.CHI_SQUARE||!_&&!J){ne=_?"override":"auto",oe=_?"caller override: chiSquare":"column family: categorical";const ie=B(R,K),ae=B(R,q);ee=T(ie.map,ie.total,ae.map,ae.total,I,{category:$.category})}else{if((_===u.WELCH||_===u.MANN_WHITNEY)&&!J)return L("compareGroups:numeric-override",`[lattice] compareGroups: ${_} needs a numeric column, but the column is not numeric.`),null;const ie=Z(R,K),ae=Z(R,q),ce=N(ie,ae,_);ne=ce.chosenBy,oe=ce.reason,ee=ce.test===u.MANN_WHITNEY?k(ie,ae,I):h(ie,ae,I)}return ee?{...ee,chosenBy:ne,reason:oe,groups:[E,U]}:(L("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Be("packages/core/src/columns/detailcolumn.js",function(e,H){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const te="__lattice_detail",L=36;function X(F){const Z=F.config&&F.config.detailColumnWidth||L;return{id:te,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Z,min:Z,max:Z,pin:F.config&&F.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(Y,B){return!!(B&&B.expanded)},formatValue(){return""}}}const D=X}),Be("packages/core/src/columns/treecolumn.js",function(e,H){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isFunction,X="__lattice_tree",D=260;function F(Y){const B=Y.tree||{},z=Y.config&&Y.config.treeColumnWidth||D,G=()=>(Y.columns&&L(Y.columns.visible)?Y.columns.visible():[]).find(c=>!c.generated)||null,P=(b,c)=>{if(c&&c.group)return c.groupValue;if(L(B.label))return B.label(b,c);if(typeof B.label=="string")return b==null?null:b[B.label];const d=G();return d&&L(d.getValue)?d.getValue(b,c):null},O=()=>{if(B.title)return B.title;const b=typeof B.label=="string"?Y.columns&&L(Y.columns.get)?Y.columns.get(B.label):null:G();return b&&(b.title||b.id)||"Hierarchy"};return{id:X,get title(){return O()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:z,min:140,pin:Y.config&&Y.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,c){return P(b,c)},formatValue(b,c){if(c&&c.grandTotal)return Y.config&&Y.config.grandTotalLabel||"Total";if(b==null)return"";if(!B.label){const d=G();if(d&&L(d.formatValue))return d.formatValue(b,c)}return String(b)}}}const Z=F}),Be("packages/core/src/columns/pivotcolumns.js",function(e,H){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="__lattice_pivot",D=500;function F(z){const{pivot:G,valueColumns:P,config:O}=z,b=G&&G.paths||[],c=z.separator||O&&O.pivot&&O.pivot.separator||" | ",d=O&&O.pivot&&O.pivot.maxColumns||D;if(!b.length||!P.length)return{tree:[],leaves:[],error:null};const l=Z(O),r=b.length*P.length+(l?P.length:0);if(r>d){const s=`pivot would generate ${r} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return L(`pivot.maxColumns:${r}`,s),{tree:[],leaves:[],error:s}}const t=[],i=[];for(const s of b){const n=[];for(const u of P){const o=B(s,u,c);n.push(o),i.push(o)}n.length===1?(n[0].title=String(s),t.push(n[0])):t.push({id:`${X}:group:${s}`,title:String(s),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(l){const s=P.map(u=>Y(u,O));i.push(...s);const n=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=n,l==="before"?t.unshift(s[0]):t.push(s[0]);else{const u={id:`${X}:group:__totals`,title:n,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};l==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:i,error:null}}function Z(z){const G=z&&z.pivot&&z.pivot.groupTotals;return G==="before"||G==="after"?G:null}function Y(z,G){return{id:`${X}:__total${G&&G.pivot&&G.pivot.separator||" | "}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:z.id,total:!0},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(P,O){const b=O&&O.totals;return b&&Object.hasOwn(b,z.id)?b[z.id]:null},formatValue(P,O){return P==null?"":z.formatValue?z.formatValue(P,O):String(P)}}}function B(z,G,P){return{id:`${X}:${z}${P}${G.id}`,field:null,title:G.title||G.id,type:G.type,dataType:G.dataType,nullable:!0,align:G.align,generated:!0,pivot:{enabled:!1,index:0,path:z,sourceId:G.id},value:{pure:!0},cell:{align:G.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:G.total,lookup:null,layout:{width:G.layout&&G.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(O,b){return O==null?"":G.formatValue?G.formatValue(O,b):String(O)}}}}),Be("packages/core/src/compute/group.js",function(e,H){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const te=H("packages/core/src/compute/handle.js"),L=te.dictSize,X=te.identity,D=te.presenceReader,F=te.rowCount,Z=te.valueReader,Y="",B="\0",z=1<<20;function G(b,c,d,l){const r=b.length,t=b.map(a=>Z(a)),i=Array.isArray(l)&&l.some(Boolean),s=i?t.map((a,f)=>l[f]?w=>l[f](a(w)):a):t;if(!i&&r>0&&b.every(a=>a&&a.kind==="dictionary"&&a.dict)){const a=b.map(w=>L(w.dict)+1);let f=1;for(let w=0;w<r;w++)f*=a[w];if(f<=Number.MAX_SAFE_INTEGER){const w=b.map(p=>p.values),m=b.map(p=>D(p)),v=p=>{let g=0;for(let k=0;k<r;k++){const y=m[k],T=y&&y(p)===0?a[k]-1:w[k][p];g=g*a[k]+T}return g},h=new Float64Array(d);for(let p=0;p<d;p++)h[p]=v(c[p]);return{packed:h,strings:null,product:f,readers:s,keyOf:v}}}const u=a=>{let f="";for(let w=0;w<r;w++){const m=s[w](a);f+=(w===0?"":Y)+(m==null?B:String(m))}return f},o=new Array(d);for(let a=0;a<d;a++)o[a]=u(c[a]);return{packed:null,strings:o,product:1/0,readers:s,keyOf:u}}function P(b,c,d,l){const r=new Uint32Array(l+1);for(let n=0;n<d;n++)r[c[n]+1]++;for(let n=0;n<l;n++)r[n+1]+=r[n];const t=new Uint32Array(d),i=r.slice(0,l);for(let n=0;n<d;n++)t[i[c[n]]++]=b[n];const s=new Array(l);for(let n=0;n<l;n++)s[n]=t.subarray(r[n],r[n+1]);return s}function O(b,c,d={}){const l=b||[],r=c||X(F(l[0],d)),t=r.length;if(l.length===0||t===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:n,readers:u}=G(l,r,t,d.project),o=new Uint32Array(t);let a=0,f=null;if(i&&n<=Math.max(1024,Math.min(z,t*4))){const h=n,p=new Int32Array(h).fill(-1);for(let g=0;g<t;g++)p[i[g]]=0;for(let g=0;g<h;g++)p[g]===0&&(p[g]=a++);for(let g=0;g<t;g++)o[g]=p[i[g]];f=new Float64Array(a);for(let g=0;g<h;g++)p[g]>=0&&(f[p[g]]=g)}else if(i){const h=new Map;for(let p=0;p<t;p++){const g=i[p];let k=h.get(g);k===void 0&&(k=a++,h.set(g,k)),o[p]=k}f=new Float64Array(a);for(const[p,g]of h)f[g]=p}else{const h=new Map;for(let p=0;p<t;p++){const g=s[p];let k=h.get(g);k===void 0&&(k=a++,h.set(g,k)),o[p]=k}}const w=P(r,o,t,a),m=new Array(a);for(let h=0;h<a;h++){const p=w[h][0],g=new Array(u.length);for(let k=0;k<u.length;k++)g[k]=u[k](p);m[h]=g}const v={keys:m,buckets:w};return f&&(v.packed=f),v}}),Be("packages/core/src/compute/pivot.js",function(e,H){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/compute/handle.js").valueComparator,Z=H("packages/core/src/compute/group.js").packKeys,B=H("packages/core/src/compute/total.js").total,z="|",G="/",P=2e3;function O(n,u,o){return`${n}${z}${u}${z}${o}`}function b(n,u){let o="";for(let a=0;a<n.length;a++){const f=n[a];o+=(a===0?"":u)+(f==null?"":String(f))}return o}function c(n,u,o={}){const a=o.separator||G,f=u.length,{keyOf:w,readers:m}=Z(n,u,0),v=new Map,h=[],p=[];for(let W=0;W<f;W++){const R=u[W],x=w(R);if(v.has(x))continue;v.set(x,h.length),p.push(x);const A=new Array(m.length);for(let $=0;$<m.length;$++)A[$]=m[$](R);h.push(A)}const g=D(o.locale),k=h.map((W,R)=>R);k.sort((W,R)=>{const x=h[W],A=h[R];for(let $=0;$<x.length;$++){const I=d(x[$],A[$],g);if(I!==0)return I}return W-R});const y=new Array(k.length),T=new Array(k.length),j=new Map;for(let W=0;W<k.length;W++){const R=k[W];y[W]=h[R],T[W]=b(h[R],a),j.set(p[R],W)}return{keys:y,paths:T,idOf:W=>{const R=j.get(w(W));return R===void 0?-1:R}}}function d(n,u,o){const a=n==null,f=u==null;return a||f?a&&f?0:a?1:-1:o(n,u)}function l(n){const u=n.values||n.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(w=>w&&w.handle);const o=typeof n.handle=="function"?n.handle:null;if(!o)return u.length&&L("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const a=typeof n.totalOf=="function"?n.totalOf:null,f=[];for(const w of u){const m=o(w);m&&f.push({colId:w,handle:m,fn:a?a(w):"sum"})}return f}function r(n,u,o){if(Array.isArray(n)){const a=o||{};return{...a,pivotHandles:n,order:u||null,groups:a.groups||null}}return n||{}}function t(n,u,o){const a=r(n,u,o),f=a.separator||G,w=l(a),m=a.maxColumns===void 0?P:a.maxColumns,v=a.groups&&a.groups.buckets?a.groups:null,h=v?v.buckets:[a.order||new Uint32Array(0)],p=a.groupPaths||(v?v.keys.map(x=>b(x,f)):[""]),g=s(h),{keys:k,paths:y,idOf:T}=c(a.pivotHandles||[],g,a),j=y.length*Math.max(1,w.length),N=i(y,w,f);if(m&&j>m){const x=new Map;return{keys:k,paths:y,fields:N,groupPaths:p,columns:j,values:x,cells:x,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${j} columns, above pivot.maxColumns of ${m}. Narrow the pivot columns or raise the limit.`,columns:j,maxColumns:m}}}const W=new Map,R=y.length;for(let x=0;x<h.length;x++){const A=h[x],$=p[x]===void 0?"":p[x],I=A.length;if(I===0)continue;const M=new Int32Array(I),S=new Uint32Array(R+1);for(let K=0;K<I;K++){const q=T(A[K]);M[K]=q,q>=0&&S[q+1]++}for(let K=0;K<R;K++)S[K+1]+=S[K];const E=new Uint32Array(I),U=S.slice(0,R);for(let K=0;K<I;K++){const q=M[K];q>=0&&(E[U[q]++]=A[K])}for(let K=0;K<R;K++){const q=S[K],_=S[K+1];if(_===q)continue;const J=E.subarray(q,_);for(let ee=0;ee<w.length;ee++){const ne=w[ee],oe=B(ne.handle,J,ne.fn,a.totalContext||{locale:a.locale});W.set(O($,y[K],ne.colId),oe)}}}return{keys:k,paths:y,fields:N,groupPaths:p,columns:j,values:W,cells:W,error:null}}function i(n,u,o){if(u.length===0)return n.slice();const a=[];for(const f of n)for(const w of u)a.push(`${f}${o}${w.colId}`);return a}function s(n){if(n.length===1)return n[0]||new Uint32Array(0);let u=0;for(const f of n)u+=f?f.length:0;const o=new Uint32Array(u);let a=0;for(const f of n)!f||f.length===0||(o.set(f,a),a+=f.length);return o}}),Be("packages/core/src/store/bitset.js",function(e,H){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return L}});const te=8;class L{static#e=new Uint8Array(256);static{for(let D=1;D<256;D++)L.#e[D]=L.#e[D>>1]+(D&1)}#t;#n;constructor(D=0){const F=Math.max(0,D|0);this.#n=F,this.#t=new Uint8Array(Math.ceil(F/te))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(D){return D<0||D>=this.#n?0:this.#t[D>>3]>>(D&7)&1}set(D){return D>=0&&D<this.#n&&(this.#t[D>>3]|=1<<(D&7)),this}clear(D){return D>=0&&D<this.#n&&(this.#t[D>>3]&=~(1<<(D&7))),this}assign(D,F){return F?this.set(D):this.clear(D)}fill(D=!1){return this.#t.fill(D?255:0),D&&this.#r(),this}grow(D){const F=Math.max(0,D|0);if(F<=this.#n)return this;const Z=Math.ceil(F/te);if(Z>this.#t.length){const Y=new Uint8Array(Z);Y.set(this.#t),this.#t=Y}return this.#n=F,this}count(){const D=this.#t,F=L.#e;let Z=0;for(let Y=0;Y<D.length;Y++)Z+=F[D[Y]];return Z}and(D){const F=D instanceof L?D.words:D,Z=this.#t,Y=Math.min(Z.length,F.length);for(let B=0;B<Y;B++)Z[B]&=F[B];for(let B=Y;B<Z.length;B++)Z[B]=0;return this}or(D){const F=D instanceof L?D.words:D,Z=this.#t,Y=Math.min(Z.length,F.length);for(let B=0;B<Y;B++)Z[B]|=F[B];return this}not(){const D=this.#t;for(let F=0;F<D.length;F++)D[F]=~D[F]&255;return this.#r(),this}clone(){const D=new L(this.#n);return D.words.set(this.#t.subarray(0,D.words.length)),D}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const D=this.#n&7;if(D===0)return;const F=this.#n>>3;F<this.#t.length&&(this.#t[F]&=(1<<D)-1)}static from(D){const F=Array.isArray(D)?D:Array.from(D),Z=new L(F.length);for(let Y=0;Y<F.length;Y++)F[Y]&&Z.set(Y);return Z}}}),Be("packages/core/src/store/dictionary.js",function(e,H){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare;class D{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let Y=0;Y<Z.length;Y++){const B=Z[Y];this.#t.has(B)||(this.#t.set(B,this.#e.length),this.#e.push(B))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let Y=0;Y<this.#e.length;Y++){const B=this.#e[Y];typeof B=="string"&&(Z+=B.length*2),Z+=16}return Z}codeOf(Z){const Y=this.#t.get(Z);if(Y!==void 0)return Y;const B=this.#e.length;return this.#e.push(Z),this.#t.set(Z,B),this.#n++,B}lookup(Z){const Y=this.#t.get(Z);return Y===void 0?-1:Y}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const Y=Z||"";if(this.#r&&this.#s===this.#n&&this.#i===Y)return this.#r;const B=this.#e.length,z=new Array(B);for(let b=0;b<B;b++)z[b]=b;const G=L(Z).compare,P=this.#e;z.sort((b,c)=>this.#o(P[b],P[c],G));const O=new Uint32Array(B);for(let b=0;b<B;b++)O[z[b]]=b;return this.#r=O,this.#s=this.#n,this.#i=Y,O}#o(Z,Y,B){return typeof Z=="string"&&typeof Y=="string"?B(Z,Y):X(Z,Y)}}}),Be("packages/core/src/store/multivalue.js",function(e,H){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return te}});class te{#e;#t;#n=0;#r=0;constructor(X={}){const D=Math.max(1,X.rows??16),F=Math.max(1,X.values??D);this.#e=new Int32Array(F),this.#t=new Uint32Array(D+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(X){return X<0||X>=this.#n?0:this.#t[X+1]-this.#t[X]}at(X){return X<0||X>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[X],this.#t[X+1])}has(X,D){if(X<0||X>=this.#n)return!1;const F=this.#e,Z=this.#t[X+1];for(let Y=this.#t[X];Y<Z;Y++)if(F[Y]===D)return!0;return!1}hasAny(X,D){for(let F=0;F<D.length;F++)if(this.has(X,D[F]))return!0;return!1}hasAll(X,D){for(let F=0;F<D.length;F++)if(!this.has(X,D[F]))return!1;return!0}hasNone(X,D){return!this.hasAny(X,D)}push(X){const D=this.#n,F=X.length;this.#s(D+1),this.#i(this.#r+F);const Z=this.#r;for(let Y=0;Y<F;Y++)this.#e[Z+Y]=X[Y]|0;return this.#r+=F,this.#n=D+1,this.#t[D]=Z,this.#t[D+1]=this.#r,D}write(X,D){if(X===this.#n){this.push(D);return}if(X<0||X>this.#n)return;const F=this.#t[X],Z=this.#t[X+1],Y=D.length;if(Z-F===Y){for(let B=0;B<Y;B++)this.#e[F+B]=D[B]|0;return}this.#o(X,D)}compact(X,D,F){const Z=this.#e,Y=this.#t,B=this.#n,z=new Int32Array(Math.max(1,this.#r)),G=new Uint32Array(D+1);let P=0;for(let O=0;O<B;O++){if(X[O]===F)continue;const b=Y[O],c=Y[O+1];G[X[O]]=P;for(let d=b;d<c;d++)z[P++]=Z[d];G[X[O]+1]=P}this.#e=z,this.#t=G,this.#n=D,this.#r=P}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(X){if(X+1<=this.#t.length)return;let D=this.#t.length-1;for(;D<X;)D=D*2||16;const F=new Uint32Array(D+1);F.set(this.#t),this.#t=F}#i(X){if(X<=this.#e.length)return;let D=this.#e.length;for(;D<X;)D=D*2||16;const F=new Int32Array(D);F.set(this.#e),this.#e=F}#o(X,D){const F=this.#e,Z=this.#t,Y=this.#n,B=D.length-(Z[X+1]-Z[X]),z=new Int32Array(Math.max(1,this.#r+B)),G=new Uint32Array(Z.length);let P=0;for(let O=0;O<Y;O++){if(G[O]=P,O===X)for(let b=0;b<D.length;b++)z[P++]=D[b]|0;else for(let b=Z[O];b<Z[O+1];b++)z[P++]=F[b];G[O+1]=P}this.#e=z,this.#t=G,this.#r=P}}}),Be("packages/core/src/compute/sort.js",function(e,H){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return R}});const te=H("packages/core/src/compute/handle.js"),L=te.bitReader,X=te.dictRanks,D=te.dictSize,F=te.identity,Z=te.isMissing,Y=te.presenceReader,B=te.rowCount,z=te.valueComparator,G=te.valueReader,P=new Uint32Array(0),O=new ArrayBuffer(8),b=new Float64Array(O),c=new Uint32Array(O),d=(b[0]=-1,(c[1]&2147483648)!==0?1:0),l=d===1?0:1;function r(A,$){b[0]=A;let I=c[d],M=c[l];(I&2147483648)!==0?(I=~I>>>0,M=~M>>>0):I=(I^2147483648)>>>0,$[0]=M,$[1]=I}function t(A,$,I,M){if(M<2)return A;const S=new Uint32Array(256*8);for(let ne=0;ne<M;ne++){const oe=$[ne],ie=I[ne];S[oe&255]++,S[256+(oe>>>8&255)]++,S[512+(oe>>>16&255)]++,S[768+(oe>>>24&255)]++,S[1024+(ie&255)]++,S[1280+(ie>>>8&255)]++,S[1536+(ie>>>16&255)]++,S[1792+(ie>>>24&255)]++}let E=A,U=$,K=I,q=new Uint32Array(M),_=new Uint32Array(M),J=new Uint32Array(M);const ee=new Uint32Array(256);for(let ne=0;ne<8;ne++){const oe=ne<<8,ie=(ne&3)<<3,ae=ne>=4;let ce=!1;for(let je=0;je<256;je++)if(S[oe+je]===M){ce=!0;break}if(ce)continue;let de=0;for(let je=0;je<256;je++)ee[je]=de,de+=S[oe+je];for(let je=0;je<M;je++){const be=U[je],re=K[je],fe=(ae?re:be)>>>ie&255,pe=ee[fe]++;q[pe]=E[je],_[pe]=be,J[pe]=re}let Ae=E;E=q,q=Ae,Ae=U,U=_,_=Ae,Ae=K,K=J,J=Ae}return E}function i(A,$,I){if(I<2)return A;const M=new Uint32Array(256*4);for(let _=0;_<I;_++){const J=$[_];M[J&255]++,M[256+(J>>>8&255)]++,M[512+(J>>>16&255)]++,M[768+(J>>>24&255)]++}let S=A,E=$,U=new Uint32Array(I),K=new Uint32Array(I);const q=new Uint32Array(256);for(let _=0;_<4;_++){const J=_<<8,ee=_<<3;let ne=!1;for(let ae=0;ae<256;ae++)if(M[J+ae]===I){ne=!0;break}if(ne)continue;let oe=0;for(let ae=0;ae<256;ae++)q[ae]=oe,oe+=M[J+ae];for(let ae=0;ae<I;ae++){const ce=E[ae],de=q[ce>>>ee&255]++;U[de]=S[ae],K[de]=ce}let ie=S;S=U,U=ie,ie=E,E=K,K=ie}return S}function s(A,$,I,M){const S=new Uint32Array(M+1);for(let K=0;K<I;K++)S[$[K]]++;let E=0;for(let K=0;K<=M;K++){const q=S[K];S[K]=E,E+=q}const U=new Uint32Array(I);for(let K=0;K<I;K++)U[S[$[K]]++]=A[K];return U}function n(A,$,I,M){return I<2?A:M<=65536||M<=I*2?s(A,$,I,M):i(A,$,I)}function u(A,$){return A.length===$&&A.byteOffset===0?A:Uint32Array.prototype.slice.call(A,0,$)}function o(A,$,I=!1){const M=$||F(A.length),S=M.length;if(S<2)return Uint32Array.from(M);const E=new Uint32Array(S),U=new Uint32Array(S),K=new Uint32Array(S),q=new Uint32Array(S),_=new Uint32Array(2);let J=0,ee=0;for(let ie=0;ie<S;ie++){const ae=M[ie],ce=A[ae];if(Number.isNaN(ce)){q[ee++]=ae;continue}r(ce,_),I?(U[J]=~_[0]>>>0,K[J]=~_[1]>>>0):(U[J]=_[0],K[J]=_[1]),E[J++]=ae}const ne=t(E.subarray(0,J),U.subarray(0,J),K.subarray(0,J),J);if(ee===0)return u(ne,J);const oe=new Uint32Array(S);return oe.set(ne.subarray(0,J),0),oe.set(q.subarray(0,ee),J),oe}function a(A,$,I=!1){const M=$||F(A.length),S=M.length;if(S<2)return Uint32Array.from(M);const E=Uint32Array.from(M),U=new Uint32Array(S);for(let K=0;K<S;K++){const q=(A[E[K]]^2147483648)>>>0;U[K]=I?~q>>>0:q}return u(i(E,U,S),S)}function f(A,$,I={}){const M=$||F(B(A,I)),S=M.length;if(S<2)return Uint32Array.from(M);const E=X(A.dict,I.locale),U=A.values,K=Y(A),q=Math.max(D(A.dict),E.length),_=q,J=Uint32Array.from(M),ee=new Uint32Array(S),ne=!!I.descending;for(let oe=0;oe<S;oe++){const ie=J[oe];let ae=K&&K(ie)===0?_:E[U[ie]];ae===void 0&&(ae=_),ee[oe]=ne?_-ae:ae}return u(n(J,ee,S,q+1),S)}function w(A,$,I){const M=$.length;let S=Uint32Array.from($);if(M<2)return S;let E=new Uint32Array(M);for(let U=1;U<M;U<<=1){for(let q=0;q<M;q+=U<<1){const _=Math.min(q+U,M),J=Math.min(q+(U<<1),M);let ee=q,ne=_,oe=q;for(;ee<_&&ne<J;)E[oe++]=I(A[S[ee]],A[S[ne]])<=0?S[ee++]:S[ne++];for(;ee<_;)E[oe++]=S[ee++];for(;ne<J;)E[oe++]=S[ne++]}const K=S;S=E,E=K}return S}function m(A,$,I){const M=L(A.values),S=$.length,E=new Uint32Array(S),U=I?1:0;let K=0;for(let q=0;q<S;q++)M($[q])===U&&(E[K++]=$[q]);for(let q=0;q<S;q++)M($[q])!==U&&(E[K++]=$[q]);return E}function v(A,$){const I=A.values,M=A.kind;if((M==="object"||M===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!A.presence)return I;const E=G(A),U=new Array(B(A)||0);for(let K=0;K<$.length;K++){const q=$[K];U[q]=E(q)}return U}function h(A,$){for(let I=0;I<$.length;I++)if(typeof A[$[I]]!="string")return!1;return!0}function p(A,$,I,M,S){const E=A.length,U=Uint32Array.from(A);if(E<2||M<1)return U;const K=new Uint32Array(E),q=M-1;for(let _=0;_<E;_++){const J=I[$[_]];K[_]=S?q-J:J}return u(n(U,K,E,M),E)}function g(A,$,I){const M=z(I),S=new Array($);for(let U=0;U<$;U++)S[U]=U;S.sort((U,K)=>M(A[U],A[K])||U-K);const E=new Uint32Array($);for(let U=0;U<$;U++)E[S[U]]=U;return E}function k(A,$,I){const M=$.length,S=new Map,E=[],U=new Uint32Array(M);for(let _=0;_<M;_++){const J=A[$[_]];let ee=S.get(J);ee===void 0&&(ee=E.length,S.set(J,ee),E.push(J)),U[_]=ee}const K=E.length,q=g(E,K,I.locale);return p($,U,q,K,!!I.descending)}function y(A,$,I){const M=v(A,$);if($.length>=2&&h(M,$)){const U=A.stringRank;return U&&U.version===A.version&&U.usable($,M,I.locale)?U.sort($,I):k(M,$,I)}const S=z(I.locale),E=I.descending?(U,K)=>S(K,U):S;return w(M,$,E)}function T(A,$,I){const M=v(A,$),S=I.compare,U=!!I.descending?(K,q)=>-S(K,q,void 0,void 0,!0):(K,q)=>S(K,q,void 0,void 0,!1);return w(M,$,U)}function j(A,$){const I=$.length,M=Y(A),S=A.values,E=A.kind==="float64"&&!!S,U=A.kind==="object"||A.kind==="multi"||A.kind===void 0;if(!M&&!E&&!U)return{present:$,absent:P};const K=new Uint32Array(I),q=new Uint32Array(I);let _=0,J=0;if(M&&E)for(let ee=0;ee<I;ee++){const ne=$[ee];M(ne)===1&&!Number.isNaN(S[ne])?K[_++]=ne:q[J++]=ne}else if(E&&!M)for(let ee=0;ee<I;ee++){const ne=$[ee];Number.isNaN(S[ne])?q[J++]=ne:K[_++]=ne}else if(M&&!U)for(let ee=0;ee<I;ee++){const ne=$[ee];M(ne)===1?K[_++]=ne:q[J++]=ne}else{const ee=G(A);for(let ne=0;ne<I;ne++){const oe=$[ne];Z(ee(oe))?q[J++]=oe:K[_++]=oe}}return J===0?{present:$,absent:P}:{present:K.subarray(0,_),absent:q.subarray(0,J)}}function N(A,$,I){if($.length===0)return A;const M=new Uint32Array(A.length+$.length);return I?(M.set($,0),M.set(A,$.length)):(M.set(A,0),M.set($,A.length)),M}function W(A,$,I={}){const M=$||F(B(A,I));if(!A||M.length<2)return Uint32Array.from(M);const{present:S,absent:E}=j(A,M);if(S.length===0)return Uint32Array.from(M);const U=!!I.descending;let K;if(typeof I.compare=="function")K=T(A,S,I);else switch(A.kind){case"float64":K=o(A.values,S,U);break;case"int32":K=a(A.values,S,U);break;case"dictionary":K=f(A,S,I);break;case"bitset":K=m(A,S,U);break;default:K=y(A,S,I);break}return N(K,E,!!I.nullsFirst)}function R(A,$,I,M={}){const S=$||[],E=S.length&&(S[0].handle||x(A,S[0].col))||A&&A[0];let U=I||F(B(E,M));for(let K=S.length-1;K>=0;K--){const q=S[K],_=q.handle||x(A,q.col)||A&&A[K];_&&(U=W(_,U,{descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,locale:q.locale!==void 0?q.locale:M.locale,compare:q.compare}))}return U instanceof Uint32Array?U:Uint32Array.from(U)}function x(A,$){if(!(!A||$===void 0)){for(let I=0;I<A.length;I++)if(A[I]&&A[I].id===$)return A[I]}}}),Be("packages/core/src/store/stringrank.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return F}});const te=H("packages/core/src/compute/sort.js"),L=te.collateStringRanks,X=te.rankSortStrings,D=1e5;class F{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(Y=D){this.#o=Y>0?Y:D,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(Y){this.#i=Y}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let Y=this.#n.byteLength;const B=this.#e;for(let z=0;z<B.length;z++)Y+=B[z].length*2+24;return Y}#f(Y,B){const z=this.#t.get(Y);if(z!==void 0)return z;if(this.#l)return-1;if(B&&this.#e.length>=this.#o)return this.#l=!0,-1;const G=this.#e.length;return this.#e.push(Y),this.#t.set(Y,G),this.#s++,G}build(Y,B){const z=B|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(z);for(let G=0;G<z;G++){const P=Y[G],O=typeof P=="string"?this.#f(P,!1):-1;this.#n[G]=O<0?0:O}this.#r=z}append(Y,B,z){const G=(B|0)+(z|0);if(G>this.#n.length){const P=new Uint32Array(G);P.set(this.#n.subarray(0,this.#r)),this.#n=P}for(let P=B|0;P<G;P++){const O=Y[P],b=typeof O=="string"?this.#f(O,!0):-1;this.#n[P]=b<0?0:b}this.#r=Math.max(this.#r,G)}ranks(Y){const B=Y||"";if(this.#a&&this.#c===this.#s&&this.#u===B)return this.#a;const z=L(this.#e,this.#e.length,Y);return this.#a=z,this.#c=this.#s,this.#u=B,z}usable(Y,B,z){if(this.#l||this.#e.length===0)return!1;const G=this.#n,P=this.#e,O=this.#r;for(let b=0;b<Y.length;b++){const c=Y[b];if(c>=O||P[G[c]]!==B[c])return!1}return!0}sort(Y,B){const z=this.ranks(B.locale),G=this.#e.length,P=Y.length,O=new Uint32Array(P),b=this.#n;for(let c=0;c<P;c++)O[c]=b[Y[c]];return X(Y,O,z,G,!!B.descending)}}}),Be("packages/core/src/store/columnstore.js",function(e,H){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return m}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/paths.js").pathGetter,B=H("packages/core/src/store/bitset.js").Bitset,G=H("packages/core/src/store/dictionary.js").Dictionary,O=H("packages/core/src/store/multivalue.js").MultiValue,c=H("packages/core/src/store/stringrank.js").StringRankIndex,d=4294967295,l=1024,r=5e3,t=.2,i=new Set(["float64","int32","bitset","dictionary","object","multi"]);function s(v){return v==null}function n(v){if(typeof v=="number")return v;if(v instanceof Date)return v.getTime();if(typeof v=="boolean")return v?1:0;const h=Number(v);return Number.isNaN(h)&&typeof v=="string"?Date.parse(v):h}function u(v){const h=n(v);return Number.isFinite(h)?h|0:0}function o(v){return s(v)?[]:Array.isArray(v)?v:[v]}function a(v,h){switch(v.kind){case"float64":case"int32":return v.buf[h];case"bitset":return v.bits.get(h)===1;case"dictionary":return v.dict.valueOf(v.buf[h]);case"multi":{const p=v.mv.at(h),g=new Array(p.length);for(let k=0;k<p.length;k++)g[k]=v.dict.valueOf(p[k]);return g}default:return v.buf[h]}}function f(v,h){switch(v.kind){case"float64":case"int32":return v.values[h];case"bitset":return(v.values[h>>3]&1<<(h&7))!==0;case"dictionary":return(v.table||[])[v.values[h]];case"multi":{const p=v.offsets[h],g=v.offsets[h+1],k=v.table||[],y=new Array(g-p);for(let T=p;T<g;T++)y[T-p]=k[v.values[T]];return y}default:return v.values[h]}}class w{#e;#t;#n;#r;#s;#i;#o;#l=!1;#a=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#j=null;#w=null;#O=!1;constructor(h,p){this.#e=h.id;const g=i.has(h.kind)?h.kind:"object";h.kind&&!i.has(h.kind)&&L(`store.kind.${h.id}`,`column "${h.id}" declares unknown storage kind "${h.kind}"; falling back to object`),this.#n=g,this.#t=g,this.#r=h.nullable!==!1,this.#o=h.dictionary??null,this.#i=p,this.#s=D(h.read)?h.read:Z(h.field||h.id),this.#h=h.stringRankIndex!=="off",this.#p=typeof h.stringRankMaxDistinct=="number"?h.stringRankMaxDistinct:0,this.#j=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#P().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const h=this.values,p=this.#i.physical();if(!h||p===0)return null;if(this.#d===null){if(typeof h[0]!="string")return null;const g=new c(this.#v());return g.build(h,p),g.version=this.#y,this.#d=g,this.#m=this.#y,g.capped?null:g}return this.#d.length<p&&this.#d.append(h,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#T(){this.#d=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let h=0;return this.#a&&(h+=this.#a.byteLength??this.#a.length*8),this.#c&&(h+=this.#c.bytes),this.#u&&(h+=this.#u.bytes),this.#g&&(h+=this.#g.bytes),this.#f&&(h+=this.#f.bytes),this.#j&&(h+=this.#j.size*24),h}get(h){if(!this.#O&&!(h<0||h>=this.#i.physical())){if(!this.#l)return this.#M(h);if(this.#r&&this.#g.get(h)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[h];case"bitset":return this.#c.get(h)===1;case"dictionary":return this.#f.valueOf(this.#a[h]);case"multi":{const p=this.#u.at(h),g=new Array(p.length);for(let k=0;k<p.length;k++)g[k]=this.#f.valueOf(p[k]);return g}default:return this.#a[h]}}}set(h,p){this.#O||(this.#l?this.#E(h,p):this.#j.set(h,p===void 0?null:p),this.#d&&this.#T(),this.#y++)}read(h){return this.#s(h)}appendColumn(h,p,g){if(this.#O||g<=0)return;if(!this.#l){this.#y++;return}const k=this.#s,y=this.#r,T=this.#g;let j=!1;switch(this.#t){case"float64":{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]);if(typeof R=="number"){y&&T.set(p+W),N[p+W]=R;continue}const x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?NaN:n(R)}break}case"int32":{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?0:u(R)}break}case"bitset":{const N=this.#c;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N.assign(p+W,!x&&!!R)}break}case"dictionary":{const N=this.#a,W=this.#f;for(let R=0;R<g;R++){const x=k(h[R]),A=x==null;y?T.assign(p+R,!A):A&&(j=!0),N[p+R]=A?0:W.codeOf(x)}break}case"multi":{const N=this.#u,W=this.#f;for(let R=0;R<g;R++){const x=k(h[R]),A=x==null;y?T.assign(p+R,!A):A&&(j=!0);const $=o(x),I=new Array($.length);for(let M=0;M<$.length;M++)I[M]=W.codeOf($[M]);N.write(p+R,I)}break}default:{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?null:R}break}}j&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#a,p,g),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(h,p,g){if(this.#O||g<=0||!h)return;if(!this.#l){this.#y++;return}const k=this.#g,y=h.presence;if(k)if(y)for(let j=0;j<g;j++)k.assign(p+j,(y[j>>3]&1<<(j&7))!==0);else for(let j=0;j<g;j++)k.set(p+j);const T=h.kind===this.#t;if(T&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(h.values,p),this.#y++;return}if(T&&this.#t==="bitset"){const j=h.values;for(let N=0;N<g;N++)this.#c.assign(p+N,(j[N>>3]&1<<(N&7))!==0);this.#y++;return}if(T&&this.#t==="dictionary"){const j=h.table||[],N=new Uint32Array(j.length);for(let A=0;A<j.length;A++)N[A]=this.#f.codeOf(j[A]);const W=h.values,R=this.#a,x=k;for(let A=0;A<g;A++){if(x&&(y&&(y[A>>3]&1<<(A&7))===0)){R[p+A]=0;continue}R[p+A]=N[W[A]]??0}this.#y++;return}if(T&&this.#t==="multi"){const j=h.table||[],N=new Uint32Array(j.length);for(let x=0;x<j.length;x++)N[x]=this.#f.codeOf(j[x]);const W=h.values,R=h.offsets;for(let x=0;x<g;x++){const A=R[x],$=R[x+1],I=new Array($-A);for(let M=A;M<$;M++)I[M-A]=N[W[M]]??0;this.#u.write(p+x,I)}this.#y++;return}for(let j=0;j<g;j++){const N=y?(y[j>>3]&1<<(j&7))===0:h.kind==="object"?h.values[j]===null:!1;this.#E(p+j,N?null:f(h,j))}this.#y++}touch(){this.#y++}columnarise(h,p){if(this.#l||this.#O)return;const g=new Array(p);for(let k=0;k<p;k++)g[k]=this.#M(k);this.#t=this.#n,this.#l=!0,this.#S(h);for(let k=0;k<p;k++)this.#E(k,g[k]);this.#j.clear(),this.#w=null,this.#T(),this.#y++}grow(h){if(!(!this.#l||this.#O||h<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(h);p.set(this.#a),this.#a=p;break}case"bitset":this.#c.grow(h);break;case"multi":break;default:this.#a.length=h;break}this.#g&&this.#g.grow(h),this.#b=h,this.#y++}}convert(h){if(this.#O||!i.has(h)||(this.#n=h,!this.#l||h===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#f},g=this.#i.physical(),k=this.#g;this.#t=h,this.#S(this.#b);for(let y=0;y<g;y++){const T=k!==null&&k.get(y)===0;T&&h!=="multi"||this.#E(y,T?null:a(p,y))}return this.#T(),this.#y++,!0}compact(h,p,g){if(!this.#O){if(this.#T(),!this.#l){const k=this.#j;if(k.size){const y=new Map;for(const[T,j]of k)h[T]!==d&&y.set(h[T],j);this.#j=y}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const k=this.#a;for(let y=0;y<p;y++)h[y]!==d&&(k[h[y]]=k[y]);if(this.#t==="object")for(let y=g;y<p;y++)k[y]=void 0;break}case"bitset":{const k=this.#c;for(let y=0;y<p;y++)h[y]!==d&&k.assign(h[y],k.get(y)===1);for(let y=g;y<p;y++)k.clear(y);break}case"multi":this.#u.compact(h,g,d);break;default:break}if(this.#g){const k=this.#g;for(let y=0;y<p;y++)h[y]!==d&&k.assign(h[y],k.get(y)===1);for(let y=g;y<p;y++)k.clear(y)}this.#y++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#j=new Map,this.#w=null,this.#b=0,this.#y++)}#S(h){const p=Math.max(1,h);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#c=new B(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#f=this.#f??new G(this.#o??[]);break;case"multi":this.#u=new O({rows:p,values:p}),this.#f=this.#f??new G(this.#o??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new B(p)),this.#b=p}#E(h,p){const g=s(p);switch(this.#r?this.#g.assign(h,!g):g&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[h]=g?NaN:n(p);break;case"int32":this.#a[h]=g?0:u(p);break;case"bitset":this.#c.assign(h,!g&&!!p);break;case"dictionary":this.#a[h]=g?0:this.#f.codeOf(p);break;case"multi":{const k=o(p),y=new Array(k.length);for(let T=0;T<k.length;T++)y[T]=this.#f.codeOf(k[T]);this.#u.write(h,y);break}default:this.#a[h]=g?null:p;break}}#M(h){if(this.#j.has(h))return this.#j.get(h);const p=this.#s(this.#i.rowAt(h));return p===void 0?null:p}#P(){if(this.#w&&this.#w.version===this.#y)return this.#w;const h=this.#i.physical(),p=new Array(h),g=this.#r?new B(h):null;for(let k=0;k<h;k++){const y=this.#M(k);p[k]=y,g&&!s(y)&&g.set(k)}return this.#w={version:this.#y,values:p,presence:g},this.#w}}class m{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#o=0;#l=0;#a=new B(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(h,p={}){this.#e=Array.isArray(h)?h:[],this.#d=Math.max(1,p.initialCapacity??l),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??t;const g={rowAt:k=>this.#r[k],physical:()=>this.#s};for(const k of this.#e){if(!k||!k.id)continue;if(this.#t.has(k.id)){L(`store.dup.${k.id}`,`duplicate column id "${k.id}" in the store schema; ignoring the second`);continue}const y=new w(k,g);this.#t.set(k.id,y),this.#n.push(y)}this.#f<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let h=this.#a.bytes+this.#r.length*8;for(const p of this.#n)h+=p.bytes;return h}append(h){const p=this.#s;if(this.#p||!h)return{from:p,to:p};const g=h.length|0;if(g===0)return{from:p,to:p};if(this.#u)for(let y=0;y<g;y++)this.#r[p+y]=h[y];if(this.#s=p+g,this.#o+=g,this.#a.grow(this.#s),!this.#c){if(this.#s>=this.#f)this.#b();else for(const y of this.#n)y.touch();return{from:p,to:this.#s}}this.#m(this.#s);const k=this.#n;for(let y=0;y<k.length;y++)k[y].appendColumn(h,p,g);return{from:p,to:this.#s}}appendPacked(h,p){const g=this.#s;if(this.#p||!h)return{from:g,to:g};const k=h.count|0;if(k===0)return{from:g,to:g};if(this.#u&&p)for(let T=0;T<k;T++)this.#r[g+T]=p[T];this.#s=g+k,this.#o+=k,this.#a.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const y=new Map;for(const T of h.columns)y.set(T.id,T);for(const T of this.#n){const j=y.get(T.id);j?T.appendPacked(j,g,k):T.grow(this.#i)}return{from:g,to:this.#s}}source(h){if(this.#u)return this.#r[h];if(!(h<0||h>=this.#s))return this.#g(h)}setSource(h,p){this.#p||h<0||h>=this.#s||this.#u&&(this.#r[h]=p)}get(h,p){const g=this.#t.get(h);return g?g.get(p):void 0}set(h,p,g){if(this.#p||p<0||p>=this.#s)return;const k=this.#t.get(h);if(!k){L(`store.set.${h}`,`set() on unknown column "${h}"`);return}k.set(p,g)}remove(h){return this.#p||h<0||h>=this.#s||this.#a.get(h)===1?!1:(this.#a.set(h),this.#l++,this.#o--,!0)}live(h){return h<0||h>=this.#s?!1:this.#a.get(h)===0}compact(h={}){if(this.#p||this.#l===0||!h.force&&this.#l/this.#s<this.#h)return null;const p=this.#s,g=new Uint32Array(p);let k=0;for(let y=0;y<p;y++)g[y]=this.#a.get(y)===1?d:k++;for(const y of this.#n)y.compact(g,p,k);if(this.#u){const y=this.#r;for(let T=0;T<p;T++)g[T]!==d&&(y[g[T]]=y[T]);y.length=k}return this.#s=k,this.#o=k,this.#l=0,this.#a=new B(Math.max(this.#i,k)),g}column(h){return this.#t.get(h)}columns(){return this.#n.slice()}liveIndices(){const h=new Uint32Array(this.#o);if(this.#l===0){for(let g=0;g<this.#s;g++)h[g]=g;return h}let p=0;for(let g=0;g<this.#s;g++)this.#a.get(g)===0&&(h[p++]=g);return h}convert(h,p){const g=this.#t.get(h);return g?g.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const h of this.#n)h.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#s=0,this.#o=0,this.#l=0,this.#i=0}}#m(h){if(h<=this.#i)return;let p=this.#i||this.#d;for(;p<h;)p*=2;for(const g of this.#n)g.grow(p);this.#a.grow(p),this.#i=p}#g(h){const p={};for(const g of this.#n)p[g.id]=g.get(h);return p}#b(){if(this.#c)return;let h=this.#d;for(;h<this.#s;)h*=2;this.#c=!0,this.#i=h,this.#a.grow(h);for(const p of this.#n)p.columnarise(h,this.#s)}}}),Be("packages/core/src/store/pool.js",function(e,H){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return F}});const te=64,L=8;function X(Y){let B=te;for(;B<Y;)B*=2;return B}class D{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(B={}){this.#n=B.limit??L}get bytes(){return this.#r}mask(B){const z=new Uint8Array(this.#i(B),0,B);return z.fill(0),z}indices(B){return new Uint32Array(this.#i(B*4),0,B)}release(B){if(!B||!B.buffer)return!1;const z=B.buffer;if(!this.#t.has(z))return!1;this.#t.delete(z),this.#s.released++;const G=z.byteLength;let P=this.#e.get(G);return P||this.#e.set(G,P=[]),P.length>=this.#n||(P.push(z),this.#r+=G),!0}releaseAll(B){for(const z of B)this.release(z)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(B){const z=X(B),G=this.#e.get(z);this.#s.acquired++;let P;return G&&G.length?(P=G.pop(),this.#r-=z,this.#s.reused++):P=new ArrayBuffer(z),this.#t.add(P),P}}function F(){return Z??=new D,Z}let Z=null}),Be("packages/core/src/compute/sortspec.js",function(e,H){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return F}});function te(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function L(Z){return!!Z&&typeof Z.compare!="function"}function X(Z){if(!Z)return!0;for(let Y=0;Y<Z.length;Y++)if(!L(Z[Y]))return!1;return!0}function D(Z,Y){const B=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,z=Z.locale!==void 0?Z.locale:Y;return{col:B,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:te(z)}}function F(Z,Y){const B=Z||[],z=new Array(B.length);for(let G=0;G<B.length;G++)z[G]=D(B[G],Y);return z}}),Be("packages/core/src/compute/facet.js",function(e,H){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const te=H("packages/core/src/compute/handle.js"),L=te.presenceReader,X=te.valueReader,D=te.dictSize,F=te.dictValue,Z=Object.freeze(["equal","quantile","log"]),Y=Object.freeze(["hour","day","week","month","quarter","year"]),B=20,z=50,G=1e4;function P(g,k){if(!g)return"none";const y=k;if(y&&(y.multi===!0||typeof y.items=="function"))return"category";const T=k&&k.base;if(T==="date"||T==="datetime"||T==="time"||T==="dateString")return"date";switch(g.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return T==="number"?"numeric":T==="boolean"?"boolean":T==="text"?"category":"none"}}function O(g){const k=g.values,y=g.kind;if((y==="float64"||y==="int32")&&k)return j=>k[j];const T=X(g);return j=>b(T(j))}function b(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(g==null||g==="")return NaN;if(typeof g=="boolean")return g?1:0;if(typeof g=="string"){const k=Number(g);if(Number.isFinite(k))return k;const y=Date.parse(g);return Number.isFinite(y)?y:NaN}return NaN}function c(g,k,y,T=z){if(!g)return{cardinality:0,exact:!0};if(g.dict)return{cardinality:D(g.dict),exact:!0};if(g.kind==="bitset")return{cardinality:2,exact:!0};const j=X(g),N=k?k.length:y,W=new Set;for(let R=0;R<N;R++){const x=j(k?k[R]:R);if(x!=null&&(W.add(x),W.size>T))return{cardinality:W.size,exact:!1}}return{cardinality:W.size,exact:!0}}const d=36e5,l=864e5;function r(g,k=B){const y=Number.isFinite(g)&&g>0?g:0,T=Math.max(1,k)*2;return y/d<=T?"hour":y/l<=T?"day":y/(7*l)<=T?"week":y/(30*l)<=T?"month":y/(91*l)<=T?"quarter":"year"}function t(g,k){if(!Number.isFinite(g))return NaN;const y=new Date(g);switch(k){case"hour":return y.setMinutes(0,0,0),y.getTime();case"day":return y.setHours(0,0,0,0),y.getTime();case"week":{y.setHours(0,0,0,0);const T=(y.getDay()+6)%7;return y.setDate(y.getDate()-T),y.getTime()}case"month":return y.setDate(1),y.setHours(0,0,0,0),y.getTime();case"quarter":return y.setMonth(Math.floor(y.getMonth()/3)*3,1),y.setHours(0,0,0,0),y.getTime();default:return y.setMonth(0,1),y.setHours(0,0,0,0),y.getTime()}}function i(g,k){const y=new Date(g);switch(k){case"hour":y.setHours(y.getHours()+1);break;case"day":y.setDate(y.getDate()+1);break;case"week":y.setDate(y.getDate()+7);break;case"month":y.setMonth(y.getMonth()+1);break;case"quarter":y.setMonth(y.getMonth()+3);break;default:y.setFullYear(y.getFullYear()+1);break}return y.getTime()}function s(g,k,y){const T=O(g),j=L(g),N=k?k.length:y;let W=1/0,R=-1/0,x=0,A=0;for(let $=0;$<N;$++){const I=k?k[$]:$;if(j&&!j(I)){x++;continue}const M=T(I);if(!Number.isFinite(M)){x++;continue}M<W&&(W=M),M>R&&(R=M),A++}return{min:W,max:R,nulls:x,finite:A}}function n(g,k,y,T){const j=O(g),N=L(g),W=k?k.length:y,R=W>T?W/T:1,x=[];for(let $=0;$<W;$+=R){const I=k?k[Math.floor($)]:Math.floor($);if(N&&!N(I))continue;const M=j(I);Number.isFinite(M)&&x.push(M)}const A=Float64Array.from(x);return A.sort(),A}function u(g,k,y,T={}){const j=T.kind||P(g,T.type);return j==="none"||!g?{kind:"none",buckets:[],suppressed:"type"}:j==="boolean"?o(g,k,y):j==="category"?a(g,k,y,T):f(g,k,y,j,T)}function o(g,k,y){const T=L(g);let j=0;if(T){const W=k?k.length:y;for(let R=0;R<W;R++)T(k?k[R]:R)||j++}const N=[{value:!1,label:"false"},{value:!0,label:"true"}];return j>0&&N.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:N}}function a(g,k,y,T){const j=T.cardinalityLimit??z,{cardinality:N}=c(g,k,y,j);if(N>j&&(T.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:N};const W=X(g),R=k?k.length:y,x=new Map;let A=0;for(let E=0;E<R;E++){const U=W(k?k[E]:E);if(U==null||U===""){A++;continue}if(Array.isArray(U)){if(!U.length){A++;continue}for(const K of U)x.set(K,(x.get(K)||0)+1);continue}x.set(U,(x.get(U)||0)+1)}let $=[...x.entries()];T.order==="alpha"?$.sort((E,U)=>String(E[0]).localeCompare(String(U[0]))):$.sort((E,U)=>U[1]-E[1]);let I=0,M=0;if($.length>j){M=$.length-j;for(let E=j;E<$.length;E++)I+=$[E][1];$=$.slice(0,j)}const S=$.map(([E])=>({value:E,label:String(E)}));return I>0&&S.push({remainder:!0,label:`Other (${M} values)`}),A>0&&S.push({null:!0,label:"Empty"}),{kind:"category",buckets:S,cardinality:N}}function f(g,k,y,T,j){const{min:N,max:W,nulls:R,finite:x}=s(g,k,y);if(!x)return{kind:T,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const A=Math.max(1,Math.floor(j.buckets||B));let $=[];if(T==="date"){const M=Y.includes(j.granularity)?j.granularity:r(W-N,A);let S=t(N,M);for(;S<=W&&$.length<4096;){const E=i(S,M);if(!(E>S))break;$.push({from:S,to:E}),S=E}return{kind:T,buckets:w($,R),granularity:M}}const I=Z.includes(j.strategy)?j.strategy:"equal";if(I==="quantile"){const M=n(g,k,y,G);if(M.length){const S=[M[0]];for(let E=1;E<A;E++){const U=M[Math.min(M.length-1,Math.floor(E/A*M.length))];U>S[S.length-1]&&S.push(U)}S.push(W);for(let E=0;E<S.length-1;E++)$.push({from:S[E],to:S[E+1]})}}else if(I==="log"&&N>0){const M=Math.log10(N),E=(Math.log10(W)-M)/A||1;for(let U=0;U<A;U++)$.push({from:10**(M+U*E),to:10**(M+(U+1)*E)})}if(!$.length){const M=(W-N)/A||1;for(let S=0;S<A;S++)$.push({from:N+S*M,to:N+(S+1)*M})}return $[$.length-1].to=W,{kind:T,buckets:w($,R),strategy:I,min:N,max:W}}function w(g,k){return k>0?[...g,{null:!0,label:"Empty"}]:g}function m(g,k,y,T,j){const N=T&&T.buckets||[],W=j&&j.length>=N.length?j.subarray(0,N.length):new Uint32Array(N.length);if(W.fill(0),!g||!N.length)return W;const R=N.length-1,x=!!N[R]&&N[R].null===!0,A=k?k.length:y;if(T.kind==="boolean"){const E=X(g);for(let U=0;U<A;U++){const K=E(k?k[U]:U);if(K==null){x&&W[R]++;continue}W[K?1:0]++}return W}if(T.kind==="category"){const E=new Map;for(let q=0;q<N.length;q++)!N[q].null&&!N[q].remainder&&E.set(N[q].value,q);const U=N.findIndex(q=>q.remainder),K=X(g);for(let q=0;q<A;q++){const _=K(k?k[q]:q);if(_==null||_===""){x&&W[R]++;continue}if(Array.isArray(_)){if(!_.length){x&&W[R]++;continue}for(const ee of _){const ne=E.get(ee);ne!==void 0?W[ne]++:U>=0&&W[U]++}continue}const J=E.get(_);J!==void 0?W[J]++:U>=0&&W[U]++}return W}const $=x?N.length-1:N.length,I=new Float64Array($+1);for(let E=0;E<$;E++)I[E]=N[E].from;I[$]=$?N[$-1].to:0;const M=O(g),S=L(g);for(let E=0;E<A;E++){const U=k?k[E]:E;if(S&&!S(U)){x&&W[R]++;continue}const K=M(U);if(!Number.isFinite(K)){x&&W[R]++;continue}const q=v(I,$,K);q>=0&&W[q]++}return W}function v(g,k,y){if(!k||y<g[0])return-1;if(y>=g[k])return y===g[k]?k-1:-1;let T=0,j=k-1;for(;T<j;){const N=T+j+1>>>1;y>=g[N]?T=N:j=N-1}return T}function h(g,k,y,T={}){const j=T.bounds||u(g,T.boundsIndices??k,y,T);return{bounds:j,counts:m(g,k,y,j)}}const p=h}),Be("packages/core/src/compute/pivotmatrix.js",function(e,H){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/compute/handle.js").valueComparator,D=H("packages/core/src/compute/total.js").total,Z=H("packages/core/src/compute/group.js").packKeys,Y=H("packages/core/src/compute/pivot.js"),B=Y.joinPath,z=Y.DEFAULT_PATH_SEPARATOR,G=Y.DEFAULT_MAX_COLUMNS,P="";function O(i,s,n={}){const u=n.separator||z,o=i||[],a=s instanceof Uint32Array?s:Uint32Array.from(s||[]),f=a.length;if(o.length===0)return{tuples:[[]],paths:[P],buckets:[a]};const{keyOf:w,readers:m}=Z(o,a,0),v=new Map,h=[],p=[],g=[];for(let W=0;W<f;W++){const R=a[W],x=w(R);let A=v.get(x);if(A===void 0){A=h.length,v.set(x,A),p.push(x);const $=new Array(m.length);for(let I=0;I<m.length;I++)$[I]=m[I](R);h.push($),g.push([])}g[A].push(R)}const k=L(n.locale),y=h.map((W,R)=>R);y.sort((W,R)=>{const x=h[W],A=h[R];for(let $=0;$<x.length;$++){const I=b(x[$],A[$],k);if(I!==0)return I}return W-R});const T=new Array(y.length),j=new Array(y.length),N=new Array(y.length);for(let W=0;W<y.length;W++){const R=y[W];T[W]=h[R],j[W]=B(h[R],u),N[W]=Uint32Array.from(g[R])}return{tuples:T,paths:j,buckets:N}}function b(i,s,n){const u=i==null,o=s==null;return u||o?u&&o?0:u?1:-1:n(i,s)}function c(i,s,n){const u=[];for(let o=0;o<i.length;o++)n.has(i[o])&&u.push(i[o]);return Uint32Array.from(u)}function d(i,s,n,u){return{value:s.length?D(i,s,n,u):null,leaves:s,count:s.length}}function l(i){const s=i&&i.opts||{},n=s.separator||z,u=s.totalContext||{locale:s.locale},o=(i.measures||[]).filter(j=>j&&j.handle),a=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),f=O(i.rowHandles||[],a,{...s,separator:n}),w=O(i.columnHandles||[],a,{...s,separator:n}),m=s.maxColumns===void 0?G:s.maxColumns,v=w.paths.length*Math.max(1,o.length),h=new Map;if(m&&v>m)return{rowAxis:f,columnAxis:w,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:v,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${v} columns, above pivot.maxColumns of ${m}. Narrow the pivot columns or raise the limit.`,columns:v,maxColumns:m}};const p=new Map,g=new Map,k=new Map,y=new Map,T=w.buckets.map(j=>new Set(j));for(let j=0;j<w.paths.length;j++){const N=w.buckets[j],W=w.paths[j];for(const R of o)k.set(t(W,R.colId),d(R.handle,N,R.fn,u))}for(let j=0;j<f.paths.length;j++){const N=f.buckets[j],W=f.paths[j];for(const R of o)g.set(t(W,R.colId),d(R.handle,N,R.fn,u));for(let R=0;R<w.paths.length;R++){const x=c(N,w.buckets[R],T[R]);if(x.length===0)continue;const A=w.paths[R];for(const $ of o)p.set(r(W,A,$.colId),d($.handle,x,$.fn,u))}}for(const j of o)y.set(j.colId,d(j.handle,a,j.fn,u));return{rowAxis:f,columnAxis:w,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:p,rowMargin:g,columnMargin:k,grand:y,columns:v,error:null}}function r(i,s,n){return`${i}\0${s}\0${n}`}function t(i,s){return`${i}\0${s}`}}),Be("packages/core/src/compute/reference.js",function(e,H){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return l}});const L=H("packages/core/src/internal/paths.js").getPath,X=H("packages/core/src/compute/handle.js"),D=X.isMissing,F=X.valueComparator,Y=H("packages/core/src/compute/filter.js").testValue,B="",z="\0";function G(i,s){const n=s.includes(".")?L(i,s):i?.[s];return n===void 0?null:n}function P(i,s,n={}){const u=s||[];let o=i.map((a,f)=>f);if(u.length===0)return o;for(let a=u.length-1;a>=0;a--)o=O(i,o,u[a],n);return o}function O(i,s,n,u){const o=n.locale!==void 0?n.locale:u.locale,a=F(o),f=n.descending!==void 0?!!n.descending:n.dir==="desc",w=[],m=[];for(const p of s){const g=G(i[p],n.col);D(g)?m.push(p):w.push(p)}const v=new Map;for(let p=0;p<w.length;p++)v.set(w[p],p);const h=(p,g)=>{const k=G(i[p],n.col),y=G(i[g],n.col);let T;return typeof n.compare=="function"?(T=n.compare(k,y,i[p],i[g],f),f&&(T=-T)):T=f?a(y,k):a(k,y),T!==0?T:v.get(p)-v.get(g)};return w.sort(h),n.nullsFirst?m.concat(w):w.concat(m)}function b(i,s,n={}){const u=[];for(let o=0;o<i.length;o++)c(i[o],s,n,o)&&u.push(o);return u}function c(i,s,n,u){if(!s)return!0;if(Array.isArray(s.conditions)){const o=s.conditions.filter(f=>f!=null);if(o.length===0)return!0;if(s.op==="or")return o.some(f=>c(i,f,n,u));const a=o.every(f=>c(i,f,n,u));return s.op==="not"?!a:a}return s.col===void 0&&typeof n.custom=="function"?!!n.custom(s,i,u):Y(G(i,s.col),s,n.locale)}function d(i,s,n,u){const o=n||i.map((m,v)=>v),a=new Map,f=[],w=[];for(const m of o){const v=s.map((g,k)=>{const y=G(i[m],g);return u&&u[k]?u[k](y):y}),h=v.map(g=>g==null?z:String(g)).join(B);let p=a.get(h);p===void 0&&(p=f.length,a.set(h,p),f.push(v),w.push([])),w[p].push(m)}return{keys:f,buckets:w}}function l(i,s,n={}){const u=F(n.locale),o=i.filter(f=>!D(f)),a=o.map(r).filter(f=>f!==null);switch(s){case"count":return i.length;case"countValues":return o.length;case"sum":return a.reduce((f,w)=>f+w,0);case"avg":return o.length===0?null:a.reduce((f,w)=>f+w,0)/o.length;case"min":return o.length===0?null:o.reduce((f,w)=>u(w,f)<0?w:f);case"max":return o.length===0?null:o.reduce((f,w)=>u(w,f)>0?w:f);case"first":return i.length===0?null:t(i[0]);case"last":return i.length===0?null:t(i[i.length-1]);default:return null}}function r(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function t(i){return i===void 0?null:i}}),Be("packages/core/src/compute/index.js",function(e,H){"use strict";const te=H("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return te.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return te.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return te.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return te.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return te.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return te.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return te.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return te.rankSortStrings}});const L=H("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return L.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return L.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L.describeSort}});const X=H("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const D=H("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D.packKeys}});const F=H("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return F.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return F.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return F.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return F.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return F.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return F.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return F.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return F.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return F.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return F.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return F.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return F.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return F.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return F.QUANTILE_SAMPLE}});const Z=H("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const Y=H("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return Y.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return Y.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return Y.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return Y.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return Y.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return Y.DEFAULT_MAX_COLUMNS}});const B=H("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return B.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return B.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return B.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return B.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return B.GRAND_PATH}});const z=H("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return z.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return z.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return z.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return z.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return z.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z.referenceValue}});const G=H("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return G.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return G.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return G.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return G.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return G.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return G.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return G.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return G.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return G.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return G.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return G.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return G.isMissing}});const P=H("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return P.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return P.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return P.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return P.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return P.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return P.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return P.SKETCH_BOUNDS}});const O=H("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const b=H("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const c=H("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return c.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return c.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return c.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c.anomalyCondition}});const d=H("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),Be("packages/core/src/source/rows.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return d}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/predicates.js").isFunction,F=32,Z="\0";function Y(l){return new B(l)}class B{#e;#t;constructor(r){this.#e=D(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||D(t)?t:F}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const i=this.#e(r);if(i!=null)return String(i)}else L("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return D(this.#t)?Number(this.#t(r))||F:this.#t}leaf(r,t,i=0,s=null){const n={key:this.keyOf(r,t),data:r,level:i,parent:s,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return n.height=this.heightOf(n),n}group(r){const t={key:c(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${Z}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${Z}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const i={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return i.height=this.heightOf(i),i}skeleton(r,t=0,i=!1){const s={key:`${Z}pending${Z}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return i&&(s.loadError=!0),s.height=this.heightOf(s),s}}function z(l,r,t,i){return{key:`${Z}pinned${Z}${t}${Z}${r}`,data:l,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function G(l,r){return new Proxy([],{get(t,i,s){if(i==="length")return l();if(typeof i=="string"){const n=Number(i);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(t,i,s)},has(t,i){if(typeof i=="string"){const s=Number(i);if(Number.isInteger(s)&&s>=0)return s<l()}return Reflect.has(t,i)}})}function P(l){return l==null?"":String(l)}const O="";function b(l){if(l==null)return O;const r=String(l);return r.startsWith(O)?O+r:r}function c(l){const r=l||[];let t="g";for(let i=0;i<r.length;i++)t+=Z+b(r[i]);return t}function d(l){const r=new Array(l.length),t=[];for(let i=0;i<l.length;i++)t.push(l[i]),r[i]=c(t);return r}}),Be("packages/core/src/source/handles.js",function(e,H){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce;class F{#e;#t;#n;#r=new Map;#s=0;constructor(B,z,G){this.#e=B,this.#t=z,this.#n=L(G)?G:()=>!1}get store(){const B=this.#e.store;return B&&L(B.column)?B:null}invalidate(){this.#s++}handle(B){const z=this.store;if(z){const b=z.column(B);if(b)return b}const G=this.#r.get(B);if(G&&G.builtAt===this.#s)return G.handle;const P=this.#i(B);if(!P)return;if(z&&this.#n()){D(`source.dropped.${B}`,`column "${B}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const O=this.#o(P);return this.#r.set(B,{handle:O,builtAt:this.#s}),O}#i(B){const z=this.#e.columns;return z&&L(z.get)?z.get(B):void 0}#o(B){const z=this.#t()||[],G=z.length,P=new Array(G),O=L(B.getValue)?c=>B.getValue(c):c=>c?.[B.field||B.id];for(let c=0;c<G;c++)P[c]=z[c]===void 0?void 0:O(z[c]);const b=this.#s;return{id:B.id,kind:"object",nullable:!1,values:P,presence:null,dict:null,offsets:null,get(c){return P[c]},version:b}}}function Z(Y,B,z){return new F(Y,B,z)}}),Be("packages/core/src/compute/incremental.js",function(e,H){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/store/columnstore.js").toFloat,X=Object.freeze(["sum","avg","countValues","min","max"]),D=Object.freeze(["float64"]),F=1e15;function Z(G,P){return typeof G!="string"||!X.includes(G)?!1:!!P&&D.includes(P.kind)}function Y(G){if(G==null)return null;const P=L(G);return Number.isNaN(P)?null:P}class B{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-1/0;#o=!1;#l=!1;constructor(P){this.#e=P}get valid(){return this.#o&&!this.#l}get fn(){return this.#e}seed(P){this.#a();for(let O=0;O<P.length;O++){const b=Y(P[O]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(P,O,b){this.#a();for(let c=0;c<b.length;c++){const d=b[c];if(O&&O(d)===0)continue;const l=P[d];Number.isNaN(l)||this.#c(l)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(P){if(!Number.isFinite(P)){this.#l=!0;return}const O=this.#t+P;this.#n+=Math.abs(this.#t)>=Math.abs(P)?this.#t-O+P:P-O+this.#t,this.#t=O,this.#r++,P<this.#s&&(this.#s=P),P>this.#i&&(this.#i=P)}#u(P){const O=this.#t-P;this.#n+=Math.abs(this.#t)>=Math.abs(P)?this.#t-O-P:-P-O+this.#t,this.#t=O,this.#r--}update(P,O){if(!this.#o)return!1;const b=Y(P),c=Y(O);return b===null&&c===null?!0:b!==null&&!Number.isFinite(b)||c!==null&&!Number.isFinite(c)?!1:this.#e==="min"||this.#e==="max"?b===null||c===null?!1:this.#e==="min"?c<this.#s?(this.#s=c,!0):b>this.#s:c>this.#i?(this.#i=c,!0):b<this.#i:Math.abs(this.#t)>F?!1:(b!==null&&this.#u(b),c!==null&&this.#c(c),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const z=B}),Be("packages/core/src/source/filterwire.js",function(e,H){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return k}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="source.remote.hostFilter",D="source.where.pageRelative";function F(j,N){!Array.isArray(j)||!j.length||L(D,`filters.where (${j.join(", ")}) runs over the rows the ${N} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(j){const N=(j||{}).config;!N||!N.hostFilter||L(X,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const Y="source.where.notApplied";function B(j,N){L(`${Y}:${j}`,`filters.where("${j}") is registered but the ${N} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const z="source.where.overThreshold";function G(j,N,W,R){!Array.isArray(j)||!j.length||L(`${z}:${N}`,`filters.where (${j.join(", ")}) is not applied to the ${N} pushdown source:`,W===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${W.toLocaleString()} rows, at or past the whereRowLimit of ${R.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const P=new Map;function O(j){let N=P.get(j);return N||(N=new Intl.DateTimeFormat("en-US",{timeZone:j,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),P.set(j,N)),N}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function c(j,N){const W=O(N).formatToParts(new Date(j)),R={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const x of W)x.type==="year"?R.y=+x.value:x.type==="month"?R.m=+x.value:x.type==="day"?R.d=+x.value:x.type==="hour"?R.h=+x.value%24:x.type==="minute"?R.mi=+x.value:x.type==="second"&&(R.s=+x.value);return R}function d(j,N){const W=c(j,N);return Date.UTC(W.y,W.m-1,W.d,W.h,W.mi,W.s)-Math.floor(j/1e3)*1e3}function l(j,N,W,R){const x=Date.UTC(j,N-1,W),A=x-d(x,R);return x-d(A,R)}function r(j,N,W){const R=new Date(Date.UTC(j.y,j.m-1,j.d+N));return l(R.getUTCFullYear(),R.getUTCMonth()+1,R.getUTCDate(),W)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(j,N){if(typeof j!="string")return null;const W=j.trim().toLowerCase().replace(/[\s_-]+/g,""),R=/^last(\d*|n)days?$/.exec(W);if(R){const x=R[1]==="n"?"":R[1],A=Number(x||N);return!Number.isFinite(A)||A<=0?null:{kind:"lastNDays",n:Math.floor(A)}}switch(W){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function s(j,N={}){const W=i(j,N.n);if(!W)return null;const R=N.tz||b(),x=N.now instanceof Date?N.now.getTime():typeof N.now=="number"?N.now:Date.now(),A=c(x,R),$=l(A.y,A.m,A.d,R),I=r(A,1,R);let M=$,S=I;switch(W.kind){case"today":break;case"yesterday":M=r(A,-1,R),S=$;break;case"lastNDays":S=N.includeToday?I:$,M=r(A,N.includeToday?-(W.n-1):-W.n,R);break;case"thisWeek":{const E=Number.isFinite(N.weekStartsOn)?Number(N.weekStartsOn):1,K=(new Date(Date.UTC(A.y,A.m-1,A.d)).getUTCDay()-E+7)%7;M=r(A,-K,R),S=r(A,-K+7,R);break}case"thisMonth":M=l(A.y,A.m,1,R),S=l(A.m===12?A.y+1:A.y,A.m===12?1:A.m+1,1,R);break;case"thisQuarter":case"quarterToDate":{const E=Math.floor((A.m-1)/3)*3+1;M=l(A.y,E,1,R),S=W.kind==="quarterToDate"?I:E===10?l(A.y+1,1,1,R):l(A.y,E+3,1,R);break}case"thisYear":case"yearToDate":M=l(A.y,1,1,R),S=W.kind==="yearToDate"?I:l(A.y+1,1,1,R);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(S).toISOString(),bounds:"[)",tz:R,relative:W.kind==="lastNDays"?`last${W.n}Days`:W.kind,n:W.n}}function n(j){if(!j||typeof j!="object")return null;const N=j.value;if(N&&typeof N=="object"&&!Array.isArray(N)&&"relative"in N)return{token:String(N.relative),n:typeof N.n=="number"?N.n:void 0};if(j.op==="relative"&&typeof j.value=="string")return{token:j.value,n:void 0};const W=j.meta;return W&&typeof W.relative=="string"&&j.value===void 0?{token:W.relative,n:typeof W.n=="number"?W.n:void 0}:null}function u(){return`Known tokens: ${t.filter(N=>N!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function o(j){const N=n(j);return N?i(N.token,N.n)!==null:!1}function a(j,N={}){const W=n(j);if(!W)return j;const R=s(W.token,{...N,n:W.n});return R?{...j,type:j.type||"date",op:"between",value:[R.from,R.to],bounds:j.bounds||R.bounds,meta:{...j.meta||{},relative:R.relative,tz:R.tz}}:(L(`source.relative.${W.token}`,`unknown relative date token "${W.token}"; sending the condition unresolved.`,u()),j)}function f(j){return!!j&&typeof j=="object"&&Array.isArray(j.conditions)}function w(j,N){if(j){if(f(j)){for(const W of j.conditions)w(W,N);return}N(j)}}function m(j,N){if(!j)return null;if(!f(j))return N(j);const W=j;let R=!1;const x=[];for(const A of W.conditions){const $=m(A,N);$!==A&&(R=!0),$&&x.push($)}return!R&&x.length===W.conditions.length?j:x.length?{...W,conditions:x}:null}function v(j){if(!j)return null;if(!f(j))return j;const N=j,W=[];for(const R of N.conditions){const x=v(R);x&&W.push(x)}return W.length?{op:N.op,conditions:W}:null}function h(j){const N=v(j);return N?f(N)&&N.op==="and"?N:{op:"and",conditions:[N]}:null}function p(j){const N=(j||[]).filter(Boolean);return N.length?{op:"and",conditions:N}:null}function g(j,N={}){const W=m(j,R=>a(R,N));return h(W)}function k(j){const N=y(j.filters??null);return JSON.stringify([N,j.sort??null,j.quick??"",j.groupBy??null,j.pivotBy??null,T(j.context)])}function y(j){if(!j)return null;if(f(j)){const R=j;return{op:R.op,conditions:R.conditions.map(y)}}const N=j,W=N.meta&&typeof N.meta.relative=="string"?N.meta.relative:n(N)?.token;return{col:N.col,op:N.op,bounds:N.bounds??null,caseSensitive:N.caseSensitive??!1,value:W?`rel:${W}`:N.value??null}}function T(j){if(j==null)return null;try{return JSON.parse(JSON.stringify(j))}catch{return L("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Be("packages/core/src/source/tree.js",function(e,H){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return c}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F="",Z="\0tree:";function Y(d,l){return{physical:d,key:l,level:0,children:[],value:void 0}}function B(d,l){const r=[],t=new Map;for(let i=0;i<d.length;i++){const s=d[i],n=l.pathOf(s),u=Array.isArray(n)?n.map(a=>String(a)):[];if(!u.length){const a=Y(s,l.keyOf(s));r.push(a);continue}let o=null;for(let a=0;a<u.length;a++){const f=u.slice(0,a+1).join(F),w=a===u.length-1;let m=t.get(f);m&&w&&m.physical===-1&&(m.physical=s,m.key=l.keyOf(s)),m||(m=Y(w?s:-1,w?l.keyOf(s):Z+f),m.level=a,m.value=u[a],t.set(f,m),o?o.children.push(m):r.push(m)),o=m}}return{roots:r,nodes:t}}function z(d,l){const r=new Map,t=[];for(let u=0;u<d.length;u++){const o=d[u],a=l.keyOf(o),f=Y(o,a);r.set(a,f);const w=l.parentOf(o);w!=null&&w!==""&&t.push({node:f,parent:String(w)})}let i=null;const s=new Map;for(const{node:u,parent:o}of t){const a=r.get(o);if(a){s.set(u.key,a);continue}l.orphans&&l.orphans!=="root"&&(i||(i=Y(-1,`${Z}orphans`),i.value=l.orphans),s.set(u.key,i))}const n=[];for(const u of r.values()){const o=s.get(u.key);o?o.children.push(u):n.push(u)}return i&&i.children.length&&n.push(i),{roots:G(n,r,l.orphans,i),nodes:r}}function G(d,l,r,t){const i=new Set,s=[...d];for(;s.length;){const f=s.pop();if(!i.has(f.key)){i.add(f.key);for(const w of f.children)s.push(w)}}const n=[];for(const f of l.values())i.has(f.key)||n.push(f);if(!n.length)return d;const u=!!r&&r!=="root";D("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(u?`they are shown under "${r}".`:"they are shown at the root."));for(const f of n)f.children=f.children.filter(w=>i.has(w.key));if(!u)return[...d,...n];let o=t;const a=[...d];return o||(o=Y(-1,`${Z}orphans`),o.value=r,a.push(o)),o.children.push(...n),a}function P(d){let l=0;const r=(t,i)=>{for(const s of t)s.level=i,i>l&&(l=i),s.children.length&&r(s.children,i+1)};return r(d,0),l}function O(d,l){if(!d||typeof d!="object")return null;const r=d.path,t=d.parentKey,i=L(d.hasChildren)?s=>!!d.hasChildren(l.dataAt(s)):null;if(L(r))return{mode:"path",pathOf:s=>r(l.dataAt(s)),keyOf:l.keyOf,declaresChildren:i};if(t!=null){const s=L(t)?t:n=>n?.[t];return{mode:"parentKey",parentOf:n=>s(l.dataAt(n)),keyOf:l.keyOf,orphans:d.orphans||"root",declaresChildren:i}}return D("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(d,l){const r=l.mode==="path"?B(d,l):z(d,l),t=P(r.roots);return{...r,depth:t}}function c(d,l){const r=new Map,t=i=>{for(let s=0;s<i.length;s++){const n=i[s];if(n.physical>=0){const u=l?l(n.physical):!1,o=u&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:s+1,setsize:i.length,hasChildren:n.children.length>0||u,lazy:o})}n.children.length&&t(n.children)}};return t(d),r}}),Be("packages/core/src/source/settle.js",function(e,H){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return L}});const te=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function L(X){const D=X&&typeof X=="object"?X.reason:null;return typeof D=="string"&&te.includes(D)}}),Be("packages/core/src/source/memory.js",function(e,H){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return K}});const L=H("packages/core/src/internal/lru.js").Lru,X=H("packages/core/src/internal/warn.js"),D=X.warnOnce,F=X.fail,Y=H("packages/core/src/internal/predicates.js").isFunction,z=H("packages/core/src/internal/compare.js").defaultCompare,P=H("packages/core/src/internal/merge.js").mergeRow,O=H("packages/core/src/source/rows.js"),b=O.createRowFactory,c=O.groupKey,d=O.groupPathElement,l=O.groupPrefixKeys,r=O.lazyRowView,i=H("packages/core/src/source/handles.js").createHandleProvider,s=H("packages/core/src/compute/incremental.js"),n=s.RunningTotal,u=s.isIncremental,a=H("packages/core/src/compute/handle.js").presenceReader,f=H("packages/core/src/source/filterwire.js"),w=f.querySignature,m=f.mapConditions,v=f.resolveRelativeCondition,h=H("packages/core/src/source/tree.js"),p=h.buildTree,g=h.resolveTree,k=h.indexTree,y=H("packages/core/src/source/settle.js"),T=y.PIPELINE_SETTLE_REASONS,j=y.isPipelineSettle,N=Object.freeze(["filter","sort","group","total","pivot","flatten"]),W=Object.freeze([]);function R(q,_){if(!q)return null;const J=_==="grand"?q.grandTotal:q.groupTotal;return J??q.total}function x(q){return!!q&&!q.running}function A(q){if(q)return q.value&&Y(q.value.compare)?q.value.compare:Y(q.compare)?q.compare:void 0}function $(q){const _=q&&q.dataType;return!_||!Y(_.items)?null:{items:_.items,type:q.itemType&&q.itemType.name||"text"}}function I(q){return!!q&&(typeof q=="object"||typeof q=="function")&&Y(q.then)}const M=new Uint32Array(0),S=4096;function E(q,_){return new K(q,_)}function U(q,_){if(_==="regex")try{const J=new RegExp(q,"iu");return ee=>J.test(ee)}catch{return J=>J.includes(q)}if(_==="fuzzy"){const J=[...q].filter(ee=>ee!==" ");return J.length?ee=>{let ne=0;for(let oe=0;oe<ee.length&&ne<J.length;oe++)ee[oe]===J[ne]&&ne++;return ne===J.length}:()=>!0}if(_==="words"){const J=q.split(/\s+/).filter(Boolean);return J.length?ee=>J.every(ne=>ee.includes(ne)):()=>!0}return J=>J.includes(q)}class K{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#o;#l=new Map;#a=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=K.#g();static#g(){return{slots:[],groupHeadings:W,unnumbered:W,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#j=new Map;#w=-1;#O=[];#v=new Map;#T=-1;#S=[];#E=null;#M=null;#P=null;#N=null;#R=null;#L=null;#U=null;#G=null;#x=Symbol("unset");#F=new Map;#Y=null;get#I(){return this.#m.slots}set#I(_){this.#m.slots=_}get#K(){return this.#m.inlineLeaves}set#K(_){this.#m.inlineLeaves=_}get#H(){return this.#m.groupHeadings}set#H(_){this.#m.groupHeadings=_}get#z(){return this.#m.unnumbered}set#z(_){this.#m.unnumbered=_}get#fe(){return this.#m.pivot}set#fe(_){this.#m.pivot=_}constructor(_,J){this.#t=_||{mode:"memory"},this.#e=J||{};const ee=this.#e.config||{};this.#n=this.#t.rows||ee.rows||[],this.#i=b(this.#e),this.#o=i(this.#e,()=>this.#n,()=>this.#r),this.#h=new L(Number(ee.rowCacheSize)||S);for(const ne of N)this.#l.set(ne,{key:null,result:null,id:0,computed:!1})}count(){this.#D();const _=this.#ne();return _?_.length:this.#I.length}#ne(){const _=Number(this.#_("pageSize",0))||0;if(_<=0)return null;const J=this.#I.length,ee=Math.max(1,Math.ceil(J/_)),oe=Math.min(Math.max(0,Number(this.#_("page",0))||0),ee-1)*_;return{offset:oe,length:Math.max(0,Math.min(_,J-oe))}}pageInfo(){this.#D();const _=Number(this.#_("pageSize",0))||0,J=this.#I.length;if(_<=0)return{page:0,pageSize:0,total:J,pageCount:1};const ee=Math.max(1,Math.ceil(J/_));return{page:Math.min(Math.max(0,Number(this.#_("page",0))||0),ee-1),pageSize:_,total:J,pageCount:ee}}totalCount(){return this.#ue().length}matchCount(){return this.#D(),this.#m.matchCount}at(_){this.#D();const J=this.#ne();if(J)return _<0||_>=J.length?void 0:this.#Le(J.offset+_,_);if(!(_<0||_>=this.#I.length))return this.#Le(_,_)}byKey(_){this.#D(),this.#p||this.#Ce();const J=this.#p.get(_);if(J!==void 0)return this.#je(J);for(let ee=0;ee<this.#I.length;ee++){const ne=this.#I[ee];if(typeof ne!="number"&&ne&&ne.key===_)return this.#Le(ee)}}loaded(_){return _>=0&&_<this.count()}hint(_,J){}display(){return this.#D(),this.#Y||(this.#Y=this.#Nt()),this.#Y}invalidateQuickText(){this.#F.clear(),this.invalidate("filter")}invalidate(_){const J=N.indexOf(_);J<0&&F(`unknown pipeline stage "${_}"; expected one of ${N.join(", ")}`);for(let ee=J;ee<N.length;ee++){const ne=this.#l.get(N[ee]);ne.key=null,ne.computed=!1}this.#Y=null}apply(_){const J=[],ee={added:[],updated:[],removed:[],rejected:J};if(!_)return ee;let ne=!1;const oe=new Set;if(_.remove&&_.remove.length)for(const ie of _.remove){const ae=this.#de(ie);if(ae===void 0){J.push({operation:"remove",id:this.#ye(ie),reason:"unknown-id"});continue}ee.removed.push(this.#i.keyOf(this.#r?this.#ae(ae):this.#n[ae],ae)),this.#r||(this.#n[ae]=void 0),this.#h.delete(ae),this.#F.delete(ae),ne=!0}if(_.update&&_.update.length){const ie=this.#j.size||this.#Ke()?this.#Ze():null,ae=this.#v.size?this.#kt():null,ce=ae&&ae.length?this.#Ze():null;for(const de of _.update){const Ae=this.#de(de);if(Ae===void 0){J.push({operation:"update",id:this.#Pe(de),reason:"unknown-id"});continue}const je=this.#r?this.#s&&this.#s.has(Ae)?this.#s.get(Ae):this.#ae(Ae):this.#n[Ae],be=P(je,de);for(const re of this.#te(je,be))oe.add(re);if(this.#r||(this.#n[Ae]=be),ie&&this.#Tt(ie,Ae,je,be),ce&&this.#lt(ae,ce,Ae,je,be),this.#p){const re=this.#i.keyOf(je,Ae),fe=this.#i.keyOf(be,Ae);re!==fe&&(this.#p.delete(re),this.#p.set(fe,Ae))}this.#h.delete(Ae),this.#F.delete(Ae),ee.updated.push(this.#je(Ae))}}if(_.add&&_.add.length&&this.#r){typeof _.at=="number"&&_.at<this.#Ne()&&(this.#h.clear(),this.#F.clear()),this.#p=null;for(const ie of _.add){const ae=this.#se(this.#Pe(ie));ae!==void 0&&ee.added.push(this.#je(ae))}ne=!0}else if(_.add&&_.add.length){const ie=typeof _.at=="number"?_.at:this.#n.length,ae=this.#n.length;let ce=_.add===this.#n?_.add.slice():_.add;if(this.#i.keyed){const de=[];for(const Ae of ce){const je=this.#Pe(Ae);if(this.#de(je)!==void 0){J.push({operation:"add",id:je,reason:"duplicate-id"});continue}de.push(Ae)}de.length!==ce.length&&(ce=de)}if(!ce.length)return ee;if(ie>=ae)for(let de=0;de<ce.length;de++)this.#n.push(ce[de]);else this.#n.splice(ie,0,...ce),this.#h.clear(),this.#F.clear();for(let de=0;de<ce.length;de++)ee.added.push(this.#je(ie>=ae?ae+de:ie+de));ne=!0}return this.#c++,ne&&(this.#p=null,this.#nt()),this.#o.invalidate(),this.#Y=null,ne||this.#X(oe)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:ee.added.length,updated:ee.updated.length,removed:ee.removed.length}),this.#s=null,ee}groupHeadingsAt(_){this.#D();const J=this.#H;if(!J.length||!Number.isInteger(_)||_<0)return W;let ee=0,ne=J.length-1,oe=-1;for(;ee<=ne;){const ae=ee+ne>>1;J[ae].at<=_?(oe=ae,ee=ae+1):ne=ae-1}if(oe<0)return W;const ie=[];for(let ae=J[oe].row;ae;ae=ae.parent)ie.push(ae);return ie.reverse(),ie}unnumberedRowCount(_){this.#D();const J=this.#z;if(!J.length||!Number.isInteger(_)||_<0)return 0;let ee=0,ne=J.length-1,oe=-1;for(;ee<=ne;){const ie=ee+ne>>1;J[ie].at<=_?(oe=ie,ee=ie+1):ne=ie-1}return oe+1}moveRow(_,J){if(this.#r)return D("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const ee=this.#n;if(!Number.isInteger(_)||!Number.isInteger(J)||_<0||_>=ee.length)return!1;const ne=Math.max(0,Math.min(ee.length-1,J));if(ne===_)return!1;const[oe]=ee.splice(_,1);return ee.splice(ne,0,oe),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#F.clear(),this.#nt(),this.#o.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(_){this.#pe(),this.#c++,this.#u++,this.#p=null,this.#F.clear(),this.#h.clear(),this.#nt(),this.#o.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#pe(),this.#h.clear(),this.#F.clear(),this.#p=null,this.#I=[],this.#K=null,this.#Y=null,this.#nt();for(const _ of N)this.#l.set(_,{key:null,result:null,id:0,computed:!1})}#pe(){for(const{controller:_}of this.#b.values())try{_.abort()}catch{}this.#b.clear()}setRows(_){this.#n=_||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#F.clear(),this.#h.clear(),this.#nt(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(_){this.#s=_||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#F.clear(),this.#o.invalidate()}data(){if(!this.#r)return this.#n;const _=this.#e.store;if(!_||!Y(_.source))return this.#n;const J=_.physical||0,ee=new Array(J);for(let ne=0;ne<J;ne++)ee[ne]=_.live&&!_.live(ne)?void 0:_.source(ne);return ee}#Ie(){const _=this.#_("detail",null);return!_||!Y(_.isOpen)||_.inline===!1?null:_}#Oe(){const _=(this.#e.config||{}).tree;return this.#x!==_&&(this.#x=_,this.#G=g(_,{dataAt:J=>this.#ae(J),keyOf:J=>this.#i.keyOf(this.#ae(J),J)})),this.#G}#me(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#me())return null;this.#D();const _=this.#m.grand;return _?this.#i.grandTotal(_,this.#et(this.#m.grandLeaves)):null}pivot(){return this.#D(),this.#fe}pivotMatrix(){this.#D();const _=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!Y(J))return null;const ee=this.#_("groupBy",[]),ne=this.#_("pivotBy",[]);if(!ee.length&&!ne.length)return D("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const oe=this.#Ze().map(ae=>({colId:ae.id,handle:this.#o.handle(ae.id),fn:R(ae,"group")})).filter(ae=>ae.handle&&ae.fn),ie=this.#e.config||{};return J({rowHandles:ee.map(ae=>this.#o.handle(ae)).filter(Boolean),columnHandles:ne.map(ae=>this.#o.handle(ae)).filter(Boolean),measures:oe,leaves:_||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(_){const J=[];if(!_)return J;for(let ee=0;ee<_.length;ee++){const ne=this.#je(_[ee]);ne&&ne.key!=null&&J.push(String(ne.key))}return J}leavesOf(_){this.#D();const J=this.#l.get("group"),ee=J&&J.result;if(!ee||!ee.nodes)return[];const ne=ee.nodes.get(_);if(!ne)return[];const oe=[],ie=ae=>{const ce=ae.row&&ae.row.children;if(ce&&ce.length){for(const de of ce){const Ae=ee.nodes.get(de.key);Ae&&ie(Ae)}return}if(ae.leaves)for(let de=0;de<ae.leaves.length;de++)oe.push(this.#je(ae.leaves[de]))};return ie(ne),oe}#ye(_){return typeof _=="string"?_:this.#Pe(_)}#Pe(_){try{return this.#i.keyOf(_,-1)}catch{return"(unkeyed)"}}#de(_){if(typeof _=="string")return this.#se(_);if(this.#i.keyed){const ee=this.#i.keyOf(_,-1),ne=this.#se(ee);if(ne!==void 0)return ne}if(this.#r)return;const J=this.#n.indexOf(_);return J>=0?J:void 0}#se(_){return this.#p||this.#Ce(),this.#p.get(_)}#Ce(){this.#p=new Map;const _=this.#Ne(),J=this.#e.store,ee=J&&Y(J.live)?ne=>J.live(ne):null;for(let ne=0;ne<_;ne++){if(ee&&!ee(ne))continue;const oe=this.#ae(ne);oe!==void 0&&this.#p.set(this.#i.keyOf(oe,ne),ne)}}#te(_,J){const ee=[];for(const ne of this.#W())this.#Ue(ne)&&this.#J(ne,_,J,new Set)&&ee.push(ne);return ee}#J(_,J,ee,ne){if(ne.has(_))return!1;ne.add(_);const oe=this.#Ue(_);if(!oe)return!1;const ie=oe.value&&oe.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ae=>this.#J(String(ae),J,ee,ne)):Y(oe.getValue)?!Object.is(oe.getValue(J),oe.getValue(ee)):!1}#W(){const _=new Set;for(const ee of this.#_("sort",[]))_.add(ee.col);for(const ee of this.#_("groupBy",[]))_.add(ee);const J=ee=>{if(ee){if(Array.isArray(ee.conditions)){ee.conditions.forEach(J);return}ee.col&&_.add(ee.col)}};return J(this.#_("filters",null)),[..._]}#X(_){if(!_.size)return!1;if(this.#_("quick",""))return!0;for(const J of this.#W())if(_.has(J))return!0;return!1}#D(){if(!this.#a){this.#a=!0;try{this.#Me()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Me(){const _=this.#B("filter",()=>this.#V(),()=>this.#Re()),J=this.#q(_),ee=this.#B("group",()=>this.#ge(),()=>this.#Ye(J)),ne=this.#B("total",()=>this.#we(),()=>this.#Ve(ee));this.#B("pivot",()=>this.#k(),()=>this.#jt(ee)),this.#B("flatten",()=>this.#Se(),()=>this.#Ge(ee)),this.#Be(ee,ne)}#q(_){const J=this.#l.get("sort"),ee=this.#ie();if(J.computed&&J.key===ee&&!this.#b.has("sort"))return J.result;const ne=this.#b.get("sort");return ne&&ne.key===ee?J.result:J.result&&this.#Ee(_)?(this.#Te(_,ee),J.result):this.#B("sort",()=>ee,()=>this.#Fe(_))}#re(){if(this.#y===null){const _=this.#e.pipelineWorker,J=Y(_)?_():null;this.#y=J||!1}return this.#y||null}#ve(){const _=this.#_("sort",[]);if(!Array.isArray(_)||!_.length)return null;const J=(this.#e.config||{}).locale,ee=[],ne=[];for(const oe of _){const ie=this.#Ue(oe.col);if(ie&&ie.running)continue;if(ie&&ie.value&&Y(ie.value.compare))return null;const ae=this.#o.handle(oe.col);if(!ae)return null;ee.push({col:oe.col,descending:oe.dir==="desc",nullsFirst:!!oe.nullsFirst,locale:J}),ne.push(ae)}return ee.length?{entries:ee,handles:ne,locale:J}:null}#Ee(_){if(this.#ce())return!1;const J=this.#re();if(!J)return!1;const ee=Number(J.threshold);return Number.isFinite(ee)&&_.length<ee?!1:!!this.#ve()}#Te(_,J){const ee=this.#re(),ne=ee&&this.#ve();if(!ne){this.#B("sort",()=>J,()=>this.#Fe(_));return}const oe=new AbortController;this.#b.set("sort",{key:J,controller:oe});const ie=ne.entries.length===1?ee.sortColumn(ne.handles[0],_,{descending:ne.entries[0].descending,nullsFirst:ne.entries[0].nullsFirst,locale:ne.locale,signal:oe.signal,key:"sort"}):ee.sortMulti(ne.handles,ne.entries.map((ae,ce)=>({...ae,handle:ne.handles[ce]})),_,{signal:oe.signal,key:"sort"});if(!I(ie)){this.#b.delete("sort"),this.#B("sort",()=>J,()=>ie);return}ie.then(ae=>this.#le(J,ae),ae=>this.#he("sort",J,ae))}#le(_,J){const ee=this.#b.get("sort");if(!(!ee||ee.key!==_)){if(this.#ie()!==_){this.#b.delete("sort");return}this.#b.delete("sort"),this.#B("sort",()=>_,()=>J),this.#Y=null,this.#D(),this.#Qe("model:changed",{reason:T[0]})}}#he(_,J,ee){const ne=this.#b.get(_);if(!(!ne||ne.key!==J)&&(this.#b.delete(_),!(ee&&ee.name==="AbortError")&&_==="sort"&&this.#ie()===J)){const oe=this.#B("filter",()=>this.#V(),()=>this.#Re());this.#B("sort",()=>J,()=>this.#Fe(oe)),this.#Y=null,this.#D(),D("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",ee),this.#Qe("model:changed",{reason:T[1]})}}#Be(_,J){const ee=_&&_.leaves?_.leaves.length:this.#m.slots.length;this.#m.matchCount=ee,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=_&&_.leaves?_.leaves.length:0,this.#m.groupLeaves=_&&_.leaves?_.leaves:null}#B(_,J,ee){const ne=this.#l.get(_),oe=J();return ne.computed&&ne.key===oe||(ne.result=ee(),ne.key=oe,ne.computed=!0,ne.id++,_==="flatten"&&(this.#Y=null)),ne.result}#C(_){return this.#l.get(_).id}#V(){const _=(this.#e.config||{}).hostFilter,J=_&&Y(_.active)&&_.active()?1:0,ee=this.#_("where",null),ne=ee?ee.version:0,oe=this.#gt("filter.sig",`${this.#ut()}`,()=>w({filters:this.#_("filters",null),quick:this.#_("quick",""),quickMode:this.#_("quickMode","contains")}));return`${this.#u}|${oe}|${J}|${ne}`}#ie(){const _=this.#ce();return`${this.#C("filter")}|${JSON.stringify(this.#_("sort",[]))}`+(_?`|manual:${_.version}`:"")}#ce(){const _=this.#_("rowOrder",null);return _&&Array.isArray(_.keys)?_:null}#oe(_,J){this.#p||this.#Ce();const ee=this.#p,ne=this.#Ne(),oe=J.keys.length,ie=new Float64Array(ne);for(let ae=0;ae<ne;ae++)ie[ae]=oe+ae;for(let ae=0;ae<oe;ae++){const ce=ee.get(J.keys[ae]);ce!==void 0&&(ie[ce]=ae)}return Uint32Array.from(_).sort((ae,ce)=>ie[ae]-ie[ce])}orderedKeys(){this.#p||this.#Ce();const _=this.#p,J=new Map;for(const[ae,ce]of _)J.set(ce,ae);const ee=Uint32Array.from([...J.keys()]).sort(),ne=this.#ce(),oe=ne?this.#oe(ee,ne):this.#Fe(ee),ie=new Array(oe.length);for(let ae=0;ae<oe.length;ae++)ie[ae]=J.get(oe[ae]);return ie}#ge(){const _=this.#_("pivotBy",[]).length>0?"p":"u";return`${this.#C("sort")}|${JSON.stringify(this.#_("groupBy",[]))}|${_}`}#we(){const _=this.#Xe()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#C("group")}|${JSON.stringify(this.#_("totals",[]))}|${_}${J}|${this.#c}`}#k(){return`${this.#C("group")}|${JSON.stringify(this.#_("pivotBy",[]))}`}#Se(){const J=this.#ze()||!this.#me()?this.#C("total"):"x",ee=`${this.#ut()}`,ne=this.#gt("flatten.keys",ee,()=>{const ie=this.#_("expanded",null);return ie?[...ie].sort().join(""):"*"}),oe=this.#gt("flatten.detail",ee,()=>{const ie=this.#_("detail",null);return ie&&Y(ie.signature)?ie.signature():""});return`${J}|${this.#C("pivot")}|${ne}|${oe}`}#ze(){const _=this.#_("groupBy",[]);return Array.isArray(_)&&_.length>0}stageState(){const _=[];for(const[J,ee]of this.#l){const ne=ee.result;_.push({stage:J,materialised:!!ee.computed,bytes:ne&&typeof ne.byteLength=="number"?ne.byteLength:null,rows:ne&&typeof ne.length=="number"?ne.length:null,rebuilds:ee.id})}return _}facetIndices(_){return this.#Re(_||null)}facetRows(_){const J=this.facetIndices(_),ee=[];for(let ne=0;ne<J.length;ne++){const oe=this.#je(J[ne]);oe&&ee.push(oe)}return ee}invalidateRows(){this.#h.clear(),this.#F.clear(),this.#Y=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#ue()}filteredIndices(){const _=this.#l.get("filter");if(_&&_.computed&&_.key===this.#V())return _.result||this.#ue();this.#D();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#ue()}unfilteredRows(){const _=this.#ue(),J=[];for(let ee=0;ee<_.length;ee++){const ne=this.#je(_[ee]);ne&&J.push(ne)}return J}#Re(_=null){const J=this.#ue(),ee=this.#_("filters",null),ne=_?this.#st("pruneColumn")(ee,_):ee,oe=this.#it(ne),ie=String(this.#_("quick","")||"").trim().toLowerCase(),ae=ie?U(ie,String(this.#_("quickMode","contains")||"contains")):null,ce=(this.#e.config||{}).hostFilter,de=!!(ce&&Y(ce.active)&&ce.active()),Ae=this.#_("where",null),je=!!(Ae&&Ae.active);if(!oe&&!ie&&!de&&!je)return J;let be=null;oe&&(be=this.#st("evaluateFilters")(oe,{handle:Oe=>this.#o.handle(Oe),count:this.#Ne(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:Oe=>$(this.#Ue(Oe))}));const re=new Uint32Array(J.length);let fe=0;for(let pe=0;pe<J.length;pe++){const Oe=J[pe];if(!(be&&!be[Oe])&&!(ae&&!this.#ct(Oe,ae))){if(de||je){const ve=this.#je(Oe);if(de&&!ce.passes(ve)||je&&!Ae.passes(ve.data,ve.key))continue}re[fe++]=Oe}}if(be){const pe=(this.#e.compute||{}).releaseMask;Y(pe)&&pe({pool:this.#e.pool},be)}return re.subarray(0,fe)}handleFor(_){return this.#o.handle(_)}#Fe(_){const J=this.#ce();if(J)return this.#oe(_,J);const ee=this.#_("sort",[]).filter(ie=>{const ae=this.#Ue(ie.col);return!ae||!ae.running?!0:(D(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!ee.length)return _;const ne=(this.#e.config||{}).locale;if(ee.length===1){const ie=ee[0],ae=this.#o.handle(ie.col);if(!ae)return D(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),_;const ce=this.#Ue(ie.col);return this.#st("sortColumn")(ae,_,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ne,compare:A(ce)})}const oe=[];for(const ie of ee){const ae=this.#o.handle(ie.col);if(!ae){D(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}oe.push({handle:ae,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ne,compare:A(this.#Ue(ie.col))})}return oe.length?this.#st("sortMulti")(oe.map(ie=>ie.handle),oe,_):_}#Ye(_){const J=this.#_("groupBy",[]),ee=this.#Oe();if(ee&&!J.length){const pe=p(_,ee);return this.#L=k(pe.roots,ee.declaresChildren),{roots:null,leaves:_,nodes:new Map,tree:pe}}if(this.#L=null,ee&&J.length&&D("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!J.length)return{roots:null,leaves:_,nodes:new Map};const ne=(this.#e.config||{}).timeZone,oe=[],ie=[];let ae=!1;for(const pe of J){const Oe=this.#o.handle(pe);if(!Oe){D(`source.group.${pe}`,`grouping ignores unknown column "${pe}".`);continue}oe.push(Oe);const ve=this.#Ue(pe),$e=ve&&ve.dataType;if($e&&Y($e.groupProjector)){const he=ve.typeOptions&&ve.typeOptions.timeZone||ne||void 0,ye=$e.groupProjector(ve,he);ie.push(ye||null),ye&&(ae=!0)}else ie.push(null)}if(!oe.length)return{roots:null,leaves:_,nodes:new Map};const{keys:ce,buckets:de}=this.#st("groupByColumns")(oe,_,{locale:(this.#e.config||{}).locale,project:ae?ie:void 0}),Ae=this.#_("pivotBy",[]).length>0,je=[],be=new Map;for(let pe=0;pe<de.length;pe++){const Oe=ce[pe];let ve=null;const $e=[];for(let he=0;he<Oe.length;he++){$e.push(d(Oe[he]));const ye=c($e),Se=he===Oe.length-1;let Ie=be.get(ye);if(!Ie){const we=this.#i.group({path:[...$e],column:J[he],value:Oe[he],level:he,parent:ve,expanded:Ae&&Se?!1:this.#pt(ye,{key:ye,column:J[he],value:Oe[he],level:he,path:[...$e]}),hasChildren:!(Ae&&Se)});Ie={row:we,leaves:null},be.set(ye,Ie),ve?ve.children.push(we):je.push(we)}Ie.row.leafCount+=de[pe].length,he===Oe.length-1&&(Ie.leaves=de[pe]),ve=Ie.row}}const re=this.#_("sort",[])||[],fe=(pe,Oe)=>{if(!pe||pe.length<2){if(pe)for(const ye of pe)fe(ye.children,Oe+1);return}const ve=J[Oe],$e=re.find(ye=>ye.col===ve),he=$e&&$e.dir==="desc"?-1:1;pe.sort((ye,Se)=>he*z(ye.groupValue,Se.groupValue));for(const ye of pe)fe(ye.children,Oe+1)};return fe(je,0),{roots:je,leaves:_,nodes:be,keys:ce,buckets:de}}#_e(_,J){const ee=new Map,ne=new Map,oe=ie=>{const ae=ie.physical>=0?[ie.physical]:[];for(const ce of ie.children)ae.push(...oe(ce));if(ie.children.length){const ce=this.#rt(J,Uint32Array.from(ae),null);ie.physical>=0?ee.set(ie.physical,ce):ne.set(ie.key,ce)}return ae};for(const ie of _.roots)oe(ie);return{byPhysical:ee,byKey:ne}}#Ve(_){const J=this.#Ze();if(!J.length)return this.#M=null,this.#P=null,{grand:null};const ee={id:this.#C("group"),columns:J.map(re=>re.id).join("")},ne=this.#M&&this.#M.id===ee.id&&this.#M.columns===ee.columns,oe=this.#Ke()&&ne?this.#E:null,ie=oe?J.filter(re=>oe.has(re.id)):J,ae=ne?this.#P:null,ce=this.#Xe()?null:this.#tt(),de=this.#be(J),Ae=re=>{const fe=_.nodes.get(re.key);let pe=fe&&fe.leaves?fe.leaves:null;if(re.children&&re.children.length){const $e=re.children.map(Ae);let he=0;for(const Ie of $e)he+=Ie.length;const ye=new Uint32Array(he);let Se=0;for(const Ie of $e)ye.set(Ie,Se),Se+=Ie.length;pe=ye}pe=pe||new Uint32Array(0);const Oe=ce?ce.get(re.key)||M:pe,ve=this.#at(re,oe?ie:J,Oe,de);return re.totals=oe?{...re.totals,...ve}:ve,pe};if(_.roots&&ie.length)for(const re of _.roots)Ae(re);if(this.#U=_.tree?this.#_e(_.tree,J):null,this.#M=ee,this.#E=this.#Ke()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#P=null,{grand:null};const be=ce?this.#qe():_.leaves;return this.#P=this.#We(J,be,oe,ae),{grand:this.#P}}#We(_,J,ee,ne){const oe={},ie=this.#C("group");ie!==this.#w&&(this.#St(),this.#w=ie);const ae=this.#O;this.#O=[];for(const ce of _){if(!x(ce))continue;const de=this.#o.handle(ce.id);if(!de)continue;const Ae=R(ce,"grand");if(!u(Ae,de)){if(ee&&!ee.has(ce.id)&&ne&&ce.id in ne){oe[ce.id]=ne[ce.id];continue}oe[ce.id]=this.#rt([ce],J,null,"grand")[ce.id];continue}let je=this.#j.get(ce.id);if((!je||je.fn!==Ae)&&(je=new n(Ae),this.#j.set(ce.id,je)),je.valid){let be=!0;for(const re of ae)if(re.colId===ce.id&&!je.update(re.before,re.after)){be=!1;break}if(be){oe[ce.id]=je.value();continue}je.invalidate()}je.seedColumn(de.values,a(de),J),oe[ce.id]=je.valid?je.value():this.#rt([ce],J,null,"grand")[ce.id]}return oe}#be(_){const J=this.#C("group");J!==this.#T&&(this.#v.clear(),this.#T=J);const ee=new Map;for(const oe of _){if(!x(oe))continue;const ie=this.#o.handle(oe.id),ae=R(oe,"group");u(ae,ie)&&ee.set(oe.id,{fn:ae})}if(!ee.size)return this.#S.length=0,ee;const ne=this.#S;this.#S=[];for(const oe of ne){const{beforeKeys:ie,afterKeys:ae,colDeltas:ce}=oe,de=ie.length?new Set(ie):null,Ae=ae.length?new Set(ae):null;for(const{colId:je,before:be,after:re}of ce)if(ee.has(je)){for(const fe of ie)Ae&&Ae.has(fe)||this.#ke(fe,je,be,null);for(const fe of ae)de&&de.has(fe)||this.#ke(fe,je,null,re);for(const fe of ie)Ae&&!Ae.has(fe)||this.#ke(fe,je,be,re)}}return ee}#ke(_,J,ee,ne){const oe=this.#v.get(_),ie=oe&&oe.get(J);!ie||!ie.valid||ie.update(ee,ne)||ie.invalidate()}#at(_,J,ee,ne){if(!ne||!ne.size)return this.#rt(J,ee,_);const oe={};let ie=null,ae=this.#v.get(_.key);for(const ce of J){const de=ne.get(ce.id);if(!de){(ie||(ie=[])).push(ce);continue}const Ae=this.#o.handle(ce.id);if(!Ae)continue;ae||(ae=new Map,this.#v.set(_.key,ae));let je=ae.get(ce.id);if((!je||je.fn!==de.fn)&&(je=new n(de.fn),ae.set(ce.id,je)),je.valid||je.seedColumn(Ae.values,a(Ae),ee),je.valid){oe[ce.id]=je.value();continue}(ie||(ie=[])).push(ce)}return ie&&Object.assign(oe,this.#rt(ie,ee,_)),oe}#Tt(_,J,ee,ne){const oe=!this.#Xe()||this.#Ot(J);for(const ie of _){const ae=ie.getValue;if(!Y(ae))continue;const ce=ae(ee),de=ae(ne);Object.is(ce,de)||(this.#E&&this.#E.add(ie.id),oe&&this.#j.has(ie.id)&&this.#O.push({colId:ie.id,before:ce,after:de}))}}#kt(){const _=this.#_("groupBy",[]),J=[];for(const ee of _){const ne=this.#Ue(ee);ne&&J.push(ne)}return J}#ee(_,J){const ee=new Array(_.length);for(let ne=0;ne<_.length;ne++){const oe=_[ne].getValue;ee[ne]=d(Y(oe)?oe(J):void 0)}return ee}#lt(_,J,ee,ne,oe){if(this.#Xe()&&!this.#Ot(ee))return;const ie=l(this.#ee(_,ne)),ae=l(this.#ee(_,oe)),ce=ie.length!==ae.length||ie.some((Ae,je)=>Ae!==ae[je]),de=[];for(const Ae of J){const je=Ae.getValue;if(!Y(je))continue;const be=je(ne),re=je(oe);!ce&&Object.is(be,re)||de.push({colId:Ae.id,before:be,after:re})}!de.length&&!ce||this.#S.push({beforeKeys:ie,afterKeys:ae,colDeltas:de})}#Ot(_){const J=this.#l.get("filter"),ee=J&&J.computed?J.result:null;if(!ee)return!0;let ne=0,oe=ee.length-1;for(;ne<=oe;){const ie=ne+oe>>1,ae=ee[ie];if(ae===_)return!0;ae<_?ne=ie+1:oe=ie-1}return!1}#Xe(){return(this.#e.config||{}).totalFilteredOnly!==!1}#et(_){return this.#Xe()?_:this.#qe().length}#qe(){return(!this.#N||this.#N.version!==this.#u)&&(this.#N={version:this.#u,indices:this.#ue()}),this.#N.indices}#tt(){const _=this.#_("groupBy",[]),J=`${this.#u}|${JSON.stringify(_)}`;if(this.#R&&this.#R.key===J)return this.#R.map;const ee=new Map,ne=[];for(const oe of _){const ie=this.#o.handle(oe);ie&&ne.push(ie)}if(ne.length){const oe=this.#qe(),{keys:ie,buckets:ae}=this.#st("groupByColumns")(ne,oe,{locale:(this.#e.config||{}).locale}),ce=new Map;for(let de=0;de<ae.length;de++){const Ae=ie[de],je=[];for(let be=0;be<Ae.length;be++){je.push(d(Ae[be]));const re=c(je);let fe=ce.get(re);fe||(fe=[],ce.set(re,fe));for(let pe=0;pe<ae[de].length;pe++)fe.push(ae[de][pe])}}for(const[de,Ae]of ce)ee.set(de,Uint32Array.from(Ae))}return this.#R={key:J,map:ee},ee}#Ke(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#nt(){this.#St(),this.#A(),this.#E=null,this.#M=null,this.#P=null}#St(){this.#j.clear(),this.#O.length=0,this.#w=-1}#A(){this.#v.clear(),this.#S.length=0,this.#T=-1}#jt(_){const J=this.#_("pivotBy",[]);if(!J.length)return this.#fe=null,null;const ee=(this.#e.compute||{}).pivot;if(!Y(ee))return D("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#fe=null,null;const ne=J.map(ie=>this.#o.handle(ie)).filter(Boolean),oe=this.#Ze();return this.#fe=ee(ne,_.leaves,{groups:_.keys&&_.buckets?{keys:_.keys,buckets:_.buckets}:null,totals:oe.map(ie=>ie.id),handle:ie=>this.#o.handle(ie),totalOf:ie=>R(oe.find(ae=>ae.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#fe}#Ge(_){const J=this.#l.get("total").result,ee=!!(this.#e.config||{}).groupFooter,ne=this.#Ie();if(_.tree)return this.#At(_,J,ne);if(!_.roots&&!ne){if(J&&J.grand&&!this.#me()){const Ae=this.#i.grandTotal(J.grand,this.#et(_.leaves.length));if(this.#K===_.leaves&&Array.isArray(this.#I))this.#I[this.#I.length-1]=Ae;else{const je=Array.from(_.leaves);je.push(Ae),this.#I=je,this.#K=_.leaves}this.#z=[{at:this.#I.length-1}]}else this.#K=null,this.#I=_.leaves,this.#z=W;return this.#H=W,this.#I}const oe=[],ie=[],ae=[],ce=Ae=>{if(oe.push(Ae),!ne)return;const je=this.#je(Ae);!je||!ne.isOpen(je.key)||(je.master=!0,je.expanded=!0,ae.push({at:oe.length}),oe.push(this.#i.detail(je,ne.heightOf(je))))};if(!_.roots){for(let Ae=0;Ae<_.leaves.length;Ae++)ce(_.leaves[Ae]);return J&&J.grand&&!this.#me()&&(ae.push({at:oe.length}),oe.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#K=null,this.#H=W,this.#z=ae.length?ae:W,this.#I=oe,oe}const de=(Ae,je,be)=>{if(Ae.expanded=Ae.hasChildren===!1?!1:this.#pt(Ae.key,{key:Ae.key,column:Ae.groupColumn,value:Ae.groupValue,level:Ae.level,path:Ae.groupPath}),Ae.posinset=je+1,Ae.setsize=be,ie.push({at:oe.length,row:Ae}),ae.push({at:oe.length}),oe.push(Ae),!!Ae.expanded){if(Ae.children&&Ae.children.length)for(let re=0;re<Ae.children.length;re++)de(Ae.children[re],re,Ae.children.length);else{const re=_.nodes.get(Ae.key),fe=re&&re.leaves?re.leaves:null;if(fe)for(let pe=0;pe<fe.length;pe++)ce(fe[pe])}ee&&Ae.totals&&(ae.push({at:oe.length}),oe.push(this.#i.footer(Ae)))}};for(let Ae=0;Ae<_.roots.length;Ae++)de(_.roots[Ae],Ae,_.roots.length);return J&&J.grand&&!this.#me()&&(ae.push({at:oe.length}),oe.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#H=ie,this.#z=ae,this.#I=oe,oe}#ue(){const _=this.#e.store;if(_&&Y(_.liveIndices))return _.liveIndices();const J=new Uint32Array(this.#n.length);let ee=0;for(let ne=0;ne<this.#n.length;ne++)this.#n[ne]!==void 0&&(J[ee++]=ne);return J.subarray(0,ee)}#Ne(){const _=this.#e.store;return _&&typeof _.physical=="number"?_.physical:this.#n.length}#ae(_){const J=this.#e.store;return J&&Y(J.source)?J.source(_):this.#n[_]}#Le(_,J=_){const ee=this.#I[_];if(typeof ee!="number")return ee.index=J,ee;const ne=this.#je(ee);return ne.index=J,ne}#je(_){let J=this.#h.get(_);J||(J=this.#i.leaf(this.#ae(_),_),this.#h.set(_,J));const ee=this.#L?this.#L.get(_):null;if(ee){J.level=ee.level,J.posinset=ee.posinset,J.setsize=ee.setsize,J.hasChildren=ee.hasChildren,J.expanded=ee.hasChildren&&!ee.lazy&&this.#pt(J.key);const ne=this.#U?this.#U.byPhysical.get(_):void 0;ne?J.totals=ne:J.totals&&(J.totals=null)}else J.hasChildren&&(J.level=0,J.hasChildren=!1,J.expanded=!1,J.posinset=void 0,J.setsize=void 0);return J}#At(_,J,ee){const ne=[],oe=[],ie=ce=>{if(ce.leafCount!==void 0)return ce.leafCount;let de=ce.physical>=0?1:0;for(const Ae of ce.children)de+=ie(Ae);return ce.leafCount=de,de},ae=ce=>{const de=this.#pt(ce.key);if(ce.physical>=0){if(ne.push(ce.physical),ee&&ee.isOpen(this.#je(ce.physical).key)){const Ae=this.#je(ce.physical);oe.push({at:ne.length}),ne.push(this.#i.detail(Ae,ee.heightOf(Ae)))}}else ne.push(this.#i.group({path:[ce.key],column:null,value:ce.value,level:ce.level,parent:null,expanded:de,hasChildren:ce.children.length>0,leafCount:ie(ce),totals:this.#U?this.#U.byKey.get(ce.key):void 0}));if(de)for(const Ae of ce.children)ae(Ae)};for(const ce of _.tree.roots)ae(ce);return J&&J.grand&&!this.#me()&&(oe.push({at:ne.length}),ne.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#K=null,this.#H=W,this.#z=oe.length?oe:W,this.#I=ne,ne}#Nt(){return r(()=>this.count(),_=>this.at(_))}#ct(_,J){let ee=this.#F.get(_);if(ee===void 0){const ne=this.#ae(_),oe=this.#ot(),ie=[],ae=this.#e.columnHidden;for(const ce of oe){if(ce.quickFilter===!1||Y(ae)&&ae(ce.id))continue;const de=ce.value&&Y(ce.value.quickFilterText)?ce.value.quickFilterText({value:void 0,data:ne,row:null,column:ce,colId:ce.id,grid:null,context:this.#_("context",null)}):null,Ae=de??(Y(ce.formatValue)?ce.formatValue(Y(ce.getValue)?ce.getValue(ne):void 0):"");Ae!=null&&Ae!==""&&ie.push(String(Ae))}ee=ie.join(" ").toLowerCase(),this.#F.set(_,ee)}return J(ee)}#Ze(){const _=this.#_("totals",[]),J=_&&_.length?new Set(_):null;return this.#ot().filter(ee=>J?J.has(ee.id):!!(ee.total||ee.groupTotal||ee.grandTotal))}#rt(_,J,ee,ne="group"){const oe={},ie=(this.#e.compute||{}).total;for(const ae of _){if(!x(ae))continue;const ce=this.#o.handle(ae.id);if(!ce)continue;const de=R(ae,ne);if(de)if(Y(de)){const Ae=new Array(J.length);for(let je=0;je<J.length;je++)Ae[je]=ce.get(J[je]);oe[ae.id]=de(Ae,{row:ee,column:ae,grid:this.#e.grid||null,context:this.#_("context",null),valueAt:(je,be)=>{const re=this.#o.handle(je);return re&&be>=0&&be<J.length?re.get(J[be]):null}})}else Y(ie)&&(oe[ae.id]=ie(ce,J,de))}return oe}#it(_){if(!_)return _;const J=this.#e.config||{},ee={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return m(_,ne=>{const oe=v(ne,ee),ie=this.#Ue(oe&&oe.col),ae=ie&&ie.type==="datetime";if(oe&&oe.type)return oe.type==="datetime"&&!oe.timeZone&&ie?{...oe,timeZone:J.timeZone||void 0}:oe;if(ae)return{...oe,type:"datetime",timeZone:J.timeZone||void 0};const ce=ie&&(ie.dataType?.base||ie.type);return ce?{...oe,type:ce}:oe})}#pt(_,J){const ee=this.#_("expanded",null);return ee?Y(ee.has)?ee.has(_,J):Array.prototype.includes.call(ee,_):!0}#_(_,J){if(_==="context"||!Y(this.#e.stateVersion))return this.#Mt(_,J);const ee=this.#mt(_),ne=this.#f.get(_);if(ne&&ne.version===ee)return ne.value;const oe=this.#Mt(_,J);return this.#f.set(_,{version:ee,value:oe}),oe}#Mt(_,J){const ee=this.#e.state;if(ee&&Y(ee[_])){const ne=ee[_]();return ne??J}return J}#ut(){const _=this.#e.stateVersion;return Y(_)?_():0}#xt(){const _=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${Y(_)?_():0}|${Y(J)?J():0}`}#mt(_){return _==="totals"?this.#xt():`${this.#ut()}`}#gt(_,J,ee){if(!Y(this.#e.stateVersion))return ee();const ne=this.#d.get(_);if(ne&&ne.version===J)return ne.key;const oe=ee();return this.#d.set(_,{version:J,key:oe}),oe}#st(_){const J=(this.#e.compute||{})[_];return Y(J)||F(`ctx.compute.${_} is required by the memory source pipeline`),J}#ot(){const _=this.#e.columns;return _&&Y(_.all)?_.all():[]}#Ue(_){const J=this.#e.columns;return J&&Y(J.get)?J.get(_):void 0}#Qe(_,J){const ee=this.#e.emit;Y(ee)&&ee(_,J)}}}),Be("packages/core/src/source/abort.js",function(e,H){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return F}});class te extends Error{constructor(Y,B="superseded"){super(`[lattice] request ${Y?`"${Y}" `:""}${B}`),this.name="SupersededError",this.superseded=!0,this.key=Y}}class L{#e;constructor(Y,B,z,G){this.#e=Y,this.key=B,this.controller=z,this.signal=z.signal,this.seq=G}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(Y){this.signal.aborted||this.controller.abort(new te(this.key,Y)),this.#e.settle(this)}}class X{#e=new Map;#t=0;begin(Y="",B="superseded"){const z=this.#e.get(Y);z&&!z.signal.aborted&&z.controller.abort(new te(Y,B));const G=new L(this,Y,new AbortController,++this.#t);return this.#e.set(Y,G),G}tokenFor(Y){return this.#e.get(Y)}pending(Y=""){const B=this.#e.get(Y);return!!B&&!B.signal.aborted}get size(){return this.#e.size}settle(Y){this.#e.get(Y.key)===Y&&this.#e.delete(Y.key)}abort(Y="",B="superseded"){const z=this.#e.get(Y);z&&z.abort(B)}abortAll(Y="superseded"){for(const B of[...this.#e.values()])B.abort(Y);this.#e.clear()}}function D(){return new X}function F(Z){if(!Z||typeof Z!="object")return!1;const Y=Z;return Y.superseded===!0||Y.name==="AbortError"||Y.name==="SupersededError"}}),Be("packages/core/src/source/blockcache.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return D}});const te=100,L=32;class X{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class D{#e=new Map;#t;#n;#r=0;#s=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||te)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||L))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const Y=this.#e.get(Z);return!!Y&&Y.state==="pending"}loaded(Z){const Y=this.#e.get(Z);return!!Y&&Y.state==="loaded"}begin(Z,Y){let B=this.#e.get(Z);return B||(B=new X(Z)),B.state="pending",B.token=Y,B.error=null,this.#i(Z,B),B}fill(Z,Y){const B=this.#e.get(Z)||new X(Z);B.rows=Y,B.state="loaded",B.token=null,this.#i(Z,B)}failed(Z,Y){const B=this.#e.get(Z)||new X(Z);B.state="error",B.error=Y,B.token=null,this.#i(Z,B)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const Y=this.blockOf(Z),B=this.#e.get(Y);if(!(!B||B.state!=="loaded"||!B.rows))return this.#i(Y,B),B.rows[Z-Y*this.#t]}rowLoaded(Z){const Y=this.blockOf(Z),B=this.#e.get(Y);return!!B&&B.state==="loaded"&&!!B.rows&&Z-Y*this.#t<B.rows.length}erroredAt(Z){const Y=this.#e.get(this.blockOf(Z));return!!Y&&Y.state==="error"}loadedExtent(){let Z=0;for(const Y of this.#e.values()){if(Y.state!=="loaded"||!Y.rows)continue;const B=Y.id*this.#t+Y.rows.length;B>Z&&(Z=B)}return Z}fillOf(Z){const Y=this.#e.get(Z);return Y&&Y.state==="loaded"&&Y.rows?Y.rows.length:null}protect(Z,Y){this.#r=this.blockOf(Math.max(0,Z)),this.#s=this.blockOf(Math.max(0,Y))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[Y,B]of this.#e){if(this.#e.size-Z.length<=this.#n)break;Y>=this.#r&&Y<=this.#s||B.state!=="pending"&&Z.push(Y)}for(const Y of Z)this.#e.delete(Y);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,Y){this.#e.delete(Z),this.#e.set(Z,Y)}}}),Be("packages/core/src/source/pagewindow.js",function(e,H){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return te}});function te(L,X,D,F){const Z=Math.floor(Number(L)||0);if(Z<=0)return null;const Y=Math.max(0,Math.floor(Number(X)||0)),B=Math.max(0,Math.floor(Number(D)||0));if(F){const z=Math.max(1,Math.ceil(B/Z)),G=Math.min(Y,z-1),P=G*Z;return{page:G,pageSize:Z,offset:P,length:Math.max(0,Math.min(Z,B-P)),pageCount:z,total:B}}return{page:Y,pageSize:Z,offset:Y*Z,length:Z,pageCount:Math.max(Y+2,Math.ceil(B/Z)),total:null}}}),Be("packages/core/src/source/paged.js",function(e,H){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return w}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/warn.js").warnOnce,B=H("packages/core/src/internal/schedule.js").settleDebounce,z=H("packages/core/src/source/abort.js"),G=z.createAbortScope,P=z.isAbortError,O=H("packages/core/src/source/blockcache.js"),b=O.BlockCache,c=O.DEFAULT_PAGE_SIZE,d=O.DEFAULT_MAX_CACHED_PAGES,r=H("packages/core/src/source/rows.js").createRowFactory,t=H("packages/core/src/source/filterwire.js"),i=t.wireFilters,s=t.querySignature,n=t.warnHostFilterNotApplied,o=H("packages/core/src/source/pagewindow.js").pageWindow,a=120;function f(m,v){return new w(m,v)}class w{mode="paged";#e;#t;#n;#r=G();#s;#i;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(v,h){this.#e=v||{mode:"paged"},this.#t=h||{},this.#n=new b({pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||d}),this.#s=r(this.#t),this.#i=new L(this.#n.pageSize*4),this.#h=B((p,g)=>this.#w(p,g),a),this.#f=this.#E(),D(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const v=this.#y();return v?v.length:this.#b()}#b(){if(this.#T(),this.#l!==null)return this.#l;const v=Math.max(this.#u,this.#n.loadedExtent());return this.#c?v:v+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const v=this.#y();if(!v){const h=this.#b();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:v.page,pageSize:v.pageSize,total:v.total,pageCount:v.pageCount,counting:v.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const v=this.#b(),h=o(this.#P("pageSize",0),this.#P("page",0),v,this.exact());if(!h)return this.#g="",null;const p=`${this.#m}:${h.offset}:${h.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,h.length>0)){const g=h.offset+h.length-1;this.#d={start:h.offset,end:g},this.#w(h.offset,g)}return h}at(v){const h=this.#y();if(h){if(v<0||v>=h.length)return;const p=this.#j(h.offset+v);return p&&(p.index=v),p}return this.#j(v)}#j(v){if(v<0||v>=this.#b())return;const h=this.#i.get(v);if(h&&(h.data!==null||!this.#n.rowLoaded(v)))return h;const p=this.#n.rowAt(v);if(p===void 0){const k=this.#s.skeleton(v,0,this.#n.erroredAt(v));return this.#i.set(v,k),k}const g=this.#s.leaf(p,v);return g.index=v,this.#i.set(v,g),this.#o.set(g.key,v),g}byKey(v){const h=this.#o.get(v);return h===void 0?void 0:this.#j(h)}loaded(v){const h=this.#y();return h?v>=0&&v<h.length&&this.#n.rowLoaded(h.offset+v):this.#n.rowLoaded(v)}loadedCount(){this.#T();let v=0;for(const h of this.#n.ids()){if(!this.#n.loaded(h))continue;const p=this.#n.fillOf(h);typeof p=="number"&&(v+=p)}return v}residentRows(){this.#T();const v=this.#y(),h=v?v.offset:0,p=v?v.offset+v.length:1/0,g=[],k=this.#n.ids().sort((y,T)=>y-T);for(const y of k){if(!this.#n.loaded(y))continue;const{start:T}=this.#n.rangeOf(y),j=this.#n.fillOf(y)||0;for(let N=T;N<T+j;N++){if(N<h||N>=p)continue;const W=this.#i.peek(N);if(W&&W.data!==null&&W.data!==void 0){g.push(W);continue}const R=this.#n.rowAt(N);if(R===void 0)continue;const x=this.#s.leaf(R,N);x.index=N,this.#i.set(N,x),this.#o.set(x.key,N),g.push(x)}}return g}hint(v,h){if(this.#p)return;const p=this.#T();let g=Math.max(0,Math.floor(v)),k=Math.max(g,Math.floor(h));const y=this.#y();if(y){if(y.length===0)return;g=y.offset,k=y.offset+y.length-1}this.#d={start:g,end:k},this.#n.protect(g,k);for(const T of this.#n.evict())this.#v(T);this.#h(g,k),p&&this.#h.flush()}#w(v,h){if(this.#p)return;this.#n.protect(v,h);const p=this.#n.blockOf(v),g=this.#n.blockOf(h);for(let k=p;k<=g&&!(this.#l!==null&&k*this.#n.pageSize>=this.#l);k++)this.#n.has(k)||this.#O(k)}apply(v){const h={added:[],updated:[],removed:[]};if(!v)return h;if(v.update)for(const p of v.update){const g=this.#s.keyOf(p,-1),k=this.#o.get(g);if(k===void 0)continue;const y=this.#s.leaf(p,k);y.index=k,this.#i.set(k,y),h.updated.push(y)}return(v.add&&v.add.length||v.remove&&v.remove.length)&&this.reload(),h}reload(v){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#O(v){if(!D(this.#e.fetch))return;const h=this.#r.begin(`block:${v}`);this.#n.begin(v,h);const{start:p,end:g}=this.#n.rangeOf(v),k=this.#f;try{const y=await this.#e.fetch({range:{start:p,end:g},sort:this.#P("sort",[]),filters:i(this.#P("filters",null),this.#M()),quick:this.#P("quick","")||void 0,context:this.#P("context",null),signal:h.signal});if(!h.current||k!==this.#f||this.#p)return;h.settle();const T=y&&y.rows||[];this.#n.fill(v,T);for(let N=0;N<T.length;N++)this.#i.delete(p+N);const j=y&&typeof y.total=="number"?y.total:y&&typeof y.count=="number"?y.count:null;j!==null?(this.#l=j,this.#c=!0):T.length<this.#n.pageSize?(this.#c=!0,this.#l=p+T.length):this.#u=Math.max(this.#u,p+T.length),this.#N("model:changed",{reason:"page",block:v,from:p,to:p+T.length}),this.#N("rows:changed",{companion:!0,reason:"page",block:v,from:p,to:p+T.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#N("source:total",{total:this.#l,groupPath:[]}))}catch(y){if(h.settle(),P(y))return;this.#n.failed(v,y);for(let T=p;T<g;T++)this.#i.delete(T);this.#N("model:changed",{reason:"page-error",block:v,range:{start:p,end:g}}),this.#N("source:error",{error:y,block:v,range:{start:p,end:g}})}}#v(v){const{start:h,end:p}=this.#n.rangeOf(v);for(let g=h;g<p;g++){const k=this.#i.peek(g);k&&this.#o.delete(k.key),this.#i.delete(g)}}#T(){const v=this.#E();return v===this.#f?!1:(this.#f=v,this.#S("query"),!0)}#S(v){this.#r.abortAll(v),this.#n.clear(),this.#i.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#N("model:changed",{reason:v})}#E(){return s({filters:this.#P("filters",null),sort:this.#P("sort",[]),quick:this.#P("quick",""),context:this.#P("context",null)})}#M(){const v=this.#t.config||{};return{tz:v.timeZone,weekStartsOn:v.weekStartsOn}}#P(v,h){const p=this.#t.state;if(p&&D(p[v])){const g=p[v]();return g??h}return h}#N(v,h){const p=this.#t.emit;D(p)&&p(v,h)}}}),Be("packages/core/src/source/aggregates.js",function(e,H){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return z}});const te=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function L(){const G=new Set;for(const[P,O]of Object.entries(te))O.pushable&&G.add(P);return G}function X(G,P,O){let b=G.split("%c").join(P);return O!==void 0&&(b=b.split("%w").join(O)),b}function D(G){const P=G||{},O=P.default==="engine"||P.default==="engine-if-identical"?P.default:"client",b={};if(P.overrides&&typeof P.overrides=="object")for(const[c,d]of Object.entries(P.overrides))(d==="engine"||d==="client")&&(b[c]=d);return{default:O,overrides:b}}function F(G,P){const O=te[G];if(!O||!O.pushable)return"client";const b=P.overrides[G];return b==="engine"||b==="client"?b:P.default==="client"?"client":P.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function Z(G,P){const O=D(P),b=[],c=[];for(const d of G||[]){const l=te[d.fn],r=F(d.fn,O),t={id:d.id,col:d.col,fn:d.fn,class:l?l.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),r==="engine"?b.push(t):(t.reason=l&&!l.pushable?l.note||"the engine cannot express this stat":"client by config",c.push(t))}return{engine:b,client:c,config:O}}const Y=/^[A-Za-z_][A-Za-z0-9_$]*$/;function B(G,P=[]){return(G||[]).every(b=>{if(typeof b=="string")return Y.test(b);if(!b||typeof b!="object")return!1;const c=b;return Array.isArray(P)&&P.includes(c.bucket)&&typeof c.col=="string"&&Y.test(c.col)&&typeof c.size=="number"&&Number.isFinite(c.size)&&c.size>0})}function z(){return Object.entries(te).map(([G,P])=>({stat:G,class:P.class,sql:P.sql?X(P.sql,"col",P.twoColumn?"weight":void 0):"",note:P.note||(P.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Be("packages/core/src/source/pushdown.js",function(e,H){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return q}});const L=H("packages/core/src/internal/compare.js").defaultCompare,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/merge.js").toArray,B=H("packages/core/src/internal/warn.js").warnOnce,z=H("packages/core/src/source/filterwire.js"),G=z.isGroup,P=z.warnWherePageRelative,O=z.warnWhereOverThreshold,b=z.wireFilters,c=H("packages/core/src/source/aggregates.js"),d=c.resolveAggregatePlan,l=c.groupKeysPushable,r=c.STAT_PUSHDOWN,i=H("packages/core/src/source/abort.js").SupersededError,s=1e3;function n(_){const J=_&&_.signal;if(!J||!J.aborted)return;const ee=J.reason;throw ee instanceof Error?ee:new i("","superseded before it was sent")}const u=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function o(_){if(!_||typeof _!="object")return!1;const J=_.returning==="row"||_.returning==="key"?_.returning:"none";return{append:_.append===!0,update:_.update===!0,delete:_.delete===!0,returning:J}}function a(_,J){if(!_||typeof J!="string")return;if(!J.includes("."))return _[J];let ee=_;for(const ne of J.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[ne]}return ee}function f(_){if(_===!0)return!0;if(!_||typeof _!="object")return!1;const J=_;return J.enabled===!1?!1:J.enabled===!0||D(J.commit)}function w(_){const J={...u,..._||{}};return J.operators=new Set(J.operators||[]),J.mutate=o(J.mutate),J}function m(_,J){return!_||!_.op||!J.operators.size?!1:J.operators.has(_.op)}function v(_,J){if(!_)return{pushed:null,residual:null};if(!J.filter)return{pushed:null,residual:_};if(J.filter==="term"){if(G(_)){const ie=_.conditions||[];if(String(_.op)!=="and")return{pushed:null,residual:_};const ae=ie.findIndex(de=>!G(de)&&m(de,J));if(ae<0)return{pushed:null,residual:_};const ce=ie.filter((de,Ae)=>Ae!==ae);return{pushed:ie[ae],residual:ce.length?{op:"and",conditions:ce}:null}}return m(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_}}if(!G(_))return m(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_};if(String(_.op)!=="and")return(_.conditions||[]).every(ae=>G(ae)?v(ae,J).residual===null:m(ae,J))?{pushed:_,residual:null}:{pushed:null,residual:_};const ee=[],ne=[];for(const ie of _.conditions||[]){if(G(ie)){if(J.filter==="flat"){ne.push(ie);continue}const ae=v(ie,J);ae.pushed&&ee.push(ae.pushed),ae.residual&&ne.push(ae.residual);continue}(m(ie,J)?ee:ne).push(ie)}const oe=ie=>ie.length===0?null:ie.length===1?ie[0]:{op:"and",conditions:ie};return{pushed:oe(ee),residual:oe(ne)}}const h="__lattice_leaves";function p(_){return _.aggregates?_.aggregates instanceof Set?_.aggregates:new Set(Z(_.aggregates)):new Set}function g(_){const J=p(_);return J.size?J.has("count")?_.filter!=="tree"||!_.operators||!_.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function k(_,J,ee,ne,oe,ie,ae){const ce=Array.isArray(_.groupBy)?_.groupBy:[],de=Array.isArray(_.groupPath)?_.groupPath:[],Ae=Array.isArray(_.groupValues)?_.groupValues:null;if(!J.group){const je=g(J);if(je)return je}return l(ce)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ne?oe?ie?"a host `where` predicate can only run in the browser, over rows the engine grouped":ae?"fullDataset holds the whole matching set, so the grid groups it itself":!Ae||Ae.length!==de.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const y="pushdown:pivot-unsupported",T="pushdown:group-unsupported",j=Symbol("lattice.remote.ungroupedLevel");function N(_,J,ee,ne,oe,ie){const ae=Array.isArray(_.pivotBy)?_.pivotBy:[],ce=Array.isArray(_.groupBy)?_.groupBy:[],de=Array.isArray(_.groupPath)?_.groupPath:[],Ae=Array.isArray(_.groupValues)?_.groupValues:null;return J.pivot?l(ae)?ce.length&&!l(ce)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ne?oe?ie?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!Ae||Ae.length!==de.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function W(_,J,ee=!1){const ne=v(_.filters||null,J),oe=[];ne.residual&&oe.push("filter");const ie=_.sort||[],ae=ie.length===0||J.sort==="multi"&&ie.length>=1||J.sort==="single"&&ie.length===1;!ae&&ie.length&&oe.push("sort");const ce=_.quick?String(_.quick):"",de=!ce||!!J.quick;de||oe.push("quick");const Ae=_.where&&_.where.active?_.where:null;Ae&&oe.push("where");const je={filters:ne.residual,sort:ae?null:ie,quick:de?"":ce,where:Ae},be=!!ee,re=Array.isArray(_.groupBy)&&_.groupBy.length>0,fe=re?k(_,J,ne,ae,de,Ae,be):"",pe=_.pivotMode!==!1&&Array.isArray(_.pivotBy)&&_.pivotBy.length>0,Oe=pe?N(_,J,ne,ae,de,Ae):"",ve=pe&&Oe==="";pe&&!ve&&oe.push("pivot");const $e=pe?ve&&re:re&&fe==="";re&&!pe&&!$e&&oe.push("group");const he=($e||ve)&&Array.isArray(_.groupValues)?_.groupValues.length:0,ye=$e||pe?!1:be||!!(je.filters||je.sort||je.quick||je.where)||!J.range;return{pushed:{..._,filters:ne.pushed,sort:ae?ie:[],quick:de?ce:"",range:ye?null:_.range},residual:je,needsAll:ye,unpushed:oe,full:be,grouped:$e,groupLevel:he,groupReason:pe?"":fe,pivoted:ve,pivotReason:Oe}}function R(_){const J=Array.isArray(_.totals)?_.totals:[],ee=_.totalFns&&typeof _.totalFns=="object"?_.totalFns:{},ne=[],oe=[];for(const ie of J){const ae=String(ie),ce=typeof ee[ae]=="string"?ee[ae]:null,de=ce?r[ce]:null;ce?!de||!de.pushable||!de.sql?oe.push({id:ae,fn:ce,class:de?de.class:"fallback",reason:de&&de.note?de.note:`the pushdown map cannot express "${ce}"`}):de.twoColumn?oe.push({id:ae,fn:ce,class:de.class,reason:`"${ce}" reduces two columns, and a grouped request carries no weight column`}):ne.push({id:ae,col:ae,fn:ce,class:de.class}):oe.push({id:ae,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ne,client:oe}}const x=Object.freeze({items:_=>_==null?[]:Array.isArray(_)?_:[_]});function A(_,J,ee){if(!J)return _;let ne=_;if(J.filters&&D(ee.evaluateFilters)){const oe=ne,ie={count:ne.length,handle:de=>({id:de,get:Ae=>a(oe[Ae],de)}),itemwise:de=>oe.some(Ae=>Array.isArray(a(Ae,de)))?x:null},ae=ee.evaluateFilters(J.filters,ie),ce=[];for(let de=0;de<ne.length;de++)ae[de]&&ce.push(ne[de]);ne=ce}if(J.where&&J.where.active&&(J.whole||P(J.where.names,"pushdown"),ne=ne.filter(oe=>J.where.passes(oe))),J.quick){const oe=J.quick.toLowerCase();ne=ne.filter(ie=>{if(!ie||typeof ie!="object")return!1;for(const ae of Object.values(ie))if(ae!=null&&String(ae).toLowerCase().includes(oe))return!0;return!1})}if(J.sort&&J.sort.length&&D(ee.sortMulti)){const oe=[...new Set(J.sort.map(de=>de.col))],ie=ne,ae=oe.map(de=>({id:de,get:Ae=>a(ie[Ae],de)})),ce=ee.sortMulti(ae,J.sort.map(de=>({col:de.col,dir:de.dir})),Uint32Array.from({length:ne.length},(de,Ae)=>Ae),{});ne=Array.from(ce,de=>ie[de])}return ne}function $(_){return JSON.stringify({filters:_.filters||null,sort:_.sort||[],quick:_.quick||"",groupBy:_.groupBy||[],groupPath:_.groupPath||[],context:_.context??null})}function I(_){if(!_||typeof _!="object")return 16;let J="";try{J=JSON.stringify(_)}catch{return 200}return J.length*2+64}function M(_){const J=_||{};return{enabled:!!J.enabled,maxRows:Number.isFinite(J.maxRows)?J.maxRows:1e6,maxBytesEstimate:Number.isFinite(J.maxBytesEstimate)?J.maxBytesEstimate:512*1024*1024}}const S=5e4;function E(_){return Number.isFinite(_)&&_>=0?_:S}function U(_){return!!_&&D(_.then)}async function K(_){if(!_||_.total!==void 0||!U(_.pendingTotal))return _;const J=await _.pendingTotal,{pendingTotal:ee,...ne}=_;return typeof J=="number"?{...ne,total:J}:ne}function q(_={}){const J=_.adapter;if(!J||!D(J.execute))return B("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{..._,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=w(J.capabilities),ne=J.capabilities&&Object.getOwnPropertyDescriptor(J.capabilities,"operators");ne&&D(ne.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(J.capabilities.operators||[]),set:()=>{}});const oe=J.name||"adapter";let ie=null;const ae=()=>D(J.ready)?(ie||(ie=Promise.resolve(J.ready()).then(()=>{Object.assign(ee,w(J.capabilities))},ke=>{throw ie=null,ke})),ie):null,ce=M(_.fullDataset),de=!!_.allowPartialResults,Ae=E(_.whereRowLimit);let je=null;const be=_.aggregates;let re=null,fe=null,pe=null,Oe=null,ve=null,$e,he=null,ye=0,Se=null;const Ie=()=>!ce.enabled||!re?null:(Se!==re.key&&(ye++,Se=re.key),{rows:re.rows,version:ye}),we=async ke=>{const Ee=ke.where&&ke.where.active?ke.where:null;if(!Ee)return{request:ke,probe:null};const{where:Ce,...Re}=ke,xe=W(Re,ee,ce.enabled);if(xe.needsAll)return{request:ke,probe:null};const ze=$(xe.pushed);let Ve=null;return(!je||je.key!==ze)&&(ee.total?(n(ke),Ve=await K(await J.execute(xe.pushed,ke)),je={key:ze,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):je={key:ze,size:null}),je.size!==null&&je.size<Ae?{request:ke,probe:null}:(O(Ee.names,oe,je.size,Ae),{request:Re,probe:Ve})},Fe=async(ke,Ee)=>{he=null;const Ce=R(ke.pushed);pe={engine:Ce.engine,client:Ce.client,groupBy:ke.pushed.groupBy},Ce.client.length&&B(`source.pushdown.group.totals.${oe}.${Ce.client.map(ze=>ze.id).join(".")}`,`the ${oe} adapter cannot compute the group subtotal for ${Ce.client.map(ze=>`"${ze.id}" (${ze.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Re=await J.executeGroupLevel(ke.pushed,Ce.engine,Ee)||{};let xe=Re.rows||[];return!ee.range&&Ee.range&&(xe=xe.slice(Ee.range.start,Ee.range.end)),it(Re),Re.total===void 0?{rows:xe}:{rows:xe,total:Re.total}},He=new Map,Ke=64,nt=async(ke,Ee)=>{he=null;const Ce=ke.pushed,Re=Ce.groupBy,xe=Array.isArray(Ce.groupValues)?Ce.groupValues:[],ze=xe.length,Ve=[...Ce.filters?[Ce.filters]:[],...Re.slice(0,ze).map((ht,ut)=>({col:ht,op:"eq",value:xe[ut]===void 0?null:xe[ut],caseSensitive:!0}))],Qe=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},Ne=Ee.range?Ee.range.start:0;if(ze>=Re.length){const ht={...Ce,filters:Qe,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ut=await K(await J.execute(ht,Ee))||{};let Tt=ut.rows||[];return!ee.range&&Ee.range&&(Tt=Tt.slice(Ee.range.start,Ee.range.end)),typeof ut.total=="number"?{rows:Tt,total:ut.total}:{rows:Tt}}const Ge=Re[ze],qe=R(Ce),Je=p(ee),Ze=qe.engine.filter(ht=>Je.has(ht.fn)),lt=[...qe.engine.filter(ht=>!Je.has(ht.fn)).map(ht=>({id:ht.id,fn:ht.fn,class:ht.class,reason:`the ${oe} adapter does not compute "${ht.fn}"`})),...qe.client];pe={engine:Ze,client:lt,groupBy:Re},lt.length&&B(`source.pushdown.group.totals.${oe}.${lt.map(ht=>ht.id).join(".")}`,`the ${oe} adapter cannot compute the group subtotal for ${lt.map(ht=>`"${ht.id}" (${ht.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const ot=[...Ze.map(ht=>({id:ht.id,col:ht.col,fn:ht.fn})),{id:h,col:Ge,fn:"count"}],st={...Ce,filters:Qe,range:null},Ot=JSON.stringify([$(st),xe,Ge,ot]);let At=Ne>0?He.get(Ot):void 0;if(!At){for(At=Promise.resolve(J.executeGroupedAggregates(st,[Ge],ot)),He.delete(Ot),He.set(Ot,At);He.size>Ke;)He.delete(He.keys().next().value);At.catch(()=>{He.get(Ot)===At&&He.delete(Ot)})}const Rt=await At||[];n(Ee);const We=ht=>{const ut={};for(const Tt of Ze)ut[Tt.id]=ht?ht[Tt.id]:void 0;return ut},gt=(Ce.sort||[]).find(ht=>ht&&ht.col===Ge),ct=gt&&gt.dir==="desc"?-1:1,bt=Rt.filter(ht=>ht&&ht.level===1).map(ht=>({[Ge]:ht.keys[0]===void 0?null:ht.keys[0],leafCount:Number(ht.values&&ht.values[h])||0,totals:We(ht.values)})).sort((ht,ut)=>ct*L(ht[Ge],ut[Ge]));if(ze===0){const ht=Rt.find(Tt=>Tt&&Tt.level===0),ut=ht?Number(ht.values&&ht.values[h]):NaN;it({matchCount:Number.isFinite(ut)?ut:bt.reduce((Tt,Ht)=>Tt+Ht.leafCount,0),...ht?{grand:We(ht.values)}:{}})}const Et=Ee.range?Ee.range.end:bt.length;return{rows:bt.slice(Ne,Et),total:bt.length}},it=ke=>{typeof ke.matchCount=="number"&&(Oe=ke.matchCount,ve=ke.grand?{totals:ke.grand,leafCount:ke.matchCount}:null,$e===void 0&&D(J.unfilteredCount)&&($e=null,Promise.resolve(J.unfilteredCount()).then(Ee=>{$e=typeof Ee=="number"?Ee:null}).catch(Ee=>{B(`source.pushdown.group.unfiltered.${oe}`,`the ${oe} adapter could not count the unfiltered set (${Ee&&Ee.message?Ee.message:Ee}), so "N of M" falls back to the display count for its denominator.`)})))},mt=async(ke,Ee)=>{he=null;const Ce=R(ke.pushed);pe={engine:Ce.engine,client:Ce.client,groupBy:ke.pushed.groupBy,pivotBy:ke.pushed.pivotBy},Ce.client.length&&B(`source.pushdown.pivot.totals.${oe}.${Ce.client.map(Qe=>Qe.id).join(".")}`,`the ${oe} adapter cannot compute the pivot cells for ${Ce.client.map(Qe=>`"${Qe.id}" (${Qe.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Re=await J.executePivotLevel(ke.pushed,Ce.engine,Ee)||{};let xe=Re.rows||[];!ee.range&&Ee.range&&(xe=xe.slice(Ee.range.start,Ee.range.end)),it(Re);const ze=Re.pivot&&typeof Re.pivot=="object"?Re.pivot:{},Ve={cells:Array.isArray(ze.cells)?ze.cells:[],...Array.isArray(ze.axis)?{axis:ze.axis}:{}};return Re.total===void 0?{rows:xe,pivot:Ve}:{rows:xe,total:Re.total,pivot:Ve}},kt=ke=>{B(`source.pushdown.pivot.${oe}.${ke}`,`pushdown:pivot-unsupported: the ${oe} adapter cannot pivot this query because ${ke}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Ee=new Error(`[lattice] ${y}: the ${oe} adapter cannot pivot this query because ${ke}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Ee.code=y,Ee.reason=ke,Ee},St=(ke,Ee)=>{const Ce={key:Ee,state:"pending",value:null};return he=Ce,ke.then(Re=>(he===Ce&&(he={key:Ee,state:"settled",value:typeof Re=="number"?Re:null}),Re),Re=>{throw he===Ce&&(he={key:Ee,state:"failed",value:null}),Re})};let Pt=0,Nt=[];const Ft=()=>Pt===0?null:new Promise(ke=>{const Ee=setTimeout(ke,s);Nt.push(()=>{clearTimeout(Ee),ke()})});let Lt;const Ut=async ke=>{const Ee=ae();Ee&&await Ee;const Re=ke&&ke.pivotMode!==!1&&Array.isArray(ke.pivotBy)&&ke.pivotBy.length>0?{request:ke,probe:null}:await we(ke);n(ke);let xe=W(Re.request,ee,ce.enabled);if(ee.group&&xe.grouped&&!xe.pivoted&&!D(J.executeGroupLevel)&&(B(`source.pushdown.group.method.${oe}`,`the ${oe} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),xe=W(Re.request,{...ee,group:!1,aggregates:null},ce.enabled)),xe.pivoted&&!D(J.executePivotLevel)&&(xe=W(Re.request,{...ee,pivot:!1},ce.enabled),xe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),xe.grouped&&!xe.pivoted&&!ee.group&&!D(J.executeGroupedAggregates)&&(B(`source.pushdown.group.aggregates.method.${oe}`,`the ${oe} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),xe=W(Re.request,{...ee,aggregates:null},ce.enabled)),fe=xe,xe.pivoted)return mt(xe,ke);if(xe.pivotReason&&kt(xe.pivotReason),xe.grouped)return ee.group?Fe(xe,ke):nt(xe,ke);const Ve=!!xe.groupReason&&!xe.full;Ve?B(`source.pushdown.group-unsupported.${oe}.${xe.groupReason}`,`pushdown:group-unsupported: the ${oe} adapter was not asked to group this query because ${xe.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):xe.groupReason&&B(`source.pushdown.group.${oe}.${xe.groupReason}`,`the ${oe} adapter was not asked to group this query because ${xe.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const Qe=ot=>Ve?{...ot,[j]:!0}:ot;if(!xe.needsAll){const ot=Re.probe||await J.execute(xe.pushed,ke),st=ot.rows||[];return U(ot.pendingTotal)&&ot.total===void 0?Qe({rows:st,pendingTotal:St(ot.pendingTotal,$(xe.pushed))}):(he=null,!ee.total&&ot.total===void 0?Qe({rows:st}):Qe({rows:st,total:ot.total??st.length}))}xe.unpushed.length&&B(`source.pushdown.residual.${oe}.${xe.unpushed.join(".")}`,`the ${oe} adapter cannot push ${xe.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const Ne=$(xe.pushed);if(!re||re.key!==Ne){const ot=await K(await J.execute(xe.pushed,ke));he=null;const st=ot.rows||[];if(xe.full){const Ot=typeof ot.total=="number"?Math.max(ot.total,st.length):st.length;if(Ot>ce.maxRows)throw new Error(`[lattice] fullDataset refused: the ${oe} adapter's matching set is ${Ot.toLocaleString()} rows, past the configured maxRows of ${ce.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const At=st.length*I(st[0]);if(At>ce.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${oe} adapter's matching set is an estimated ${Math.round(At/(1024*1024)).toLocaleString()} MB across ${st.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ce.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof ot.total=="number"&&st.length<ot.total){const Ot=!!(xe.residual.filters||xe.residual.quick||xe.residual.sort&&xe.residual.sort.length);if(Ot&&!de)throw new Error(`[lattice] the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result, and the query has residual ${xe.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ot?B(`source.pushdown.partial.residual.${oe}`,`the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):B(`source.pushdown.partial.${oe}`,`the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}re={key:Ne,rows:st,total:typeof ot.total=="number"?ot.total:null}}let Ge=xe;if(xe.residual.where){const ot=re.total??re.rows.length;if(ot>=Ae){O(xe.residual.where.names,oe,ot,Ae);const{where:st,...Ot}=Re.request;Ge=W(Ot,ee,ce.enabled),fe=Ge}}const qe=re.total!==null&&re.rows.length>=re.total,Je=A(re.rows,{...Ge.residual,whole:qe},_.compute||{}),Ze=ke.range?ke.range.start:0,lt=ke.range?ke.range.end:Je.length;return Qe({rows:Je.slice(Ze,lt),total:Je.length})},ft=async(ke,Ee,Ce)=>{const xe=Ce&&Ce.waitForPage&&Lt&&D(Lt.pageForegroundIdle)?Lt.pageForegroundIdle():Ft();xe&&await xe;const ze=ae();ze&&await ze;const Ve=W(ke,ee,ce.enabled);fe=Ve;const Qe=d(Ee,be),Ne=Array.isArray(ke.groupBy)?ke.groupBy:[],Ge=Ne.length>0,qe=!Ve.residual.filters&&!Ve.residual.quick,Je=!Ge||l(Ne,ee.buckets);let Ze=Qe.engine,lt=Qe.client;if(ee.aggregates&&Ze.length){const At=ee.aggregates instanceof Set?ee.aggregates:new Set(Z(ee.aggregates)),Rt=Ze.filter(We=>!At.has(We.fn));Rt.length&&(Ze=Ze.filter(We=>At.has(We.fn)),lt=[...Rt.map(We=>({...We,reason:`the ${oe} adapter does not compute "${We.fn}"`})),...lt])}const ot=At=>{lt=[...Ze.map(Rt=>({...Rt,reason:At})),...lt],Ze=[]};Ze.length&&!qe?ot(Ve.residual.quick&&!Ve.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Ze.length&&!Je&&ot("a grouping key the engine cannot form forces all-client (no mixed provenance)");let st={},Ot;return Ze.length&&(D(Ge?J.executeGroupedAggregates:J.executeAggregates)?Ge?Ot=await J.executeGroupedAggregates(Ve.pushed,Ne,Ze)||[]:st=await J.executeAggregates(Ve.pushed,Ze)||{}:(B(`source.pushdown.aggregates.${oe}${Ge?".grouped":""}`,`the ${oe} adapter cannot compute ${Ge?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ot(`adapter cannot compute ${Ge?"grouped ":""}aggregates`))),pe={engine:Ze,client:lt,...Ge?{groupBy:Ne}:{}},{values:st,engine:Ze,client:lt,...Ot!==void 0?{groups:Ot}:{}}},dt=async ke=>{Pt++;try{return await Ut(ke)}finally{if(Pt--,Pt===0&&Nt.length){const Ee=Nt;Nt=[];for(const Ce of Ee)Ce()}}},wt=f(_.edit),rt=_.edit&&typeof _.edit=="object"&&D(_.edit.commit);let me=_.edit;if(wt&&!rt)if(ee.mutate&&ee.mutate.update){const ke=Ee=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${oe} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ce={kind:"update",key:String(Ee.key),patch:{[Ee.colId]:Ee.value}};return J.mutate(Ce,Ee.request||{})};me={..._.edit===!0?{}:_.edit,commit:ke}}else B(`source.pushdown.readonly.${oe}`,`edit is enabled but the ${oe} adapter declares mutate: ${ee.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const Te=wt&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(ke,Ee)=>J.mutate(ke,Ee||{})}:null,Ue=async ke=>{const Ee=ae();Ee&&await Ee;const{range:Ce,signal:Re,export:xe,...ze}=ke||{},Ve={...ze,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:W(Ve,ee,ce.enabled),signal:Re}};async function*ge(ke,Ee={}){const{plan:Ce,signal:Re}=await Ue(ke),xe=Math.max(1,Math.floor(Number(Ee.pageSize))||5e3),ze={signal:Re,stream:!0};if(!Ce.needsAll)for(let Ne=0;;Ne+=xe){n(ze);const Ge=await J.execute({...Ce.pushed,range:{start:Ne,end:Ne+xe}},ze);Ge&&U(Ge.pendingTotal)&&Ge.pendingTotal.then(null,()=>{});const qe=Ge&&Ge.rows||[];if(qe.length&&(yield qe),qe.length<xe)return}n(ze);const Ve=await K(await J.execute({...Ce.pushed,range:void 0},ze)),Qe=A(Ve&&Ve.rows||[],{...Ce.residual,whole:!0},_.compute||{});for(let Ne=0;Ne<Qe.length;Ne+=xe)yield Qe.slice(Ne,Ne+xe)}return Lt={..._,edit:me,rowMutate:Te,mode:"remote",fetch:dt,foregroundIdle:Ft,aggregate:ft,countMatching:async ke=>{const{plan:Ee,signal:Ce}=await Ue(ke);if(!Ee.needsAll&&ee.total){n({signal:Ce});const xe=await K(await J.execute({...Ee.pushed,range:{start:0,end:0}},{signal:Ce}));if(xe&&typeof xe.total=="number")return xe.total}let Re=0;for await(const xe of ge(ke))Re+=xe.length;return Re},streamMatching:ge,capabilitiesOf:w,planQuery:W,wireFilters:b,resolveAggregatePlan:ke=>d(ke,be),STAT_PUSHDOWN:r,lastPlan:()=>fe?{...fe,...pe?{aggregates:pe}:{},...he?{total:{deferred:!0,state:he.state,value:he.value}}:{}}:null,fullFrame:Ie,counts:()=>({match:Oe,total:$e??null,pending:!!he&&he.state==="pending"}),grandTotals:()=>ve},Lt}}),Be("packages/core/src/source/remote.js",function(e,H){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return $}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/warn.js").warnOnce,B=H("packages/core/src/internal/schedule.js").settleDebounce,z=H("packages/core/src/source/abort.js"),G=z.createAbortScope,P=z.isAbortError,O=H("packages/core/src/source/blockcache.js"),b=O.BlockCache,c=O.DEFAULT_PAGE_SIZE,d=O.DEFAULT_MAX_CACHED_PAGES,l=H("packages/core/src/source/rows.js"),r=l.createRowFactory,t=l.groupKey,i=H("packages/core/src/source/filterwire.js"),s=i.wireFilters,n=i.querySignature,u=i.warnHostFilterNotApplied,a=H("packages/core/src/source/pagewindow.js").pageWindow,w=H("packages/core/src/source/memory.js").MemorySource,v=H("packages/core/src/compute/handle.js").valueComparator,h=H("packages/core/src/compute/pivot.js"),p=h.pivotKey,g=h.joinPath,k=h.DEFAULT_PATH_SEPARATOR,T=H("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,j=1,N=120,W=1e3;function R(I,M,S){for(let E=0;E<Math.max(I.length,M.length);E++){const U=I[E],K=M[E],q=U==null,_=K==null;if(q||_){if(q&&_)continue;return q?1:-1}const J=S(U,K);if(J!==0)return J}return 0}function x(I,M){return new $(I,M)}class A{constructor(M,S,E,U){this.path=M,this.keyPath=U||M,this.values=[],this.level=S,this.key=t(this.keyPath),this.cache=new b(E),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class ${mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#o=G();#l;#a;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#j="";#w=null;#O=-1;constructor(M,S){this.#e=M||{mode:"remote"},this.#t=S||{},D(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#U(),this.unfilteredIndices=()=>this.#G(),this.handleFor=_=>this.#x(_),this.display=()=>this.#F(),this.grandTotalRow=()=>this.#I(),this.unfilteredRows=()=>this.#z(),this.facetIndices=_=>this.#Y(_));const E=this.#e.counts;D(E)&&(this.matchCount=()=>this.#K("match"),this.totalCount=()=>this.#K("total"));const U=this.#e.grandTotals;D(U)&&(this.grandTotalRow=()=>this.#H());const K=this.#e.foregroundIdle;D(K)&&(this.foregroundIdle=()=>this.#ye(K),this.#e.pageForegroundIdle=()=>this.#b?this.#ye(K):null);const q=this.#e;D(q.countMatching)&&D(q.streamMatching)&&(this.selectionQuery=()=>this.#fe(),this.countMatching=_=>q.countMatching(_),this.streamMatching=(_,J)=>q.streamMatching(_,J),this.loadedRows=()=>this.#ne(),this.resident=()=>this.#R()!==null),this.#n={pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||d},this.#l=r(this.#t),this.#a=new L(this.#n.pageSize*4),this.#h=B((_,J)=>this.#P(_,J),N),this.#r=new A([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#d=this.#ve(),D(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Be()}count(){const M=this.#S();return M?M.length:this.#v()}#v(){const M=this.#R();return M?M.count():(this.#q(),this.#te(this.#r))}#T(){if(this.#R())return!0;const M=S=>{if(S.count===null&&!S.complete)return!1;for(const E of S.children.values())if(this.#Ee(E.key)&&!M(E))return!1;return!0};return M(this.#r)}pageInfo(){const M=this.#S(),S=this.totalPending();if(!M){const E=this.#v();return{page:0,pageSize:0,total:this.#T()?E:null,pageCount:1,counting:S}}return{page:M.page,pageSize:M.pageSize,total:M.total,pageCount:M.pageCount,counting:S||M.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const M=this.#v(),S=a(this.#C("pageSize",0),this.#C("page",0),M,this.#T());if(!S)return this.#j="",null;const E=`${this.#y}:${S.offset}:${S.length}`;return E!==this.#j&&!this.#p&&(this.#j=E,S.length>0&&!this.#R()&&this.#P(S.offset,S.offset+S.length-1)),S}at(M){const S=this.#S();if(S){if(M<0||M>=S.length)return;const E=this.#E(S.offset+M);return E&&(E.index=M),E}return this.#E(M)}#E(M){const S=this.#R();if(S)return S.at(M);if(this.#q(),M<0||M>=this.#v())return;const E=this.#W(this.#r,M);if(!E)return;const U=this.#X(E.node,E.local);return U&&(U.index=M),U||this.#l.skeleton(M,E.node.level,E.node.cache.erroredAt(E.local))}byKey(M){const S=this.#R();if(S)return S.byKey(M);const E=this.#c.get(M);if(!E)return;const U=E.lastIndexOf(":"),K=this.#s.get(E.slice(0,U));return K&&this.#X(K,Number(E.slice(U+1)))||void 0}loaded(M){const S=this.#S();if(S){if(M<0||M>=S.length)return!1;M+=S.offset}const E=this.#R();if(E)return E.loaded(M);if(M<0||M>=this.#v())return!1;const U=this.#W(this.#r,M);return!!U&&U.node.cache.rowLoaded(U.local)}hint(M,S){if(this.#p)return;this.#b=!0;const E=this.#q();let U=Math.max(0,Math.floor(M)),K=Math.max(U,Math.floor(S));const q=this.#S();if(q){if(q.length===0)return;U=q.offset,K=q.offset+q.length-1}for(const[_,J]of this.#M(U,K)){_.cache.protect(J.min,J.max);for(const ee of _.cache.evict())this.#Me(_,ee)}this.#h(U,K),E&&this.#h.flush()}#M(M,S){const E=this.#v(),U=new Map;for(let K=M;K<=S&&K<E;K++){const q=this.#W(this.#r,K);if(!q)continue;const _=U.get(q.node);_?(_.min=Math.min(_.min,q.local),_.max=Math.max(_.max,q.local)):U.set(q.node,{min:q.local,max:q.local})}return U.size||U.set(this.#r,{min:M,max:M}),U}#P(M,S){if(!this.#p)for(const[E,U]of this.#M(M,S)){E.cache.protect(U.min,U.max);const K=E.cache.blockOf(U.min),q=E.cache.blockOf(U.max);for(let _=K;_<=q&&!(E.count!==null&&_*E.cache.pageSize>=E.count);_++)E.cache.has(_)||this.#Ie(E,_)}}apply(M){const S={added:[],updated:[],removed:[]};if(!M)return S;if(M.update)for(const E of M.update){const U=this.#c.get(this.#l.keyOf(E,-1));if(!U)continue;this.#a.delete(U);const K=U.lastIndexOf(":"),q=this.#s.get(U.slice(0,K));if(!q)continue;const _=Number(U.slice(K+1)),J=q.cache.blockOf(_);if(!q.cache.loaded(J))continue;const{start:ee}=q.cache.rangeOf(J),ne=[];for(let ie=ee;ie<ee+q.cache.pageSize;ie++){const ae=q.cache.rowAt(ie);if(ae===void 0)break;ne.push(ie===_?E:ae)}q.cache.fill(J,ne);const oe=this.#X(q,_);oe&&S.updated.push(oe)}return(M.add&&M.add.length||M.remove&&M.remove.length)&&this.reload({keepExpanded:!0}),S}reload(M){this.#o.abortAll("reload"),this.#h.cancel(),M&&M.keepExpanded===!1&&this.#i.clear(),this.#re(),this.#V("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#re(),this.#s.clear(),this.#i.clear(),this.#w&&D(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(M){this.#i.has(M)||(this.#i.add(M),this.#V("group:toggled",{key:M,expanded:!0}),this.#V("model:changed",{reason:"expand",key:M}))}collapse(M){this.#i.delete(M)&&(this.#V("group:toggled",{key:M,expanded:!1}),this.#V("model:changed",{reason:"collapse",key:M}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#q();const M=this.#f;if(!M||!M.keys.size||!this.#C("pivotBy",[]).length)return null;if(!M.result){const S=v((this.#t.config||{}).locale),E=[...M.keys.entries()].sort((K,q)=>R(K[1],q[1],S)),U=E.map(([K])=>K);M.result={keys:E.map(([,K])=>K),paths:U,fields:this.#se(U),groupPaths:[],columns:U.length*Math.max(1,this.#Te().length),values:M.cells,cells:M.cells,error:null}}return M.result}invalidateHandles(){this.#w&&(D(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),D(this.#w.invalidate)&&this.#w.invalidate("filter"))}#N(){const M=this.#e.fullFrame;return D(M)?M():null}#R(){const M=this.#N();return M?(this.#w||(this.#w=new w({mode:"memory"},this.#L())),M.version!==this.#O&&(this.#w.setRows(M.rows),this.#O=M.version),this.#w):null}#L(){const M=this.#t,S=M.state||{};return{...M,state:{...S,page:()=>0,pageSize:()=>0}}}#U(){const M=this.#R();return M?M.filteredIndices():new Uint32Array(0)}#G(){const M=this.#R();return M?M.unfilteredIndices():new Uint32Array(0)}#x(M){const S=this.#R();return S?S.handleFor(M):void 0}#F(){const M=this.#R();return M?M.display():[]}#Y(M){const S=this.#R();return S&&D(S.facetIndices)?S.facetIndices(M):new Uint32Array(0)}#I(){const M=this.#R();return M&&D(M.grandTotalRow)?M.grandTotalRow():null}#K(M){const S=this.#R();if(S){const q=M==="match"?S.matchCount:S.totalCount;if(D(q))return q.call(S)}const E=this.#e.counts,U=D(E)?E():null,K=U?U[M]:null;return typeof K=="number"?K:this.#v()}#H(){const M=this.#R();if(M&&D(M.grandTotalRow))return M.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const E=this.#e.grandTotals,U=D(E)?E():null;return!U||!U.totals?null:this.#l.grandTotal(U.totals,U.leafCount||0)}#z(){const M=this.#R();if(M&&D(M.unfilteredRows))return M.unfilteredRows();const S=[],E=this.count();for(let U=0;U<E;U++){const K=this.at(U);K&&S.push(K)}return S}#fe(){const M=this.#C("quick",""),S={protocol:j,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:s(this.#C("filters",null),this.#B()),sort:this.#C("sort",[]),context:this.#C("context",null)};M&&(S.quick=M);const E=this.#C("where",null);return E&&E.active&&(S.where=E),S}#ne(){const M=this.#C("groupBy",[]).length,S=[];for(const E of this.#s.values())if(!(E.level!==M&&!E.flat))for(const U of E.cache.ids()){if(!E.cache.loaded(U))continue;const{start:K,end:q}=E.cache.rangeOf(U);for(let _=K;_<q&&E.cache.rowLoaded(_);_++){const J=this.#X(E,_);J&&!J.group&&S.push(J)}}return S}loadedCount(){const M=this.#R();if(M){const U=M.matchCount();return typeof U=="number"?U:M.count()}this.#q();const S=this.#C("groupBy",[]).length;let E=0;for(const U of this.#s.values())if(!(U.level!==S&&!U.flat))for(const K of U.cache.ids()){if(!U.cache.loaded(K))continue;const q=U.cache.fillOf(K);typeof q=="number"&&(E+=q)}return E}residentRows(){const M=this.#R();return M?M.display():this.#C("groupBy",[]).length>0?null:(this.#q(),this.#ne())}#pe(M,S,E){const{start:U,end:K}=M.cache.rangeOf(S),q=this.#C("groupBy",[]),_=this.#C("pivotBy",[]),J=this.#C("quick",""),ee=this.#Te(),ne={protocol:j,range:{start:U,end:K},groupPath:M.path,groupValues:M.values,groupBy:q,totals:ee,totalFns:this.#le(ee),pivotBy:_,pivotMode:_.length>0,filters:s(this.#C("filters",null),this.#B()),sort:this.#C("sort",[]),context:this.#C("context",null),signal:E};J&&(ne.quick=J);const oe=this.#C("where",null);return oe&&oe.active&&(ne.where=oe),ne}async#Ie(M,S){if(!D(this.#e.fetch))return;if(!this.#m){this.#m=!0;const q=this.#g;this.#g=[],queueMicrotask(()=>{for(const _ of q)_()})}const E=this.#o.begin(`${M.key}:${S}`);M.cache.begin(S,E);const U=this.#d,{start:K}=M.cache.rangeOf(S);try{const q=await this.#e.fetch(this.#pe(M,S,E.signal));if(!E.current||U!==this.#d||this.#p)return;E.settle();const _=q&&q.rows||[];if(!!(q&&q[T])&&!M.flat){M.flat=!0,M.children.clear();for(const[oe,ie]of[...this.#c])ie.startsWith(`${M.key}:`)&&(this.#a.delete(ie),this.#c.delete(oe))}M.cache.fill(S,_),M.failed=!1;for(let oe=0;oe<_.length;oe++)this.#a.delete(`${M.key}:${K+oe}`);const ee=q&&typeof q.count=="number"?q.count:q&&typeof q.total=="number"?q.total:null,ne=q&&D(q.pendingTotal?.then)?q.pendingTotal:null;ee!==null?(M.count=ee,M.complete=!0):_.length<M.cache.pageSize?(M.count=K+_.length,M.complete=!0):ne&&(M.counting=!0,M.announced=null),q&&Array.isArray(q.pivotFields)&&this.#Pe(q.pivotFields),q&&q.pivot&&typeof q.pivot=="object"&&this.#Ce(q.pivot),this.#V("model:changed",{reason:"page",groupPath:M.path,block:S}),this.#V("rows:changed",{companion:!0,reason:"page",groupPath:M.path,block:S}),this.#me(M),ne&&this.#Oe(M,ne,U)}catch(q){if(E.settle(),P(q))return;M.cache.failed(S,q),M.failed=!0;const{end:_}=M.cache.rangeOf(S);for(let J=K;J<_;J++)this.#a.delete(`${M.key}:${J}`);this.#V("model:changed",{reason:"page-error",groupPath:M.path,block:S}),this.#V("source:error",{error:q,groupPath:M.path,block:S})}}async#Oe(M,S,E){let U;try{U=await S}catch(K){if(E!==this.#d||this.#p)return;M.counting=!1,P(K)||(M.failed=!0),P(K)||this.#V("source:error",{error:K,groupPath:M.path});return}E!==this.#d||this.#p||(M.counting=!1,typeof U=="number"&&(M.count=U,M.complete=!0,this.#me(M),this.#V("model:changed",{reason:"total",count:U,groupPath:M.path})))}#me(M){typeof M.count!="number"||!M.complete||M.announced!==M.count&&(M.announced=M.count,this.#V("source:total",{total:M.count,groupPath:M.path}))}#ye(M){if(this.#p)return null;this.#q();const S=this.#m?null:new Promise(_=>{this.#g.push(_),setTimeout(_,W)}),E=M();if(!S&&!E)return null;const U=(async()=>{S&&await S;for(let _=M();_;_=M())await _})();let K;const q=new Promise(_=>{K=setTimeout(_,W)});return Promise.race([U,q]).then(()=>clearTimeout(K))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#R())return!1;this.#q();const M=this.#r;return M.count===null&&!M.complete&&M.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Pe(M){M.length===this.#u.length&&M.every((S,E)=>S===this.#u[E])||(this.#u=M,this.#V("column:pivoted",{pivotFields:M,remote:!0}))}#de(){const M=this.#t.config||{};return M.pivot&&M.pivot.separator||k}#se(M){const S=this.#de(),E=this.#Te();if(!E.length)return M.slice();const U=[];for(const K of M)for(const q of E)U.push(`${K}${S}${q}`);return U}#Ce(M){const S=this.#de();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const E=this.#f;let U=!1;const K=_=>{const J=Array.isArray(_)?_:[_],ee=g(J,S);return E.keys.has(ee)||(E.keys.set(ee,J),U=!0),ee},q=this.#C("groupBy",[]).length>0;for(const _ of Array.isArray(M.axis)?M.axis:[])K(_);for(const _ of Array.isArray(M.cells)?M.cells:[]){if(!_||typeof _!="object")continue;const J=K(_.pivot);if(q&&!(Array.isArray(_.group)&&_.group.length))continue;const ee=g(Array.isArray(_.group)?_.group:[],S);for(const[ne,oe]of Object.entries(_.values||{}))E.cells.set(p(ee,J,ne),oe)}E.result=null,U&&this.#Pe((this.pivot()||{fields:[]}).fields)}#te(M){let S=this.#J(M);for(const E of M.children.values())this.#Ee(E.key)&&(S+=this.#te(E));return S}#J(M){if(M.count!==null)return M.count;const S=M.cache.loadedExtent();return M.complete?S:M.row&&M.row.leafCount>0?M.level>=this.#C("groupBy",[]).length?Math.max(S,M.row.leafCount):S===0?1:Math.min(S+M.cache.pageSize,Math.max(S,M.row.leafCount)):S+M.cache.pageSize}#W(M,S){let E=S,U=0;const K=[...M.children.entries()].filter(([,_])=>this.#Ee(_.key)).sort((_,J)=>_[0]-J[0]);for(const[_,J]of K){const ee=_-U+1;if(E<ee)return{node:M,local:U+E};E-=ee,U=_+1;const ne=this.#te(J);if(E<ne)return this.#W(J,E);E-=ne}const q=this.#J(M);return U+E<q?{node:M,local:U+E}:null}#X(M,S){const E=`${M.key}:${S}`,U=this.#a.get(E);if(U)return U;const K=M.cache.rowAt(S);if(K===void 0)return null;const q=this.#C("groupBy",[]);let _;if(M.level<q.length&&!M.flat){const J=q[M.level],ee=this.#f!==null&&M.level===q.length-1&&this.#C("pivotBy",[]).length>0,ne=this.#he(K,J),oe=ne==null,ie=[...M.path,oe?"":String(ne)],ae=[...M.keyPath,oe?null:String(ne)];if(_=this.#l.group({path:ie,keyPath:ae,column:J,value:ne,level:M.level,parent:M.row,leafCount:Number(K.leafCount)||0,expanded:ee?!1:this.#Ee(t(ae)),...ee?{hasChildren:!1}:{}}),_.totals=this.#D(K),_.data=K,!ee){let ce=this.#s.get(_.key);ce?ce.row=_:(ce=new A(ie,M.level+1,this.#n,ae),ce.row=_,this.#s.set(ce.key,ce)),ce.values=[...M.values,ne],M.children.set(S,ce)}}else _=this.#l.leaf(K,S,M.level,M.row);return this.#a.set(E,_),this.#c.set(_.key,E),_}#D(M){const S=M||{};if(S.totals&&typeof S.totals=="object")return S.totals;const E={};for(const U of this.#Te())Object.hasOwn(S,U)&&(E[U]=S[U]);return E}#Me(M,S){const{start:E,end:U}=M.cache.rangeOf(S);for(let K=E;K<U;K++){const q=`${M.key}:${K}`,_=this.#a.peek(q);_&&this.#c.delete(_.key),this.#a.delete(q)}}#q(){const M=this.#ve();return M===this.#d?!1:(this.#d=M,this.#o.abortAll("query"),this.#re(),this.#m=!1,this.#V("model:changed",{reason:"query"}),!0)}#re(){for(const M of this.#s.values())M.cache.clear(),M.count=null,M.complete=!1,M.announced=null,M.counting=!1,M.failed=!1,M.children.clear(),M.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#f=null}#ve(){const M=this.#C("where",null);return`${n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),groupBy:this.#C("groupBy",[]),pivotBy:this.#C("pivotBy",[]),context:this.#C("context",null)})}|${M?M.version:0}`}#Ee(M){const S=this.#C("expanded",null);return S?D(S.has)?S.has(M):Array.prototype.includes.call(S,M):this.#i.has(M)}#Te(){const M=this.#C("totals",[]);if(M&&M.length)return[...M];const S=this.#t.columns;return!S||!D(S.all)?[]:S.all().filter(E=>!!E.total).map(E=>E.id)}#le(M){const S=this.#t.columns,E={};if(!S||!D(S.get))return E;for(const U of M){const K=S.get(U);if(!K)continue;const q=K.groupTotal!=null?K.groupTotal:K.total;typeof q=="string"&&(E[U]=q)}return E}#he(M,S){const E=this.#t.columns,U=E&&D(E.get)?E.get(S):void 0;return U&&D(U.getValue)?U.getValue(M):M?.[S]}#Be(){u(this.#t)}#B(){const M=this.#t.config||{};return{tz:M.timeZone,weekStartsOn:M.weekStartsOn}}#C(M,S){const E=this.#t.state;if(E&&D(E[M])){const U=E[M]();return U??S}return S}#V(M,S){const E=this.#t.emit;D(E)&&E(M,S)}}}),Be("packages/core/src/source/gapbuffer.js",function(e,H){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return L}});const te=64;class L{#e;#t=0;#n=0;constructor(D=te){this.#e=new Uint32Array(Math.max(1,D)),this.#n=this.#e.length}static from(D,F=te){const Z=new L(D.length+Math.max(1,F));return Z.#e.set(D,0),Z.#t=D.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(D){return D<0||D>=this.length?0:D<this.#t?this.#e[D]:this.#e[D+(this.#n-this.#t)]}insert(D,F){const Z=D<0?0:D>this.length?this.length:D;this.#r(Z),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=F}push(D){this.insert(this.length,D)}removeAt(D){return!Number.isInteger(D)||D<0||D>=this.length?!1:(this.#r(D),this.#n++,!0)}toArray(){const D=new Uint32Array(this.length);return D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),this.#t),D}clear(){this.#t=0,this.#n=this.#e.length}#r(D){if(D!==this.#t)if(D<this.#t){const F=this.#t-D;this.#e.copyWithin(this.#n-F,D,this.#t),this.#t=D,this.#n-=F}else{const F=D-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+F),this.#t=D,this.#n+=F}}#s(){const D=this.#e.length-this.#n,F=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+te));F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),F.length-D),this.#e=F,this.#n=F.length-D}}}),Be("packages/core/src/store/ingest.js",function(e,H){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return s}});const te=H("packages/core/src/internal/schedule.js"),L=te.now,X=te.nextFrame,D=H("packages/core/src/internal/warn.js"),F=D.infoOnce,Z=D.warnOnce,B=H("packages/core/src/internal/predicates.js").isFunction,G=H("packages/core/src/internal/paths.js").pathGetter,O=H("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function c(n,u={}){if(u.multi)return"multi";if(n.length===0)return"object";let o=0,a=0,f=0,w=0,m=0;for(let h=0;h<n.length;h++){const p=n[h];typeof p=="number"?o++:typeof p=="boolean"?a++:typeof p=="string"?f++:p instanceof Date?w++:Array.isArray(p)&&m++}const v=n.length;return o===v?"float64":a===v?"bitset":w===v?"float64":f===v?"text":m===v?"multi":"object"}function d(n,u,o){return u<=0||n<o*u?"dictionary":"object"}function l(n,u,o){const a=new Map,f=new Map;for(const j of n){if(j.computed)continue;const N=B(j.read)?j.read:G(j.field||j.id);f.set(j.id,N),a.set(j.id,N)}const w=u?.order??[],m=u?.fns??{},v=u?.deps??{},h=u?.wrapDeps??null,p=w.filter(j=>B(m[j])),g=p.some(j=>v[j]==="*");let k=new WeakMap;const y=j=>{const N={};if(g)for(const[W,R]of f)N[W]=R(j);for(const W of p){const R=v[W];let x;if(R==="*")x=N;else{x={};const A=R||[];for(let $=0;$<A.length;$++){const I=A[$];x[I]=I in N?N[I]:f.get(I)?.(j)}}N[W]=m[W](h?h(x,W):x,{data:j,row:null,column:null,grid:null,context:o})}return N},T=j=>{if(j===null||typeof j!="object"&&typeof j!="function")return y(j);let N=k.get(j);return N===void 0&&(N=y(j),k.set(j,N)),N};for(const j of p)a.set(j,N=>T(N)[j]);return{readers:a,reset(){k=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(u,o){this.spec=u,this.read=o,this.kind="object",this.inferred=!1,this.nullable=u.nullable!==!1}}class t{#e;#t=[];#n=null;#r;#s=0;#i;#o=!1;#l=!1;#a=0;#c;constructor(u,o={},a={}){this.#e=Array.isArray(u)?u:Array.from(u||[]),this.#i={...b,...a};const f=o.columns??[];this.#r=l(f,o.computed??null,o.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(f,o.computed??null),this.#n=new O(this.#t.map(w=>({id:w.spec.id,kind:w.kind,nullable:w.nullable,read:w.read,dictionary:w.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const u=L(),{chunkMs:o,chunkRows:a}=this.#i,f=this.#e.length;do{const w=Math.min(this.#s+a,f);this.#n.append(this.#e.slice(this.#s,w)),this.#f(this.#s,w),this.#s=w,this.#r.reset(),this.#h(!1)}while(this.#s<f&&L()-u<o);return this.#a+=L()-u,this.#i.onProgress?.({loaded:this.#s,total:f}),this.#s>=f?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),decisions:this.#t.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,inferred:u.inferred,distinct:u.candidate||u.change?this.#d(u):null,change:u.change,reason:u.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(u,o){const a=this.#e,f=Math.min(this.#i.sampleSize,a.length),w=this.#i.dictionaryRatio,m=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const v of u){if(!v||!v.id)continue;if(v.computed&&(v.pure===!1||o&&!m.has(v.id))){Z(`ingest.impure.${v.id}`,`column "${v.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(v.id)??(B(v.read)?v.read:G(v.field||v.id)),p=new r(v,h);if(v.kind)p.kind=v.kind,p.reason="declared by the caller";else if(v.dictionary)p.kind=v.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const g=[];for(let y=0;y<f&&g.length<this.#i.sampleSize;y++){const T=h(a[y]);T!=null&&g.push(T)}p.inferred=!0;const k=c(g,{multi:v.multi});if(k==="text"){const y=new Set(g).size;p.kind=d(y,g.length,w),p.candidate=this.#c,p.reason=`sampled ${y} distinct in ${g.length}`}else p.kind=k,p.reason=`inferred from ${g.length} sampled values`,k==="object"&&g.length&&F(`ingest.mixed.${v.id}`,`column "${v.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(g))}this.#t.push(p)}}#f(u,o){const a=this.#e;for(const f of this.#t){if(!f.candidate||!f.distinct)continue;const w=f.distinct;for(let m=u;m<o;m++){const v=f.read(a[m]);v!=null&&w.add(v)}}}#d(u){if(u.distinct)return u.distinct.size;const o=this.#n.column(u.spec.id);return o?.dict?o.dict.size:0}#h(u){const o=this.#i.dictionaryRatio,a=this.#e.length;for(const f of this.#t){if(!f.candidate)continue;const w=this.#d(f);if(f.kind==="dictionary"&&w>=o*a){const m=this.#n.column(f.spec.id);f.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${w} distinct values is at or above ${o*100}% of ${a} rows`;continue}if(f.kind==="object"&&w>=o*a){f.candidate=!1,f.distinct=null,f.reason=`${w} distinct values is at or above ${o*100}% of ${a} rows`;continue}u&&f.kind==="object"&&w<o*a&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${w} distinct values is below ${o*100}% of ${a} rows`,f.distinct=null),u&&(f.candidate=!1)}}}async function i(n,u={},o={}){const a=new t(n,u,o),f=o.scheduler?.frame??X;for(;a.slice();)await new Promise(w=>{f(w)});return a.result()}function s(n,u={},o={}){const a=new t(n,u,{...o,chunkMs:1/0});for(;a.slice(););return a.result()}}),Be("packages/core/src/store/columnpack.js",function(e,H){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return d}});const L=H("packages/core/src/internal/paths.js").pathGetter,X=H("packages/core/src/store/ingest.js"),D=X.inferKind,F=X.decideText,Z=X.INGEST_DEFAULTS,B=H("packages/core/src/store/columnstore.js").toFloat,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function G(l){if(!Array.isArray(l)||l.length===0)return!1;for(const r of l)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!z.has(r.kind))return!1;return!0}function P(l){const r=B(l);return Number.isFinite(r)?r|0:0}function O(l){return l==null?[]:Array.isArray(l)?l:[l]}function b(l,r,t,i){if(l.kind)return l.kind;const s=[];for(let o=0;o<r.length&&s.length<Z.sampleSize;o++){const a=r[o];a!=null&&s.push(a)}const n=D(s,{multi:l.multi});if(n!=="text")return n;const u=new Set(s).size;return F(u,s.length,i)}function c(l,r,t={}){const i=r.length|0,s=t.dictionaryRatio??Z.dictionaryRatio,n=[];for(const u of l){const o=L(u.field||u.id),a=u.nullable!==!1,f=new Array(i);for(let p=0;p<i;p++){const g=o(r[p]);f[p]=g===void 0?null:g}const w=b(u,f,i,s),m=a?new Uint8Array(i+7>>3):null,v=p=>{m&&(m[p>>3]|=1<<(p&7))};let h;switch(w){case"float64":{const p=new Float64Array(i);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),p[g]=y?NaN:B(k)}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"int32":{const p=new Int32Array(i);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),p[g]=y?0:P(k)}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(i+7>>3);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),!y&&k&&(p[g>>3]|=1<<(g&7))}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(i),g=[],k=new Map;for(let y=0;y<i;y++){const T=f[y];if(T===null){p[y]=0;continue}v(y);let j=k.get(T);j===void 0&&(j=g.length,g.push(T),k.set(T,j)),p[y]=j}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:g};break}case"multi":{const p=[],g=new Map,k=new Uint32Array(i+1),y=[];for(let T=0;T<i;T++){const j=f[T];k[T]=y.length,j===null||v(T);const W=O(j);for(let R=0;R<W.length;R++){const x=W[R];let A=g.get(x);A===void 0&&(A=p.length,p.push(x),g.set(x,A)),y.push(A)}}k[i]=y.length,h={id:u.id,kind:w,nullable:a,values:Int32Array.from(y),presence:m,offsets:k,table:p};break}default:{const p=new Array(i);for(let g=0;g<i;g++){const k=f[g];k!==null&&v(g),p[g]=k}h={id:u.id,kind:"object",nullable:a,values:p,presence:m,offsets:null,table:null};break}}n.push(h)}return{count:i,columns:n}}function d(l){const r=[];if(!l||!Array.isArray(l.columns))return r;const t=i=>{ArrayBuffer.isView(i)&&i.buffer&&!r.includes(i.buffer)&&r.push(i.buffer)};for(const i of l.columns)t(i.values),t(i.presence),t(i.offsets);return r}}),Be("packages/core/src/source/stream.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,F=H("packages/core/src/internal/schedule.js"),Z=F.now,Y=F.nextFrame,B=F.cancelFrame,z=F.whenIdle,P=H("packages/core/src/internal/compare.js").defaultCompare,O=H("packages/core/src/internal/warn.js"),b=O.warnOnce,c=O.infoOnce,l=H("packages/core/src/internal/paths.js").getPath,r=H("packages/core/src/source/abort.js"),t=r.createAbortScope,i=r.isAbortError,s=H("packages/core/src/source/rows.js"),n=s.createRowFactory,u=s.lazyRowView,a=H("packages/core/src/source/gapbuffer.js").GapBuffer,w=H("packages/core/src/source/memory.js").createMemorySource,v=H("packages/core/src/source/filterwire.js").querySignature,p=H("packages/core/src/store/columnpack.js").isPortableSchema,g=25e4,k=Symbol("lattice.stream.storeBacked"),y=8,T=.1,j=1e3,N=50;function W($){return Math.min(j,Math.max(N,Math.floor($/4)))}function R($){if($ instanceof Date)return $.getTime();if(typeof $=="number")return Number.isFinite($)?$:NaN;if(typeof $=="string"){const I=$.trim();if(!I)return NaN;const M=Date.parse(I);return Number.isNaN(M)?Number(I):M}return NaN}function x($,I){return new A($,I)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#o;#l;#a=new Map;#c=t();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#j=!1;#w=!1;#O=!1;#v=!1;#T="";#S=0;#E=0;#M=0;#P=null;#N=1/0;#R=!1;#L=null;#U=null;#G=null;#x=null;#F=!1;#Y=0;#I=0;#K=!1;constructor(I,M){this.#e=I||{mode:"stream"},this.#t=M||{},this.#o=n(this.#t),this.#l=new L(4096),this.#T=this.#We();const S=(this.#t.config||{}).ingest;this.#F=!!S&&S.retainSource===!1,D(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const E=Number(this.#e.poll);Number.isFinite(E)&&E>0&&(this.#x=setInterval(()=>{this.#v||this.reload()},E),this.#x&&D(this.#x.unref)&&this.#x.unref()),this.#z()}#H(){const I=Number(this.#e.maxAge);return Number.isFinite(I)&&I>0?I:0}#z(){const I=this.#H();if(!I)return;const M=this.#e.ageBy;D(M)?this.#U=M:typeof M=="string"&&M?this.#U=S=>l(S,M):this.#U=null,this.#P=[],this.#L=setInterval(()=>{this.#v||this.#fe()&&(this.#q(),this.#ce())},W(I)),this.#L&&D(this.#L.unref)&&this.#L.unref()}#fe(){const I=this.#H();return!I||!this.#P?!1:this.#R?!0:this.#N<Date.now()-I*(1+T)}#ne(I,M){if(!this.#P)return;const S=this.#U?R(this.#U(M)):Date.now();this.#P[I]=S,Number.isNaN(S)||(S<this.#N&&(this.#N=S),S<Date.now()-this.#H()&&(this.#R=!0))}#pe(){return this.#be("groupBy",[]).length>0?!0:!!this.#be("pivotMode",!1)&&this.#be("pivotBy",[]).length>0}#Ie(){if(this.#g||this.#v)return;const I=this.#pe();if(I&&!this.#b){this.#b=w({mode:"memory",rows:this.#n},this.#Oe()),this.#j=!1;return}!I&&this.#b&&(this.#b.destroy(),this.#b=null)}#Oe(){if(this.#y)return this.#y;const I=this,M={liveIndices:()=>I.#me(),live:S=>I.#n[S]!==void 0,source:S=>I.#Se(S),get physical(){return I.#n.length}};return this.#F&&(M.column=S=>{const E=I.#t.store;return E&&D(E.column)?E.column(S):void 0}),this.#y=Object.create(this.#t,{store:{value:M,enumerable:!0,configurable:!0}}),this.#y}#me(){const I=new Uint32Array(this.#n.length);let M=0;for(let S=0;S<this.#n.length;S++)this.#n[S]!==void 0&&(I[M++]=S);return I.subarray(0,M)}#ye(){return this.#g?this.#g:this.#b?(this.#j&&(this.#j=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(I="filter"){if(this.#g){this.#g.invalidate(I);return}this.#Ie(),this.#b&&this.#b.invalidate(I),(I==="filter"||I==="sort")&&this.#Te()}count(){const I=this.#ye();return I?I.count():this.#r?this.#r.length:this.#S}matchCount(){const I=this.#ye();return I&&D(I.matchCount)?I.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const I=this.#ye();return I&&D(I.totalCount)?I.totalCount():this.#S}unfilteredRows(){const I=this.#ye();if(I&&D(I.unfilteredRows))return I.unfilteredRows();const M=[];for(let S=0;S<this.#n.length;S++){if(!this.#n[S])continue;const E=this.#Re(S);E&&M.push(E)}return M}at(I){const M=this.#ye();if(M)return M.at(I);if(I<0||I>=this.count())return;const S=this.#r?this.#r.at(I):I,E=this.#Re(S);return E.index=I,E}byKey(I){const M=this.#ye();if(M)return M.byKey(I);const S=this.#a.get(I);return S===void 0?void 0:this.#Re(S)}leavesOf(I){const M=this.#ye();return M&&D(M.leavesOf)?M.leavesOf(I):[]}loaded(I){return I>=0&&I<this.count()}hint(I,M){if(this.#g){this.#g.hint(I,M);return}this.#Pe(),this.#p=Math.max(0,Math.floor(I))}#Pe(){this.#v||this.#We()===this.#T||this.reload()}display(){const I=this.#ye();return I?I.display():u(()=>this.count(),M=>this.at(M))}apply(I){if(this.#g)return this.#g.apply(I);const M={added:[],updated:[],removed:[]};if(!I)return M;if(I.update){let S=!1;for(const E of I.update){const U=this.#a.get(this.#o.keyOf(E,-1));if(U===void 0)continue;const K=this.#Be(U);this.#F?this.#ze(U,E):this.#n[U]=E,this.#l.delete(U),this.#B(U,K),this.#P&&(this.#ne(U,E),S=!0),this.#j=!0,M.updated.push(this.#Re(U))}S&&this.#q()}if(I.add&&I.add.length){const S=this.#D(I.add);for(const E of S)M.added.push(this.#Re(E))}return I.remove&&I.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#ce(),M}reload(I){this.#c.abortAll("reload"),this.#Ve(),this.#b&&(this.#b.destroy(),this.#b=null),this.#j=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#E=0,this.#M=0,this.#P&&(this.#P=[]),this.#N=1/0,this.#R=!1,this.#w=!1,this.#O=!1,this.#u={loaded:0,estimated:void 0},this.#T=this.#We(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#P=null,this.#c.abortAll("destroyed"),this.#Ve(),this.#f!==null&&(this.#k(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#v||!D(this.#e.open))return;this.#O=!0;const I=this.#c.begin("stream");this.#Te(),this.#Ie();let M;try{M=this.#e.open({sort:this.#be("sort",[]),filters:this.#be("filters",null),quick:this.#be("quick","")||void 0,context:this.#be("context",null),signal:I.signal})}catch(E){this.#ke("source:error",{error:E});return}const S=D(M[Symbol.asyncIterator])?M[Symbol.asyncIterator]():M[Symbol.iterator]();this.#G=S;try{for(;;){const E=await S.next();if(!I.current||this.#v)return;if(E.done){this.#ie();return}if(await this.#de(E.value,I),!I.current||this.#v)return;if(E.value&&E.value.done){this.#ie();return}if(await this.#oe(),!I.current||this.#v)return}}catch(E){if(i(E))return;this.#ke("source:error",{error:E})}finally{I.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const I=this.#ye();I&&(D(I.invalidateHandles)&&I.invalidateHandles(),D(I.invalidate)&&I.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#Y,inline:this.#I,storeBacked:this.#F}}#de(I,M){if(!I)return;const S=I.rows;if(S&&S.length&&this.#Ce(S))return this.#J(I,M);const E=Z();S&&S.length&&(this.#D(S),this.#I++),this.#se(I),this.#h+=Z()-E,this.#ce()}#se(I){this.#u.loaded=I.progress&&typeof I.progress.loaded=="number"?I.progress.loaded:this.#n.length,I.progress&&typeof I.progress.estimated=="number"&&(this.#u.estimated=I.progress.estimated)}#Ce(I){if(this.#K||this.#g)return!1;const M=this.#W();if(!M)return!1;const S=this.#t.store;if(!S||!D(S.appendPacked))return!1;const E=this.#X();return!E||!p(E)?(this.#K=!0,c("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):I.length<M.threshold?!1:!this.#te(I)}#te(I){if(!this.#o.keyed)return!1;const M=new Set;for(let S=0;S<I.length;S++){const E=this.#o.keyOf(I[S],this.#n.length+S);if(E!=null){if(M.has(E)||this.#a.has(E))return!0;M.add(E)}}return!1}async#J(I,M){const S=I.rows,E=this.#W(),U=this.#X();let K;try{K=await E.columnize(U,S,{key:"ingest:stream",signal:M&&M.signal})}catch(ne){if(i(ne)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ne),this.#K=!0,M&&(!M.current||this.#v)))return;this.#D(S),this.#I++,this.#se(I),this.#ce();return}if(M&&(!M.current||this.#v))return;const q=this.#t.store,_=this.#F?void 0:S,{from:J}=q.appendPacked(K,_),ee=K.count|0;for(let ne=0;ne<ee;ne++){const oe=J+ne,ie=S[ne],ae=this.#o.keyed?this.#o.keyOf(ie,oe):null;if(this.#n[oe]=this.#F?k:ie,this.#S++,this.#ne(oe,ie),ae!==null&&this.#a.set(ae,oe),!this.#r||!this.#le(oe))continue;const ce=this.#C(oe);this.#r.insert(ce,oe),ce<=this.#p&&this.#m++}this.#j=!0,this.#q(),this.#Y++,this.#se(I),this.#ce()}#W(){const I=this.#t.ingestWorker;return D(I)?I():null}#X(){const I=this.#t.storeSchema;return D(I)?I():null}#D(I){const M=[],S=this.#t.store,E=new Array(I.length),U=[],K=new Set;for(let _=0;_<I.length;_++){const J=this.#o.keyed?this.#o.keyOf(I[_],this.#n.length+U.length):null;E[_]=J,!(J!==null&&(this.#a.has(J)||K.has(J)))&&(J!==null&&K.add(J),U.push(I[_]))}let q=U.length&&S&&D(S.append)?S.append(U).from:this.#n.length;for(let _=0;_<I.length;_++){const J=I[_],ee=E[_];if(ee!==null&&this.#a.has(ee)){const ie=this.#a.get(ee),ae=this.#Be(ie);this.#F||(this.#n[ie]=J,S&&D(S.setSource)&&S.setSource(ie,J)),this.#ze(ie,J),this.#l.delete(ie),this.#ne(ie,J),this.#B(ie,ae);continue}const ne=q++;if(this.#n[ne]=this.#F?k:J,this.#S++,this.#ne(ne,J),ee!==null&&this.#a.set(ee,ne),M.push(ne),!this.#r||!this.#le(ne))continue;const oe=this.#C(ne);this.#r.insert(oe,ne),oe<=this.#p&&this.#m++}return this.#j=!0,this.#q(),M}#Me(I){const M=this.#n[I];let S=!1;if(this.#r){const q=this.#Ee(I);q>=0&&q<=this.#p&&(S=!0)}else I<=this.#p&&(S=!0);const E=M===k?this.#Se(I):M,U=this.#o.keyed?this.#o.keyOf(E,I):null;U!==null&&this.#a.get(U)===I&&this.#a.delete(U),this.#n[I]=void 0,this.#P&&(this.#P[I]=NaN),this.#l.delete(I);const K=this.#t.store;return K&&D(K.remove)&&K.remove(I),this.#S--,S}#q(){let I=0,M=0;const S=this.#ve();I+=S.dropped,M+=S.aboveAnchor;const E=this.#re();I+=E.dropped,M+=E.aboveAnchor,I&&(this.#j=!0,this.#E+=I,this.#Te(),this.#m-=M,this.#ke("stream:evicted",{evicted:I,total:this.#E,live:this.#S}))}#re(){const I=this.#e.maxRows;if(!Number.isFinite(I)||I<=0||this.#S<=I)return{dropped:0,aboveAnchor:0};const M=Math.max(1,Math.floor(I*(1-T)));let S=0,E=0;for(;this.#S>M&&this.#M<this.#n.length;){const U=this.#M++;this.#n[U]!==void 0&&(this.#Me(U)&&E++,S++)}return{dropped:S,aboveAnchor:E}}#ve(){const I=this.#H();if(!I||!this.#P||!this.#fe())return{dropped:0,aboveAnchor:0};const M=Date.now()-I;let S=0,E=0,U=1/0;for(let K=this.#M;K<this.#n.length;K++){if(this.#n[K]===void 0)continue;const q=this.#P[K];if(!(Number.isNaN(q)||q===void 0)){if(q>=M){q<U&&(U=q);continue}this.#Me(K)&&E++,S++}}for(this.#N=U,this.#R=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:S,aboveAnchor:E}}#Ee(I){if(!this.#r)return I;for(let M=0;M<this.#r.length;M++)if(this.#r.at(M)===I)return M;return-1}#Te(){this.#s=this.#be("sort",[]),this.#i=this.#be("filters",null);const I=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#H()>0,M=this.#be("where",null),S=(this.#t.config||{}).hostFilter,E=!!(M&&M.active)||!!(S&&D(S.active)&&S.active());if(!(I||this.#s.length>0||!!this.#i||!!this.#be("quick","")||E)){this.#r=null;return}this.#r=new a(Math.max(64,this.#n.length+64));for(let K=0;K<this.#n.length;K++)this.#n[K]!==void 0&&this.#le(K)&&this.#r.insert(this.#C(K),K)}#le(I){const M=this.#Se(I);if(this.#i&&!this.#he(this.#i,M))return!1;const S=String(this.#be("quick","")||"").toLowerCase();if(S&&!this.#Ye(M).includes(S))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&D(E.active)&&E.active()&&!E.passes(this.#Re(I)))return!1;const U=this.#be("where",null);if(U&&U.active){const K=this.#Re(I);if(!U.passes(K.data,K.key))return!1}return!0}#he(I,M){if(!I)return!0;const S=I;if(Array.isArray(S.conditions))return S.op==="or"?S.conditions.some(K=>this.#he(K,M)):S.op==="not"?!S.conditions.some(K=>this.#he(K,M)):S.conditions.every(K=>this.#he(K,M));const E=I,U=(this.#t.compute||{}).testValue;return D(U)?!!U(this.#Fe(M,E.col),E,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Be(I){if(!this.#r)return-1;if(!this.#s.length)return this.#Ee(I);let M=0,S=this.#r.length;for(;M<S;){const E=M+S>>>1;this.#V(this.#r.at(E),I)<0?M=E+1:S=E}for(let E=M;E<this.#r.length;E++){const U=this.#r.at(E);if(U===I)return E;if(this.#V(U,I)>0)break}return this.#Ee(I)}#B(I,M){if(!this.#r||!this.#s.length)return;const S=this.#le(I);if(M>=0&&this.#r.at(M)===I)this.#r.removeAt(M),M<=this.#p&&this.#m--;else if(M>=0)return;if(!S)return;const E=this.#C(I);this.#r.insert(E,I),E<=this.#p&&this.#m++}#C(I){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let M=0,S=this.#r.length;for(;M<S;){const E=M+S>>>1;this.#V(I,this.#r.at(E))<0?S=E:M=E+1}return M}#V(I,M){const S=this.#Se(I),E=this.#Se(M);for(const U of this.#s){const K=this.#_e(U.col),q=this.#Fe(S,U.col),_=this.#Fe(E,U.col),ee=(K&&K.value&&D(K.value.compare)?K.value.compare:P)(q,_);if(ee!==0)return U.dir==="desc"?-ee:ee}return 0}#ie(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const I=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:g;!this.#F&&this.#n.length<I&&(this.#g=w({mode:"memory",rows:this.#n},this.#t),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#ce(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:I})}#ce(){this.#f!==null||this.#v||(this.#f=this.#we(()=>{this.#f=null,this.#d++;const I=this.#m;this.#m=0,this.#h=0,this.#ke("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:I,anchor:this.#p}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#oe(){return this.#d===0||this.#h<this.#ge()?Promise.resolve():(this.#h=0,new Promise(I=>{const M=(this.#t.scheduler||{}).idle;D(M)?M(()=>I()):z(()=>I())}))}#ge(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:y}#we(I){const M=this.#t.scheduler||{};return D(M.frame)?M.frame(I):Y(I)}#k(I){const M=this.#t.scheduler||{};D(M.cancel)?M.cancel(I):B(I)}#Se(I){const M=this.#n[I];if(M!==void 0&&M!==k)return M;if(M===void 0)return;const S=this.#t.store;return S&&D(S.source)?S.source(I):void 0}#ze(I,M){const S=this.#t.store;if(!S||!D(S.set))return;const E=this.#X();if(Array.isArray(E))for(const U of E){if(!U||!U.id)continue;const K=D(U.read)?U.read:q=>l(q,U.field||U.id);S.set(U.id,I,K(M))}}#Re(I){let M=this.#l.get(I);return M||(M=this.#o.leaf(this.#Se(I),I),this.#l.set(I,M)),M}#Fe(I,M){const S=this.#_e(M);return S&&D(S.getValue)?S.getValue(I):I?.[M]}#Ye(I){const M=this.#t.columns,S=M&&D(M.all)?M.all():[],E=[];for(const U of S){const K=D(U.getValue)?U.getValue(I):void 0;K!=null&&K!==""&&E.push(String(K))}return E.join(" ").toLowerCase()}#_e(I){const M=this.#t.columns;return M&&D(M.get)?M.get(I):void 0}#Ve(){const I=this.#G;if(this.#G=null,I&&D(I.return))try{I.return()}catch{}}#We(){return v({context:this.#be("context",null)})}#be(I,M){const S=this.#t.state;if(S&&D(S[I])){const E=S[I]();return E??M}return M}#ke(I,M){const S=this.#t.emit;D(S)&&S(I,M)}}}),Be("packages/core/src/source/url.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=H("packages/core/src/internal/predicates.js"),D=X.isObject,F=X.isFunction,Y=H("packages/core/src/internal/paths.js").getPath,z=H("packages/core/src/source/abort.js").isAbortError,G=500,P=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),O=Symbol("lattice.url.skip");function b(m,v={}){const h=D(v)?v:{},p=F(h.fetch)?h.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,g=h.format==="json"||h.format==="ndjson"?h.format:void 0,k=typeof h.rowsPath=="string"&&h.rowsPath?h.rowsPath:void 0,y=F(h.map)?h.map:void 0,T=D(h.headers)?h.headers:void 0,j=Number.isFinite(h.batchSize)&&h.batchSize>0?Math.floor(h.batchSize):G,N=h.lenient===!0,W=Number.isFinite(h.poll)&&h.poll>0?Math.floor(h.poll):void 0,R=typeof m=="string"&&m.length>0;R||L("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*x($={}){if(!R)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const I=$&&$.signal;let M;try{M=await p(m,T?{signal:I,headers:T}:{signal:I})}catch(U){throw z(U)?U:new Error(`[lattice] createUrlSource: request to ${m} failed — ${U&&U.message||U}`)}if(!M||!M.ok){const U=M?M.status:"no response";throw new Error(`[lattice] createUrlSource: ${U} for ${m}`)}const S=c(m,g,M),E=M.body&&F(M.body.getReader)?M.body.getReader():null;try{if(!E){const q=await M.text();(S||r(q,m))==="ndjson"?yield*o(null,null,q,0,M,m,j,N):yield*u(q,m,k,y);return}const U=new TextDecoder("utf-8");if(S==="json"){yield*u(await n(E,U,""),m,k,y);return}if(S==="ndjson"){yield*o(E,U,"",0,M,m,j,N);return}const K=await t(E,U,m);K.format==="json"?yield*u(await n(E,U,K.seed),m,k,y):yield*o(E,U,K.seed,K.bytes,M,m,j,N)}finally{if(E&&F(E.cancel))try{await E.cancel()}catch{}}}const A={mode:"stream",open:x,autoStart:h.autoStart!==!1};return W!==void 0&&(A.poll=W),Number.isFinite(h.maxRows)&&(A.maxRows=h.maxRows),Number.isFinite(h.maxAge)&&(A.maxAge=h.maxAge),(typeof h.ageBy=="string"||F(h.ageBy))&&(A.ageBy=h.ageBy),Number.isFinite(h.coalesceMs)&&(A.coalesceMs=h.coalesceMs),Number.isFinite(h.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=h.promoteToMemoryBelow),A}function c(m,v,h){if(v)return v;const p=d(m);if(p)return p;const g=h&&h.headers&&F(h.headers.get)?h.headers.get("content-type"):null;return l(g)}function d(m){const v=String(m).split(/[?#]/)[0].toLowerCase();if(v.endsWith(".ndjson")||v.endsWith(".jsonl"))return"ndjson";if(v.endsWith(".json"))return"json"}function l(m){if(!m)return;const v=m.split(";")[0].trim().toLowerCase();if(P.has(v))return"ndjson";if(v==="application/json"||v==="text/json"||v.endsWith("+json"))return"json"}function r(m,v){const h=m.replace(/^\s+/,""),p=i(h);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${v} — pass opts.format: 'json' | 'ndjson'.`);return p}async function t(m,v,h){let p="",g=0;for(;;){const{value:y,done:T}=await m.read();if(y&&(g+=y.byteLength,p+=v.decode(y,{stream:!0})),T){p+=v.decode();break}const j=p.replace(/^\s+/,"");if(j){if(j[0]==="[")return{format:"json",seed:p,bytes:g};if(j[0]!=="{"||p.indexOf(`
7
+ `||u==="\r"){n++;continue}if(u>="0"&&u<="9"){n=O(i,n,s);continue}if(u==="."&&i[n+1]>="0"&&i[n+1]<="9"){n=O(i,n,s);continue}if(u==='"'||u==="'"){n=b(i,n,s);continue}if(u==="["){const a=i.indexOf("]",n+1);if(a<0)throw new z("a [column reference] was opened and never closed",n);s.push({kind:X,value:i.slice(n+1,a).trim(),at:n}),n=a+1;continue}if(P(u)){n=c(i,n,s);continue}const o=i.slice(n,n+2);if(Y.includes(o)){s.push({kind:F,value:o==="!="?"<>":o,at:n}),n+=2;continue}if(B.includes(u)){s.push({kind:F,value:u,at:n}),n++;continue}throw new z(`unexpected character ${JSON.stringify(u)}`,n)}return s.push({kind:Z,value:null,at:i.length}),s}function P(i){return/[A-Za-z_À-￿]/.test(i)}function O(i,s,n){let u=s,o=!1;for(;u<i.length;){const a=i[u];if(a>="0"&&a<="9"){u++;continue}if(a==="."&&!o){o=!0,u++;continue}if((a==="e"||a==="E")&&/[0-9+-]/.test(i[u+1]||"")){for(u+=2;u<i.length&&i[u]>="0"&&i[u]<="9";)u++;break}break}return n.push({kind:te,value:Number(i.slice(s,u)),at:s}),u}function b(i,s,n){const u=i[s];let o=s+1,a="";for(;o<i.length;){if(i[o]===u){if(i[o+1]===u){a+=u,o+=2;continue}return n.push({kind:L,value:a,at:s}),o+1}a+=i[o],o++}throw new z("a string was opened and never closed",s)}function c(i,s,n){let u=s;for(;u<i.length&&/[A-Za-z0-9_.À-￿]/.test(i[u]);)u++;const o=i.slice(s,u);let a=u;for(;a<i.length&&i[a]===" ";)a++;return n.push({kind:i[a]==="("?D:X,value:o,at:s}),u}const d={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function l(i){const s=String(i??"").replace(/^\s*=/,"");if(!s.trim())throw new z("the formula is empty");const n=G(s);let u=0;const o=()=>n[u],a=()=>n[u++],f=k=>{const y=o();if(y.kind!==F||y.value!==k)throw new z(`expected ${JSON.stringify(k)}`,y.at);u++},w=k=>{let y=m();for(;;){const T=o();if(T.kind!==F)break;const j=d[T.value];if(!j||j<k)break;u++;const N=w(T.value==="^"?j:j+1);y={kind:"bin",op:T.value,left:y,right:N}}return y},m=()=>{const k=o();return k.kind===F&&(k.value==="-"||k.value==="+")?(u++,{kind:"unary",op:k.value,arg:m()}):v()},v=()=>{let k=h();for(;o().kind===F&&o().value==="%";)u++,k={kind:"unary",op:"%",arg:k};return k},h=()=>{const k=a();if(k.kind===te)return{kind:"num",value:k.value};if(k.kind===L)return{kind:"str",value:k.value};if(k.kind===X)return{kind:"ref",name:k.value};if(k.kind===D){f("(");const y=[];if(!(o().kind===F&&o().value===")"))for(;;){if(y.push(w(1)),o().kind===F&&o().value===","){u++;continue}break}return f(")"),{kind:"call",name:String(k.value).toUpperCase(),args:y}}if(k.kind===F&&k.value==="("){const y=w(1);return f(")"),y}throw k.kind===Z?new z("the formula ends unexpectedly",k.at):new z(`unexpected ${JSON.stringify(k.value)}`,k.at)},p=w(1),g=o();if(g.kind!==Z)throw new z(`unexpected ${JSON.stringify(g.value)}: is an operator missing?`,g.at);return p}function r(i){const s=new Set,n=u=>{if(!(!u||typeof u!="object")){if(u.kind==="ref"){s.add(String(u.name));return}if(u.kind==="bin"){n(u.left),n(u.right);return}if(u.kind==="unary"){n(u.arg);return}if(u.kind==="call")for(const o of u.args)n(o)}};return n(i),[...s]}function t(i){return typeof i=="string"&&/^\s*=/.test(i)&&i.trim()!=="="}}),Be("packages/core/src/formula/evaluate.js",function(e,H){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return O}});const L=H("packages/core/src/formula/parse.js").FormulaError;function X(b){if(b==null||b==="")return 0;if(typeof b=="boolean")return b?1:0;if(b instanceof Date)return b.getTime();const c=typeof b=="number"?b:Number(String(b).replace(/[,\s]/g,""));if(!Number.isFinite(c))throw new L(`${JSON.stringify(b)} is not a number`);return c}function D(b){return b==null?"":String(b)}function F(b){if(typeof b=="boolean")return b;if(b==null||b==="")return!1;if(typeof b=="number")return b!==0;const c=String(b).trim().toLowerCase();return c==="false"||c==="no"||c==="0"?!1:c!==""}function Z(b){const c=[];for(const d of b){if(Array.isArray(d)){for(const l of d)l!=null&&l!==""&&c.push(X(l));continue}d==null||d===""||c.push(X(d))}return c}function Y(b,c){const d=10**c,l=b*d;return Math.sign(l)*Math.round(Math.abs(l)+Number.EPSILON*Math.abs(l))/d}function B(b,c){if(!b.length)return 0;const d=b.slice().sort((i,s)=>i-s),l=(d.length-1)*Math.min(1,Math.max(0,c)),r=Math.floor(l),t=Math.ceil(l);return r===t?d[r]:d[r]+(l-r)*(d[t]-d[r])}function z(b,c){let d=0,l=0,r=0;for(const i of b){d++;const s=i-l;l+=s/d,r+=s*(i-l)}const t=c?d-1:d;return t>0?Math.sqrt(r/t):0}const G={SUM:b=>Z(b).reduce((c,d)=>c+d,0),AVERAGE:b=>{const c=Z(b);return c.length?c.reduce((d,l)=>d+l,0)/c.length:0},MIN:b=>{const c=Z(b);return c.length?Math.min(...c):0},MAX:b=>{const c=Z(b);return c.length?Math.max(...c):0},COUNT:b=>Z(b).length,PRODUCT:b=>Z(b).reduce((c,d)=>c*d,1),ROUND:b=>Y(X(b[0]),b.length>1?X(b[1]):0),ROUNDDOWN:b=>{const c=10**(b.length>1?X(b[1]):0),d=X(b[0])*c;return(d<0?Math.ceil(d):Math.floor(d))/c},ROUNDUP:b=>{const c=10**(b.length>1?X(b[1]):0),d=X(b[0])*c;return(d<0?Math.floor(d):Math.ceil(d))/c},ABS:b=>Math.abs(X(b[0])),FLOOR:b=>Math.floor(X(b[0])),CEILING:b=>Math.ceil(X(b[0])),SQRT:b=>Math.sqrt(X(b[0])),POWER:b=>X(b[0])**X(b[1]),MOD:b=>{const c=X(b[1]);if(c===0)throw new L("MOD by zero");return(X(b[0])%c+c)%c},IF:b=>F(b[0])?b[1]:b.length>2?b[2]:!1,AND:b=>b.every(F),OR:b=>b.some(F),NOT:b=>!F(b[0]),COALESCE:b=>b.find(c=>c!=null&&c!=="")??null,CONCAT:b=>b.map(D).join(""),LEN:b=>D(b[0]).length,UPPER:b=>D(b[0]).toUpperCase(),LOWER:b=>D(b[0]).toLowerCase(),TRIM:b=>D(b[0]).trim(),LEFT:b=>D(b[0]).slice(0,b.length>1?X(b[1]):1),RIGHT:b=>{const c=b.length>1?X(b[1]):1;return c<=0?"":D(b[0]).slice(-c)},MEDIAN:b=>B(Z(b),.5),PERCENTILE:b=>{const c=X(b[b.length-1]);return B(Z(b.slice(0,-1)),c>1?c/100:c)},QUARTILE1:b=>B(Z(b),.25),QUARTILE3:b=>B(Z(b),.75),STDEV:b=>z(Z(b),!0),STDEVP:b=>z(Z(b),!1),VAR:b=>{const c=z(Z(b),!0);return c*c},VARP:b=>{const c=z(Z(b),!1);return c*c},COUNTDISTINCT:b=>{const c=new Set;for(const d of b){const l=Array.isArray(d)?d:[d];for(const r of l)r!=null&&r!==""&&c.add(r)}return c.size},IQR:b=>{const c=Z(b);return B(c,.75)-B(c,.25)}};G.AVG=G.AVERAGE,G.CEIL=G.CEILING,G.POW=G.POWER,G.STDEVS=G.STDEV,G.PERCENTILEINC=G.PERCENTILE;function P(b,c){const d=Number(b),l=Number(c);if(b!==null&&b!==""&&c!==null&&c!==""&&Number.isFinite(d)&&Number.isFinite(l))return d<l?-1:d>l?1:0;const t=D(b).toLowerCase(),i=D(c).toLowerCase();return t<i?-1:t>i?1:0}function O(b,c={}){const d=typeof c.lookup=="function"?c.lookup:null,l=c.functions?{...G,...c.functions}:G,r=t=>{switch(t.kind){case"num":return t.value;case"str":return t.value;case"ref":{if(!d)throw new L(`there is no column called ${JSON.stringify(t.name)} here`);const i=d(String(t.name));if(i===void 0)throw new L(`there is no column called ${JSON.stringify(t.name)}`);return i}case"unary":{if(t.op==="%")return X(r(t.arg))/100;const i=X(r(t.arg));return t.op==="-"?-i:i}case"bin":{const i=t.op;if(i==="=")return P(r(t.left),r(t.right))===0;if(i==="<>")return P(r(t.left),r(t.right))!==0;if(i==="<")return P(r(t.left),r(t.right))<0;if(i==="<=")return P(r(t.left),r(t.right))<=0;if(i===">")return P(r(t.left),r(t.right))>0;if(i===">=")return P(r(t.left),r(t.right))>=0;const s=X(r(t.left)),n=X(r(t.right));if(i==="+")return s+n;if(i==="-")return s-n;if(i==="*")return s*n;if(i==="^")return s**n;if(i==="/"){if(n===0)throw new L("division by zero");return s/n}throw new L(`unknown operator ${JSON.stringify(i)}`)}case"call":{const i=c.lazy&&c.lazy[t.name];if(typeof i=="function")return i(t.args,r,c);const s=l[t.name];if(typeof s!="function")throw new L(`there is no function called ${t.name}`);return s(t.args.map(r),c)}default:throw new L("the formula could not be read")}};return r(b)}}),Be("packages/core/src/formula/index.js",function(e,H){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/formula/parse.js"),L=te.parseFormula,X=te.referencesOf,D=te.looksLikeFormula,F=te.FormulaError,Z=te.tokenise,Y=H("packages/core/src/formula/evaluate.js"),B=Y.evaluateAst,z=Y.FUNCTIONS;function G(O){const{grid:b,row:c,data:d}=O||{},l=n=>String(n).toLowerCase().replace(/[\s_-]/g,""),r=b&&b.columns&&typeof b.columns.all=="function"?b.columns.all():[],t=b&&b.permissions,i=t&&typeof t.isReadable=="function"?n=>t.isReadable(n):()=>!0,s=new Set;for(const n of r)i(n)||(s.add(l(n.id)),n.field&&s.add(l(n.field)),n.title&&s.add(l(n.title)));return n=>{const u=l(n);if(s.has(u))throw new F(`"${n}" cannot be read`);for(const o of r)if(l(o.id)===u||o.field&&l(o.field)===u||o.title&&l(o.title)===u)return c&&b.rows&&typeof b.rows.value=="function"?b.rows.value(c.key,o.id):d?d[o.field||o.id]:void 0;if(d&&typeof d=="object"){for(const o of Object.keys(d))if(l(o)===u){if(!i(o))throw new F(`"${n}" cannot be read`);return d[o]}}}}function P(O,b={}){try{const c=L(O);return{ok:!0,value:B(c,{lookup:G(b),functions:b.formulaFunctions}),references:X(c)}}catch(c){return{ok:!1,error:c instanceof F?c.message:"the formula could not be read",at:c instanceof F?c.at:void 0}}}}),Be("packages/core/src/internal/version.js",function(e,H){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return X}});const te="1.98.2";async function L(){return te}const X="1.98.2"}),Be("packages/core/src/internal/merge.js",function(e,H){"use strict";Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/predicates.js").isObject;function X(B,z,G){if(B!==void 0)return B===!0?{enabled:!0,...G}:B===!1?{enabled:!1}:L(B)?B:{[z]:B,enabled:!0}}function D(B){return B==null?[]:Array.isArray(B)?B:[B]}const F=Object.freeze(new Set(["__proto__","constructor","prototype"]));function Z(B,z){if(!L(B))return L(z)?{...z}:z;if(!L(z))return z===void 0?B:z;const G={...B};for(const P of Object.keys(z)){if(F.has(P))continue;const O=z[P];O!==void 0&&(G[P]=L(O)&&L(G[P])?Z(G[P],O):O)}return G}function Y(B,z){if(!L(B)||!L(z)||B===z)return z;const G=Object.create(Object.getPrototypeOf(B));return Object.assign(G,B,z),G}}),Be("packages/core/src/internal/schedule.js",function(e,H){"use strict";Object.defineProperty(e,"now",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}});function te(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const L=typeof requestAnimationFrame=="function";function X(B){return L?requestAnimationFrame(B):setTimeout(()=>B(te()),16)}function D(B){B!=null&&(L?cancelAnimationFrame(B):clearTimeout(B))}function F(B){let z=null,G=null;const P=()=>{z=null;const b=G;G=null,B(...b||[])},O=(...b)=>{G=b,z===null&&(z=X(P))};return O.cancel=()=>{D(z),z=null,G=null},O.flush=()=>{z!==null&&(D(z),P())},O}function Z(B,z){let G=null,P=null;const O=()=>{if(G=null,P===null)return;const d=P;P=null,B(...d),b()},b=()=>{G=setTimeout(O,z),typeof G?.unref=="function"&&G.unref()},c=(...d)=>{G===null?(B(...d),b()):(P=d,clearTimeout(G),b())};return c.flush=()=>{if(G!==null&&clearTimeout(G),G=null,P===null)return;const d=P;P=null,B(...d)},c.cancel=()=>{G!==null&&clearTimeout(G),G=null,P=null},c.pending=()=>G!==null||P!==null,c}function Y(B,z=50){return typeof requestIdleCallback=="function"?requestIdleCallback(B,{timeout:z}):setTimeout(()=>B({timeRemaining:()=>0,didTimeout:!0}),1)}}),Be("packages/core/src/internal/paths.js",function(e,H){"use strict";Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return Z}});const te=new Map;function L(Y){let B=te.get(Y);if(B)return B;if(!Y.includes("."))B=z=>z?.[Y];else{const z=Y.split("."),G=z.length;B=P=>{let O=P;for(let b=0;b<G;b++){if(O==null)return;O=O[z[b]]}return O}}return te.set(Y,B),B}const X=new Map;function D(Y){let B=X.get(Y);if(B)return B;if(!Y.includes("."))B=(z,G)=>{z!=null&&(z[Y]=G)};else{const z=Y.split("."),G=z.length-1;B=(P,O)=>{let b=P;for(let c=0;c<G;c++){if(b==null)return;const d=z[c];b[d]==null&&(b[d]={}),b=b[d]}b!=null&&(b[z[G]]=O)}}return X.set(Y,B),B}function F(Y,B){return L(B)(Y)}function Z(Y,B,z){D(B)(Y,z)}}),Be("packages/core/src/internal/compare.js",function(e,H){"use strict";Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return X}});const te=new Map;function L(D,F){const Z=`${D||""}|${F?JSON.stringify(F):""}`;let Y=te.get(Z);return Y||(Y=new Intl.Collator(D||void 0,{numeric:!0,sensitivity:"variant",...F}),te.set(Z,Y)),Y}function X(D,F){if(D===F)return 0;if(D==null)return 1;if(F==null)return-1;if(typeof D=="number"&&typeof F=="number")return Number.isNaN(D)?Number.isNaN(F)?0:1:Number.isNaN(F)||D<F?-1:D>F?1:0;const Z=String(D),Y=String(F);return Z<Y?-1:Z>Y?1:0}}),Be("packages/core/src/defaults.js",function(e,H){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return P}});const L=H("packages/core/src/internal/predicates.js").isObject,D=H("packages/core/src/internal/merge.js").merge,Z=H("packages/core/src/internal/warn.js").warnOnce;let Y=null;class B extends Error{}function z(O,b=new Set){if(Array.isArray(O)){if(b.has(O))throw new B;b.add(O);const d=O.map(l=>z(l,b));return b.delete(O),d}if(!L(O)||Object.getPrototypeOf(O)!==Object.prototype&&Object.getPrototypeOf(O)!==null)return O;if(b.has(O))throw new B;b.add(O);const c={};for(const[d,l]of Object.entries(O))c[d]=z(l,b);return b.delete(O),c}function G(O){if(O===void 0)return z(Y??{});if(O===null)return Y=null,{};if(!L(O))return Z("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(O)?"an array":typeof O}. The call was ignored and the defaults are unchanged.`),z(Y??{});try{Y=z(O)}catch(b){if(!(b instanceof B))throw b;return Z("defaults:cyclic","defaults() expects a configuration object with no circular references, but the object passed refers back to itself. The call was ignored and the defaults are unchanged."),z(Y??{})}return z(Y)}function P(O){return Y===null?O:D(z(Y),O)}}),Be("packages/core/src/internal/uid.js",function(e,H){"use strict";Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return L}});let te=0;function L(X="l"){return`${X}${(++te).toString(36)}`}}),Be("packages/core/src/events/names.js",function(e,H){"use strict";Object.defineProperty(e,"EVENT_NAMES",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isKnownEvent",{enumerable:!0,get:function(){return X}});const te=Object.freeze(["ready","destroy","render:first","render:done","config:changed","licence:changed","model:changed","rows:changed","rows:queued","rows:deferred","rows:paused","rows:resumed","row:received","row:sent","row:copied","row:moved","source:error","source:total","stream:chunk","stream:end","stream:evicted","rowDrag:started","rowDrag:moved","rowDrag:left","rowDrag:ended","cell:changed","cell:pending","cell:confirmed","cell:reverted","cell:conflict","cell:clicked","cell:dblclicked","cell:contextmenu","cell:mouseover","cell:mouseout","cell:mousedown","cell:mouseup","cell:edit:start","cell:edit:end","row:edit:start","row:edit:end","row:clicked","row:dblclicked","row:pending","row:confirmed","row:reverted","row:conflict","form:opened","form:closed","form:saved","form:error","sort:changed","filter:changed","group:toggled","facet:computed","facet:filtered","facet:expanded","facet:failed","column:moved","column:resized","column:visible","column:pinned","column:grouped","column:pivoted","column:filter:open","column:profile:open","column:menu:open","columns:changed","columns:tagged","columngroup:changed","header:contextmenu","pivot:drill","selection:changed","range:changed","clipboard:copy","page:changed","scroll","scroll:end","size:changed","detail:toggled","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),L=new Set(te);function X(D){return D==="*"||L.has(D)}}),Be("packages/core/src/events/bus.js",function(e,H){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return d}});const te=H("packages/core/src/internal/warn.js"),L=te.warnOnce,X=te.DEV,F=H("packages/core/src/internal/uid.js").uid,Y=H("packages/core/src/events/names.js").isKnownEvent,B="*";function z(l,r){!X||Y(r)||L(`bus.unknown:${r}`,`${l}('${r}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const G=new Set(["api","user","init","ai"]),P=new WeakMap;function O(l){let r=P.get(l);return r||(r=F("h"),P.set(l,r)),r}function b(){return typeof performance=="object"&&performance?performance.now():Date.now()}function c(l){if(!l||typeof l!="object")return{};const r={};for(const[t,i]of Object.entries(l))t!=="grid"&&(i==null?r[t]=String(i):Array.isArray(i)?r[t]=`[${i.length}]`:typeof i=="object"?r[t]=i.key?`row ${i.key}`:"{…}":typeof i=="function"?r[t]="[function]":r[t]=String(i).slice(0,60));return r}class d{#e=new Map;#t=!1;#n=[];#r=200;#s=new Map;#i=null;#o=!1;#l=0;constructor(r=null){this.#i=r}attach(r){this.#i=r}get grid(){return this.#i}get destroyed(){return this.#o}on(r,t){if(typeof t!="function")return L(`bus.handler:${r}`,`on('${r}') needs a function; ignored.`),()=>{};z("on",r);let i=this.#e.get(r);return i||(i=[],this.#e.set(r,i)),i.push(t),()=>this.off(r,t)}once(r,t){if(typeof t!="function")return L(`bus.handler:${r}`,`once('${r}') needs a function; ignored.`),()=>{};z("once",r);const i=s=>{this.off(r,t),t(s)};return this.#s.set(t,i),this.on(r,i)}off(r,t){if(t===void 0){this.#e.delete(r);return}const i=this.#e.get(r);if(!i)return;const s=this.#s.get(t),n=s&&i.includes(s)?s:t,u=i.indexOf(n);u>=0&&i.splice(u,1),s&&n===s&&this.#s.delete(t),i.length===0&&this.#e.delete(r)}count(r){const t=this.#e.get(r),i=r===B?null:this.#e.get(B);return(t?t.length:0)+(i?i.length:0)}#a(r,t,i,s,n){this.#n.push({type:r,origin:t,listeners:(s?s.length:0)+(n?n.length:0),payload:c(i),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(r,t){this.#t=!!r,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),r||(this.#n=[])}eventLog(){return this.#n.map(r=>({...r}))}clearEventLog(){this.#n=[]}counts(){const r={};for(const[t,i]of this.#e)r[t]=i.length;return r}emit(r,t,i){const s=i??(t&&t.origin),n=G.has(s)?s:"api",u={...t||null,type:r,origin:n,grid:this.#i};if(this.#o)return u;const o=this.#e.get(r),a=r===B?void 0:this.#e.get(B);if(this.#t&&this.#a(r,n,t,o,a),!o&&!a)return u;const f=this.#t?b():0;this.#l++;try{o&&this.#c(o.slice(),u,r),a&&this.#c(a.slice(),u,B)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=b()-f)}return u}emitBefore(r,t,i){const s=i??(t&&t.origin),n=G.has(s)?s:"user";let u=!1,o=null;const a=p=>{u=!0,p!=null&&o===null&&(o=String(p))},f={...t||null,type:r,origin:n,grid:this.#i,get defaultPrevented(){return u},get reason(){return o},preventDefault(p){a(p)}};if(this.#o)return!0;const w=this.#e.get(r);this.#t&&this.#a(r,n,t,w,void 0);const m=w?w.slice():[];if(m.length===0)return!0;const v=()=>(u&&o===null&&(o="prevented"),u&&t&&typeof t=="object"&&(t.reason=o),!u),h=[];for(const p of m)try{const g=p(f);g&&typeof g.then=="function"?h.push(g):g===!1&&a("prevented")}catch(g){a("error"),L(`bus.beforeThrow:${r}:${O(p)}`,`a '${r}' before-handler threw; the action was cancelled.`,g)}return h.length===0?v():Promise.allSettled(h).then(p=>{for(const g of p)g.status==="rejected"?(a("error"),L(`bus.beforeReject:${r}`,`a '${r}' before-handler rejected; the action was cancelled.`,g.reason)):g.value===!1&&a("prevented");return v()})}#c(r,t,i){for(let s=0;s<r.length;s++)try{r[s](t)}catch(n){L(`bus.throw:${i}:${O(r[s])}`,`a '${i}' handler threw; other handlers were unaffected.`,n)}}clear(){this.#e.clear(),this.#s.clear()}destroy(){this.clear(),this.#o=!0,this.#i=null}}}),Be("packages/core/src/registry/free-tier-notice.js",function(e,H){"use strict";Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return te}});const te="Free for non-commercial use: latticegrid.dev/free"}),Be("packages/core/src/registry/licence.js",function(e,H){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return R}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=H("packages/core/src/registry/free-tier-notice.js"),D=X.FREE_TIER_NOTICE;Object.defineProperty(e,"FREE_TIER_NOTICE",{enumerable:!0,get:function(){return X.FREE_TIER_NOTICE}});const F="lattice-grid",Z=1,Y="LG1",B=64,z="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",P=(()=>{const x=new Int16Array(128).fill(-1);for(let A=0;A<G.length;A++)x[G.charCodeAt(A)]=A;return x[43]=62,x[47]=63,x})();function O(x){if(typeof x!="string")return null;let A="";for(let U=0;U<x.length;U++){const K=x.charCodeAt(U);if(K!==61){if(K>127||P[K]<0)return null;A+=x[U]}}const $=A.length;if($%4===1)return null;const I=new Uint8Array(Math.floor($*3/4));let M=0,S=0,E=0;for(let U=0;U<$;U++)M=M<<6|P[A.charCodeAt(U)],S+=6,S>=8&&(S-=8,I[E++]=M>>S&255);return E===I.length?I:I.subarray(0,E)}function b(x){let A="",$=0;for(;$+2<x.length;$+=3){const M=x[$]<<16|x[$+1]<<8|x[$+2];A+=G[M>>18&63]+G[M>>12&63]+G[M>>6&63]+G[M&63]}const I=x.length-$;if(I===1){const M=x[$]<<16;A+=G[M>>18&63]+G[M>>12&63]}else if(I===2){const M=x[$]<<16|x[$+1]<<8;A+=G[M>>18&63]+G[M>>12&63]+G[M>>6&63]}return A}function c(x){const A=new Uint8Array(x.length);for(let $=0;$<x.length;$++)A[$]=x.charCodeAt($)&127;return A}function d(x){if(typeof TextDecoder=="function")return new TextDecoder().decode(x);let A="";for(let $=0;$<x.length;$++)A+=String.fromCharCode(x[$]);return A}function l(x){const A={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,terms:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof x=="string"?x:""};if(typeof x!="string"||x.length===0)return{...A,reason:"missing"};const $=x.trim(),I=$.split(".");if(I.length!==3)return A;const[M,S,E]=I;if(M!==Y)return{...A,reason:"prefix"};const U=O(S),K=O(E);if(!U||!K)return A;let q;try{q=JSON.parse(d(U))}catch{return A}return q===null||typeof q!="object"?A:{ok:!0,reason:null,product:typeof q.p=="string"?q.p:null,issuedTo:typeof q.t=="string"?q.t:null,expires:typeof q.e=="string"?q.e:null,terms:typeof q.terms=="string"?q.terms:null,features:Array.isArray(q.f)?q.f.slice():[],deployments:Array.isArray(q.d)?q.d.slice():[],version:typeof q.v=="number"?q.v:0,message:c(S),signature:K,raw:$}}function r(x,A){if(!x)return!1;const $=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(x)?`${x}T23:59:59.999Z`:x);return Number.isNaN($)?!0:A>$}function t(x){return x==="non-commercial"?"non-commercial":"commercial"}let i=null,s=null,n=null;function u(){const x=globalThis.crypto;return x&&x.subtle?x.subtle:null}async function o(x){if(i&&s===x)return i;const A=u();if(!A)return null;const $=O(x);if(!$)return null;try{const I=await A.importKey("raw",$,{name:"Ed25519"},!1,["verify"]);return i=I,s=x,I}catch{return null}}async function a(){return n!==null||(n=await o(z)!==null),n}async function f(x,A={}){const $=A.warn!==!1,I=A.product||F,M=A.publicKey||z,S=A.now??Date.now(),E=A.host??m(),U=w(E)?"":` ${D}`,K=l(x);if(!K.ok){const ne=K.reason==="missing"?"missing":"malformed";return $&&L(`licence.${ne}`,ne==="missing"?`no licence key supplied. The grid renders in full and carries a trial watermark on any host other than localhost. Get a key at latticegrid.dev.${U}`:`licence key could not be read. The grid will render with a watermark.${U}`),{valid:!1,reason:ne,terms:"commercial"}}const q={product:K.product||void 0,issuedTo:K.issuedTo||void 0,expires:K.expires||void 0,terms:t(K.terms)};if(K.product!==I)return $&&L("licence.product",`licence key is for '${K.product}', not '${I}'. The grid will render with a watermark.`),{valid:!1,...q,reason:"product"};if(r(K.expires,S))return $&&L("licence.expired",`licence expired on ${K.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...q,reason:"expired"};const _=K.deployments||[];if(_.length&&E&&!w(E)&&!v(E,_))return $&&L("licence.domain",`licence key is not valid for ${E}; it covers ${_.join(", ")}. The grid will render with a watermark.`),{valid:!1,...q,reason:"domain"};const J=await o(M);if(!J){const ne=!!K.signature&&K.signature.length===B;return $&&L("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),ne?{valid:!0,...q,reason:"unverified"}:{valid:!1,...q,reason:"signature"}}let ee=!1;try{ee=await u().verify({name:"Ed25519"},J,K.signature,K.message)}catch{ee=!1}return ee?{valid:!0,...q}:($&&L("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...q,reason:"signature"})}function w(x){const A=String(x??m()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!A||A==="localhost"||A.endsWith(".localhost")||A==="::1"||A==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(A)}function m(){const x=globalThis.location;return x&&typeof x.hostname=="string"?x.hostname:null}function v(x,A){const $=h(x);return!$||!Array.isArray(A)?!1:A.some(I=>{const M=h(I);if(!M)return!1;if(M==="*")return!0;if(M.startsWith("*.")){const S=M.slice(2);return $===S||$.endsWith(`.${S}`)}return $===M})}function h(x){return String(x??"").trim().toLowerCase().replace(/\.$/,"")}class p{#e="";#t={valid:!1,reason:"missing",terms:"commercial"};#n=null;#r=null;#s;#i=new Set;constructor(A={}){this.#s=A}set(A){this.#e=typeof A=="string"?A.trim():"";const $=l(this.#e);return this.#t=$.ok?{valid:!r($.expires,Date.now())&&$.product===(this.#s.product||F),product:$.product||void 0,issuedTo:$.issuedTo||void 0,expires:$.expires||void 0,terms:t($.terms),reason:"pending"}:{valid:!1,reason:$.reason||"malformed",terms:"commercial"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const A=this.#e;return this.#n=f(A,this.#s).then($=>{if(this.#e===A){this.#t=$;for(const I of this.#i)I($)}return $}),this.#n}onSettled(A){return this.#i.add(A),()=>this.#i.delete(A)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!w(this.#r)}setHost(A){this.#r=A}state(){return this.#t.valid?"licensed":w(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing",terms:"commercial"},this.#n=null,this.#i.clear()}}const g=Symbol.for("lattice-grid/licence/holder");function k(){const x=globalThis,A=x&&x[g];if(A&&typeof A.set=="function"&&typeof A.watermark=="function")return A;const $=new p;if(x)try{x[g]=$}catch{}return $}const y=k();function T(x){return y.set(x)}function j(){return y.info()}function N(){return y.watermark()}function W(){return y.state()}function R(){return y}}),Be("packages/core/src/registry/registry.js",function(e,H){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return i}});const te=H("packages/core/src/internal/warn.js"),L=te.warnOnce,X=te.DEV,F=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/registry/licence.js"),Y=Z.LicenceHolder,B=Z.sharedLicence,z=["renderer","editor","filter","dataType","totalFn","pipe","component"],G=["all","header","body","totals","panels"];class P{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#s;#i=null;#o=null;#l=new Set;#a=new Map;constructor(n={}){for(const u of z)this.#t.set(u,new Map);this.#s=n.holder||B(),this.#o=n.grid??null,this.#i=this.#s.onSettled(()=>{this.#f({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),n.licence&&this.setLicence(n.licence)}registerModules(n,u={}){u.licence&&this.setLicence(u.licence),u.grid!==void 0&&(this.#o=u.grid);const o=Array.isArray(n)?n:[n],a=[];for(const f of o){if(!f||typeof f!="object"||typeof f.name!="string"||!f.name){L("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(f.name)){X&&this.#u(this.#e.get(f.name),f);continue}if(!F(f.install)){L(`registry.module.install:${f.name}`,`module '${f.name}' has no install() and was ignored.`);continue}const w={registry:this,grid:this.#o};try{f.install(w)}catch(m){L(`registry.module.throw:${f.name}`,`module '${f.name}' threw during install; it was not registered.`,m);continue}this.#e.set(f.name,f);for(const m of O(f))this.#n.add(m);a.push(f.name),this.#f({reason:"module",name:f.name,capabilities:this.capabilities(),regions:d(f)})}return a}unregisterModule(n){const u=this.#e.get(n);if(!u)return!1;if(F(u.uninstall))try{u.uninstall({registry:this,grid:this.#o})}catch(o){L(`registry.module.uninstall:${n}`,`module '${n}' threw during uninstall.`,o)}return this.#e.delete(n),this.#c(),this.#f({reason:"unmodule",name:n,capabilities:this.capabilities(),regions:d(u)}),!0}modules(){return[...this.#e.values()]}has(n){return this.#e.has(n)}#c(){this.#n.clear();for(const n of this.#e.values())for(const u of O(n))this.#n.add(u)}#u(n,u){!n||n===u||b(n,u)||L(`registry.module.reconfigure:${u.name}`,`module '${u.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(n){return this.#n.has(n)}onChange(n){return F(n)?(this.#r.add(n),this.#a.set(n,this.#o),()=>{this.#r.delete(n),this.#a.delete(n)}):()=>{}}#f(n){for(const u of[...this.#r])try{u(n)}catch(o){L("registry.onChange.throw","a registry change handler threw.",o)}}register(n,u,o){const a=this.#t.get(n);if(!a){L(`registry.kind:${n}`,`unknown registry kind '${n}'; expected one of ${z.join(", ")}.`);return}if(!u||typeof u!="string"){L(`registry.name:${n}`,`register('${n}', ...) needs a name.`);return}a.has(u)&&a.get(u)!==o&&L(`registry.replace:${n}:${u}`,`'${u}' was already registered as a ${n} and has been replaced.`),a.set(u,o),this.#f({reason:"register",name:u,kind:n,capabilities:this.capabilities(),regions:l(n)})}registerAll(n,u){if(u)for(const o of Object.keys(u))this.register(n,o,u[o])}get(n,u){const o=this.#t.get(n);return o?o.get(u):void 0}names(n){const u=this.#t.get(n);return u?[...u.keys()]:[]}#d(n,u){const o=this.#t.get(n).get(u);return o!==void 0?o:this.#t.get("component").get(u)}renderer(n){return this.#d("renderer",n)}editor(n){return this.#d("editor",n)}filter(n){return this.#d("filter",n)}dataType(n){return this.get("dataType",n)}totalFn(n){return this.get("totalFn",n)}pipe(n){return this.get("pipe",n)}setLicence(n){return this.#s.set(n)}licence(){return this.#s.info()}licenceVerified(){return this.#s.verify()}watermark(){return this.#s.watermark()}attach(n){n!=null&&(this.#l.add(n),this.#o=n)}detach(n){if(n!=null){this.#l.delete(n);for(const[u,o]of[...this.#a])o===n&&(this.#r.delete(u),this.#a.delete(u));if(this.#o===n){const u=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#o=u}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(n){if(n!=null){this.detach(n);return}for(const u of[...this.#e.keys()])this.unregisterModule(u);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#o=null}}function O(s){const n=s.capabilities,u=Array.isArray(n)?n.filter(o=>typeof o=="string"):[];return[s.name,...u]}function b(s,n){return s.install!==n.install||s.uninstall!==n.uninstall||(s.version||"")!==(n.version||"")?!1:c(O(s),O(n))&&c(d(s),d(n))}function c(s,n){const u=new Set(s),o=new Set(n);if(u.size!==o.size)return!1;for(const a of u)if(!o.has(a))return!1;return!0}function d(s){const n=s.regions;return!Array.isArray(n)||n.length===0?["all"]:n.filter(u=>G.includes(u))}function l(s){switch(s){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const r=new P;function t(){return r}function i(s,n={}){return r.registerModules(s,n)}}),Be("packages/core/src/internal/text.js",function(e,H){"use strict";Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return D}});function te(F){return F?(F.includes(".")?F.slice(F.lastIndexOf(".")+1):F).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,Y=>Y.toUpperCase()):""}const L={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function X(F){const Z=F==null?"":String(F);return/[&<>"']/.test(Z)?Z.replace(/[&<>"']/g,Y=>L[Y]):Z}function D(F){return String(F).replace(/\w\S*/g,Z=>Z[0].toUpperCase()+Z.slice(1).toLowerCase())}}),Be("packages/core/src/format/number.js",function(e,H){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return X}});const L=H("packages/core/src/internal/predicates.js").isNil;function X(D,F){const Z=D||{},Y=Z.locale||F||void 0,B=Z.style||"decimal",z=typeof Z.scale=="number"?Z.scale:1,G=Z.nullDisplay??"",P=Z.zeroDisplay,O=Z.prefix||"",b=Z.suffix||"",c=Z.negative||"minus",d=Z.signed===!0,l={style:B,notation:Z.notation||"standard"};B==="currency"&&(l.currency=Z.currency||"USD",Z.currencyDisplay&&(l.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(l.minimumFractionDigits=Z.decimals,l.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(l.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(l.maximumFractionDigits=Z.maxDecimals),l.minimumFractionDigits>(l.maximumFractionDigits??20)&&(l.maximumFractionDigits=l.minimumFractionDigits)),Z.thousandsSeparator===!1&&(l.useGrouping=!1),l.notation==="compact"&&(l.compactDisplay=Z.compactDisplay||"short");const r=new Intl.NumberFormat(Y,l),t=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,i=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let s=",",n=".";if(t||i)for(const m of r.formatToParts(12345.6))m.type==="group"?s=m.value:m.type==="decimal"&&(n=m.value);const u=m=>{let v=m;return t&&(v=v.split(s).join("")),i&&(v=v.split(n).join("")),t&&(v=v.split("").join(t)),i&&(v=v.split("").join(i)),v},o=!!(t||i),a=O!==""&&B==="currency",f=m=>{let v;if(a){const h=r.formatToParts(m);let p=!1;v="";for(const g of h)v+=g.value,!p&&g.type==="currency"&&(v+=O,p=!0);p||(v=O+v)}else v=O+r.format(m);return o&&(v=u(v)),v+b},w=m=>{if(L(m)||m==="")return G;const v=typeof m=="number"?m:Number(m);if(Number.isNaN(v))return G;const h=z===1?v:v*z;return h===0&&P!==void 0?P:h<0?c==="parentheses"?`(${f(-h)})`:c==="suffix"?`${f(-h)}-`:f(h):d&&h>0?`+${f(h)}`:f(h)};return w.negativeClass=Z.negativeClass||null,w.spec=Z,w}}),Be("packages/core/src/format/date.js",function(e,H){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"toIsoDate",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"toIsoDateTime",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"compareIso",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce,F=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function Z(i){const s=[];let n=0,u="";const o=()=>{u&&(s.push({token:null,text:u}),u="")};for(;n<i.length;){const a=i[n];if(a==="'"){if(i[n+1]==="'"){u+="'",n+=2;continue}const w=i.indexOf("'",n+1);if(w===-1){u+=i.slice(n+1),n=i.length;continue}u+=i.slice(n+1,w),n=w+1;continue}const f=F.find(w=>i.startsWith(w,n));if(f){o(),s.push({token:f,text:f}),n+=f.length;continue}/[A-Za-z]/.test(a)&&D(`date.pattern.token:${a}`,`the date pattern "${i}" contains '${a}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${F.join(" ")}.`),u+=a,n+=1}return o(),s}const Y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function B(i){if(L(i)||i==="")return null;if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isNaN(i)?null:new Date(i);if(typeof i=="string"){const s=Y.exec(i.trim());if(s){const[,u,o,a,f="0",w="0",m="0"]=s;return new Date(+u,+o-1,+a,+f,+w,+m)}const n=new Date(i);return Number.isNaN(n.getTime())?null:n}return null}function z(i,s){return String(i).padStart(s,"0")}function G(i){if(!i)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const s=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),n={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const o={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const a of s.formatToParts(u))switch(a.type){case"year":o.year=Number(a.value);break;case"month":o.month=Number(a.value);break;case"day":o.day=Number(a.value);break;case"hour":o.hour=Number(a.value)%24;break;case"minute":o.minute=Number(a.value);break;case"second":o.second=Number(a.value);break;case"weekday":o.weekday=n[a.value]??0;break;default:break}return o}}function P(i,s,n){const u=Z(i),o=G(n),a=new Set(u.filter(h=>h.token).map(h=>h.token)),f=a.has("MMM")?new Intl.DateTimeFormat(s,{month:"short",timeZone:n}):null,w=a.has("MMMM")?new Intl.DateTimeFormat(s,{month:"long",timeZone:n}):null,m=a.has("EEE")?new Intl.DateTimeFormat(s,{weekday:"short",timeZone:n}):null,v=a.has("EEEE")?new Intl.DateTimeFormat(s,{weekday:"long",timeZone:n}):null;return h=>{const p=o(h);let g="";for(const k of u){if(!k.token){g+=k.text;continue}switch(k.token){case"yyyy":g+=z(p.year,4);break;case"yy":g+=z(p.year%100,2);break;case"MMMM":g+=w.format(h);break;case"MMM":g+=f.format(h);break;case"MM":g+=z(p.month,2);break;case"M":g+=String(p.month);break;case"dd":g+=z(p.day,2);break;case"d":g+=String(p.day);break;case"EEEE":g+=v.format(h);break;case"EEE":g+=m.format(h);break;case"HH":g+=z(p.hour,2);break;case"H":g+=String(p.hour);break;case"hh":g+=z(p.hour%12===0?12:p.hour%12,2);break;case"h":g+=String(p.hour%12===0?12:p.hour%12);break;case"mm":g+=z(p.minute,2);break;case"m":g+=String(p.minute);break;case"ss":g+=z(p.second,2);break;case"s":g+=String(p.second);break;case"SSS":g+=z(p.ms,3);break;case"a":g+=p.hour<12?"AM":"PM";break;default:g+=k.text;break}}return g}}const O=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function b(i,s){const n=i||{},u=n.locale||s||void 0,o=n.nullDisplay??"",a=n.timeZone;let f;if(n.pattern)f=P(n.pattern,u,a);else if(n.dateStyle||n.timeStyle){const p={timeZone:a};n.dateStyle&&(p.dateStyle=n.dateStyle),n.timeStyle&&(p.timeStyle=n.timeStyle);const g=new Intl.DateTimeFormat(u,p);f=k=>g.format(k)}else{const p=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:a});f=g=>p.format(g)}const w=n.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,v=(typeof n.relative=="object"&&n.relative?n.relative.threshold??7:7)*24*36e5,h=(p,g)=>{const k=B(p);if(!k)return o;if(w){const y=g&&typeof g.now=="number"?g.now:Date.now(),T=k.getTime()-y;if(Math.abs(T)<v){for(const[j,N]of O)if(Math.abs(T)>=N||j==="second")return w.format(Math.round(T/N),j)}}return f(k)};return h.spec=n,h}function c(i){if(L(i)||i==="")return null;if(typeof i=="string"){const u=/^(\d{4}-\d{2}-\d{2})/.exec(i.trim());if(u)return u[1];const o=B(i);return o?c(o):null}const s=B(i);if(!s)return null;const n=u=>String(u).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}`}function d(i,s){if(L(i)||i==="")return null;if(typeof i=="string"){const u=i.trim();if(l.test(u)){const f=B(u);return f?r(f,s):null}const o=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(u);if(o){const[,f,w,m,v]=o;return`${f}T${w}:${m}${v&&v!=="00"?`:${v}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(u))return`${u}T00:00`;const a=B(u);return a?d(a):null}const n=B(i);return n?r(n,s):null}const l=/(?:Z|[+-]\d{2}:?\d{2})$/i;function r(i,s){const n=f=>String(f).padStart(2,"0");if(s)try{const f=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(i).reduce((v,h)=>(h.type!=="literal"&&(v[h.type]=h.value),v),{}),w=f.hour==="24"?"00":f.hour,m=Number(f.second);return`${f.year}-${f.month}-${f.day}T${w}:${f.minute}`+(m?`:${f.second}`:"")}catch{}const u=`${i.getFullYear()}-${n(i.getMonth()+1)}-${n(i.getDate())}`,o=i.getSeconds(),a=`${n(i.getHours())}:${n(i.getMinutes())}${o?`:${n(o)}`:""}`;return`${u}T${a}`}function t(i,s){const n=L(i)||i===""?null:String(i),u=L(s)||s===""?null:String(s);return n===null?u===null?0:1:u===null||n<u?-1:n>u?1:0}}),Be("packages/core/src/format/boolean.js",function(e,H){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isNil,X={true:"☑",false:"☐",null:""},D={true:"◉",false:"◯",null:""};function F(Y){if(L(Y)||Y==="")return null;if(typeof Y=="boolean")return Y;if(typeof Y=="number")return Y!==0;const B=String(Y).trim().toLowerCase();return B==="true"||B==="yes"||B==="y"||B==="1"?!0:B==="false"||B==="no"||B==="n"||B==="0"?!1:null}function Z(Y,B){const z=Y||{},G=z.display||"text",P=z.trueLabel??"Yes",O=z.falseLabel??"No",b=z.nullLabel??"";let c=P,d=O;const l=b;G==="checkbox"?(c=X.true,d=X.false):G==="switch"?(c=D.true,d=D.false):G==="icon"&&(c=z.trueIcon??P,d=z.falseIcon??O);const r=t=>{const i=F(t);return i===null?l:i?c:d};return r.display=G,r.labels={true:P,false:O,null:b},r.locale=B,r.spec=z,r}}),Be("packages/core/src/format/text.js",function(e,H){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/text.js").titleCase;function F(Z,Y){const B=Z||{},z=B.locale||Y||void 0,G=B.nullDisplay??"",P=B.emptyDisplay??"",O=B.transform||"none",b=typeof B.truncate=="number"?{chars:B.truncate}:B.truncate||null,c=b?b.chars:0,d=b?b.ellipsis??"…":"",l=t=>{switch(O){case"upper":return z?t.toLocaleUpperCase(z):t.toUpperCase();case"lower":return z?t.toLocaleLowerCase(z):t.toLowerCase();case"title":return D(t);default:return t}},r=t=>{if(L(t))return G;let i=typeof t=="string"?t:String(t);return i===""?P:(O!=="none"&&(i=l(i)),c>0&&i.length>c&&(i=i.slice(0,c)+d),i)};return r.spec=B,r}}),Be("packages/core/src/format/mask.js",function(e,H){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const te=new Set(["0","#","?",",","."]),L="\0";function X(B){const z=[];let G="",P=!1;for(let O=0;O<B.length;O++){const b=B[O];if(b==="\\"){G+=b+(B[O+1]??""),O+=1;continue}if(b==='"'){P=!P,G+=b;continue}if(b===";"&&!P){z.push(G),G="";continue}G+=b}return z.push(G),z}function D(B){let z="",G="",P="",O=1,b=!1,c=!1;const d=a=>{c?G+=a:z+=a};for(let a=0;a<B.length;a++){const f=B[a];if(f==="\\"){d(B[a+1]??""),a+=1;continue}if(f==='"'){const w=B.indexOf('"',a+1);d(w===-1?B.slice(a+1):B.slice(a+1,w)),a=w===-1?B.length:w;continue}if(f==="%"){O*=100,d("%");continue}if(f==="@"){b=!0,d("\0");continue}if(te.has(f)){P+=f,c=!0;continue}d(f)}let l=-1;for(let a=P.length-1;a>=0;a--){const f=P[a];if(f==="0"||f==="#"||f==="?"){l=a;break}}let r=!1,t="";for(let a=0;a<P.length;a++){const f=P[a];if(f===","){a>l?O/=1e3:r=!0;continue}t+=f}const i=t.indexOf("."),s=i===-1?t:t.slice(0,i),n=i===-1?"":t.slice(i+1);let u=0;for(const a of s)a==="0"&&(u+=1);let o=0;for(const a of n)a==="0"&&(o+=1);return{prefix:z,suffix:G,minInt:u,minDec:o,maxDec:n.length,grouping:r,scale:O,hasNumber:l!==-1,isText:b}}function F(B,z){const G=new Intl.NumberFormat(z,{minimumIntegerDigits:Math.max(B.minInt,1),minimumFractionDigits:B.minDec,maximumFractionDigits:Math.max(B.maxDec,B.minDec),useGrouping:B.grouping}),{prefix:P,suffix:O,scale:b,hasNumber:c}=B;return d=>{if(!c)return P+O;const l=b===1?d:d*b;return P+G.format(l)+O}}function Z(B,z){const P=X(String(B)).map(D),O=P.map(t=>F(t,z)),b=0,c=P.length>1?1:-1,d=P.length>2?2:-1,l=P.length>3?3:-1,r=t=>{if(t==null||t==="")return"";if(typeof t!="number"||Number.isNaN(t)){const i=Number(t);if(Number.isNaN(i))return l===-1?String(t):(P[l].prefix+P[l].suffix).split("\0").join(String(t));t=i}return t===0&&d!==-1?O[d](0):t<0&&c!==-1?O[c](-t):O[b](t)};return r.spec={mask:B},{format:r,ooxml:Y(String(B))}}function Y(B){return B.trim()}}),Be("packages/core/src/format/shorthand.js",function(e,H){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return Y}});const te=["currency","number","percent","date","boolean","text","relative"],L=/[#0?@;"\\]/,X=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function D(B){return typeof B!="string"||B===""||Z(B)?!1:L.test(B)}function F(B){return typeof B!="string"||B===""||Z(B)?!1:X.test(B)}function Z(B){const z=B.indexOf(":"),G=z===-1?B:B.slice(0,z);return te.includes(G)?G:null}function Y(B){const z=Z(B);if(!z)return null;const G=B.indexOf(":"),P=G===-1?"":B.slice(G+1),O=P===""?[]:P.split(":");switch(z){case"currency":{const b={type:"number",style:"currency",currency:O[0]||"USD"};return O[1]!==void 0&&O[1]!==""&&(b.decimals=Number(O[1])),b}case"number":{const b={type:"number",style:"decimal"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"percent":{const b={type:"number",style:"percent"};return O[0]!==void 0&&O[0]!==""&&(b.decimals=Number(O[0])),b}case"date":return{type:"date",pattern:P||void 0};case"relative":return{type:"date",relative:!0};case"boolean":{const b=P.split("/"),c={type:"boolean",display:"text"};return b[0]!==void 0&&b[0]!==""&&(c.trueLabel=b[0]),b[1]!==void 0&&b[1]!==""&&(c.falseLabel=b[1]),b[2]!==void 0&&(c.nullLabel=b[2]),c}case"text":{const b={type:"text"};return O[0]&&(b.transform=O[0]),O[1]!==void 0&&O[1]!==""&&(b.truncate=Number(O[1])),b}default:return null}}}),Be("packages/core/src/format/index.js",function(e,H){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return g}});const te=H("packages/core/src/internal/predicates.js"),L=te.isFunction,X=te.isObject,F=H("packages/core/src/internal/warn.js").warnOnce,Z=H("packages/core/src/format/number.js"),Y=Z.compileNumber,B=H("packages/core/src/format/date.js"),z=B.compileDate,G=B.scanPattern,P=H("packages/core/src/format/boolean.js"),O=P.compileBoolean,b=H("packages/core/src/format/text.js"),c=b.compileText,d=H("packages/core/src/format/mask.js"),l=d.compileMask,r=H("packages/core/src/format/shorthand.js"),t=r.parseShorthand,i=r.looksLikeMask,s=r.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return Z.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return B.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return B.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return B.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return B.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return P.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return P.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return b.compileText}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return d.compileMask}}),Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return d.splitSections}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return d.parseSection}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return r.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return r.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return r.looksLikeDatePattern}});const n=new Set(["decimal","currency","percent","unit"]),u=new Set(["type","locale"]),o={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])},a=new Set(["number","date","boolean","text"]);function f(j,N){const W=j.type;if(W===void 0||a.has(W)||!n.has(String(W)))return;const R=N?`"${N}"`:"with no id";F(`format:unknown-style-key:${N||""}:${W}`,`column ${R} has format: { type: "${W}" }, which is not a valid format type ("number", "date", "boolean" or "text") and is ignored; did you mean style: "${W}" instead?`)}function w(j,N,W){const R=o[N],x=W?`"${W}"`:"with no id";for(const A of j){if(u.has(A)||R.has(A))continue;const $=Object.keys(o).find(I=>I!==N&&o[I].has(A));$?F(`format:inapplicable:${W||""}:${A}`,`column ${x} has format key "${A}", which applies to a ${$} column, not the ${N} column it was applied to; it is ignored.`):F(`format:unknown:${W||""}:${A}`,`column ${x} has an unrecognised format key "${A}" for its ${N} format; it is ignored.`)}}function m(j){if(j.type==="number"||j.type==="date"||j.type==="boolean"||j.type==="text")return!0;const N=n.has(String(j.style));return!!(j.pattern||j.dateStyle||j.timeStyle||j.relative||j.timeZone||j.trueLabel||j.falseLabel||j.display||j.trueIcon||j.falseIcon||j.transform||j.truncate||j.emptyDisplay||N||j.currency||j.decimals!==void 0||j.minDecimals!==void 0||j.maxDecimals!==void 0||j.notation||j.negative||j.scale!==void 0||j.prefix||j.suffix||j.zeroDisplay!==void 0)}function v(j,N){if(j.type==="number"||j.type==="date"||j.type==="boolean"||j.type==="text")return j.type;if(j.pattern||j.dateStyle||j.timeStyle||j.relative||j.timeZone)return"date";if(j.trueLabel||j.falseLabel||j.display||j.trueIcon||j.falseIcon)return"boolean";if(j.transform||j.truncate||j.emptyDisplay)return"text";if(j.style||j.currency||j.decimals!==void 0||j.minDecimals!==void 0||j.maxDecimals!==void 0||j.notation||j.negative||j.scale!==void 0||j.prefix||j.suffix||j.zeroDisplay!==void 0)return"number";const W=N&&N.base;return W==="number"?"number":W==="date"||W==="dateString"?"date":W==="boolean"?"boolean":"text"}function h(j,N=null,W=void 0,R=void 0,x=void 0){if(j==null||j==="")return null;const A=X(j)?Object.keys(j):null;if(typeof j=="function"){const M=(S,E)=>String(j({...E||{},value:S,locale:W})??"");return M.ooxml=N&&N.excel||"General",M}if(typeof j=="string"){if(i(j)){const{format:S,ooxml:E}=l(j,W);return S.ooxml=E,S}const M=t(j)||(s(j)?{type:"date",pattern:j}:null);return M?h(M,N,W,R,x):(F(`format:${j}`,`unrecognised format string "${j}"; the value will be stringified`),null)}if(!X(j))return F("format:shape","format must be a spec object or a string; ignoring",j),null;if(N&&L(N.format)&&!m(j)||N&&L(N.format)&&Array.isArray(N.formatPatterns)&&j.type===void 0)return null;const $=v(j,N);$==="date"&&R&&j.timeZone===void 0&&(j={...j,timeZone:R}),f(j,x),w(A||Object.keys(j),$,x);let I;switch($){case"number":I=Y(j,W);break;case"date":I=z(j,W);break;case"boolean":I=O(j,W);break;default:I=c(j,W);break}return I.ooxml=g(j,$,W,N),I.kind=$,I}const p={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function g(j,N,W=void 0,R=null){if(N==="date"){if(j.pattern){let M="";for(const S of G(j.pattern))M+=S.token?p[S.token]??S.text:S.text;return M}return R&&R.excel||"yyyy-mm-dd"}if(N==="boolean")return"General";if(N==="text")return"@";if(j.notation==="compact"||j.notation==="scientific")return"General";const x=typeof j.decimals=="number"?j.decimals:typeof j.minDecimals=="number"?j.minDecimals:j.style==="currency"?2:0;let $=`${j.thousandsSeparator===!1?"":"#,#"}#0${x>0?`.${"0".repeat(x)}`:""}`,I="";return j.style==="currency"&&(I+=k(T(j.currency||"USD",W))),j.prefix&&(I+=k(j.prefix)),$=I+$,j.style==="percent"&&($=`${$}%`),j.suffix&&($+=k(j.suffix)),j.negative==="parentheses"?`${$};(${$})`:j.negative==="suffix"?`${$};${$}-`:$}function k(j){return`"${String(j).split('"').join("")}"`}const y=new Map;function T(j,N){const W=`${j}|${N||""}`;let R=y.get(W);if(R!==void 0)return R;R=j;try{const A=new Intl.NumberFormat(N,{style:"currency",currency:j}).formatToParts(0).find($=>$.type==="currency");A&&(R=A.value)}catch{}return y.set(W,R),R}}),Be("packages/core/src/columns/types/temporal.js",function(e,H){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Ie}});const te=H("packages/core/src/internal/predicates.js"),L=te.isNil,X=te.isFunction,D=H("packages/core/src/format/date.js"),F=D.toDate,Z=D.compilePattern,Y=D.compileDate,B=D.toIsoDateTime,z=D.compareIso,G=864e5,P=Object.freeze({}),O=1e3,b=60*O,c=60*b,d=24*c,l=7*d,r=new WeakMap;function t(we,Fe){const He=we&&we.locale||"",Ke=we&&we.column;if(!Ke)return He?{locale:He}:P;const nt=r.get(Ke);if(nt&&nt.locale===He)return nt.bag;const it=Ke.typeOptions||Ke[Fe]||(i(Ke.format)?Ke.format:null),mt={...it||P,locale:it&&it.locale||He||void 0};return r.set(Ke,{locale:He,bag:mt}),mt}function i(we){return we!==null&&typeof we=="object"&&!Array.isArray(we)&&!(we instanceof Date)}function s(we,Fe){const He=we===null||Number.isNaN(we)?null:we,Ke=Fe===null||Number.isNaN(Fe)?null:Fe;return He===null?Ke===null?0:1:Ke===null||He<Ke?-1:He>Ke?1:0}const n=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,u=/^(\d{3,6})$/;function o(we,Fe,He,Ke){return!(we>=0&&we<=23)||!(Fe>=0&&Fe<=59)||!(He>=0&&He<=59)||!(Ke>=0&&Ke<=999)?null:we*c+Fe*b+He*O+Ke}function a(we){if(L(we))return null;const Fe=String(we).trim();if(Fe==="")return null;const He=u.exec(Fe);if(He){const Pt=He[1];if(Pt.length===5)return null;const Nt=Pt.length===3?1:2;return o(Number(Pt.slice(0,Nt)),Number(Pt.slice(Nt,Nt+2)),Number(Pt.slice(Nt+2,Nt+4)||0),0)}const Ke=n.exec(Fe);if(!Ke)return null;let nt=Number(Ke[1]);const it=Number(Ke[2]||0),mt=Number(Ke[3]||0),kt=Ke[4]?Number(Ke[4].padEnd(3,"0")):0,St=Ke[5]?Ke[5][0].toLowerCase():null;if(St){if(nt<1||nt>12)return null;nt=nt%12,St==="p"&&(nt+=12)}return o(nt,it,mt,kt)}function f(we){return L(we)||we===""?null:typeof we=="number"?Number.isFinite(we)?(we%d+d)%d:null:we instanceof Date?Number.isNaN(we.getTime())?null:we.getHours()*c+we.getMinutes()*b+we.getSeconds()*O+we.getMilliseconds():a(we)}const w=new Map;function m(we){const Fe=we.pattern||"",He=we.timeStyle||(we.seconds?"medium":"short"),Ke=`${we.locale||""}|${Fe}|${He}`;let nt=w.get(Ke);if(nt)return nt;if(Fe)nt=Z(Fe,we.locale||void 0,"UTC");else{const it=new Intl.DateTimeFormat(we.locale||void 0,{timeStyle:He,timeZone:"UTC"});nt=mt=>it.format(mt)}return w.set(Ke,nt),nt}function v(we,Fe){const He=Fe||P;if(we==null||typeof we!="number"||!Number.isFinite(we))return He.nullDisplay??"";const Ke=(we%d+d)%d;return m(He)(new Date(Ke))}function h(we){return we instanceof Date?!Number.isNaN(we.getTime()):typeof we=="number"?Number.isFinite(we)&&we>=0&&we<d:typeof we!="string"||!we.includes(":")?!1:a(we)!==null}function p(we){const Fe=f(we);return Fe==null?"":v(Fe,{pattern:Fe%O===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const g=new Map;function k(we){const Fe=we||"";let He=g.get(Fe);return He||(He=new Intl.DateTimeFormat("en-GB",{timeZone:we||void 0,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}),g.set(Fe,He)),He}function y(we,Fe){const He={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Ke of k(Fe).formatToParts(new Date(we)))Ke.type==="year"?He.year=Number(Ke.value):Ke.type==="month"?He.month=Number(Ke.value):Ke.type==="day"?He.day=Number(Ke.value):Ke.type==="hour"?He.hour=Number(Ke.value)%24:Ke.type==="minute"?He.minute=Number(Ke.value):Ke.type==="second"&&(He.second=Number(Ke.value));return He}function T(we,Fe){const He=y(we,Fe);return Date.UTC(He.year,He.month-1,He.day,He.hour,He.minute,He.second,0)-Math.floor(we/1e3)*1e3}function j(we,Fe){const He=we.hour||0,Ke=we.minute||0,nt=we.second||0,it=we.ms||0;if(!Fe)return new Date(we.year,we.month-1,we.day,He,Ke,nt,it).getTime();const mt=Date.UTC(we.year,we.month-1,we.day,He,Ke,nt,it);let kt=mt-T(mt,Fe);return kt=mt-T(kt,Fe),kt}const N=/(?:Z|[+-]\d{2}:?\d{2})$/i,W=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function R(we,Fe){if(L(we))return null;const He=String(we).trim();if(He==="")return null;const Ke=Fe&&Fe.timeZone||void 0;if(!N.test(He)){const nt=W.exec(He);if(nt){const it=(nt[4]||"").trim(),mt=it===""?0:a(it);if(mt===null)return null;const kt=j({year:Number(nt[1]),month:Number(nt[2]),day:Number(nt[3]),hour:Math.floor(mt/c),minute:Math.floor(mt/b)%60,second:Math.floor(mt/O)%60,ms:mt%O},Ke);return Number.isNaN(kt)?null:new Date(kt)}}return F(He)}function x(we){if(typeof we=="number")return Number.isFinite(we)?we:null;const Fe=F(we);return Fe?Fe.getTime():null}const A=new Map;function $(we){const Fe=[we.locale||"",we.pattern||"",we.dateStyle||"",we.timeStyle||"",we.timeZone||"",we.seconds?"1":""].join("|");let He=A.get(Fe);if(He)return He;const Ke=we.pattern?{type:"date",pattern:we.pattern,timeZone:we.timeZone}:{type:"date",dateStyle:we.dateStyle||"medium",timeStyle:we.timeStyle||(we.seconds?"medium":"short"),timeZone:we.timeZone};return He=Y(Ke,we.locale||void 0),A.set(Fe,He),He}function I(we,Fe){const He=Fe||P,Ke=x(we);return Ke==null?He.nullDisplay??"":$(He)(Ke)}function M(we){return we instanceof Date?!Number.isNaN(we.getTime()):typeof we!="string"||!W.test(we.trim())?!1:R(we)!==null}const S=Object.freeze([{key:"w",ms:l,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:d,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms:c,intl:"hour",long:["hour","hours"],names:["h","hr","hrs","hour","hours"]},{key:"m",ms:b,intl:"minute",long:["minute","minutes"],names:["m","min","mins","minute","minutes"]},{key:"s",ms:O,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),E=new Map;for(const we of S)for(const Fe of we.names)E.set(Fe,we);const U=Object.freeze(S.filter(we=>we.key!=="w")),K=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,q=/^\d+(?:\.\d+)?$/,_=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function J(we){const Fe=we&&we.defaultUnit?E.get(String(we.defaultUnit).toLowerCase()):null;return Fe?Fe.ms:b}function ee(we){return(we&&we.defaultUnit?E.get(String(we.defaultUnit).toLowerCase()):null)||E.get("m")}function ne(we,Fe){if(L(we))return null;let He=String(we).trim().toLowerCase();if(He==="")return null;let Ke=1;if(He[0]==="-"?(Ke=-1,He=He.slice(1).trim()):He[0]==="+"&&(He=He.slice(1).trim()),He==="")return null;const nt=_.exec(He);if(nt){const St=nt[3]!==void 0,Pt=Number(nt[1])*c+Number(nt[2])*b+(St?Number(nt[3])*O:0)+(nt[4]?Number(nt[4].padEnd(3,"0")):0);return Ke*Pt}if(q.test(He))return Math.round(Ke*Number(He)*J(Fe||P));let it=He,mt=0,kt=0;for(;it!=="";){const St=K.exec(it);if(!St)return null;const Pt=E.get(St[2]);if(!Pt)return null;mt+=Number(St[1])*Pt.ms,it=it.slice(St[0].length),kt++}return kt===0?null:Math.round(Ke*mt)}function oe(we){return L(we)||we===""?null:typeof we=="number"?Number.isFinite(we)?we:null:ne(we)}const ie=new Map;function ae(we,Fe,He){const Ke=`${He||""}|${Fe.intl}`;let nt=ie.get(Ke);if(nt===void 0){try{nt=new Intl.NumberFormat(He||void 0,{style:"unit",unit:Fe.intl,unitDisplay:"long"})}catch{nt=null}ie.set(Ke,nt)}return nt?nt.format(we):`${we} ${we===1?Fe.long[0]:Fe.long[1]}`}function ce(we,Fe){return String(we).padStart(Fe,"0")}function de(we,Fe){const He=Fe||P;if(we==null||typeof we!="number"||!Number.isFinite(we))return He.nullDisplay??"";const Ke=He.style||"short",nt=we<0;let it=Math.round(Math.abs(we));const mt=nt?"-":"";if(it===0&&He.zeroDisplay!=null)return He.zeroDisplay;if(Ke==="clock"){const Nt=Math.floor(it/c),Ft=Math.floor(it/b)%60,Lt=Math.floor(it/O)%60;return`${mt}${ce(Nt,2)}:${ce(Ft,2)}:${ce(Lt,2)}`}if(it===0){const Nt=ee(He);return Ke==="long"?ae(0,Nt,He.locale):`0${Nt.key}`}const kt=He.weeks===!0?S:U,St=typeof He.maxUnits=="number"&&He.maxUnits>0?He.maxUnits:He.maxUnits===void 0?2:1/0,Pt=[];for(const Nt of kt){if(Pt.length>=St)break;const Ft=Math.floor(it/Nt.ms);Ft!==0&&(it-=Ft*Nt.ms,Pt.push(Ke==="long"?ae(Ft,Nt,He.locale):`${Ft}${Nt.key}`))}return mt+Pt.join(" ")}function Ae(we){if(typeof we!="string")return!1;const Fe=we.trim();return Fe===""||_.test(Fe)||!/[a-z]/i.test(Fe)?!1:ne(Fe)!==null}const je=Date.UTC(1899,11,30),be=new Map;function re(we,Fe){const He=we||"";let Ke=be.get(He);Ke||(Ke=new Intl.DateTimeFormat("en-GB",{timeZone:we||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),be.set(He,Ke));const nt=typeof Fe=="number"?Fe:Date.now();for(const it of Ke.formatToParts(new Date(nt)))if(it.type==="timeZoneName")return it.value;return""}function fe(we){if(we)return we;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function pe(we,Fe){const He=fe(we),Ke=re(we,Fe);return Ke?`${He} (${Ke})`:He}function Oe(we,Fe){if(we&&we.timeZone)return we.timeZone;const He=Fe&&Fe.grid;return(He&&X(He.get)?He.get("timeZone"):void 0)||void 0}function ve(we,Fe){const He=Fe||P,Ke=x(we);if(Ke==null)return He.nullDisplay??"";const nt=$(He)(Ke);if(!He.showOrigin)return nt;const it=He.originZone;return it?it===(He.timeZone||fe(He.timeZone))?nt:`${nt} (${pe(it,Ke)})`:`${nt} (no origin recorded)`}function $e(we,Fe,He,Ke){if(Fe==="instant"||!Fe)return we;const nt=y(we,He);if(Fe==="month")return j({year:nt.year,month:nt.month,day:1},He);if(Fe==="week"){const it=Ke>=1&&Ke<=7?Ke:1,kt=((new Date(Date.UTC(nt.year,nt.month-1,nt.day)).getUTCDay()+6)%7+1-it+7)%7,St=new Date(Date.UTC(nt.year,nt.month-1,nt.day-kt));return j({year:St.getUTCFullYear(),month:St.getUTCMonth()+1,day:St.getUTCDate()},He)}return j({year:nt.year,month:nt.month,day:nt.day},He)}function he(we,Fe){const He=we&&we.group,Ke=He&&He.granularity||"day";if(Ke==="instant")return null;const nt=He&&He.weekStart;return it=>typeof it=="number"?$e(it,Ke,Fe,nt):it}const ye={time:{base:"number",storage:"float64",matches:h,format:we=>v(f(we.value),t(we,"time")),parse:we=>a(we.text),compare:(we,Fe)=>s(f(we),f(Fe)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:we=>{const Fe=f(we);return Fe===null?null:Fe/G},toStorage:we=>f(we),toClipboard:p,fromClipboard:a},datetime:{base:"dateString",storage:"dictionary",matches:M,format:we=>I(we.value,t(we,"datetime")),parse:we=>B(R(we.text,t(we,"datetime"))??we.text),compare:z,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(we,Fe)=>B(we,Fe&&Fe.timeZone),toClipboard:we=>L(we)?"":String(we),fromClipboard:we=>B(we)},duration:{base:"number",storage:"float64",matches:Ae,format:we=>de(oe(we.value),t(we,"duration")),parse:we=>ne(we.text,t(we,"duration")),compare:(we,Fe)=>s(oe(we),oe(Fe)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:we=>{const Fe=oe(we);return Fe===null?null:Fe/G},toStorage:we=>oe(we),toClipboard:we=>de(oe(we),{style:"short",maxUnits:-1}),fromClipboard:we=>ne(we)},timestamp:{base:"number",storage:"float64",format:we=>{const Fe=t(we,"timestamp");return ve(we.value,{...Fe,timeZone:Oe(Fe,we)})},parse:we=>{const Fe=t(we,"timestamp"),He=R(we.text,{timeZone:Oe(Fe,we)});return He?He.getTime():null},compare:(we,Fe)=>s(x(we),x(Fe)),groupProjector:(we,Fe)=>he(we,Fe),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(we,Fe)=>{const He=x(we);if(He==null)return null;const Ke=y(He,Fe&&Fe.timeZone||void 0);return(Date.UTC(Ke.year,Ke.month-1,Ke.day,Ke.hour,Ke.minute,Ke.second)-je)/G},toStorage:we=>x(we),toClipboard:we=>{const Fe=x(we);return Fe==null?"":new Date(Fe).toISOString()},fromClipboard:we=>x(we)}},Se=["datetime","time","duration"],Ie=ye}),Be("packages/core/src/internal/lru.js",function(e,H){"use strict";Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return te}});class te{#e;#t=new Map;#n;constructor(X=256,D=null){this.#e=X,this.#n=D}get size(){return this.#t.size}get max(){return this.#e}set max(X){this.#e=X,this.#r()}has(X){return this.#t.has(X)}get(X){const D=this.#t;if(!D.has(X))return;const F=D.get(X);return D.delete(X),D.set(X,F),F}peek(X){return this.#t.get(X)}set(X,D){const F=this.#t;return F.has(X)&&F.delete(X),F.set(X,D),this.#r(),D}delete(X){const D=this.#t.get(X);return this.#t.delete(X)&&this.#n&&this.#n(D,X),D}clear(){if(this.#n)for(const[X,D]of this.#t)this.#n(D,X);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const X=this.#t;for(;X.size>this.#e;){const D=X.keys().next().value,F=X.get(D);X.delete(D),this.#n&&this.#n(F,D)}}}}),Be("packages/core/src/columns/types/network.js",function(e,H){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/lru.js").Lru,F=4294967295,Z=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Y(A){if(L(A))return null;if(typeof A=="string")return B(A);const $=Number(A);return Number.isFinite($)?$<0?$<-2147483648?null:$>>>0:$>F?null:Math.trunc($)>>>0:null}function B(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const I=Z.exec($);if(!I)return null;let M=0;for(let S=1;S<=4;S++){const E=I[S];if(E.length>1&&E.charCodeAt(0)===48)return null;const U=Number(E);if(U>255)return null;M=M*256+U}return M}function z(A){const $=Y(A);return $===null?"":`${$>>>24&255}.${$>>>16&255}.${$>>>8&255}.${$&255}`}function G(A){return typeof A=="string"&&B(A)!==null}function P(A,$){const I=Y(A),M=Y($);return I===null?M===null?0:1:M===null||I<M?-1:I>M?1:0}const O=64,b=F*O+32,c=/^(?:0|[1-9]\d?)$/;function d(A,$){return A*O+$}function l(A){if(L(A))return null;if(typeof A=="string"){const M=r(A);return M===null?null:l(M)}if(typeof A=="object"){const M=Y(A.address),S=Number(A.prefix);return M===null||!Number.isInteger(S)||S<0||S>32?null:{address:M,prefix:S}}const $=Number(A);if(!Number.isInteger($)||$<0||$>b)return null;const I=$%O;return I>32?null:{address:($-I)/O,prefix:I}}function r(A){if(L(A))return null;const $=String(A).trim();if($==="")return null;const I=$.indexOf("/");if(I<0)return null;const M=B($.slice(0,I));if(M===null)return null;const S=$.slice(I+1).trim();if(!c.test(S))return null;const E=Number(S);return E>32?null:d(M,E)}function t(A){const $=l(A);return $?`${z($.address)}/${$.prefix}`:""}function i(A){return typeof A=="string"&&r(A)!==null}function s(A,$){const I=l(A),M=l($);return I?M?I.address!==M.address?I.address<M.address?-1:1:I.prefix-M.prefix:-1:M?1:0}function n(A){return A===0?0:4294967295<<32-A>>>0}function u(A){const $=l(A);return $?($.address&n($.prefix))>>>0:null}function o(A){const $=l(A);return $?($.address&n($.prefix)|~n($.prefix)>>>0)>>>0:null}function a(A){const $=l(A);return $?2**(32-$.prefix):null}function f(A){const $=l(A);return $?$.prefix===32?1:$.prefix===31?2:2**(32-$.prefix)-2:null}function w(A,$){const I=l(A);if(!I)return!1;const M=Y($);if(M===null)return!1;const S=n(I.prefix);return(M&S)>>>0===(I.address&S)>>>0}function m(A,$){const I=u(A),M=u($);return I===null||M===null?!1:I<=o($)&&M<=o(A)}const v=/^[0-9a-fA-F]{1,4}$/,h=new D(512);function p(A){if(L(A))return null;let $=String(A).trim();if($==="")return null;const I=$.indexOf("%");if(I>=0&&($=$.slice(0,I)),$==="")return null;if($.indexOf(".")>=0){const q=$.lastIndexOf(":");if(q<0)return null;const _=B($.slice(q+1));if(_===null)return null;$=`${$.slice(0,q+1)}${(_>>>16&65535).toString(16)}:${(_&65535).toString(16)}`}const M=$.split("::");if(M.length>2)return null;const S=g(M[0]);if(S===null)return null;if(M.length===1)return S.length===8?S:null;const E=g(M[1]);if(E===null)return null;const U=8-S.length-E.length;if(U<1)return null;const K=S.slice();for(let q=0;q<U;q++)K.push(0);for(const q of E)K.push(q);return K}function g(A){if(A==="")return[];const $=[];for(const I of A.split(":")){if(!v.test(I))return null;$.push(parseInt(I,16))}return $}function k(A){if(typeof A!="string")return p(A);if(h.has(A))return h.get(A);const $=p(A);return h.set(A,$),$}function y(A){if(A[0]===0&&A[1]===0&&A[2]===0&&A[3]===0&&A[4]===0&&A[5]===65535)return`::ffff:${z((A[6]<<16|A[7])>>>0)}`;let $=-1,I=0,M=-1,S=0;for(let K=0;K<8;K++)A[K]===0?(M<0?(M=K,S=1):S++,S>I&&(I=S,$=M)):(M=-1,S=0);if(I<2)return A.map(K=>K.toString(16)).join(":");const E=A.slice(0,$).map(K=>K.toString(16)).join(":"),U=A.slice($+I).map(K=>K.toString(16)).join(":");return`${E}::${U}`}function T(A){const $=p(A);return $===null?null:y($)}function j(A){return T(A)??""}function N(A){return typeof A=="string"&&A.indexOf(":")>=0&&p(A)!==null}function W(A,$){const I=k(A),M=k($);if(!I)return M?1:0;if(!M)return-1;for(let S=0;S<8;S++)if(I[S]!==M[S])return I[S]<M[S]?-1:1;return 0}const R=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:G,parse:A=>B(A.text),compare:P,format:A=>z(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>Y(A),toClipboard:A=>z(A),fromClipboard:A=>B(A)},cidr:{base:"number",storage:"float64",matches:i,parse:A=>r(A.text),compare:s,format:A=>t(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:A=>{const $=l(A);return $===null?null:d($.address,$.prefix)},toClipboard:A=>t(A),fromClipboard:A=>r(A)},ipv6:{base:"text",storage:"dictionary",matches:N,parse:A=>T(A.text),compare:W,format:A=>j(A.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:A=>T(A),toClipboard:A=>j(A),fromClipboard:A=>T(A)}}),x=R}),Be("packages/core/src/i18n/catalogue.js",function(e,H){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return D}});const L=H("packages/core/src/registry/free-tier-notice.js").FREE_TIER_NOTICE,X=Object.freeze({"count.rows":{one:"{count} row",other:"{count} rows"},"count.comments":{one:"{count} comment",other:"{count} comments"},"comments.someUnresolved":"{comments}, {unresolved} unresolved","comments.allResolved":"{comments}, all resolved","count.unresolvedComments":{one:"{count} unresolved comment",other:"{count} unresolved comments"},"count.items":{one:"{count} item",other:"{count} items"},"count.keys":{one:"{count} key",other:"{count} keys"},"count.values":{one:"value",other:"values"},"count.waiting":{one:"{count} waiting",other:"{count} waiting"},"count.rowsAdded":{one:"{count} row added",other:"{count} rows added"},"count.rowsRemoved":{one:"{count} row removed",other:"{count} rows removed"},"value.empty":"empty","a11y.sort.cleared":"Sort cleared","a11y.sort.by":"Sorted by {columns}","a11y.sort.column":"{column} {direction}","a11y.sort.ascending":"ascending","a11y.sort.descending":"descending","a11y.filter.cleared":"Filter cleared, {rows}","a11y.filter.applied":"Filtered to {shown} of {total}","a11y.find.count":{one:"{current} of {count} match",other:"{current} of {count} matches"},"a11y.find.countLoaded":{one:"{current} of {count} match in loaded rows",other:"{current} of {count} matches in loaded rows"},"a11y.find.none":"No matches","a11y.find.noneLoaded":"No matches in loaded rows","a11y.selection.cleared":"Selection cleared","a11y.selection.count":{one:"{count} row selected",other:"{count} rows selected"},"tabs.tablist":"Tabs","a11y.tabs.selected":"{label} tab selected","a11y.scrollbar.horizontal":"Horizontal scrollbar","a11y.scrollbar.vertical":"Vertical scrollbar","designer.canvas":"Dashboard canvas","designer.chrome":"Designer tools","designer.page":"Page {n}","a11y.designer.edit":"Edit mode","a11y.designer.view":"View mode","layout.region":"Dashboard layout","layout.move":"Move {title}","layout.resize":"Resize {title}","layout.close":"Close {title}","a11y.layout.grabbed":"{title} grabbed, column {x} of {columns}, row {y}","a11y.layout.position":"{title}, column {x} of {columns}, row {y}","a11y.layout.dropped":"{title} dropped, column {x} of {columns}, row {y}","a11y.layout.cancelled":"{title} move cancelled","a11y.layout.resizeCancelled":"{title} resize cancelled","a11y.layout.reverted":"{title} returned to column {x}, row {y}","a11y.layout.resizeGrabbed":"{title} resize grabbed, {w} by {h} cells","a11y.layout.resizeStep":"{title}, {w} by {h} cells","a11y.layout.resized":"{title} resized to {w} by {h} cells","a11y.layout.closed":"{title} closed","layout.maximise":"Maximise {title}","layout.minimise":"Minimise {title}","layout.restore":"Restore {title}","a11y.layout.maximised":"{title} maximised, filling the dashboard; press Escape to restore it","a11y.layout.minimised":"{title} minimised","a11y.layout.restored":"{title} restored to column {x}, row {y}","a11y.group.cleared":"Grouping cleared","a11y.group.by":"Grouped by {columns}","a11y.group.expanded":"{label} expanded, {rows} shown","a11y.group.collapsed":"{label} collapsed, {rows} shown","a11y.page.position":"Page {page} of {pages}","a11y.updates.paused":"Updates paused","a11y.updates.resumed":"Updates resumed","a11y.edit.refusedOne":"Edit to {column} was refused and put back to {value}{reason}","a11y.edit.refusedMany":{one:"{count} edit was refused and put back{reason}",other:"{count} edits were refused and put back{reason}"},"a11y.edit.reason":", {reason}","a11y.history.undo":"Undid {label}","a11y.history.redo":"Redid {label}","a11y.history.undoLast":"Undid the last change","a11y.history.redoLast":"Redid the last change","a11y.column.cannotResize":"{column} cannot be resized","a11y.column.resized":"{column} is {width} pixels wide","a11y.column.atMinimum":"{column} is at its narrowest, {width} pixels","a11y.column.atMaximum":"{column} is at its widest, {width} pixels","a11y.column.cannotMove":"{column} cannot be moved","a11y.column.alreadyFirst":"{column} is already first in its group","a11y.column.alreadyLast":"{column} is already last in its group","a11y.column.cannotMoveThere":"{column} cannot be moved there","a11y.column.moved":"{column} moved to position {at} of {of}","a11y.group.formed":"{column} grouped with {other} in a new band","a11y.group.dissolved":"band {group} dissolved","a11y.group.renamed":"band renamed to {group}","a11y.group.moved":"band {group} moved to position {at} of {of}","a11y.column.addedToGroup":"{column} added to band {group}","a11y.column.removedFromGroup":"{column} removed from its band","a11y.column.notInGroup":"{column} is not in a band","a11y.column.cannotGroup":"{column} cannot be grouped","a11y.group.cannotMove":"band {group} cannot be moved there","columngroup.newGroup":"New group","columngroup.rename":"Rename band","columngroup.dissolve":"Dissolve band","columngroup.group":"Group with adjacent column","columngroup.untitled":"Untitled band","panel.bandCollapse":"Collapse band {band}","panel.bandExpand":"Expand band {band}","panel.bandVisible":"Show or hide every column in band {band}","panel.bandRenameFor":"Rename band {band}","panel.bandDissolveFor":"Dissolve band {band}","header.filter":"Filter {column}","header.menu":"Column menu for {column}","header.toggleGroup":"Toggle {group}","header.dragHint":"Drag {column} to reorder, or onto another column to group","header.dragRole":"draggable column header","header.group":"group","header.selectAllRows":"Select all rows","header.clearSelection":"Clear selection","cell.selectRow":"Select row","cell.detail.show":"Show detail","cell.detail.hide":"Hide detail","cell.detail.showInPane":"Show in the detail pane","cell.detail.showingInPane":"Showing in the detail pane","cell.group.expand":"Expand","cell.group.collapse":"Collapse","cell.delta.up":"up","cell.delta.down":"down","cell.delta.unchanged":"unchanged","cell.delta.moved":"{direction} {magnitude}","cell.delta.describedUnchanged":"{label}, unchanged","cell.delta.described":"{label}, {direction} by {magnitude}","cell.qr.of":"QR code for {text}","cell.qr.empty":"No QR code","cell.rating.of":"{rating} of {max}","cell.rating.empty":"Not rated","a11y.panel.cannotMove":"{column} cannot be moved","a11y.panel.alreadyFirst":"{column} is already first","a11y.panel.alreadyLast":"{column} is already last","a11y.panel.moved":"{column} moved to position {at} of {of}","a11y.panel.removedFrom":"{column} removed from {list}","a11y.panel.addedTo":"{column} added to {list}","a11y.panel.cannotAddTo":"{column} cannot be added to {list}","a11y.annotate.erased":"Annotation removed","a11y.annotate.noMarks":"No annotations to erase","a11y.annotate.focusedMark":"Mark {at} of {of} selected","a11y.annotate.confirmClear":"Clear all annotations? Choose Clear or Keep.","a11y.annotate.cleared":"All annotations cleared","a11y.range.written":{one:"{count} cell updated",other:"{count} cells updated"},"a11y.range.cleared":{one:"{count} cell cleared",other:"{count} cells cleared"},"paste.preview.title":"Review paste","paste.preview.summary":{one:"{changes} cell will change, {rejected} rejected.",other:"{changes} cells will change, {rejected} rejected."},"paste.preview.changesHeading":{one:"{count} change",other:"{count} changes"},"paste.preview.rejectedHeading":{one:"{count} rejected",other:"{count} rejected"},"paste.preview.colOld":"Current","paste.preview.colNew":"New","paste.preview.colCell":"Cell","paste.preview.colReason":"Reason","paste.preview.empty":"This paste would change nothing.","paste.preview.confirm":"Apply","paste.preview.cancel":"Cancel","paste.preview.reason.permission":"Not permitted","paste.preview.reason.readOnly":"Read-only","paste.preview.reason.validation":"Invalid value","paste.preview.reason.locked":"Being edited","paste.preview.reason.missing":"No such cell","a11y.paste.previewOpened":{one:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel.",other:"Paste preview: {changes} cell changes, {rejected} rejected. Review, then apply or cancel."},"a11y.paste.cancelled":"Paste cancelled; nothing changed","status.total":"{rows}","status.counting":"Counting rows…","status.shownOfTotal":"{shown} of {total}","status.selected":"{count} selected","status.selectedAcrossSource":"{count} selected across the source","status.selectedAcrossSourceCounting":"All matching rows selected, counting…","status.count":"Count {count}","status.loading":"Loading {count}…","status.loadingOf":"Loading {loaded} of {total} ({percent}%)","status.stat.sum":"Sum","status.stat.min":"Min","status.stat.max":"Max","status.stat.avg":"Avg","status.paused":"Paused","status.pausedWaiting":"Paused · {waiting}","status.coalesced":"{count} coalesced","status.hiddenComments":"{comments} on hidden rows","pagination.label":"Pagination","pagination.first":"First page","pagination.previous":"Previous page","pagination.next":"Next page","pagination.last":"Last page","pagination.page":"Page","pagination.ofPages":"of {pages}","pagination.summary":"{from}–{to} of {total}","pagination.pageSize":"Rows per page","pagination.range":"{from}–{to}","pagination.counting":"{from}–{to}, counting…","pagination.jump":"Page number, press Enter to jump","pagination.jumpBounded":"Page number, 1 to {pages}, press Enter to jump","panel.columns":"Columns","panel.filters":"Filters","panel.views":"Views","panel.quickFilter":"Quick filter","find.label":"Find in grid","find.placeholder":"Find in grid","find.next":"Next match","find.previous":"Previous match","find.close":"Close find","find.matchCase":"Match case","find.wholeCell":"Whole cell","find.columnScope":"Search in","find.allColumns":"All columns","find.count":"{current} of {total}","find.countPartial":"{current} of {total} so far","find.none":"No matches","find.searching":"Searching…","find.loadedRows":"in loaded rows","panel.formatting":"Formatting","panel.statistics":"Statistics","stat.noData":"No data","stat.tone.good":"good","stat.tone.bad":"bad","stat.tone.flat":"flat","panel.regression":"Regression","panel.compare":"Compare","panel.insights":"Insights","insights.subset":"Filtered subset vs whole","insights.dataset":"This grid vs another dataset","insights.groups":"Group comparison","insights.noFilter":"Filter the grid to compare the subset against the whole.","insights.by":"Group by","insights.test":"Test","insights.effect":"Effect size","insights.interval":"Confidence interval","insights.pValue":"p-value","insights.smallSample":"small sample — interpret with care","insights.needGroups":"Choose two columns with groups to compare.","insights.empty":"No columns to analyse.","insights.anomalies":"Anomalies","insights.anomalyCount":"{count} flagged of {n}","insights.anomalyMethod":"Method","insights.anomalyThreshold":"Threshold","anomaly.chip":"{count} anomalies flagged","anomaly.chipActive":"Showing {count} anomalies — clear","compare.first":"First column","compare.second":"Second column","compare.needTwo":"Two numeric columns are needed to compare","compare.noPairs":"No rows have a value in both","compare.pairs":"{count} pairs","compare.pearson":"Correlation (Pearson)","compare.spearman":"Rank correlation (Spearman)","compare.kendall":"Kendall’s tau","compare.covariance":"Covariance","compare.slope":"Slope","compare.intercept":"Intercept","compare.r2":"R²","compare.stdError":"Standard error","compare.weighted":"Weighted average","panel.zone.group":"row groups","panel.zone.values":"values","panel.zone.pivot":"pivot columns","groupZone.label":"Row groups","groupZone.title":"Group by","groupZone.hint":"Drag a column here to group rows by its values","groupZone.chip":"{column}, group {at} of {of}","groupZone.remove":"Stop grouping by {column}","groupZone.add":"Add a group","total.sum":"Sum","total.avg":"Average","total.min":"Min","total.max":"Max","total.count":"Count","total.countValues":"Count of values","total.first":"First","total.last":"Last","total.custom":"Total","total.median":"Median","total.p25":"25th percentile","total.p75":"75th percentile","total.p90":"90th percentile","total.p95":"95th percentile","total.p99":"99th percentile","total.iqr":"Interquartile range","total.mad":"Median absolute deviation","total.variance":"Variance","total.varianceP":"Variance (population)","total.stddev":"Standard deviation","total.stddevP":"Standard deviation (population)","total.range":"Range","total.distinct":"Distinct","total.mode":"Mode","total.skewness":"Skewness","total.kurtosis":"Kurtosis","total.geomean":"Geometric mean","total.harmean":"Harmonic mean","total.sumSquares":"Sum of squares","total.weightedAvg":"Weighted average","total.argmin":"Lowest by","total.argmax":"Highest by","total.hhi":"Concentration (HHI)","total.entropy":"Entropy","total.evenness":"Evenness","total.top3Share":"Top 3 share","total.top10Share":"Top 10 share","total.gini":"Gini coefficient","total.trimmedMean":"Trimmed mean","total.winsorizedMean":"Winsorized mean","total.robustOutliers":"Outliers (robust)","total.jarqueBera":"Jarque–Bera","total.passRate":"Pass rate","total.failureCount":"Failures","stats.column":"Column","stats.choose":"Choose a column to profile","stats.noColumns":"No numeric columns to profile","stats.noValues":"Nothing numeric in this column","stats.count":"Count","stats.present":"Present","stats.missing":"Missing","stats.distinct":"Distinct","stats.min":"Minimum","stats.max":"Maximum","stats.mean":"Mean","stats.median":"Median","stats.q1":"Lower quartile","stats.q3":"Upper quartile","stats.iqr":"Interquartile range","stats.stddev":"Standard deviation","stats.outliers":"Outliers","stats.distribution":"Distribution","stats.distribution.detail":"Distribution: rows per range","stats.bin":"{count} between {from} and {to}","stats.topValues":"Top values","stats.section.shape":"Shape","stats.section.robust":"Robust","stats.section.concentration":"Concentration","stats.section.capability":"Capability","stats.cp":"Cp","stats.cpk":"Cpk","stats.pp":"Pp","stats.ppk":"Ppk","stats.outOfSpec":"Out of specification","stats.filtered":"Over the {count} filtered rows","stats.unavailable":"Not computed by the source: {stats}.","stats.unavailable.notPlain":"`{column}` is not a plain column the engine can name","stats.unavailable.where":"a `where` predicate is in force ({list}), which only the browser can run","stats.unavailable.filter":"the grid's filter did not fully push to the engine","stats.unavailable.quick":"the quick search did not push to the engine","stats.unavailable.client":'the source did not compute "{fn}" in the engine ({reason}); set the pushdown source\'s `{setting}`',"stats.unavailable.outliers":"the count of values outside Tukey's fences is not an engine aggregate","stats.unavailable.histogram":"the shape of the column is not an engine aggregate","stats.unavailable.topValues":"the source did not answer a grouped count in the engine","regression.noModel":"No model configured. Set predictors and a response on the panel.","regression.cannotFit":"The model cannot be fitted over the current rows.","regression.observations":"Fitted over {count} rows","regression.r2":"R²","regression.adjR2":"Adjusted R²","regression.coefficients":"Coefficients","regression.term":"Term","regression.estimate":"Estimate ± SE","regression.stdError":"Std error","regression.t":"t","regression.p":"p","regression.vif":"Variance inflation (VIF)","regression.heteroscedasticity":"Heteroscedasticity (Breusch–Pagan)","regression.heteroscedastic":"Heteroscedastic: BP {statistic}, p {p}","regression.homoscedastic":"No heteroscedasticity detected: BP {statistic}, p {p}","menu.sortAscending":"Sort ascending","menu.sortDescending":"Sort descending","menu.clearSort":"Clear sort","menu.groupBy":"Group by this column","menu.ungroup":"Stop grouping by this column","menu.hideColumn":"Hide column","menu.pinStart":"Pin to start","menu.pinEnd":"Pin to end","menu.unpin":"Unpin","menu.autosize":"Fit to content","ai.valuesNotAmongOptions":'{values} {shown} not among the options for "{column}"',"menu.clearCells":{one:"Clear cell",other:"Clear {count} cells"},"menu.fillDown":"Fill down","menu.copy":"Copy","menu.copyWithHeaders":"Copy with headers","menu.paste":"Paste","menu.filterEllipsis":"Filter…","menu.columnStatistics":"Column statistics","menu.pinColumn":"Pin column","menu.sizeToFit":"Size to fit content","menu.sizeAllToFit":"Size all columns to fit","menu.width":"Width","menu.narrower":"Narrower","menu.wider":"Wider","menu.moveColumn":"Move column","menu.moveLeft":"Move left","menu.moveRight":"Move right","menu.moveToStart":"Move to start","menu.moveToEnd":"Move to end","menu.unpivot":"Remove from pivot","menu.pivotBy":"Pivot by this column","menu.stopTotalling":"Stop totalling","menu.totalColumn":"Total this column","menu.aggregate":"Aggregate","menu.aggregateNone":"None","menu.aggregateGroup":"Group subtotals","menu.aggregateGrand":"Grand total","menu.aggregateSame":"Same as total","menu.redactColumn":"Redact column","menu.stopRedacting":"Stop redacting","menu.stopRedactingAll":"Stop redacting everything","menu.sortGroupsAscending":"Sort groups ascending","menu.sortGroupsDescending":"Sort groups descending","menu.filterGroups":"Filter groups…","menu.expandAll":"Expand all","menu.collapseAll":"Collapse all","menu.clearGrouping":"Clear grouping","menu.colour":"Colour","menu.importCsv":"Import rows from CSV…","import.title":"Import rows","import.clipboard":"the clipboard","import.summary":{one:"{count} row from {name}",other:"{count} rows from {name}"},"import.opened":{one:"Import preview open, {count} row",other:"Import preview open, {count} rows"},"import.done":{one:"{count} row imported",other:"{count} rows imported"},"import.confirm":"Import","import.cancel":"Cancel","import.colSource":"Column","import.colField":"Maps to","import.colType":"Type","import.skip":"— skip —","import.mapLabel":'Map "{source}" to a field',"import.modeLabel":"On import","import.sheetLabel":"Sheet","import.append":"Add to existing rows","import.replace":"Replace all rows","menu.deleteRow":{one:"Delete row",other:"Delete {count} rows"},"toolbar.undo":"Undo","toolbar.redo":"Redo","toolbar.undoLabelled":"Undo {label}","toolbar.redoLabelled":"Redo {label}","toolbar.exportCsv":"Export to CSV","toolbar.exportExcel":"Export to Excel","toolbar.clipboard":"Copy visible rows to the clipboard","toolbar.print":"Print","toolbar.pause":"Hold incoming updates","toolbar.resume":"Resume updates","toolbar.applyHeld":{one:"Apply {count} held update",other:"Apply {count} held updates"},"toolbar.restoreView":"Restore the default view","toolbar.maximiseGrid":"Maximise the grid to fill the window","toolbar.restoreSize":"Restore the grid to the page (Esc)","toolbar.annotate.pen":"Draw freehand","toolbar.annotate.arrow":"Draw an arrow","toolbar.annotate.rect":"Draw a rectangle","toolbar.annotate.highlight":"Highlight","toolbar.annotate.erase":"Erase","toolbar.annotate.clearAll":"Clear all annotations","toolbar.annotate.clearAllConfirm":"Clear","toolbar.annotate.clearAllKeep":"Keep","overlay.noRows":"No rows to show","overlay.noResults":"No rows match the current filters","overlay.loading":"Loading…","overlay.error":"Something went wrong","overlay.loadingRows":"Loading rows {from} to {to}","overlay.rowError":"Failed to load","comments.panel":"Cell comments","comments.close":"Close comments","comments.write":"Write a comment","comments.post":"Comment","comments.delete":"Delete","comments.valueMoved":"Written when the value was {was}: it is now {now}.","comments.resolve":"Resolve","comments.reopen":"Reopen","comments.loading":"Loading…","comments.empty":"No comments yet.","comments.unknownAuthor":"Unknown","comments.edited":"{time} (edited)","comments.cellTitle":"{column}: {row}","presence.hidden":{one:"{count} not in view",other:"{count} not in view"},"presence.someoneElse":"someone else","a11y.presence.refused":"This cell is being edited by {name}","presence.peer":"{name}: jump to their cursor","presence.peerIdle":"{name}, idle: jump to their cursor","presence.peerHidden":"{name}, not in the current view","facets.filter":"{column} distribution filter","header.totalOf":"{total} of {column}","diff.before":"Was: {value}","diff.empty":"(empty)","kanban.columnCards":{one:"{title}, {count} card",other:"{title}, {count} cards"},"kanban.laneCards":{one:"{lane}, {title}, {count} card",other:"{lane}, {title}, {count} cards"},"kanban.blocked":"Blocked","kanban.ready":"Ready","kanban.blockedBy":{one:"blocked by {count} card",other:"blocked by {count} cards"},"kanban.card.assignedTo":"Assigned to {names}","kanban.card.overdue":"Overdue","kanban.card.dueSoon":"Due soon","kanban.card.progress":"{percent}% complete","kanban.card.checklist":"{done} of {total} done","gantt.lag":"+{days}d","gantt.lead":"{days}d","gantt.a11y.moved":"{name} moved to {date}","gantt.a11y.day":"day {day}","gantt.a11y.resized":"{name} resized to {days} days","gantt.a11y.linkFrom":"Linking from {name}. Focus the successor and press L.","gantt.a11y.linked":"Linked {from} to {to}, finish to start.","gantt.a11y.linkCancelled":"Link cancelled.","gantt.a11y.deleted":"{name} deleted.","gantt.a11y.readOnly":"Read-only.","gantt.row.moveHandle":"Drag to reorder or re-parent {name}","gantt.a11y.rowMoved":"{name} moved.","gantt.a11y.rowReparented":"{name} moved under {parent}.","gantt.a11y.rowPromoted":"{name} moved to the top level.","gantt.a11y.rowMoveCancelled":"Move cancelled.","gantt.a11y.copied":"{count} tasks copied.","gantt.a11y.cut":"{count} tasks cut.","gantt.a11y.pasted":"{count} tasks pasted.","gantt.task.newName":"New task","gantt.a11y.taskAdded":"{name} added.","gantt.menu.addAbove":"Add task above","gantt.menu.addBelow":"Add task below","gantt.menu.addChild":"Add subtask","gantt.menu.addSuccessor":"Add successor","gantt.menu.addPredecessor":"Add predecessor","gantt.menu.toMilestone":"Convert to milestone","gantt.menu.toTask":"Convert to task","gantt.menu.delete":"Delete task","gantt.a11y.linkCycle":"Linking {from} to {to} would create a cycle; link not created.","gantt.a11y.linkCreated":"{from} linked to {to}, {type}.","gantt.a11y.linkDeleted":"Link from {from} to {to} deleted.","gantt.a11y.linkLabel":"Link, {from} to {to}, {type}","gantt.linkEditor.title":"Edit link from {from} to {to}","gantt.linkEditor.type":"Link type","gantt.linkEditor.lag":"Lag, in days","gantt.linkEditor.apply":"Apply","gantt.linkEditor.delete":"Delete link","gantt.linkEditor.cancel":"Cancel","gantt.a11y.undone":"Undone.","gantt.a11y.redone":"Redone.","gantt.a11y.nothingToUndo":"Nothing to undo.","gantt.a11y.nothingToRedo":"Nothing to redo.","gantt.workload.title":"Resource workload","gantt.workload.resource":"Resource","gantt.workload.total":"Total","gantt.workload.unassigned":"Unassigned","gantt.workload.ungrouped":"No group","gantt.workload.cell":"{hours} h from {date}","gantt.workload.over":"{hours} h from {date}, over a capacity of {capacity} h","gantt.workload.expand":"Show {name}’s tasks","gantt.workload.collapse":"Hide {name}’s tasks","gantt.workload.expandGroup":"Show the {name} group","gantt.workload.collapseGroup":"Hide the {name} group","gantt.workload.unitToggle":"Hours / % / Cost","gantt.workload.unitHours":"Showing hours","gantt.workload.unitPercent":"Showing percent of capacity","gantt.workload.unitCost":"Showing cost","gantt.workload.cellPercent":"{percent}% from {date}","gantt.workload.overPercent":"{percent}% from {date}, over capacity","gantt.workload.cellNoCapacity":"No available hours from {date}","gantt.workload.cellCost":"{cost} from {date}","gantt.workload.otherProjectLabel":"{name} (other project)","gantt.workload.external":"External booking","gantt.a11y.hoursSet":"{name}: {hours} h from {date}","gantt.a11y.hoursCleared":"{name}: no hours from {date}","gantt.a11y.hoursRefused":"{date} is not a working day; {name} was not changed.","gantt.histogram.title":"Resource histogram","gantt.histogram.tableTitle":"Resource histogram data","gantt.histogram.resource":"Resource","gantt.histogram.period":"Period","gantt.histogram.hours":"Hours","gantt.histogram.percent":"Percent of capacity","gantt.histogram.cost":"Cost","gantt.histogram.capacity":"Capacity","gantt.histogram.overAllocated":"Over-allocated","gantt.histogram.yes":"Yes","gantt.histogram.no":"No","gantt.histogram.tip":"{name}, {from} to {to}: {value}{capacity}{tasks}","gantt.histogram.tipHours":"{hours} h","gantt.histogram.tipPercent":"{percent}% of capacity","gantt.histogram.tipCost":"{cost}","gantt.histogram.tipCapacity":", capacity {hours} h","gantt.histogram.tipTasks":" ({tasks})","gantt.histogram.tipOver":", over capacity","gantt.histogram.tipNoCapacity":"no available hours","gantt.picker.title":"Assign resources to {name}","gantt.picker.open":"Edit assignments for {name}","gantt.picker.search":"Search resources","gantt.picker.list":"Resources","gantt.picker.selected":"Assigned resources","gantt.picker.load":"{load}% booked of {capacity}% over these dates","gantt.picker.none":"No matching resources","gantt.picker.units":"{name}, units in percent","gantt.picker.remove":"Remove {name}","gantt.picker.apply":"Apply","gantt.picker.cancel":"Cancel","gantt.picker.warn":"{name} would be over-allocated: {load}% booked of {capacity}%","gantt.picker.ok":"No resource would be over-allocated","gantt.picker.assign":"Assign","gantt.col.effort":"Effort","gantt.col.units":"Units","gantt.unscheduled":"Unscheduled","gantt.col.unscheduled":"Unscheduled","gantt.inactive":"Inactive","gantt.col.inactive":"Inactive","gantt.col.slack":"Slack","gantt.col.deadline":"Deadline","gantt.col.constraint":"Constraint","gantt.col.constraintDate":"Constraint date","gantt.col.earlyStart":"Early start","gantt.col.lateStart":"Late start","gantt.col.lateFinish":"Late finish","gantt.col.baselineStart":"Baseline start","gantt.col.baselineEnd":"Baseline finish","gantt.col.variance":"Variance","gantt.col.note":"Note","gantt.col.sequence":"#","gantt.col.predecessors":"Predecessors","gantt.col.successors":"Successors","gantt.link.invalid":"Cannot read “{token}” as a link. Write a task number, a type and a lag, like 3FS+2; links not changed.","gantt.link.unknownRef":"No task is numbered “{token}”; links not changed.","gantt.link.self":"“{token}” links a task to itself; links not changed.","gantt.link.duplicate":"“{token}” repeats a link already listed; links not changed.","gantt.link.cycle":"“{token}” would create a cycle; links not changed.","gantt.constraint.ASAP":"As soon as possible","gantt.constraint.MSO":"Must start on","gantt.constraint.MFO":"Must finish on","gantt.constraint.ALAP":"As late as possible","gantt.constraint.SNET":"Start no earlier than","gantt.constraint.SNLT":"Start no later than","gantt.constraint.FNET":"Finish no earlier than","gantt.constraint.FNLT":"Finish no later than","gantt.row.ancestor":"Shown because a task inside it matches the filter","gantt.progress.handle":"Drag to set the progress of {name}","gantt.a11y.progress":"{name} {percent}% complete","gantt.col.name":"Task name","gantt.col.start":"Start","gantt.col.end":"Finish","gantt.col.duration":"Duration","gantt.col.assignee":"Assignee","gantt.col.progress":"%","gantt.col.wbs":"WBS","gantt.zoom.label":"Zoom","gantt.zoom.day":"Day","gantt.zoom.week":"Week","gantt.zoom.month":"Month","gantt.zoom.quarter":"Quarter","gantt.zoom.fit":"Fit to plan","gantt.tip.range":"{from} to {to}","gantt.tip.duration":"{days}d","gantt.tip.slack":"slack {days}d","gantt.tip.effort":"{hours}h","gantt.tip.row":"{label}: {value}","gantt.tip.start":"Start","gantt.tip.end":"End","gantt.tip.date":"Date","gantt.tip.durationLabel":"Duration","gantt.tip.durationValue":"{days} days","gantt.tip.complete":"Complete","gantt.tip.effortLabel":"Effort","gantt.tip.effortValue":"{hours} h","gantt.tip.assigned":"Assigned","gantt.tip.cost":"Cost","gantt.tip.slackLabel":"Slack","gantt.tip.slackValue":"{days} days","gantt.tip.deadline":"Deadline","gantt.mode.fixedDuration":"Fixed duration","gantt.mode.fixedEffort":"Fixed effort","gantt.mode.fixedUnits":"Fixed units","gantt.scurve.spi":"SPI {index}","gantt.scurve.cpi":"CPI {index}","gantt.print.page":"Page {page} of {pages}","gantt.print.printed":"Printed {date}","gantt.dataBand.title":"Data band","gantt.dataBand.name":"Task","gantt.dataBand.resource":"Resource","gantt.dataBand.total":"Total","gantt.dataBand.unassigned":"Unassigned","gantt.dataBand.collapse":"Collapse {name}","gantt.dataBand.expand":"Expand {name}","gantt.dataBand.cell":"{name}, {date}: {value}","gantt.issues.title":"Scheduling conflicts","gantt.issues.empty":"No scheduling conflicts","gantt.issues.count":"{count} scheduling conflicts","gantt.issues.toggle":"Toggle the conflicts panel","gantt.issues.cycle":"Circular dependency: {tasks}","gantt.issues.constraint":"{task} cannot meet its {constraint} constraint of {date}","gantt.issues.lock":"{task} is locked but a dependency would move it","gantt.issues.deadline":"{task} finishes after its deadline of {date}","gantt.issues.fixRemoveLink":"Remove link","gantt.issues.fixAsap":"Set as soon as possible","gantt.issues.fixUnlock":"Unlock task","gantt.issues.fixClearDeadline":"Clear deadline","gantt.resize.startHandle":"Drag to change the start of {name}","gantt.a11y.resizedStart":"{name} start moved to {date}, now {days} days","gantt.a11y.startEdge":"Start edge can be resized: drag the left edge, or press Ctrl+Shift+Left or Right.","gantt.a11y.chain":"Dependency chain highlighted: {preds} predecessors, {succs} successors.","timeline.scrub":"Scrub through recent changes","timeline.goLive":"Go live","timeline.returnToPresent":"Return to the present","a11y.fillHandle":"Drag to fill","panel.icons":"Icons","value.tooLong":"Too long","shortcuts.title":"Keyboard shortcuts","shortcuts.close":"Close keyboard shortcuts","shortcuts.hint":"Press Escape to close.","shortcuts.or":"or","a11y.reorder.moved":"Moved to position {position} of {total}","a11y.reorder.sorted":"Rows cannot be reordered while the grid is sorted","a11y.reorder.filtered":"Rows cannot be reordered while a filter is applied","a11y.reorder.grouped":"Rows cannot be reordered while the grid is grouped","a11y.reorder.grab":"Reorder row","a11y.reorder.sortedManual":"Rows cannot be reordered while the grid is sorted. Press Alt+Shift+M, or the Manual order button in the heading, to order them by hand","a11y.reorder.groupDerived":"The row cannot join that group: the group is worked out from the value, so there is no single value to give it","a11y.reorder.groupReadOnly":"The row cannot join that group: its grouping value cannot be edited","a11y.reorder.invalid":"The row cannot join that group: the new value was not valid","a11y.reorder.vetoed":"The move was declined; the row stays where it was","a11y.reorder.vetoedBecause":"The move was declined ({reason}); the row stays where it was","a11y.reorder.refused":"The row cannot be moved there","a11y.reorder.regrouped":"Moved into {group}","a11y.rowOrder.entered":"Manual order: the rows keep their places and can be moved by hand","a11y.rowOrder.exited":"Manual order ended; the rows follow the sort","rowOrder.button":"Manual order","rowOrder.enter":"Order the rows by hand instead of by the sort","rowOrder.exit":"Return to the sorted order","a11y.transfer.moved":"Row moved to the other grid","a11y.transfer.copied":"Row copied to the other grid","a11y.transfer.refused":"That grid does not accept this row","a11y.transfer.declined":"The drop was declined; the row stays where it was","a11y.transfer.stale":"The drop target changed while it was being confirmed; the row stays where it was","shortcuts.group.grid":"In the data","shortcuts.group.header":"On a column heading","shortcuts.group.panel":"In the column list","shortcut.moveCell":"Move the focused cell","shortcut.rowEnds":"First / last cell of the row","shortcut.gridEnds":"First cell of the first row / last cell of the last row","shortcut.pageRows":"Move one viewport of rows","shortcut.nextCell":"Leave the grid for the next / previous focusable element (arrows move between cells)","shortcut.undo":"Undo the last edit, paste, fill or clear","shortcut.redo":"Redo the step that was undone","shortcut.startEdit":"Start editing the focused cell","shortcut.toggleRow":"Toggle selection of the focused row","shortcut.cancel":"Cancel the current edit or drag","shortcut.expandCollapse":"Expand / collapse a group or tree row","shortcut.focusHeader":"Move focus to the column header","shortcut.focusPanel":"Move focus to the tool panel","shortcut.contextMenu":"Open the context menu for the focused cell","shortcut.moveRow":"Move the focused row, when row reorder is enabled","shortcut.manualOrder":"Order the rows by hand, or return to the sort, when row reorder allows a manual order","shortcut.headingMove":"Move between headings","shortcut.headingEnds":"First / last heading","shortcut.headingSort":"Sort by the column, Shift to add to the sort","shortcut.headingResize":"Resize the column, Ctrl for a coarse step","shortcut.headingAutosize":"Size the column to its content","shortcut.headingReorder":"Move the column","shortcut.headingMenu":"Open the column menu","shortcut.headingExit":"Return focus to the data","shortcut.listGroup":"Group by the column, or stop grouping by it","shortcut.listValues":"Add the column to values, or take it out","shortcut.listPivot":"Pivot by the column, or stop pivoting by it","shortcut.listMove":"Move the column","shortcut.find":"Find in the grid","tags.label":"Show columns","tags.all":"All columns","tags.showing":"Showing {tag}","form.title":"Edit row","form.save":"Save","form.cancel":"Cancel","form.loading":"Loading…","form.loadFailed":"Could not load this record.","form.loadTimeout":"The record did not arrive in time.","form.retry":"Try again","form.choose":"Choose…","form.newTitle":"New row","form.createFailed":"Could not add this record.","presentation.cards":"Showing records as cards","presentation.table":"Showing records as a table","editor.format":"Format","editor.codeHint":"Tab indents · Esc cancels · Ctrl+Enter saves","editor.colours":"Colours","editor.customColour":"Custom colour","editor.hexValue":"Hex value","editor.hexPlaceholder":"#rrggbb","editor.clearColour":"Clear colour","editor.time":"Time","editor.noIcon":"No icon","editor.selectAll":"Select all","editor.passwordHint":"Enter the value twice to save it.","editor.clearRating":"Clear rating","editor.clear":"Clear","editor.value":"Value","editor.currency":"Currency","formatting.format":"Format","formatting.noRules":"No rules yet. The first one that matches a cell wins.","formatting.clearAll":"Clear all","formatting.addRule":"Add rule","formatting.condition":"Condition","formatting.value":"Value","formatting.secondValue":"Second value","formatting.moveEarlier":"Move earlier","formatting.moveLater":"Move later","formatting.ruleKind":"Rule type","formatting.aCondition":"A condition","formatting.aColourScale":"A colour scale","formatting.compare":"Compare a value","formatting.distribution":"By the distribution","formatting.colourScale":"Colour scale","formatting.scaleBounds":"Scale bounds","formatting.preview":"Preview","formatting.livePreview":"Live preview","history.title":"History","history.show":"Show history","history.empty":"Nothing to undo yet.","prompt.ask":"Ask","prompt.apply":"Apply","prompt.discard":"Discard","panel.searchColumns":"Search columns","panel.searchColumnsPlaceholder":"Search columns…","panel.searchColumnsToFilter":"Search columns to filter","panel.showAll":"Show all","panel.hideAll":"Hide all","panel.clearAll":"Clear all","panel.clear":"Clear","panel.filterAllColumns":"Filter all columns","panel.columnFiltered":"This column is filtered","panel.clearFilterOn":"Clear the filter on {column}","panel.clearFilter":"Clear this filter","panel.filterEmptyNoMatch":"No column matches “{query}”.","panel.filterEmptyNone":"No column on this grid can be filtered.","panel.filterSummaryActive":"{active} of {total} columns filtered","panel.filterSummaryNone":"No filters · {total} columns available","panel.filterBy":"Filter by {column}","panel.filteredBy":"Filtered by {column}","panel.columnDragHint":"Drag {column} into a zone above, or onto another column to reorder","panel.gridActions":"Grid actions","views.default":"Default","views.namePlaceholder":"Name this view…","views.nameLabel":"Name for the current layout","views.save":"Save view","licence.watermark":"Unlicensed: Lattice Grid trial","licence.watermark.free":L,"filter.op.contains":"Contains","filter.op.notContains":"Does not contain","filter.op.equals":"Equals","filter.op.notEqual":"Does not equal","filter.op.startsWith":"Starts with","filter.op.endsWith":"Ends with","filter.op.blank":"Is blank","filter.op.notBlank":"Is not blank","filter.op.lessThan":"Less than","filter.op.lessThanOrEqual":"Less than or equal","filter.op.greaterThan":"Greater than","filter.op.greaterThanOrEqual":"Greater than or equal","filter.op.inRange":"In range","filter.op.matches":"Matches","filter.op.before":"Before","filter.op.after":"After","filter.op.relative":"Relative to today","filter.rel.today":"Today","filter.rel.yesterday":"Yesterday","filter.rel.tomorrow":"Tomorrow","filter.rel.lastNDays":"Last N days","filter.rel.nextNDays":"Next N days","filter.rel.thisWeek":"This week","filter.rel.lastWeek":"Last week","filter.rel.thisMonth":"This month","filter.rel.lastMonth":"Last month","filter.rel.thisQuarter":"This quarter","filter.rel.quarterToDate":"Quarter to date","filter.rel.thisYear":"This year","filter.rel.yearToDate":"Year to date","filter.operator":"Operator","filter.join":"Join","filter.value":"Value","filter.from":"From","filter.to":"To","filter.addCondition":"Add condition","filter.noConditions":"No conditions","filter.removeCondition":"Remove condition","filter.search":"Search","filter.searchValues":"Search values","filter.noMatches":"No values match","filter.selectAll":"Select all","filter.clear":"Clear","filter.all":"All","filter.allExcept":"All but {count}","filter.loadingValues":"Loading values…","filter.topValues":"Top {shown} of {total} values","filter.valuesFailed":"Values could not be loaded: {error}","filter.valuesUnsupported":"This source cannot list the values of {column}; filter by condition instead.","filter.true":"True","filter.false":"False","filter.expression":"Filter expression","filter.column":"Column","filter.relativePeriod":"Relative period","filter.days":"Number of days","filter.tab.set":"Values","filter.tab.text":"Text","filter.tab.number":"Number","filter.tab.date":"Date","filter.tab.advanced":"Advanced","filterRow.label":"Filter row","filterRow.conditions":{one:"{count} condition",other:"{count} conditions"},"chart.empty":"Nothing to chart","chart.summary":"{type} chart of {measure} by {dimension}","chart.summaryShare":"{type} chart of {measure}","chart.summaryType":"{type} chart","chart.summaryGauge":"{type} chart of {measure}, {fn}: {value}","chart.waterfallTotal":"Total","chart.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.pen":"Freehand pen","chart.annotate.pen.described":"Freehand drawing from {from} to {to}","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.measure":"Measure","chart.annotate.measure.dx":"Δx {value}","chart.annotate.measure.dy":"Δy {value}","chart.annotate.measure.pct":"{value}%","chart.annotate.measure.categories":{one:"{count} category",other:"{count} categories"},"chart.annotate.measure.slope.perDay":"Slope {value} per day","chart.annotate.measure.slope.perCategory":"Slope {value} per category","chart.annotate.measure.slope.perUnit":"Slope {value} per unit","chart.annotate.measure.dur.d":"{count} d","chart.annotate.measure.dur.h":"{count} h","chart.annotate.measure.dur.min":"{count} min","chart.annotate.measure.dur.s":"{count} s","chart.annotate.measure.dur.ms":"{count} ms","chart.annotate.measure.announce":"Measurement: {readout}","chart.annotate.measure.start":"Measure start: {x}, {y}","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.floatingBar":"Floating bar","chart.type.horizontalFloatingBar":"Horizontal floating bar","chart.type.populationPyramid":"Population pyramid","chart.type.bullet":"Bullet","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.ohlc":"OHLC","chart.type.polarArea":"Polar area","chart.type.nightingale":"Nightingale rose","chart.type.rose":"Rose","chart.type.radialBar":"Radial bar","chart.type.polarScatter":"Polar scatter","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.pyramid":"Pyramid","chart.type.pictorial":"Pictorial","chart.type.serpentine":"Serpentine timeline","chart.type.spiral":"Spiral timeline","chart.edit.aggregated":"This value is a total of several rows, so it cannot be dragged.","chart.edit.refused":"That change was not applied.","chart.edit.refusedWhy":"That change was not applied: {reason}","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.type.forceTree":"Force-directed tree","chart.type.pack":"Packed circles","chart.type.tree":"Tree","chart.type.voronoiTreemap":"Voronoi treemap","chart.type.alluvial":"Alluvial","chart.type.arc":"Arc diagram","chart.type.barRace":"Bar chart race","chart.type.bubblemap":"Bubble map","chart.type.bump":"Bump chart","chart.type.calendar":"Calendar heat map","chart.type.choropleth":"Choropleth map","chart.type.decomposition":"Decomposition tree","chart.type.diverging":"Diverging bar","chart.type.dumbbell":"Dumbbell","chart.type.fan":"Fan chart","chart.type.hexbin":"Hexagonal bin","chart.type.hexmap":"Hex map","chart.type.icicle":"Icicle","chart.type.markermap":"Marker map","chart.type.motion":"Motion chart","chart.type.parallel":"Parallel coordinates","chart.type.ridgeline":"Ridgeline","chart.type.roc":"ROC curve","chart.type.scatter3d":"3D scatter","chart.type.slope":"Slope chart","chart.type.splom":"Scatter plot matrix","chart.type.venn":"Venn diagram","chart.type.waffle":"Waffle","chart.type.wordCloud":"Word cloud","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kanban.requiredTitle":"Required fields","kanban.requiredSave":"Save","kanban.requiredCancel":"Cancel","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),D=Object.freeze(Object.keys(X))}),Be("packages/core/src/i18n/format.js",function(e,H){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return O}});const L=H("packages/core/src/internal/predicates.js").isFunction,X=/\{(\w+)\}/g,D=new Map,F=new Map;function Z(b){const c=b||"";if(D.has(c))return D.get(c);let d=null;try{d=new Intl.PluralRules(b||void 0)}catch{d=null}return D.set(c,d),d}function Y(b,c,d="conjunction"){const l=Array.isArray(b)?b.filter(i=>i!=null&&i!==""):[];if(l.length===0)return"";if(l.length===1)return String(l[0]);const r=`${c||""}|${d}`;let t=F.get(r);if(t===void 0){try{t=new Intl.ListFormat(c||void 0,{style:"long",type:d})}catch{t=null}F.set(r,t)}return t?t.format(l.map(String)):l.map(String).join(", ")}function B(b,c){return b==null?"":typeof b=="number"?Number.isFinite(b)?b.toLocaleString(c||void 0,{maximumFractionDigits:20}):"":String(b)}function z(b,c,d){if(typeof b=="string")return b;if(!b||typeof b!="object")return"";const l=c&&typeof c.count=="number"?c.count:null;if(l===null)return b.other??"";const r=Z(d),t=r?r.select(l):l===1?"one":"other";return b[t]??b.other??""}function G(b,c={},d){const l=z(b,c,d);return l?l.replace(X,(r,t)=>Object.prototype.hasOwnProperty.call(c,t)?B(c[t],d):r):""}function P(b,c,d="en-GB"){return typeof b=="string"&&b?b:typeof c=="string"&&c?c:d}function O(b,c){const d=b?b[c]:void 0;return d==null||L(d)?c:d}}),Be("packages/core/src/i18n/registry.js",function(e,H){"use strict";Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"localeCatalogue",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"registeredTags",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/i18n/catalogue.js").EN_GB,X=new Map([["en-gb",L]]);function D(Y,B){const z=typeof Y=="string"?Y.toLowerCase():"";return!z||!B||typeof B!="object"?!1:(X.set(z,B),!0)}function F(Y){if(typeof Y!="string"||!Y)return null;const B=Y.toLowerCase(),z=X.get(B);if(z)return z;const G=B.split("-")[0],P=X.get(G);if(P)return P;for(const[O,b]of X)if(O.split("-")[0]===G)return b;return null}function Z(){return[...X.keys()]}}),Be("packages/core/src/i18n/index.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return s}});const te=H("packages/core/src/i18n/catalogue.js"),L=te.EN_GB,X=te.MESSAGE_KEYS,D=H("packages/core/src/i18n/format.js"),F=D.formatMessage,Z=D.formatList,Y=D.lookup,B=D.resolveLocale,G=H("packages/core/src/internal/predicates.js").isFunction,O=H("packages/core/src/internal/warn.js").warnOnce,b=H("packages/core/src/i18n/registry.js"),c=b.registerLocale,d=b.localeCatalogue;Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return te.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return te.MESSAGE_KEYS}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"registerLocale",{enumerable:!0,get:function(){return b.registerLocale}});const l="en-GB";class r{#e=l;#t=L;constructor(u={}){this.configure(u)}configure(u={}){this.#e=B(u.locale,u.declared,l);const o=u.messages,a=d(this.#e);if(!a&&this.#e.toLowerCase()!=="en-gb"&&(!o||typeof o!="object")&&O(`i18n:locale:not-loaded:${this.#e.toLowerCase()}`,`locale "${this.#e}" is not loaded: import "@toclocoinc/lattice-grid/locales/${this.#e}" to add its text; English is used until then.`),!o||typeof o!="object"){this.#t=a?{...L,...a}:L;return}const w=Object.keys(o).filter(m=>!(m in L));w.length&&O(`i18n:unknown:${w[0]}`,`message keys not in the catalogue and so ignored: ${w.slice(0,5).join(", ")}${w.length>5?`, and ${w.length-5} more`:""}`),this.#t={...L,...a||{},...o}}get locale(){return this.#e}t(u,o){return F(Y(this.#t,u),o||{},this.#e)}list(u,o){return Z(u,this.#e,o)}number(u,o){const a=Number(u);return Number.isFinite(a)?a.toLocaleString(this.#e,o||{maximumFractionDigits:20}):""}}const t=new r;function i(n){return n instanceof r?n:new r(n||{})}function s(n){const u=n&&typeof n=="object"?n:{},o=X.filter(f=>{const w=u[f];return w==null||w===""||G(w)}),a=Object.keys(u).filter(f=>!(f in L));return{missing:o,unknown:a}}}),Be("packages/core/src/columns/types/structured.js",function(e,H){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const te=H("packages/core/src/internal/predicates.js"),L=te.isNil,X=te.isObject,F=H("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function Y(r,t){const i=t||{},s=i.emptyDisplay??Z.emptyDisplay;if(L(r)||r==="")return s;const u=[...typeof i.char=="string"&&i.char!==""?i.char:Z.char][0]||Z.char,o=i.fixedLength??Z.fixedLength,a=Number.isFinite(i.length)&&Number(i.length)>0?Math.floor(Number(i.length)):Z.length,f=typeof r=="string"?r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?String(r):null;let w=0;if(f!==null){const m=Number.isFinite(i.lastVisible)?Math.floor(Number(i.lastVisible)):Z.lastVisible,v=[...f];if(w=m>0&&m<v.length?m:0,w>0){const h=v.slice(v.length-w).join(""),p=Math.max(1,(o?a:v.length)-w);return u.repeat(p)+h}return u.repeat(o?a:Math.max(1,v.length))}return u.repeat(a)}const B=48;function z(r){try{const t=JSON.stringify(r);return t===void 0?null:t}catch{return null}}function G(r,t){if(L(r))return"";const i=Number.isFinite(t&&t.inlineLimit)?Number(t.inlineLimit):B;if(typeof r=="string")return r.length>i?`${r.slice(0,i-1)}…`:r;if(typeof r!="object")return String(r);const s=z(r);if(s!==null&&s.length<=i)return s;if(Array.isArray(r)){const u=r.length;return`[${F.t("count.items",{count:u})}]`}const n=Object.keys(r).length;return`{${F.t("count.keys",{count:n})}}`}function P(r,t){if(r==null)return"null";const i=typeof r;if(i==="number"||i==="boolean"||i==="bigint")return String(r);if(i==="string")return JSON.stringify(r);if(i!=="object")return JSON.stringify(String(r));const s=t||new WeakSet;return s.has(r)?'"[circular]"':(s.add(r),r instanceof Date?JSON.stringify(r.toISOString()):Array.isArray(r)?`[${r.map(o=>P(o,s)).join(",")}]`:`{${Object.keys(r).sort().map(o=>`${JSON.stringify(o)}:${P(r[o],s)}`).join(",")}}`)}function O(r,t){if(L(r))return L(t)?0:1;if(L(t))return-1;const i=P(r),s=P(t);return i<s?-1:i>s?1:0}function b(r){if(L(r))return null;const t=String(r);if(t.trim()==="")return null;try{return JSON.parse(t)}catch{return t}}function c(r){const t=r&&r.cell&&r.cell.props;return X(t)?t:{}}const d=Object.freeze({json:{base:"object",storage:"object",format:r=>G(r&&r.value,c(r&&r.column)),parse:r=>b(r&&r.text),compare:O,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:r=>{if(L(r))return"";if(typeof r=="string")return r;try{const t=JSON.stringify(r,null,2);return t===void 0?String(r):t}catch{return String(r)}},fromClipboard:r=>b(r)},secret:{base:"text",storage:"object",format:r=>Y(r&&r.value,c(r&&r.column)),parse:r=>{const t=r&&r.text;return L(t)||String(t)===""?null:String(t)},compare:(r,t)=>{const i=L(r)||r==="",s=L(t)||t==="";return i===s?0:i?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:r=>Y(r),fromClipboard:r=>L(r)||String(r)===""?null:String(r)}}),l=d}),Be("packages/core/src/columns/types/unit.js",function(e,H){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return M}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce;function F(S,E,U,K){return Object.freeze({symbol:S,factor:E,aliases:Object.freeze(U||[]),binary:!!(K&&K.binary),prefix:K&&K.prefix||null,auto:!(K&&K.auto===!1)})}function Z(S,E,U,K){return F(S,E,U,K)}const Y=Object.freeze({data:Object.freeze([F("B",1,["byte","bytes"]),F("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),F("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),F("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),F("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),F("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),F("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),F("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),F("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),F("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([F("bps",1,["bit","bits","bit/s","b/s"]),F("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),F("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),F("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),F("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([F("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),F("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),F("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),F("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),F("in",.0254,["inch","inches"],{auto:!1}),F("ft",.3048,["foot","feet"],{auto:!1}),F("yd",.9144,["yard","yards"],{auto:!1}),F("m",1,["metre","metres","meter","meters"]),F("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),F("mi",1609.344,["mile","miles"],{auto:!1}),F("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([F("mg",.001,["milligram","milligrams"]),F("g",1,["gram","grams"]),F("oz",28.349523125,["ounce","ounces"],{auto:!1}),F("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),F("kg",1e3,["kilogram","kilograms"]),F("st",6350.29318,["stone"],{auto:!1}),F("t",1e6,["tonne","tonnes","ton"],{auto:!1}),F("ton (US)",907184.74,["ton","shortton"],{auto:!1}),F("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([F("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),F("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),F("ms",.001,["msec","msecs","millisecond","milliseconds"]),F("s",1,["sec","secs","second","seconds"]),F("m",60,["min","mins","minute","minutes"]),F("h",3600,["hr","hrs","hour","hours"]),F("d",86400,["day","days"])]),speed:Object.freeze([F("mm/s",.001,["millimetre/s","millimeter/s"]),F("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),F("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),F("mph",.44704,["mile/h","miles/h"],{auto:!1}),F("kn",1852/3600,["knot","knots"],{auto:!1}),F("m/s",1,["metre/s","meter/s","mps"]),F("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([F("mm/s²",.001,["mm/s2"]),F("ft/s²",.3048,["ft/s2"],{auto:!1}),F("m/s²",1,["m/s2","metre/s2","meter/s2"]),F("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([F("mm²",1e-6,["mm2"]),F("cm²",1e-4,["cm2"]),F("in²",64516e-8,["in2","sqin"],{auto:!1}),F("ft²",.09290304,["ft2","sqft"],{auto:!1}),F("yd²",.83612736,["yd2","sqyd"],{auto:!1}),F("m²",1,["m2","sqm"]),F("ha",1e4,["hectare","hectares"],{auto:!1}),F("ac",4046.8564224,["acre","acres"],{auto:!1}),F("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([F("µL",1e-6,["ul","microlitre","microliter"]),F("mL",.001,["millilitre","milliliter"]),F("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),F("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),F("L",1,["litre","litres","liter","liters"]),F("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),F("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),F("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),F("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([F("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),F("J",1,["joule","joules"]),F("cal",4.184,["calorie","calories"],{auto:!1}),F("kJ",1e3,["kilojoule","kilojoules"]),F("BTU",1055.05585262,["btu"],{auto:!1}),F("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),F("MJ",1e6,["megajoule","megajoules"]),F("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),F("GJ",1e9,["gigajoule","gigajoules"]),F("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([F("mW",.001,["milliwatt","milliwatts"]),F("W",1,["watt","watts"]),F("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),F("kW",1e3,["kilowatt","kilowatts"]),F("hp",745.6998715822702,["horsepower"],{auto:!1}),F("MW",1e6,["megawatt","megawatts"]),F("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([F("mN",.001,["millinewton","millinewtons"]),F("N",1,["newton","newtons"]),F("lbf",4.4482216152605,["poundforce"],{auto:!1}),F("kgf",9.80665,["kilogramforce"],{auto:!1}),F("kN",1e3,["kilonewton","kilonewtons"]),F("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([F("Pa",1,["pascal","pascals"]),F("mbar",100,["millibar"],{auto:!1}),F("inH₂O",249.0889,["inh2o"],{auto:!1}),F("mmHg",133.322387415,["torr"],{auto:!1}),F("kPa",1e3,["kilopascal","kilopascals"]),F("inHg",3386.388640341,["inhg"],{auto:!1}),F("psi",6894.757293168361,["lbf/in2"],{auto:!1}),F("bar",1e5,[],{auto:!1}),F("atm",101325,["atmosphere","atmospheres"],{auto:!1}),F("MPa",1e6,["megapascal","megapascals"]),F("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([F("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),F("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),F("kN·m",1e3,["knm","kn.m"],{auto:!1}),F("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([F("kg/m³",1,["kg/m3"]),F("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),F("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),F("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([F("L/min",1/6e4,["lpm","l/min"],{auto:!1}),F("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),F("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),F("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),F("cfm",.0004719474432,["ft3/min"],{auto:!1}),F("L/s",.001,["lps","l/s"],{auto:!1}),F("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([F("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),F("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),F("mrad",.001,["milliradian","milliradians"],{auto:!1}),F("mil",Math.PI/3200,["nato-mil"],{auto:!1}),F("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),F("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),F("rad",1,["radian","radians"]),F("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([F("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),F("rad/s",1,["radps","radians/s"]),F("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),F("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([F("ppt",1e-12,["partspertrillion"],{auto:!1}),F("ppb",1e-9,["partsperbillion"]),F("ppm",1e-6,["partspermillion"]),F("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),F("‰",.001,["permille","permil"],{auto:!1}),F("%",.01,["pct","percent"]),F("×",1,["x","ratio","times"])]),molarity:Object.freeze([F("pM",1e-12,["picomolar","picomolarity"]),F("nM",1e-9,["nanomolar","nanomolarity"]),F("µM",1e-6,["um-molar","micromolar","micromolarity"]),F("mM",.001,["millimolar","millimolarity"]),F("M",1,["molar","mol/l","mol/L","molarity"]),F("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([F("mg/s",1e-6,["milligrams/s"]),F("g/s",.001,["grams/s"]),F("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),F("kg/s",1,["kilograms/s","kgps"]),F("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),F("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),F("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([F("µPa·s",1e-6,["upas","micropascalsecond"]),F("cP",.001,["centipoise"],{auto:!1}),F("mPa·s",.001,["mpas","millipascalsecond"]),F("P",.1,["poise"],{auto:!1}),F("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([F("cSt",1e-6,["centistokes","centistoke"]),F("mm²/s",1e-6,["mm2/s"],{auto:!1}),F("St",1e-4,["stokes","stoke"],{auto:!1}),F("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([F("mW/(m·K)",.001,["mw/mk"]),F("W/(m·K)",1,["w/mk","wmk"]),F("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),F("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([F("J/(kg·K)",1,["j/kgk","jkgk"]),F("kJ/(kg·K)",1e3,["kj/kgk"]),F("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([F("nSv/h",1e-9,["nsvh"]),F("µSv/h",1e-6,["usv/h","usvh"]),F("mSv/h",.001,["msvh"]),F("Sv/h",1,["svh"]),F("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),B=Symbol("ambiguous"),z=new Map,G=new Map;function P(S,E){const U=String(S||"").trim();if(!U)throw new Error("[lattice] a unit system needs a name");if(Y[U]||G.has(U))throw new Error(`[lattice] unit system "${U}" already exists`);const K=[...E||[]];if(!K.length)throw new Error(`[lattice] unit system "${U}" has no units`);if(!K.some(_=>_.factor===1))throw new Error(`[lattice] unit system "${U}" has no base unit (none with factor 1)`);const q=new Set;for(const _ of K){if(q.has(_.symbol))throw new Error(`[lattice] unit system "${U}" declares "${_.symbol}" twice`);q.add(_.symbol)}return G.set(U,Object.freeze(K)),z.delete(U),U}function O(){return[...Object.keys(Y),...G.keys()]}function b(S){const E=c(S);return E?E.units:[]}function c(S){const E=String(S||""),U=z.get(E);if(U!==void 0)return U;const K=Y[E]||G.get(E);if(!K)return z.set(E,null),null;const q=Object.freeze([...K].sort((oe,ie)=>oe.factor-ie.factor)),_=new Map,J=new Map,ee=(oe,ie)=>{const ae=_.get(oe);ae===void 0?_.set(oe,ie):ae!==ie&&_.set(oe,B)};for(const oe of q){ee(oe.symbol.toLowerCase(),oe);for(const ie of oe.aliases)ee(ie.toLowerCase(),oe);if(oe.prefix){const ie=J.get(oe.prefix)||[];ie.push(oe),J.set(oe.prefix,ie)}}const ne={units:q,byToken:_,byPrefix:J,decimal:q.filter(oe=>!oe.binary&&oe.auto),binary:q.some(oe=>oe.binary)?q.filter(oe=>(oe.binary||oe.factor===1)&&oe.auto):null};return z.set(E,ne),ne}function d(S,E){return E&&S.binary||S.decimal}function l(S,E){const U=c(S);if(!U||L(E))return null;const K=U.units.find(_=>_.symbol===String(E));if(K)return K;const q=U.byToken.get(String(E).trim().toLowerCase());return q&&q!==B?q:null}const r=new WeakMap;function t(S){const E=S||{};if(typeof E=="object"&&E!==null){const _=r.get(E);if(_!==void 0)return _}const U=E.system||"data",K=c(U);let q=null;if(!K)D(`unit:system:${U}`,`unknown unit system "${U}"; known systems are ${O().join(", ")}`);else{let _=E.unit?l(U,E.unit):null;_||(E.unit&&D(`unit:unit:${U}:${E.unit}`,`unknown unit "${E.unit}" in system "${U}"; falling back to ${K.units[0].symbol}`),_=K.units.find(J=>J.factor===1)||K.units[0]),q={index:K,base:_,binary:E.binary===!0}}return typeof E=="object"&&E!==null&&r.set(E,q),q}const i=new WeakMap;function s(S,E){if(!S||!E||!Array.isArray(S.compound)||S.compound.length===0)return null;const U=i.get(S);if(U!==void 0)return U;const K=new Set,q=[];for(const J of S.compound){const ee=l(S.system||"data",J);if(!ee){D(`unit:compound:${S.system}:${J}`,`unknown compound unit "${J}" in system "${S.system||"data"}"; ignoring it`);continue}K.has(ee.symbol)||(K.add(ee.symbol),q.push(ee))}q.sort((J,ee)=>ee.factor-J.factor);const _=q.length>=2?q:null;return i.set(S,_),_}function n(S,E,U){return E===U||E.factor===U.factor?S:S*E.factor/U.factor}const u=new Map;function o(S){const E=S||"",U=u.get(E);if(U)return U;const K={group:",",decimal:"."};try{for(const q of new Intl.NumberFormat(S||void 0).formatToParts(12345.6))q.type==="group"?K.group=q.value:q.type==="decimal"&&(K.decimal=q.value)}catch{}return u.set(E,K),K}const a=/[\s   ]/g,f=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,w=/^[^\d+\-(.,\s]+\s*/,m=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function v(S,E){const{group:U,decimal:K}=o(E);let q=String(S).replace(a,"");if(q==="")return null;const _=K?q.indexOf(K):-1;if(U&&U!==K){if(_>=0&&q.indexOf(U,_+K.length)>=0)return null;q=q.split(U).join("")}if(K&&K!=="."&&(q=q.split(K).join(".")),!m.test(q))return null;const J=Number(q);return Number.isFinite(J)?J:null}function h(S,E,U){const K=String(S).trim().replace(/\.$/,"");if(K==="")return null;const q=E.units.find(ie=>ie.symbol===K);if(q)return q;const _=K.toLowerCase(),J=E.byToken.get(_);if(J===B)return null;if(J)return J;const ee=E.byPrefix.get(_);if(!ee||!ee.length)return null;const ne=d(E,U),oe=ee.filter(ie=>ne.includes(ie));return oe.length===1?oe[0]:null}function p(S,E,U,K){let q=S,_=0,J=!1,ee=!1;for(;q!=="";){const ne=f.exec(q)[0];if(ne==="")return null;const oe=v(ne,K&&K.locale);if(oe===null)return null;q=q.slice(ne.length).trim();const ie=q.search(/[+-]?[\d]/),ae=(ie>=0?q.slice(0,ie):q).trim();if(q=ie>=0?q.slice(ie).trim():"",ae===""){if(J)return null;ee=!0,_+=n(oe,U[0],E.base)}else{const ce=h(ae,E.index,E.binary);if(!ce)return null;_+=n(oe,ce,E.base)}if(J=!0,ee&&q!=="")return null}return J?_:null}function g(S,E){if(L(S))return null;if(typeof S=="number")return Number.isFinite(S)?S:null;const U=t(E);if(!U)return null;let K=String(S).trim();if(K==="")return null;let q=!1;K.startsWith("(")&&K.endsWith(")")&&(q=!0,K=K.slice(1,-1).trim());const _=s(E,U);if(_){K.startsWith("-")&&(q=!0,K=K.slice(1).trim());const de=p(K,U,_,E);return de===null?null:q?-de:de}let J=null;const ee=w.exec(K);if(ee&&ee[0]){const de=h(ee[0].trim(),U.index,U.binary);de&&(J=de,K=K.slice(ee[0].length).trim())}const ne=f.exec(K)[0],oe=v(ne,E&&E.locale);if(oe===null)return null;const ie=K.slice(ne.length).trim();if(J&&ie!=="")return null;const ae=J||(ie===""?U.base:h(ie,U.index,U.binary));if(!ae)return null;const ce=n(oe,ae,U.base);return q?-ce:ce}const k=new Map;function y(S,E,U,K){const q=`${S||""}|${E}|${U}|${K?1:0}`;let _=k.get(q);return _||(_=new Intl.NumberFormat(S||void 0,{minimumFractionDigits:E,maximumFractionDigits:U,useGrouping:K}),k.set(q,_)),_}function T(S,E){if(!Number.isFinite(S)||S===0)return Math.max(0,E-1);const U=Math.floor(Math.log10(Math.abs(S)));return Math.min(20,Math.max(0,E-1-U))}function j(S,E){if(!Number.isFinite(S)||S===0)return S;const U=Math.ceil(Math.log10(Math.abs(S))),K=10**(E-U);return Math.round(S*K)/K}function N(S,E,U){if(!U||U===E.base.symbol)return E.base;if(U!=="auto")return W(E,U);if(S===0||!Number.isFinite(S))return E.base;const K=Math.abs(S)*E.base.factor,q=d(E.index,E.binary);let _=q[0];for(const ne of q)K>=ne.factor&&(_=ne);if(K>=_.factor)return _;let J=_;for(const ne of E.index.units)ne.binary!==E.binary&&ne.factor!==1||ne.factor<=K&&ne.factor>(J===_?0:J.factor)&&(J=ne);if(J!==_)return J;let ee=_;for(const ne of E.index.units)ne.binary!==E.binary&&ne.factor!==1||ne.factor<ee.factor&&(ee=ne);return ee.factor<E.base.factor?ee:E.base}function W(S,E){const U=S.index.units.find(q=>q.symbol===E);if(U)return U;const K=S.index.byToken.get(String(E).toLowerCase());return K&&K!==B?K:(D(`unit:display:${E}`,`unknown display unit "${E}"; rendering in ${S.base.symbol}`),S.base)}function R(S,E,U,K){const q=S<0;let _=Math.abs(S)*E.base.factor;const J=typeof K.decimals=="number"?K.decimals:K.minDecimals??0,ee=typeof K.decimals=="number"?K.decimals:K.maxDecimals??Math.max(J,2),ne=K.space??" ",oe=[];for(let ae=0;ae<U.length;ae++){const ce=U[ae],de=ae===U.length-1;let Ae=de?_/ce.factor:Math.floor(_/ce.factor);if(_-=Ae*ce.factor,de){const be=10**ee;Ae=Math.round(Ae*be)/be+0}const je=de?y(K.locale,J,ee,K.group!==!1):y(K.locale,0,0,K.group!==!1);oe.push(`${je.format(Ae)}${ne}${ce.symbol}`)}const ie=oe.join(" ");return q?`-${ie}`:ie}function x(S,E){const U=E||{},K=U.nullDisplay??"";if(L(S)||S==="")return K;const q=typeof S=="number"?S:Number(S);if(!Number.isFinite(q))return K;const _=t(U);if(!_)return String(q);const J=s(U,_);if(J)return R(q,_,J,U);const ee=typeof U.significantFigures=="number"&&U.significantFigures>0?U.significantFigures:0,ne=ee?j(q,ee):q,oe=N(ne,_,U.display),ie=n(ne,_.base,oe);let ae=typeof U.decimals=="number"?U.decimals:U.minDecimals??0,ce=typeof U.decimals=="number"?U.decimals:U.maxDecimals??Math.max(ae,2);ee&&(ae=T(ie,ee),ce=ae);const de=y(U.locale,ae,ce,U.group!==!1).format(ie),Ae=U.space??" ";return U.placement==="prefix"?`${oe.symbol}${U.space??""}${de}`:`${de}${Ae}${oe.symbol}`}function A(S,E){const U=L(S)||Number.isNaN(S)?null:Number(S),K=L(E)||Number.isNaN(E)?null:Number(E);return U===null||Number.isNaN(U)?K===null||Number.isNaN(K)?0:1:K===null||Number.isNaN(K)||U<K?-1:U>K?1:0}function $(S){const E=typeof S.decimals=="number"&&S.decimals>0?`.${"0".repeat(S.decimals)}`:"";return`${typeof S.decimals=="number"?`#,##0${E}`:"#,##0.##"}" ${S.symbol}"`}function I(S){const E={system:"data",...S||{}},U=t(E),K=U?U.base.symbol:String(E.unit||""),q=Object.freeze({...E,unit:K}),_=Object.freeze({...q,display:K,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[q.locale||"",q]]),ee=ne=>{const oe=ne||"";let ie=J.get(oe);return ie||(ie=Object.freeze({...q,locale:ne||void 0}),J.set(oe,ie)),ie};return{base:"number",extends:"number",storage:"float64",unitConfig:q,format:ne=>x(ne.value,ne.locale?ee(ne.locale):q),parse:ne=>g(ne.text,ne.locale?ee(ne.locale):q),compare:A,defaults:{filter:"number",editor:"unit",align:"end",total:E.total||"sum"},...E.totals?{totals:E.totals}:{},excel:E.excel||$({decimals:E.decimals,symbol:K}),toStorage:ne=>typeof ne=="number"?Number.isFinite(ne)?ne:null:typeof ne=="string"?g(ne,q):L(ne)?null:g(String(ne),q),toClipboard:ne=>x(ne,_),fromClipboard:ne=>g(ne,q)}}const M=I}),Be("packages/core/src/columns/types/engineering.js",function(e,H){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/columns/types/unit.js").createUnitType;function F(B){const z=2*Math.PI/B;return G=>{let P=0,O=0,b=0;for(const d of G||[]){if(L(d))continue;const l=Number(d);Number.isFinite(l)&&(P+=Math.cos(l*z),O+=Math.sin(l*z),b+=1)}return!b||Math.hypot(P,O)/b<1e-12?null:(Math.atan2(O,P)/z%B+B)%B}}function Z(B){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:F(B)}}}const Y=Object.freeze({metres:D({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:D({system:"length",unit:"mm",maxDecimals:2}),kilometres:D({system:"length",unit:"km",maxDecimals:3}),grams:D({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:D({system:"mass",unit:"kg",maxDecimals:3}),tonnes:D({system:"mass",unit:"t",maxDecimals:3}),seconds:D({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:D({system:"duration",unit:"ms",maxDecimals:3}),hours:D({system:"duration",unit:"h",maxDecimals:2}),speed:D({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:D({system:"speed",unit:"km/h",maxDecimals:1}),mph:D({system:"speed",unit:"mph",maxDecimals:1}),knots:D({system:"speed",unit:"kn",maxDecimals:1}),acceleration:D({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:D({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:D({system:"area",unit:"ha",maxDecimals:4}),volume:D({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:D({system:"volume",unit:"m³",maxDecimals:3}),energy:D({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:D({system:"energy",unit:"kWh",maxDecimals:2}),power:D({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:D({system:"power",unit:"kW",maxDecimals:2}),force:D({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:D({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:D({system:"pressure",unit:"bar",maxDecimals:3}),psi:D({system:"pressure",unit:"psi",maxDecimals:1}),torque:D({system:"torque",unit:"N·m",maxDecimals:2}),density:D({system:"density",unit:"kg/m³",maxDecimals:2}),flow:D({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:D({system:"flow",unit:"L/min",maxDecimals:1}),radians:D({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:D({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:D({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:D({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:D({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:D({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:D({system:"fraction",unit:"bp",maxDecimals:1}),molarity:D({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:D({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:D({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:D({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:D({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:D({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:D({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:D({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Be("packages/core/src/columns/types/si.js",function(e,H){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/columns/types/unit.js"),L=te.defineUnit,X=te.registerUnitSystem,D=te.createUnitType,F=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function Y(O){const b=String(O.base),c=new Set([...O.prefixes||Z,""]),d=[];for(const l of F){if(!c.has(l.symbol))continue;const r=`${l.symbol}${b}`,t=[];if(O.name){t.push(`${l.name}${O.name}`,`${l.name}${O.name}s`);const i=l.name.slice(-1);if(i&&O.name.startsWith(i)){const s=`${l.name.slice(0,-1)}${O.name}`;t.push(s,`${s}s`)}}l.symbol==="µ"&&t.push(`u${b}`),l.factor===1&&O.aliases&&t.push(...O.aliases),d.push(L(r,l.factor,t))}for(const l of O.extra||[])d.push(l);return d}function B(O,b){const c=Y(b);return X(O,c)}function z(O,b,c){return B(O,b),D({system:O,unit:b.base,display:"auto",maxDecimals:3,...c||{}})}const G=Object.freeze({voltage:z("voltage",{base:"V",name:"volt"}),current:z("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:z("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:z("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:z("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:z("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[L("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),L("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:z("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:z("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[L("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:z("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:z("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:z("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:z("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:z("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:z("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:z("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[L("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:z("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),P=z}),Be("packages/core/src/columns/types/temperature.js",function(e,H){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return c}});const L=H("packages/core/src/internal/predicates.js").isNil,X=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:d=>d+273.15,fromKelvin:d=>d-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:d=>(d+459.67)*(5/9),fromKelvin:d=>d*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:d=>d,fromKelvin:d=>d}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:d=>d*(5/9),fromKelvin:d=>d*(9/5)})});function D(d){if(L(d))return null;const l=String(d).trim();if(l==="")return null;for(const[t,i]of Object.entries(X))if(l===t||l===i.symbol)return{key:t,scale:i};const r=l.toLowerCase();for(const[t,i]of Object.entries(X))if(i.aliases.includes(r))return{key:t,scale:i};return null}function F(d,l,r){const t=D(l),i=D(r);return!t||!i||!Number.isFinite(Number(d))?null:t.key===i.key?Number(d):i.scale.fromKelvin(t.scale.toKelvin(Number(d)))}const Z=new Map;function Y(d,l,r){const t=`${d||""}|${l}|${r}`;let i=Z.get(t);return i||(i=new Intl.NumberFormat(d||void 0,{minimumFractionDigits:l,maximumFractionDigits:r}),Z.set(t,i)),i}function B(d,l){const r=l||{},t=r.nullDisplay??"";if(L(d)||d==="")return t;const i=Number(d);if(!Number.isFinite(i))return t;const s=D(r.scale||"C");if(!s)return String(i);const n=D(r.display||r.scale||"C")||s,u=n.key===s.key?i:n.scale.fromKelvin(s.scale.toKelvin(i)),o=typeof r.decimals=="number"?r.decimals:null,a=o??r.minDecimals??0,f=o??r.maxDecimals??1;return`${Y(r.locale,a,f).format(u)}${r.space??" "}${n.scale.symbol}`}const z=/^[+-]?[\d\s.,  ]*\d/;function G(d,l){const r=String(d).trim();if(r==="")return null;const t=new Intl.NumberFormat(l||void 0).formatToParts(1.1).find(u=>u.type==="decimal")?.value||".",i=t===","?".":",",s=r.split(i).join("").split(/[\s  ]/).join("").replace(t,"."),n=Number(s);return Number.isFinite(n)?n:null}function P(d,l){if(L(d))return null;const r=l||{},t=D(r.scale||"C");if(!t)return null;if(typeof d=="number")return Number.isFinite(d)?d:null;let i=String(d).trim();if(i==="")return null;let s=!1;i.startsWith("(")&&i.endsWith(")")&&(s=!0,i=i.slice(1,-1).trim());const n=z.exec(i);if(!n)return null;const u=G(n[0],r.locale);if(u===null)return null;const o=i.slice(n[0].length).trim();if(o==="")return s?-u:u;const a=D(o);if(!a)return null;const f=a.key===t.key?u:t.scale.fromKelvin(a.scale.toKelvin(u));return s?-f:f}function O(d){const l=Object.freeze({scale:"C",...d||{}}),t=(D(l.scale)||D("C")).scale.symbol,i=Object.freeze({...l,display:l.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),s=new Map([[l.locale||"",l]]),n=u=>{const o=u||"";let a=s.get(o);return a||(a=Object.freeze({...l,locale:u||void 0}),s.set(o,a)),a};return{base:"number",extends:"number",storage:"float64",temperatureConfig:l,format:u=>B(u.value,u.locale?n(u.locale):l),parse:u=>P(u.text,u.locale?n(u.locale):l),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:l.excel||`#,##0${typeof l.decimals=="number"&&l.decimals>0?`.${"0".repeat(l.decimals)}`:".#"}" ${t}"`,toStorage:u=>typeof u=="number"?Number.isFinite(u)?u:null:typeof u=="string"?P(u,l):L(u)?null:P(String(u),l),toClipboard:u=>B(u,i),fromClipboard:u=>P(u,l)}}const b=Object.freeze({celsius:O({scale:"C"}),fahrenheit:O({scale:"F"}),kelvin:O({scale:"K"})}),c=O}),Be("packages/core/src/columns/types/radix.js",function(e,H){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"compileRadixFormat",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"compileRadixParse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return R}});const L=H("packages/core/src/internal/predicates.js").isNil,D=H("packages/core/src/internal/warn.js").warnOnce,F=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),Z=Object.freeze({2:1,8:3,16:4}),Y=Object.freeze({2:"0b",8:"0o",16:"0x"}),B=Object.freeze({2:4,8:3,16:2}),z=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),G=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),P=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),O=/[\s\u00a0\u202f_,']/g,b=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,c=Object.freeze([8,16,32,53]),d=new WeakSet,l=new WeakMap,r=new Map,t=new WeakMap,i=new WeakMap,s=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function n(x){if(x==null)return 16;const A=typeof x=="string"?x.toLowerCase():x,$=F[A];return $||(D(`radix:base:${String(x)}`,`unsupported radix ${String(x)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function u(x,A){return Math.ceil(x/Z[A])}function o(x,A){if(!x)return A?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!A)return{min:0,max:2**x-1};const $=2**(x-1);return{min:-$,max:$-1}}function a(x){return G[x]||"hexadecimal"}function f(x){if(typeof x=="string"){const A=s[x];return A||D(`radix:preset:${x}`,`unknown radix preset "${x}"; known presets are ${Object.keys(s).join(", ")}`),{...A||{}}}if(x&&typeof x.preset=="string"){const A=s[x.preset];return A||D(`radix:preset:${x.preset}`,`unknown radix preset "${x.preset}"; known presets are ${Object.keys(s).join(", ")}`),{...A||{},...x}}return x||{}}function w(x){const A=f(x),$=n(A.radix),I=Z[$];let M=null;if(A.bitWidth!==void 0&&A.bitWidth!==null&&A.bitWidth!==!1){const ne=Number(A.bitWidth);c.includes(ne)?M=ne:D(`radix:width:${String(A.bitWidth)}`,`unsupported bitWidth ${String(A.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let S=A.signed!==!1;!S&&M===null&&(D("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),M=32);const E=A.prefix===void 0||A.prefix===!0?Y[$]:A.prefix===!1?"":String(A.prefix);let U=0;A.pad===!0?U=M?u(M,$):0:typeof A.pad=="number"&&A.pad>0&&(U=Math.floor(A.pad));let K=0;A.group===!0?K=B[$]:typeof A.group=="number"&&A.group>0&&(K=Math.floor(A.group));const q=o(M,S),_=typeof A.min=="number"?Math.max(q.min,A.min):q.min,J=typeof A.max=="number"?Math.min(q.max,A.max):q.max,ee=Object.freeze({radix:$,bits:I,prefix:E,uppercase:A.uppercase!==!1,pad:U,group:K,groupSeparator:typeof A.groupSeparator=="string"?A.groupSeparator:" ",bitWidth:M,signed:S,min:_,max:J<_?_:J,nullDisplay:typeof A.nullDisplay=="string"?A.nullDisplay:"",name:a($)});return d.add(ee),ee}function m(x){if(x&&d.has(x))return x;if(typeof x=="string"){let A=r.get(x);return A||(A=w(x),r.set(x,A)),A}if(x&&typeof x=="object"){let A=l.get(x);return A||(A=w(x),l.set(x,A)),A}return m("hex")}function v(x){return x<0?-Math.round(-x):Math.round(x)}function h(x,A,$){if(A<=0||x.length<=A)return x;const I=x.length%A||A,M=[x.slice(0,I)];for(let S=I;S<x.length;S+=A)M.push(x.slice(S,S+A));return M.join($)}function p(x){const A=m(x),{radix:$,prefix:I,uppercase:M,pad:S,group:E,groupSeparator:U,signed:K,bitWidth:q,nullDisplay:_}=A,J=q?2**q:0,ee=ne=>{if(L(ne)||ne==="")return _;const oe=typeof ne=="number"?ne:Number(ne);if(!Number.isFinite(oe))return _;const ie=v(oe);let ae="",ce=ie;ie<0&&(K?(ae="-",ce=-ie):ce=(ie%J+J)%J);let de=ce.toString($);return de=M?de.toUpperCase():de.toLowerCase(),S>0&&de.length<S&&(de=de.padStart(S,"0")),E>0&&(de=h(de,E,U)),ae+I+de};return ee.options=A,ee}function g(x,A){const $=m(A);let I=t.get($);return I||(I=p($),t.set($,I)),I(x)}function k(x){const A=m(x),{radix:$,groupSeparator:I,signed:M,min:S,max:E}=A,U=z[$],K=q=>{if(L(q))return{ok:!0,value:null,reason:"blank"};let _=String(q);if(I&&I!==""&&(_=_.split(I).join("")),_=_.replace(O,""),_==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((_[0]==="-"||_[0]==="+")&&(J=_[0]==="-",_=_.slice(1)),_==="")return{ok:!1,value:null,reason:"digits"};let ee=null;for(const[oe,ie]of P){const ae=oe.exec(_);if(!ae)continue;const ce=_.slice(ae[0].length);if(ce==="")break;if(!z[ie].test(ce))return{ok:!1,value:null,reason:"digits"};ee=parseInt(ce,ie);break}if(ee===null)if(U.test(_))ee=parseInt(_,$);else if(b.test(_))ee=Number(_);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(ee))return{ok:!1,value:null,reason:"digits"};const ne=v(J?-ee:ee);return!M&&ne<0?{ok:!1,value:ne,reason:"negative"}:ne<S||ne>E?{ok:!1,value:ne,reason:"range"}:{ok:!0,value:ne,reason:"ok"}};return K.options=A,K}function y(x,A){const $=m(A);let I=i.get($);return I||(I=k($),i.set($,I)),I(x)}function T(x,A){const $=y(x,A);return $.ok?$.value:null}function j(x,A){const $=L(x)||Number.isNaN(x)?null:Number(x),I=L(A)||Number.isNaN(A)?null:Number(A);return $===null?I===null?0:1:I===null||$<I?-1:$>I?1:0}function N(x){const A=x.min>=-2147483648&&x.max<=2147483647;return x.bitWidth&&A?"int32":"float64"}function W(x){const A=w(x),$=p(A),I=k(A);return{base:"number",extends:"number",storage:N(A),matches:null,format:M=>$(M.value),parse:M=>{const S=I(M.text);return S.ok?S.value:null},compare:j,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:M=>$(M),fromClipboard:M=>{const S=I(M);return S.ok?S.value:null},radix:A,formatValue:$,parseText:I}}const R=W}),Be("packages/core/src/columns/types/aggregable.js",function(e,H){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/predicates.js").isNil;function X(G){const P=[];for(const O of G||[]){if(L(O))continue;const b=Number(O);Number.isFinite(b)&&P.push(b)}return P}function D(G){return P=>{const O=X(P);if(!O.length)return null;let b=0;for(const c of O)b+=10**(c/G);return G*Math.log10(b)}}function F(G){return P=>{const O=X(P);if(!O.length)return null;let b=0;for(const c of O)b+=10**(c/G);return G*Math.log10(b/O.length)}}function Z(G,P){const O=P&&P.column,c=(O&&O.typeOptions||{}).weight,d=P&&P.valueAt;if(!c||typeof d!="function")return null;let l=0,r=0;for(let t=0;t<G.length;t++){if(L(G[t]))continue;const i=Number(G[t]);if(!Number.isFinite(i))continue;const s=d(c,t);if(L(s))continue;const n=Number(s);!Number.isFinite(n)||n<=0||(l+=i*n,r+=n)}return r===0?null:l/r}function Y(G={}){const P=G.factor===20?20:10,O=typeof G.suffix=="string"?G.suffix:"",b=Number.isInteger(G.decimals)?G.decimals:1;return{base:"number",storage:"float64",name:G.name||"logarithmic",format:c=>{const d=c&&c.value;return L(d)||!Number.isFinite(Number(d))?"":`${Number(d).toFixed(b)}${O}`},parse:c=>{const d=String((c&&c.text)??"").replace(O,"").trim();if(!d)return null;const l=Number(d);return Number.isFinite(l)?l:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:D(P),avg:F(P)}}}}function B(G={}){const P=Number.isInteger(G.decimals)?G.decimals:1,O=G.percent===!0;return{base:"number",storage:"float64",name:G.name||"ratio",format:b=>{const c=b&&b.value;return L(c)||!Number.isFinite(Number(c))?"":O?`${Number(c).toFixed(P)}%`:Number(c).toFixed(P)},parse:b=>{const c=String((b&&b.text)??"").replace("%","").trim();if(!c)return null;const d=Number(c);return Number.isFinite(d)?d:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const z=Object.freeze({decibel:Y({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:Y({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:B({name:"ratio"}),percentRate:B({name:"percentRate",percent:!0})})}),Be("packages/core/src/columns/types/currency.js",function(e,H){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const L=H("packages/core/src/internal/predicates.js").isNil,X="⚠ no rate";function D(u){if(L(u))return null;const o=String(u).trim().toUpperCase();return o===""?null:o}function F(u){if(L(u))return null;if(typeof u=="object"&&!Array.isArray(u)){const o=Number(u.amount),a=D(u.code);return!a||!Number.isFinite(o)?null:{amount:o,code:a}}if(Array.isArray(u)&&u.length===2){const o=Number(u[0]),a=D(u[1]);return!a||!Number.isFinite(o)?null:{amount:o,code:a}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),Y=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),B=/[+-]?[\d\s., ]*\d/;function z(u,o){const a=String(u).trim();if(a==="")return null;const f=new Intl.NumberFormat(o||void 0).formatToParts(1.1).find(h=>h.type==="decimal")?.value||".",w=f===","?".":",",m=a.split(w).join("").split(/[\s ]/).join("").replace(f,"."),v=Number(m);return Number.isFinite(v)?v:null}function G(u,o){const a=o||{},f=D(a.code);if(L(u))return null;const w=F(u);if(w)return w;if(typeof u=="number")return Number.isFinite(u)&&f?{amount:u,code:f}:null;let m=String(u).trim();if(m==="")return null;let v=!1;m.startsWith("(")&&m.endsWith(")")&&(v=!0,m=m.slice(1,-1).trim());let h=null;for(const[j,N]of Object.entries(Z)){if(m.startsWith(j)){h=N,m=m.slice(j.length).trim();break}if(m.endsWith(j)){h=N,m=m.slice(0,-j.length).trim();break}}const p=B.exec(m);if(!p)return null;const g=z(p[0],a.locale);if(g===null)return null;const k=(m.slice(0,p.index)+" "+m.slice(p.index+p[0].length)).trim();!h&&k!==""&&(h=D(k));const y=h||f;return y?{amount:v?-g:g,code:y}:null}function P(u,o){if(typeof u=="function")return(a,f)=>{if(a===f)return 1;const w=u(a,f);return typeof w=="number"&&Number.isFinite(w)&&w>0?w:null};if(u&&typeof u=="object"){const a=u;return(f,w)=>{if(f===w)return 1;const m=Number(a[f]),v=Number(a[w]);return!Number.isFinite(m)||!Number.isFinite(v)||m<=0||v<=0?null:v/m}}return(a,f)=>a===f?1:null}function O(u,o,a){if(!u)return null;if(u.code===o)return u.amount;const f=a(u.code,o);return f===null?null:u.amount*f}const b=new Map;function c(u,o,a){const f=`${u||""}|${o}|${a??""}`;let w=b.get(f);if(!w){const m={style:"currency",currency:o};typeof a=="number"&&(m.minimumFractionDigits=a,m.maximumFractionDigits=a);try{w={fmt:new Intl.NumberFormat(u||void 0,m),currency:!0}}catch{w={fmt:new Intl.NumberFormat(u||void 0,typeof a=="number"?{minimumFractionDigits:a,maximumFractionDigits:a}:{}),currency:!1}}b.set(f,w)}return w}function d(u,o){const a=o||{},f=a.nullDisplay??"",w=F(u);if(!w)return f;const m=D(a.display)||w.code;let v=w.amount,h=w.code;if(m!==w.code){const k=a.rateFn||P(a.rates,a.rateBase),y=O(w,m,k);if(y===null)return`${a.missingRate??X} ${w.code}→${m}`;v=y,h=m}const{fmt:p,currency:g}=c(a.locale,h,a.decimals);return g?p.format(v):`${p.format(v)} ${h}`}function l(u){const o=F(u);return o?`${o.amount} ${o.code}`:""}function r(u){const o=u||{},a=D(o.display),f=o.rateFn||P(o.rates,o.rateBase);return(w,m)=>{const v=F(w),h=F(m);if(!v&&!h)return 0;if(!v)return 1;if(!h)return-1;if(a){const p=O(v,a,f),g=O(h,a,f);if(p!==null&&g!==null)return p===g?0:p<g?-1:1}return v.code===h.code?v.amount===h.amount?0:v.amount<h.amount?-1:1:v.code<h.code?-1:1}}function t(u){const o=u||{},a=(w,m)=>{const v=[];for(const y of w||[]){const T=F(y);T&&v.push(T)}if(!v.length)return null;if(new Set(v.map(y=>y.code)).size===1){const y=v[0].code;return{amount:m(v.map(T=>T.amount)),code:y}}const p=D(o.display);if(!p)return`${o.missingRate??X}: mixed currencies, no display currency set`;const g=o.rateFn||P(o.rates,o.rateBase),k=[];for(const y of v){const T=O(y,p,g);if(T===null)return`${o.missingRate??X}: ${y.code}→${p}`;k.push(T)}return{amount:m(k),code:p}},f=w=>w.reduce((m,v)=>m+v,0);return{sum:w=>a(w,f),avg:w=>a(w,m=>f(m)/m.length),min:w=>a(w,m=>Math.min(...m)),max:w=>a(w,m=>Math.max(...m))}}function i(u){const o=Object.freeze({code:"USD",...u||{}}),a=P(o.rates,o.rateBase),f=Object.freeze({...o,rateFn:a}),w=t(f),m=r(f),v=new Map([[o.locale||"",f]]),h=k=>{const y=k||"";let T=v.get(y);return T||(T=Object.freeze({...f,locale:k||void 0}),v.set(y,T)),T},p=Y[D(o.display||o.code)]||"",g=typeof o.decimals=="number"&&o.decimals>0?`.${"0".repeat(o.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:f,format:k=>d(k.value,k.locale?h(k.locale):f),parse:k=>G(k.text,k.locale?h(k.locale):f),compare:m,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:w},excel:o.excel||(p?`"${p}"#,##0${g}`:`#,##0${g}`),toStorage:k=>{const y=F(k);return y||(typeof k=="string"||typeof k=="number"?G(k,f):null)},toClipboard:k=>l(k),fromClipboard:k=>G(k,f)}}const s=Object.freeze({currency:i({code:"USD"}),usd:i({code:"USD"}),eur:i({code:"EUR"}),gbp:i({code:"GBP"}),jpy:i({code:"JPY",decimals:0})}),n=i}),Be("packages/core/src/columns/types/index.js",function(e,H){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return j}});const te=H("packages/core/src/columns/types/temporal.js"),L=te.TEMPORAL_TYPES,X=H("packages/core/src/columns/types/network.js"),D=X.NETWORK_TYPES,F=H("packages/core/src/columns/types/structured.js"),Z=F.STRUCTURED_TYPES,Y=H("packages/core/src/columns/types/unit.js"),B=Y.createUnitType,z=Y.UNIT_SYSTEMS,G=Y.parseUnit,P=Y.formatUnit,O=Y.registerUnitSystem,b=Y.unitSystemNames,c=Y.unitsOf,d=Y.defineUnit,l=H("packages/core/src/columns/types/engineering.js"),r=l.ENGINEERING_TYPES,t=H("packages/core/src/columns/types/si.js"),i=t.SI_TYPES,s=t.createSiType,n=t.createSiSystem,u=t.siUnits,o=t.SI_PREFIXES,a=H("packages/core/src/columns/types/temperature.js"),f=a.TEMPERATURE_TYPES,w=a.createTemperatureType,m=a.convertTemperature,v=a.formatTemperature,h=a.parseTemperature,p=a.TEMPERATURE_SCALES,g=H("packages/core/src/columns/types/radix.js"),k=g.createRadixType,y=g.RADIX_PRESETS,T=g.parseRadix,j=g.formatRadix,N=H("packages/core/src/columns/types/aggregable.js"),W=N.AGGREGABLE_TYPES,R=H("packages/core/src/columns/types/currency.js"),x=R.CURRENCY_TYPES,A=R.createCurrencyType,$=R.parseMoney,I=R.formatMoney,M=R.convertMoney,S=R.toMoney,E=R.rateFunction,U=R.moneyComparator,K=R.normaliseCode,q=R.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return Y.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return l.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return l.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return a.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return a.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return a.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return a.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return a.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return a.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return a.findScale}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return R.CURRENCY_TYPES}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return R.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return R.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return R.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return R.convertMoney}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return R.toMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return R.rateFunction}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return R.moneyComparator}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return R.normaliseCode}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return R.MISSING_RATE}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return te.TEMPORAL_TYPES}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return X.NETWORK_TYPES}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return F.STRUCTURED_TYPES}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return N.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return N.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return N.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return te.parseTime}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return te.formatTime}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return te.parseDateTime}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return te.formatDateTime}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return te.parseDuration}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return te.formatDuration}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return X.parseIpv4}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return X.formatIpv4}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return X.parseCidr}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return X.formatCidr}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return X.parseIpv6}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return X.formatIpv6}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return X.networkAddress}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return X.broadcastAddress}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return X.hostCount}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return X.containsAddress}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return X.overlaps}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return F.maskValue}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return F.summariseJson}});const _=Object.freeze({...L,...D,...Z,...W,hex:k(y.hex),hex8:k(y.hex8),hex16:k(y.hex16),hex32:k(y.hex32),binary:k(y.binary),binary8:k(y.binary8),octal:k(y.octal),bytes:B({system:"data",unit:"B",display:"auto"}),megabytes:B({system:"data",unit:"MB"}),gigabytes:B({system:"data",unit:"GB"}),bitrate:B({system:"bitrate",unit:"Mbps"}),gigabits:B({system:"bitrate",unit:"Gbps"}),...r,...i,...f,...x});{const J=new Set;for(const ee of[L,D,Z,W,r,i,f,x])for(const ne of Object.keys(ee)){if(J.has(ne))throw new Error(`[lattice] data type "${ne}" is declared twice`);J.add(ne)}}}),Be("packages/core/src/compute/handle.js",function(e,H){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return i}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,F=H("packages/core/src/internal/warn.js").warnOnce;function Z(s){const n=new Uint32Array(s);for(let u=0;u<s;u++)n[u]=u;return n}function Y(s,n){if(n&&typeof n.count=="number")return n.count;if(!s)return 0;if(typeof s.count=="number")return s.count;if(typeof s.length=="number")return s.length;const u=s.values;return s.kind==="multi"&&s.offsets?Math.max(0,s.offsets.length-1):u?s.kind==="bitset"?typeof u.size=="number"?u.size:s.presence&&typeof s.presence.size=="number"?s.presence.size:(F(`count:${s.id}`,`column "${s.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:s.presence&&typeof s.presence.size=="number"?s.presence.size:0}const B=new WeakMap;function z(s){const n=s.constructor;if(!n)return"unknown";const u=B.get(n);if(u)return u;let o="unknown";try{let a=null;typeof n.from=="function"?a=n.from([!1,!0]):(a=new n(8),a.set(1));const f=a&&a.words;f&&f.length&&(f[0]===2?o="lsb":f[0]===64&&(o="msb"))}catch{o="unknown"}return B.set(n,o),o}function G(s){if(!s)return()=>0;const n=s instanceof Uint8Array?s:s.words;if(n instanceof Uint8Array){const u=s instanceof Uint8Array?"lsb":z(s);if(u==="lsb")return o=>n[o>>>3]>>>(o&7)&1;if(u==="msb")return o=>n[o>>>3]>>>7-(o&7)&1}return typeof s.get=="function"?u=>s.get(u)?1:0:()=>0}function P(s){return!s||!s.presence?null:G(s.presence)}function O(s){return s?typeof s.size=="number"?s.size:typeof s.values=="function"?s.values().length:0:0}function b(s,n){return s?typeof s.valueOf=="function"?s.valueOf(n):typeof s.values=="function"?s.values()[n]:null:null}function c(s,n){const u=s.offsets,o=s.values;if(!u||!o)return[];const a=u[n],f=u[n+1];if(!(f>a))return[];const w=s.dict,m=new Array(f-a);for(let v=a;v<f;v++)m[v-a]=w?b(w,o[v]):o[v];return m}function d(s){if(!s)return()=>{};const n=s.values,u=P(s),o=s.kind;if(o==="dictionary"){const a=s.dict;return u?f=>u(f)?b(a,n[f]):null:f=>b(a,n[f])}if(o==="bitset"){const a=G(n);return u?f=>u(f)?a(f)===1:null:f=>a(f)===1}if(o==="multi")return u?a=>u(a)?c(s,a):null:a=>c(s,a);if(!n&&typeof s.get=="function"){const a=s.get.bind(s);return f=>{const w=a(f);return w===void 0?null:w}}return u?a=>{if(!u(a))return null;const f=n[a];return f===void 0?null:f}:a=>{const f=n[a];return f===void 0?null:f}}function l(s,n){if(s<n)return-1;if(s>n)return 1;if(s===n){const a=Object.is(s,-0),f=Object.is(n,-0);return a===f?0:a?-1:1}const u=Number.isNaN(s),o=Number.isNaN(n);return u&&o?0:u?1:-1}function r(s){const n=L(s);return(u,o)=>{if(u===o)return 0;const a=typeof u,f=typeof o;if(a==="string"&&f==="string")return n.compare(u,o);if(a==="number"&&f==="number")return l(u,o);if(a==="boolean"&&f==="boolean")return u===o?0:u?1:-1;if(u instanceof Date||o instanceof Date){const w=u instanceof Date?u.getTime():Number(u),m=o instanceof Date?o.getTime():Number(o);return l(w,m)}return X(u,o)}}function t(s,n){if(s&&typeof s.ranks=="function")return s.ranks(n);const u=s&&typeof s.values=="function"?s.values():[],o=u.length,a=r(n),f=new Array(o);for(let m=0;m<o;m++)f[m]=m;f.sort((m,v)=>a(u[m],u[v])||m-v);const w=new Uint32Array(o);for(let m=0;m<o;m++)w[f[m]]=m;return w}function i(s){return s==null||typeof s=="number"&&Number.isNaN(s)}}),Be("packages/core/src/compute/filter.js",function(e,H){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"wallMs",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return ce}});const L=H("packages/core/src/internal/predicates.js").isBlank,D=H("packages/core/src/internal/merge.js").toArray,Z=H("packages/core/src/internal/warn.js").warnOnce,Y=H("packages/core/src/format/date.js"),B=Y.toDate,z=Y.toIsoDate,G=H("packages/core/src/compute/handle.js"),P=G.bitReader,O=G.dictSize,b=G.dictValue,c=G.presenceReader,d=G.valueComparator,l=G.valueReader,r=/^\d{4}-\d{2}-\d{2}$/,t="\0null\0";function i(de,Ae){const je=de&&de.pool;if(je){const be=je.mask||je.acquireMask||je.acquire||je.take;if(typeof be=="function"){const re=be.call(je,Ae);if(re&&re.length>=Ae)return re}}return new Uint8Array(Ae)}function s(de,Ae){const je=de&&de.pool;if(!je||!Ae)return;const be=je.release||je.releaseMask||je.free||je.recycle;typeof be=="function"&&be.call(je,Ae)}function n(de,Ae,je){return de.fill(je,0,Ae),de}function u(de){return de==null||typeof de=="number"&&Number.isNaN(de)}function o(de,Ae){if(de==null)return de;if(Ae==="number")return typeof de=="number"?de:Number(de);if(Ae==="date"||Ae==="dateString"){const je=z(de);return je===null?a(de):je}return Ae==="boolean"?typeof de=="boolean"?de:de==="true"||de===1?!0:de==="false"||de===0?!1:!!de:de}function a(de){return de instanceof Date?de.getTime():typeof de=="number"?de:Date.parse(String(de))}function f(de){return typeof de=="number"?de:de instanceof Date?de.getTime():de==null||de===""?NaN:Number(de)}function w(de,Ae){const je=typeof de=="string"?de:String(de);return Ae?je:je.toLowerCase()}function m(de,Ae){return de==null?t:typeof de=="string"?Ae?de:de.toLowerCase():de instanceof Date?de.getTime():de}function v(de,Ae,je){const be=new Set;for(const re of D(de)){const fe=o(re,je);be.add(m(fe,Ae)),typeof fe=="string"&&fe!==""&&Number.isFinite(Number(fe))?be.add(Number(fe)):typeof fe=="number"&&Number.isFinite(fe)&&be.add(m(String(fe),Ae))}return be}function h(de,Ae,je){if(de==null||Ae===null||Ae===void 0)return de==null&&Ae==null;const be=typeof de,re=typeof Ae;return be==="string"&&re==="string"?je?de===Ae:de.toLowerCase()===Ae.toLowerCase():de instanceof Date||Ae instanceof Date?a(de)===a(Ae):be==="number"&&re==="number"?de===Ae||Number.isNaN(de)&&Number.isNaN(Ae):be==="number"&&re==="string"?de===Number(Ae):be==="string"&&re==="number"?Number(de)===Ae:be==="boolean"||re==="boolean"?de===Ae:Array.isArray(de)&&Array.isArray(Ae)?de.length===Ae.length&&de.every((fe,pe)=>h(fe,Ae[pe],je)):de===Ae}function p(de,Ae){try{if(de instanceof RegExp){const je=de.flags.replace(/[gy]/g,"");return new RegExp(de.source,Ae||je.includes("i")?je:`${je}i`)}return new RegExp(String(de),Ae?"":"i")}catch(je){return Z(`regex:${String(de)}`,`filter operator "matches" received an invalid pattern: ${String(de)}`,je),null}}function g(de,Ae){if(de&&de.type==="datetime"&&k.has(de.op))return W(de,Ae);const je=R(de,Ae),be=de&&de.type;return be!=="date"&&be!=="dateString"?je:re=>je(typeof re=="string"&&r.test(re)?re:z(re)??re)}const k=new Set(["eq","ne","lt","lte","gt","gte","between","notBetween","in","notIn"]),y=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3})\d*)?)?)?$/,T=new Map;function j(de,Ae){let je=T.get(Ae);if(je===void 0){try{je=new Intl.DateTimeFormat("en-CA",{timeZone:Ae,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}catch{je=null}T.set(Ae,je)}if(!je)return null;const be={};for(const re of je.formatToParts(de))re.type!=="literal"&&(be[re.type]=re.value);return be}function N(de,Ae){if(de==null||de==="")return null;if(typeof de=="string"){const fe=y.exec(de.trim());if(fe)return Date.UTC(+fe[1],+fe[2]-1,+fe[3],+(fe[4]||0),+(fe[5]||0),+(fe[6]||0),+(fe[7]||"0").padEnd(3,"0"))}const je=B(de);if(!je)return null;const be=je.getUTCMilliseconds(),re=Ae?j(je,Ae):null;return re?Date.UTC(+re.year,+re.month-1,+re.day,re.hour==="24"?0:+re.hour,+re.minute,+re.second,be):Date.UTC(je.getFullYear(),je.getMonth(),je.getDate(),je.getHours(),je.getMinutes(),je.getSeconds(),be)}function W(de,Ae){const je=typeof de.timeZone=="string"&&de.timeZone?de.timeZone:void 0,be=pe=>N(pe,je),re=Array.isArray(de.value)?de.value.map(be):be(de.value),fe=R({...de,type:"number",value:re},Ae);return pe=>fe(N(pe))}function R(de,Ae){const je=de&&de.op,be=!!(de&&de.caseSensitive),re=de&&de.type,fe=d(Ae),pe=Oe=>ve=>!Oe(ve);switch(je){case"eq":{const Oe=o(de.value,re);return ve=>h(ve,Oe,be)}case"ne":{const Oe=o(de.value,re);return ve=>!h(ve,Oe,be)}case"lt":case"lte":case"gt":case"gte":{const Oe=o(de.value,re);if(u(Oe))return()=>!1;const ve=je==="lt"?-1:je==="lte"?0:je==="gt"?1:2;return $e=>{if(u($e))return!1;const he=fe($e,Oe);return ve===-1?he<0:ve===0?he<=0:ve===1?he>0:he>=0}}case"between":case"notBetween":{const Oe=D(de.value),ve=o(Oe[0],re),$e=o(Oe[1],re),he=de.bounds||"[]",ye=he.charAt(0)!=="(",Se=he.charAt(1)!==")";if(u(ve)||u($e))return je==="between"?()=>!1:()=>!0;const Ie=we=>{if(u(we))return!1;const Fe=fe(we,ve),He=fe(we,$e);return(ye?Fe>=0:Fe>0)&&(Se?He<=0:He<0)};return je==="between"?Ie:pe(Ie)}case"in":case"notIn":{const Oe=v(de.value,be,re),ve=$e=>Oe.has(m($e,be));return je==="in"?ve:pe(ve)}case"contains":case"notContains":{const Oe=w(o(de.value,re),be),ve=$e=>$e==null?!1:w($e,be).includes(Oe);return je==="contains"?ve:pe(ve)}case"startsWith":{const Oe=w(o(de.value,re),be);return ve=>ve==null?!1:w(ve,be).startsWith(Oe)}case"endsWith":{const Oe=w(o(de.value,re),be);return ve=>ve==null?!1:w(ve,be).endsWith(Oe)}case"matches":{const Oe=p(de.value,be);return Oe?ve=>ve==null?!1:Oe.test(String(ve)):()=>!1}case"blank":return Oe=>L(Oe)||Array.isArray(Oe)&&Oe.length===0;case"notBlank":return Oe=>!(L(Oe)||Array.isArray(Oe)&&Oe.length===0);case"containsAny":case"containsNone":{const Oe=v(de.value,be,re),ve=$e=>{const he=$e==null?[]:D($e);for(let ye=0;ye<he.length;ye++)if(Oe.has(m(he[ye],be)))return!0;return!1};return je==="containsAny"?ve:pe(ve)}case"containsAll":{const Oe=D(de.value).map(ve=>m(o(ve,re),be));return ve=>{const $e=ve==null?[]:D(ve);if(Oe.length===0)return!0;const he=new Set($e.map(ye=>m(ye,be)));for(let ye=0;ye<Oe.length;ye++)if(!he.has(Oe[ye]))return!1;return!0}}default:{const Oe=ce(je);return Oe?Oe.compile(de.value):(Z(`op:${String(je)}`,`unknown filter operator "${String(je)}"; the condition is refused rather than matching every row`),()=>!1)}}}function x(de,Ae,je){return g(Ae,je)(de)}const A=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),$=new Set(["containsAny","containsAll","containsNone"]);function I(de,Ae,je){const be=de&&de.op,re=A[be]||be,fe=g({...de,op:re,type:Ae.type},je),pe=Ae.items,Oe=ve=>{const $e=pe(ve);if(!$e)return!1;for(let he=0;he<$e.length;he++)if(fe($e[he]))return!0;return!1};return A[be]?ve=>!Oe(ve):Oe}function M(de,Ae,je,be){const re=c(de);if(re){const Oe=Ae?1:0;for(let ve=0;ve<be;ve++)je[ve]=re(ve)===Oe?1:0;return je}const fe=de.kind;if(fe==="float64"||fe==="int32"||fe==="bitset")return n(je,be,Ae?1:0);const pe=l(de);for(let Oe=0;Oe<be;Oe++){const ve=pe(Oe),$e=L(ve)||Array.isArray(ve)&&ve.length===0;je[Oe]=$e===Ae?0:1}return je}function S(de,Ae,je,be){const re=de.dict,fe=O(re),pe=new Uint8Array(fe);for(let he=0;he<fe;he++)pe[he]=Ae(b(re,he))?1:0;const Oe=de.values,ve=c(de);if(!ve){for(let he=0;he<be;he++)je[he]=pe[Oe[he]];return je}const $e=Ae(null)?1:0;for(let he=0;he<be;he++)je[he]=ve(he)===1?pe[Oe[he]]:$e;return je}function E(de,Ae,je,be){const re=P(de.values),fe=Ae(!0)?1:0,pe=Ae(!1)?1:0,Oe=c(de);if(!Oe){for(let $e=0;$e<be;$e++)je[$e]=re($e)===1?fe:pe;return je}const ve=Ae(null)?1:0;for(let $e=0;$e<be;$e++)je[$e]=Oe($e)===0?ve:re($e)===1?fe:pe;return je}function U(de,Ae,je,be,re){const fe=de.values,pe=Ae.type,Oe=Ae.op;let ve=!0;switch(Oe){case"eq":case"ne":{const he=f(o(Ae.value,pe)),ye=typeof Ae.value=="number"&&Number.isNaN(Ae.value),Se=Oe==="ne"?1:0;if(ye)for(let Ie=0;Ie<re;Ie++)be[Ie]=(Number.isNaN(fe[Ie])?1:0)^Se;else for(let Ie=0;Ie<re;Ie++)be[Ie]=(fe[Ie]===he?1:0)^Se;break}case"lt":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]<he?1:0;break}case"lte":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]<=he?1:0;break}case"gt":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]>he?1:0;break}case"gte":{const he=f(o(Ae.value,pe));for(let ye=0;ye<re;ye++)be[ye]=fe[ye]>=he?1:0;break}case"between":case"notBetween":{const he=D(Ae.value),ye=f(o(he[0],pe)),Se=f(o(he[1],pe)),Ie=Ae.bounds||"[]",we=Ie.charAt(0)!=="(",Fe=Ie.charAt(1)!==")",He=Oe==="notBetween"?1:0;if(we&&Fe)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>=ye&fe[Ke]<=Se?1:0)^He;else if(we)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>=ye&fe[Ke]<Se?1:0)^He;else if(Fe)for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>ye&fe[Ke]<=Se?1:0)^He;else for(let Ke=0;Ke<re;Ke++)be[Ke]=(fe[Ke]>ye&fe[Ke]<Se?1:0)^He;break}case"in":case"notIn":{const he=new Set;for(const Se of D(Ae.value)){const Ie=f(o(Se,pe));Number.isNaN(Ie)||he.add(Ie)}const ye=Oe==="notIn"?1:0;for(let Se=0;Se<re;Se++)be[Se]=(he.has(fe[Se])?1:0)^ye;break}default:ve=!1;break}if(!ve)return!1;const $e=c(de);if($e){const he=je(null)?1:0;for(let ye=0;ye<re;ye++)$e(ye)===0&&(be[ye]=he)}return!0}function K(de,Ae,je,be){const re=l(de);for(let fe=0;fe<be;fe++)je[fe]=Ae(re(fe))?1:0;return je}function q(de,Ae,je){const be=Ae.count|0,re=je||i(Ae,be);if(!de)return n(re,be,1);const fe=typeof Ae.handle=="function"?Ae.handle(de.col):void 0,pe=typeof Ae.custom=="function"?Ae.custom:null;if(!fe){if(pe){for(let he=0;he<be;he++)re[he]=pe(de,he)?1:0;return re}return Z(`filter:col:${String(de.col)}`,`filter references unknown column "${String(de.col)}"; the condition is refused rather than matching every row`),n(re,be,0)}const Oe=de.op;if(Oe==="blank"||Oe==="notBlank")return M(fe,Oe==="notBlank",re,be);const ve=typeof Ae.itemwise=="function"?Ae.itemwise(de.col):null;if(ve&&!ce(Oe)&&!$.has(Oe))return K(fe,I(de,ve,Ae.locale),re,be);const $e=g(de,Ae.locale);switch(fe.kind){case"dictionary":return S(fe,$e,re,be);case"bitset":return E(fe,$e,re,be);case"float64":case"int32":return U(fe,de,$e,re,be)?re:K(fe,$e,re,be);default:return K(fe,$e,re,be)}}function _(de,Ae,je){if(!de)return n(i(Ae,je),je,1);if(Array.isArray(de.conditions)){const be=de.conditions.filter(pe=>pe!=null),re=de.op==="or"?"or":de.op==="not"?"not":"and";if(be.length===0)return n(i(Ae,je),je,1);const fe=_(be[0],Ae,je);for(let pe=1;pe<be.length;pe++){const Oe=_(be[pe],Ae,je);if(re==="or")for(let ve=0;ve<je;ve++)fe[ve]|=Oe[ve];else for(let ve=0;ve<je;ve++)fe[ve]&=Oe[ve];s(Ae,Oe)}if(re==="not")for(let pe=0;pe<je;pe++)fe[pe]^=1;return fe}return q(de,Ae,i(Ae,je))}function J(de,Ae){return _(de,Ae,Ae.count|0)}function ee(de,Ae){if(!de||!Ae)return de||null;const je=de;if(Array.isArray(je.conditions)){if((je.op==="or"?"or":je.op==="not"?"not":"and")!=="and")return ne(je,Ae)?null:de;const re=[];for(const fe of je.conditions){const pe=ee(fe,Ae);pe&&re.push(pe)}return re.length?{...je,op:"and",conditions:re}:null}return je.col===Ae?null:de}function ne(de,Ae){if(!de||typeof de!="object")return!1;const je=de;if(je.col===Ae)return!0;if(Array.isArray(je.conditions)){for(const be of je.conditions)if(ne(be,Ae))return!0}return!1}function oe(de,Ae,je){if(je&&je.length>=Ae){let pe=0;for(let Oe=0;Oe<Ae;Oe++)de[Oe]&&(je[pe++]=Oe);return je.subarray(0,pe)}let be=0;for(let pe=0;pe<Ae;pe++)be+=de[pe]?1:0;const re=new Uint32Array(be);let fe=0;for(let pe=0;pe<Ae;pe++)de[pe]&&(re[fe++]=pe);return re}const ie=new Map;function ae(de){if(!(!de||typeof de!="object"))for(const[Ae,je]of Object.entries(de))je&&typeof je.compile=="function"&&ie.set(Ae,je)}function ce(de){return typeof de=="string"?ie.get(de):void 0}}),Be("packages/core/src/columns/datatypes.js",function(e,H){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return I}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,D=H("packages/core/src/internal/predicates.js"),F=D.isNil,Z=D.isObject,Y=D.isFunction,z=H("packages/core/src/internal/warn.js").fail,P=H("packages/core/src/internal/text.js").titleCase,O=H("packages/core/src/format/date.js"),b=O.toDate,c=O.toIsoDate,d=O.compareIso,r=H("packages/core/src/format/boolean.js").toTriState,i=H("packages/core/src/columns/types/index.js").EXTENDED_TYPES,s=H("packages/core/src/formula/index.js"),n=s.evaluateFormula,u=s.looksLikeFormula,a=H("packages/core/src/compute/filter.js").declareOperators,f=/^\d{4}-\d{2}-\d{2}$/;function w(M){return M.getHours()===0&&M.getMinutes()===0&&M.getSeconds()===0&&M.getMilliseconds()===0}const m=new Map;function v(M){const S=M||"",E=m.get(S);if(E)return E;const U={group:",",decimal:"."};try{for(const K of new Intl.NumberFormat(M||void 0).formatToParts(12345.6))K.type==="group"?U.group=K.value:K.type==="decimal"&&(U.decimal=K.value)}catch{}return m.set(S,U),U}const h=/\d\s*[*/^]\s*[\d.(]/;function p(M,S){if(F(M))return null;let E=String(M).trim();if(E===""||E.startsWith("=")||h.test(E))return null;let U=1;E.startsWith("(")&&E.endsWith(")")&&(U=-1,E=E.slice(1,-1));const K=E.endsWith("%"),{group:q,decimal:_}=v(S);if(E=E.replace(/[\s\u00a0\u202f\u2009']/g,""),q&&q!=="."&&q!==","&&(E=E.split(q).join("")),E=E.replace(/[^0-9eE+\-.,]/g,""),_===","?E=E.split(".").join("").replace(",","."):E=E.split(",").join(""),E===""||E==="-"||E==="+")return null;const J=Number(E);return Number.isNaN(J)?null:U*(K?J/100:J)}function g(M,S){const E=F(M)||Number.isNaN(M)?null:Number(M),U=F(S)||Number.isNaN(S)?null:Number(S);return E===null?U===null?0:1:U===null||E<U?-1:E>U?1:0}function k(M,S){const E=r(M),U=r(S);return E===null?U===null?0:1:U===null?-1:E===U?0:E?1:-1}function y(M,S){const E=b(M),U=b(S);if(!E)return U?1:0;if(!U)return-1;const K=E.getTime(),q=U.getTime();return K<q?-1:K>q?1:0}const T=new Map;function j(M){const S=b(M.value);if(!S)return"";const E=M.locale||"";let U=T.get(E);return U||(U=new Intl.DateTimeFormat(M.locale||void 0,{dateStyle:"medium"}),T.set(E,U)),U.format(S)}const N={boolean:{base:"boolean",storage:"bitset",matches:M=>typeof M=="boolean",parse:M=>r(M.text),compare:k,format:M=>r(M.value)===null?"":r(M.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:M=>r(M)===null?"":String(r(M)),fromClipboard:M=>r(M)},number:{base:"number",storage:"float64",matches:M=>typeof M=="number"&&!Number.isNaN(M),parse:M=>{if(u(M.text)){const S=n(M.text,M);if(!S.ok)return null;const E=Number(S.value);return Number.isFinite(E)?E:null}return p(M.text,M.locale)},compare:g,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:M=>F(M)?"":String(M),fromClipboard:(M,S)=>p(M,S&&S.locale)},date:{base:"dateString",storage:"dictionary",matches:M=>typeof M=="string"&&f.test(M)&&!Number.isNaN(Date.parse(M))||M instanceof Date&&!Number.isNaN(M.getTime())&&w(M),parse:M=>c(M.text),compare:d,format:j,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:M=>c(M),toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>c(M)},dateString:{base:"dateString",storage:"dictionary",matches:M=>typeof M=="string"&&f.test(M)&&!Number.isNaN(Date.parse(M)),parse:M=>c(M.text),compare:d,format:j,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:M=>c(M),toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>c(M)},text:{base:"text",storage:"dictionary",matches:M=>typeof M=="string",parse:M=>M.text===""?null:String(M.text),compare:(M,S)=>F(M)?F(S)?0:1:F(S)?-1:L().compare(String(M),String(S)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},image:{base:"text",storage:"dictionary",parse:M=>M.text===""||M.text==null?null:String(M.text).trim(),compare:(M,S)=>F(M)?F(S)?0:1:F(S)?-1:L().compare(String(M),String(S)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},lookup:{base:"text",storage:"dictionary",parse:M=>{if(M.text===""||M.text==null)return null;const S=M.column&&M.column.lookup,E=S&&Y(S.options)?S.options():null;if(!E)return M.text;const U=String(M.text),K=E.find(J=>String(J.id)===U);if(K)return K.id;const q=U.trim().toLowerCase(),_=E.find(J=>String(J.label).toLowerCase()===q);return _?_.id:M.text},compare:X,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:M=>F(M)?"":String(M),fromClipboard:M=>M},object:{base:"object",storage:"object",matches:M=>M!==null&&typeof M=="object"&&!(M instanceof Date),parse:M=>{try{return M.text===""?null:JSON.parse(M.text)}catch{return M.text}},compare:(M,S)=>X(M,S),format:M=>{const S=M.value;if(F(S))return"";if(typeof S=="string")return S;try{return JSON.stringify(S)}catch{return String(S)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:M=>F(M)?"":typeof M=="string"?M:JSON.stringify(M),fromClipboard:M=>M}},W=["boolean","number","date","dateString","datetime","text","object"];function R(M,S,E,U){const K=E.get(M);if(K)return K;U.includes(M)&&z(`circular data type extends chain: ${[...U,M].join(" → ")}`);const q=S[M];q||z(`unknown data type "${M}"`);let _=null;q.extends&&(_=R(q.extends,S,E,[...U,M]));const J={..._||{},...q,name:M,defaults:{..._&&_.defaults||{},...q.defaults||{}}};return J.base||(J.base=_&&_.base||"text"),J.storage||(J.storage=_&&_.storage||"object"),E.set(M,J),J}function x(M,S){const E={...N,...i};if(S&&typeof S.dataType=="function"&&typeof S.names=="function")for(const K of S.names("dataType")){const q=S.dataType(K);q&&(E[K]=q)}if(Z(M))for(const[K,q]of Object.entries(M))E[K]=q;const U=new Map;for(const K of W)R(K,E,U,[]);R("lookup",E,U,[]);for(const K of Object.keys(E))R(K,E,U,[]);for(const K of U.values())a(K.operators);return U}function A(M,S){if(M.base==="text"&&(!M.compare||M.compare===N.text.compare)){const E=L(S);return(U,K)=>F(U)?F(K)?0:1:F(K)?-1:E.compare(String(U),String(K))}return M.compare||X}function $(M,S){return S?M.multiStorage||"multi":M.storage||"object"}function I(M){return P(String(M).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Be("packages/core/src/columns/infer.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/warn.js").infoOnce,D=H("packages/core/src/internal/predicates.js").isNil,F=100;function Z(B,z,G={}){const P=G.sampleSize??F,O=[];for(let b=0;b<B.length&&O.length<P;b++){const c=B[b];D(c)||typeof c=="number"&&Number.isNaN(c)||O.push(c)}if(O.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[b,c]of z){if(typeof c.matches!="function")continue;let d=!0;for(let l=0;l<O.length;l++)if(!c.matches(O[l])){d=!1;break}if(d)return{type:b,unanimous:!0,sampled:O.length}}return G.quiet||L(`infer:${G.colId||"?"}`,`column "${G.colId||"?"}" has mixed or ambiguous values and was inferred as "text". Declare \`type\` on the column to get correct sorting, filtering and export.`),{type:"text",unanimous:!1,sampled:O.length}}function Y(B,z,G,P,O={}){const b=O.sampleSize??F,c=[];for(let d=0;d<z.length&&c.length<b;d++){const l=G(z[d]);D(l)||typeof l=="number"&&Number.isNaN(l)||c.push(l)}return Z(c,P,{...O,colId:B}).type}}),Be("packages/core/src/columns/graph.js",function(e,H){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return P}});const te=H("packages/core/src/internal/warn.js"),L=te.DEV,X=te.fail,D=te.warnOnce,Z=H("packages/core/src/internal/predicates.js").isFunction,Y="*";function B(O){const b=O.value||{};if(!Z(b.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const d=b.pure!==!1;return b.deps===Y?{computed:!0,wholeRow:!0,deps:[],pure:d}:Array.isArray(b.deps)?{computed:!0,wholeRow:!1,deps:b.deps.slice(),pure:d}:(D(`deps:missing:${O.id}`,`computed column "${O.id}" declares no \`value.deps\`; treating it as \`deps: '*'\` (a whole-row dependency). Declare the dependencies to get precise invalidation.`),{computed:!0,wholeRow:!0,deps:[],pure:d})}function z(O){const b=new Map;for(const f of O)b.set(f.id,f);const c=new Map,d=new Map,l=new Set,r=new Set,t=new Set,i=new Set;for(const f of O){const w=B(f);if(!w.computed){c.set(f.id,[]);continue}r.add(f.id),(w.pure?t:i).add(f.id),w.wholeRow&&l.add(f.id);const m=[],v=[];for(const h of w.deps)(b.has(h)?m:v).push(h);c.set(f.id,m),v.length&&d.set(f.id,v)}for(const f of t)for(const w of c.get(f))i.has(w)&&X(`pure computed column "${f}" depends on impure column "${w}". Mark it \`value.pure: false\` or make the dependency pure.`);const s=[],n=new Map,u=[],o=f=>{const w=n.get(f);if(w!=="done"){if(w==="open"){const m=u.indexOf(f);X(`circular column dependency: ${[...u.slice(m),f].join(" → ")}`)}n.set(f,"open"),u.push(f);for(const m of c.get(f)||[])b.has(m)&&o(m);u.pop(),n.set(f,"done"),s.push(f)}};for(const f of O)o(f.id);const a=new Map;for(const f of O)a.set(f.id,[]);for(const f of O)for(const w of c.get(f.id)||[]){const m=a.get(w);m&&!m.includes(f.id)&&m.push(f.id)}if(l.size)for(const f of O){if(r.has(f.id))continue;const w=a.get(f.id);for(const m of l)w.includes(m)||w.push(m)}return{order:s,dependents:a,pure:t,impure:i,computed:r,deps:c,wholeRow:l,external:d,index:b}}function G(O,b){const c=Array.isArray(b)?b:[b],d=new Set,l=[...c];for(;l.length;){const r=l.shift();for(const t of O.dependents.get(r)||[])d.has(t)||(d.add(t),l.push(t))}for(const r of c)d.delete(r);return O.order.filter(r=>d.has(r))}function P(O,b,c){if(!L)return O;const d=b instanceof Set?b:new Set(b);return new Proxy(O,{get(l,r){return typeof r=="string"&&!d.has(r)&&!Object.hasOwn(l,r)&&D(`undeclared:${c}:${r}`,`computed column "${c}" read undeclared dependency "${r}". Add it to \`value.deps\` or the value will go stale.`),l[r]}})}}),Be("packages/core/src/model/rowkey.js",function(e,H){"use strict";Object.defineProperty(e,"KEY_DEPENDENT_FEATURES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"compositeKey",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"warnMissingKeys",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"groupPathKey",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"splitPathKey",{enumerable:!0,get:function(){return r}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/paths.js").pathGetter,F=H("packages/core/src/internal/predicates.js"),Z=F.isFunction,Y=F.isBlank,B=["changes (rows.apply / rows.queue)","streaming dedupe","selection persistence","remote reload","cell comments"],z="";function G(t){if(t===null)return"\0n";if(t===void 0)return"\0u";const i=typeof t;if(i==="string")return t;if(i==="number"||i==="bigint"||i==="boolean")return String(t);if(t instanceof Date)return`\0d${t.getTime()}`;try{return`\0o${JSON.stringify(t)}`}catch{return"\0o?"}}function P(t){if(t.length===1)return G(t[0]);let i="";for(let s=0;s<t.length;s++)s&&(i+=z),i+=G(t[s]);return i}function O(t,i={}){const s=i.warn!==!1;if(Z(t)){const n=t;return{stable:!0,fields:[],disabled:[],key(u,o){try{const a=n(u);return Array.isArray(a)?P(a):G(a)}catch(a){return L("rowKey.throw","rowKey function threw; falling back to index identity for the affected rows.",a),`#${o??-1}`}},keyEmpty(u){try{const o=n(u);return Array.isArray(o)?o.length===0||o.some(Y):Y(o)}catch{return!1}},missingFields(){return[]}}}if(Array.isArray(t)&&t.length>0){const n=t.filter(a=>typeof a=="string"),u=n.map(a=>D(a)),o=u.length;return{stable:!0,fields:n,disabled:[],key(a){const f=new Array(o);for(let w=0;w<o;w++)f[w]=u[w](a);return P(f)},keyEmpty(a){for(let f=0;f<o;f++)if(Y(u[f](a)))return!0;return!1},missingFields(a){const f=[];for(let w=0;w<o;w++)Y(u[w](a))&&f.push(n[w]);return f}}}if(typeof t=="string"&&t.length>0){const n=D(t);return{stable:!0,fields:[t],disabled:[],key(u){return G(n(u))},keyEmpty(u){return Y(n(u))},missingFields(u){return Y(n(u))?[t]:[]}}}return s&&L("rowKey.missing",`no rowKey configured, so rows are identified by object identity. This disables: ${B.join(", ")}. Set rowKey to a field name, an array of field names, or a function.`),{stable:!1,fields:[],disabled:B.slice(),key(n,u){if(n===null||typeof n!="object")return`#${u??0}:${String(n)}`;let o=b.get(n);return o===void 0&&(o=`#${c++}`,b.set(n,o)),o}}}const b=new WeakMap;let c=0;function d(t,i){if(!t||t.stable===!1||!Z(t.keyEmpty)||!Array.isArray(i)||i.length===0)return;let s=0,n=null,u;for(let w=0;w<i.length;w++){const m=i[w];t.keyEmpty(m)&&(s++,n===null&&(n=Z(t.missingFields)?t.missingFields(m):[],u=m))}if(s===0)return;const o=t.fields.length?t.fields.join(","):"(function)",a=n&&n.length?n.join(", "):t.fields.length?t.fields.join(", "):"the rowKey function",f=u!==null&&typeof u=="object"?Object.keys(u).join(", ")||"(no fields)":String(u);L(`rowKey.emptyValue:${o}`,`rowKey ${a} is missing on ${s} of ${i.length} rows; the first such row has: ${f}. Rows without a key value collapse onto one key, so selection, edits and rows.apply updates land on whichever row now shares it. Set rowKey to a field present on every row, or fix the source data.`)}function l(t){return P(t)}function r(t){return t.split(z)}}),Be("packages/core/src/columns/lookup.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return t}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare,D=H("packages/core/src/internal/predicates.js"),F=D.isFunction,Z=D.isNil,B=H("packages/core/src/internal/warn.js").warnOnce,G=H("packages/core/src/model/rowkey.js").compositeKey,P=", ",O="";function b(i,s,n,u){if(i===null||typeof i!="object")return{id:i,label:i==null?"":String(i)};const o=i[s],a=i[n],f={id:o,label:a==null?String(o??""):String(a)};i.disabled&&(f.disabled=!0),i.variant&&(f.variant=i.variant),i.icon&&(f.icon=i.icon);const w=u?i[u]:i.group;return w!==void 0&&(f.group=w),f}function c(i,s,n=0,u=[],o=[]){for(const a of i||[]){const f=a&&typeof a=="object"?a[s]:null;if(o.push({raw:a,depth:n,path:u}),Array.isArray(f)&&f.length){const w=String(a&&typeof a=="object"?a.label??a.name??a.id??"":a);c(f,s,n+1,[...u,w],o)}}return o}function d(i){return!!i&&typeof i=="object"&&!Array.isArray(i)&&F(i.router&&i.router.subscribe)}class l{#e;#t;#n;#r;#s=[];#i=new Map;#o=new Map;#l=0;#a="idle";#c=null;#u;#f=null;#d=new Map;constructor(s,n={}){this.#e=s||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#u=L(this.#n),Array.isArray(this.#e.options)?this.#h(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??P}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#s}setLocale(s){this.#n=s,this.#u=L(s)}#h(s){const n=this.#e,u=n.valueKey||"id",o=n.labelKey||"label",a=n.childrenKey||"children";this.#s=c(s,a).map(f=>{const w=b(f.raw,u,o,n.groupKey);return f.depth&&(w.depth=f.depth,w.path=f.path),w}),this.#i=new Map,this.#o=new Map,this.#s.forEach((f,w)=>{this.#i.set(f.id,f),this.#o.set(f.id,w)}),this.#a="ready",this.#l+=1}load(){if(this.#c)return this.#c;const s=this.#e.options;if(Array.isArray(s)||s===void 0)return this.#c=Promise.resolve(this.#s),this.#c;if(d(s))return this.#c=this.#p(s),this.#c;if(!F(s))return B(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array, a function, or a router route`),this.#a="ready",this.#c=Promise.resolve([]),this.#c;this.#a="loading";let n;try{n=s()}catch(u){return this.#a="error",B(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,u),this.#c=Promise.resolve([]),this.#c}return!n||!F(n.then)?(this.#h(n),this.#c=Promise.resolve(this.#s),this.#r&&this.#r(this),this.#c):(this.#c=n.then(u=>(this.#h(u),this.#r&&this.#r(this),this.#s),u=>(this.#a="error",B(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,u),[])),this.#c)}refresh(){return this.#c=null,Array.isArray(this.#e.options)?(this.#h(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#s)):this.load()}#p(s){if(this.#f)return Promise.resolve(this.#s);const n=this.#e,u=n.valueKey||"id",o=n.labelKey||"label",a=n.groupKey,f=F(s.map)?s.map:null,w=v=>b(f?f(v):v,u,o,a).id,m=v=>this.#m(v,f,u,o,a);return s.router.subscribe(s.predicate,m,{rowKey:w}),this.#f=()=>{F(s.router.detach)&&s.router.detach(m)},this.#a="ready",Promise.resolve(this.#s)}#m(s,n,u,o,a){const f=s&&s.add||[],w=s&&s.update||[],m=s&&s.remove||[];if(!(!f.length&&!w.length&&!m.length)){for(const v of f)this.#g(v,n,u,o,a);for(const v of w)this.#g(v,n,u,o,a);for(const v of m){if(!this.#d.has(v))continue;const h=this.#d.get(v);this.#d.delete(v),this.#i.delete(h);const p=this.#s.findIndex(g=>g.id===h);p>=0&&this.#s.splice(p,1)}this.#o=new Map(this.#s.map((v,h)=>[v.id,h])),this.#a="ready",this.#l+=1,this.#r&&this.#r(this)}}#g(s,n,u,o,a){const f=b(n?n(s):s,u,o,a);this.#d.set(G([f.id]),f.id);const w=this.#s.findIndex(m=>m.id===f.id);w>=0?this.#s[w]=f:this.#s.push(f),this.#i.set(f.id,f)}destroy(){this.#f&&(this.#f(),this.#f=null)}search(s,n){const u=this.#e;if(!F(u.search)){const f=String(s||"").toLowerCase();return Promise.resolve(f===""?this.#s:this.#s.filter(w=>w.label.toLowerCase().includes(f)))}const o=u.valueKey||"id",a=u.labelKey||"label";return Promise.resolve(u.search(s,n)).then(f=>(f||[]).map(w=>b(w,o,a,u.groupKey)))}option(s){return this.#i.get(s)}has(s){return this.#i.has(s)}label(s){if(Z(s)||s==="")return"";const n=this.#i.get(s);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||B(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(s)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const u=this.#e.unknownLabel;return F(u)?String(u(s)??""):typeof u=="string"?u:String(s)}text(s){if(this.multiple){const n=r(s);return n.length===0?"":n.map(u=>this.label(u)).join(this.separator)}return this.label(s)}dictionary(){return this.#s.map(s=>s.id)}sorted(){const s=this.sortBy;if(s==="optionOrder"||s==="count")return this.#s.slice();if(s==="value")return this.#s.slice().sort((u,o)=>X(u.id,o.id));const n=this.#u;return this.#s.slice().sort((u,o)=>n.compare(u.label,o.label))}comparator(){const s=this.sortBy,n=this.multiple,u=this.#u,o=this.#o;if(n&&s==="count")return(f,w)=>r(f).length-r(w).length;const a=n?f=>r(f)[0]:f=>f;return s==="value"?(f,w)=>X(a(f),a(w)):s==="optionOrder"?(f,w)=>{const m=o.has(a(f))?o.get(a(f)):Number.MAX_SAFE_INTEGER,v=o.has(a(w))?o.get(a(w)):Number.MAX_SAFE_INTEGER;return m-v}:(f,w)=>{const m=a(f),v=a(w);return Z(m)?Z(v)?0:1:Z(v)?-1:u.compare(this.label(m),this.label(v))}}groupKey(s){return this.multiple?r(s).map(u=>String(u)).sort().join(O):Z(s)?"":String(s)}countValues(s){return this.multiple?r(s).length:Z(s)?0:1}contains(s,n,u){const o=this.multiple?r(s):Z(s)?[]:[s],a=Array.isArray(n)?n:[n];switch(u){case"containsAll":return a.every(f=>o.includes(f));case"containsNone":return!a.some(f=>o.includes(f));default:return a.some(f=>o.includes(f))}}exportText(s,n="label"){return n==="value"?this.multiple?r(s).join(this.separator):Z(s)?"":String(s):this.text(s)}exportColumns(){const s=this.multiple;return this.#s.map(n=>({id:n.id,label:n.label,has:u=>s?r(u).includes(n.id):u===n.id}))}}function r(i){return Array.isArray(i)?i:Z(i)||i===""?[]:[i]}function t(i,s={}){const n=i.lookup;if(!n)return null;const u=new l(n,{colId:i.id,locale:s.locale,onChange:s.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&u.load(),u}}),Be("packages/core/src/columns/value.js",function(e,H){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return l}});const L=H("packages/core/src/internal/paths.js").getPath,X=H("packages/core/src/internal/predicates.js"),D=X.isFunction,F=X.isNil,Y=H("packages/core/src/internal/lru.js").Lru,z=H("packages/core/src/internal/warn.js").warnOnce,P=H("packages/core/src/columns/graph.js").depsProxy,O="\0";function b(s,n={}){const u=n.locale,o=n.grid??null,a=n.context,f=s.value&&s.value.format,w=s.formatter||null,m=s.dataType&&s.dataType.format,v=s.lookup||null,h=(p,g,k)=>({value:p,data:k,row:g,column:s,colId:s.id,grid:o,context:a,locale:u});if(D(f))return(p,g,k)=>{const y=f(h(p,g,k));return y==null?"":String(y)};if(w){if(v){const p=w.kind==="text";return(g,k,y)=>w(p?v.text(g):g,h(g,k,y))}return(p,g,k)=>w(p,h(p,g,k))}return D(m)?(p,g,k)=>{const y=m(h(p,g,k));return y==null?"":String(y)}:v?p=>v.text(p):p=>F(p)?"":typeof p=="string"?p:String(p)}function c(s,n){!s||!s.value||s.value.pure!==!1||z(`impure:${n}:${s.id}`,`column "${s.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${n}. The result is not stable across passes.`)}class d{#e;#t;#n;#r;#s;#i;#o=new Y(4096);constructor(n){this.#e=n.columns instanceof Map?n.columns:new Map((n.columns||[]).map(u=>[u.id,u])),this.#t=n.graph,this.#n=n.grid??null,this.#r=n.context,this.#i=n.stored||null,this.#s=n.rowKey||l}get graph(){return this.#t}setGraph(n){this.#t=n,this.#o.clear()}beginPass(){this.#o.clear()}endPass(){this.#o.clear()}invalidate(n){if(this.#o.size===0)return;const u=n&&n.rows?new Set([...n.rows].map(String)):null,o=n&&n.columns?[...n.columns]:null;if(!u&&!o){this.#o.clear();return}const a=o?this.#l(o):null;for(const f of[...this.#o.keys()]){const w=String(f).split(O);w.length===3&&(u&&!u.has(w[0])||a&&!a.has(w[2])||this.#o.delete(f))}}#l(n){const u=new Set,o=this.#t,a=[...n];for(;a.length;){const f=a.pop();if(!u.has(f)){u.add(f);for(const w of o?o.dependents.get(f)||[]:[])a.push(w)}}return u}value(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return;if(!a.computed)return this.#c(a,u,o);if(a.value.pure!==!1&&this.#i&&o&&o.physical!=null&&this.#i.has(a.id))return this.#i.get(a.id,o.physical);if(a.volatile)return this.compute(a,u,o);if(a.value.pure===!1)return this.compute(a,u,o);const f=`${this.#a(u,o)}${O}${a.id}`;if(this.#o.has(f))return this.#o.get(f);const w=this.compute(a,u,o);return this.#o.set(f,w),w}#a(n,u){return`${this.#s(n,u)}${O}${r(n)}`}#c(n,u,o){if(this.#i&&o&&o.physical!=null&&this.#i.has(n.id))return this.#i.get(n.id,o.physical);if(n.field)return n.read?n.read(u):L(u,n.field)}compute(n,u,o){const a=this.#t,f=a&&a.wholeRow.has(n.id);let w;if(f)w=u??{};else{w={};const v=a&&a.deps.get(n.id)||[];for(const p of v)w[p]=this.value(p,u,o);const h=a&&a.external.get(n.id)||[];for(const p of h)w[p]=L(u,p);w=P(w,[...v,...h],n.id)}const m={data:u,row:o,column:n,grid:this.#n,context:this.#r};return n.value.compute(w,m)}values(n,u){const o={},a=this.#t?this.#t.order:[...this.#e.keys()];for(const f of a)o[f]=this.value(f,n,u);return o}text(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;return a?a.formatValue(this.value(a,u,o),o,u):""}key(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return"";const f=this.value(a,u,o);return D(a.value.key)?String(a.value.key(this.#u(a,f,u,o))):a.lookup?a.lookup.groupKey(f):F(f)?"":String(f)}quickFilterText(n,u,o){const a=typeof n=="string"?this.#e.get(n):n;if(!a)return"";if(D(a.value.quickFilterText)){const f=this.value(a,u,o);return String(a.value.quickFilterText(this.#u(a,f,u,o))??"")}return this.text(a,u,o)}#u(n,u,o,a){return{value:u,data:o,row:a,column:n,colId:n.id,grid:this.#n,context:this.#r}}parse(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return u;const w={text:u,value:this.value(f,o,a),data:o,row:a,column:f,grid:this.#n,context:this.#r,locale:this.#n&&D(this.#n.get)?this.#n.get("locale"):void 0,formulaFunctions:this.#n&&D(this.#n.get)?this.#n.get("formulaFunctions"):void 0};return D(f.value.parse)?f.value.parse(w):f.dataType&&D(f.dataType.parse)?f.dataType.parse(w):u}validate(n,u,o,a,f){const w=typeof n=="string"?this.#e.get(n):n;if(!w||!D(w.edit.validate))return!0;const m=w.edit.validate({value:u,oldValue:o,data:a,row:f,column:w,grid:this.#n,context:this.#r});return m===!0||m===void 0?!0:String(m)}apply(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return!1;const w=this.value(f,o,a);if(D(f.value.apply)){const m=f.value.apply({value:u,oldValue:w,data:o,row:a,column:f,grid:this.#n,context:this.#r});return this.#f(f,o,a),m!==!1}return f.field?w===u?!1:(f.write(o,u),this.#f(f,o,a),!0):(z(`apply:${f.id}`,`column "${f.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(n,u,o,a){const f=typeof n=="string"?this.#e.get(n):n;if(!f)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const w=this.value(f,o,a),m=this.parse(f,u,o,a),v=this.validate(f,m,w,o,a);if(v!==!0)return{ok:!1,value:m,oldValue:w,changed:!1,error:v};const h=this.apply(f,m,o,a);return{ok:!0,value:m,oldValue:w,changed:h}}#f(n,u,o){if(this.#o.size===0)return;const a=this.#a(u,o);this.#o.delete(`${a}${O}${n.id}`);for(const f of this.#t?this.#t.dependents.get(n.id)||[]:[])this.#o.delete(`${a}${O}${f}`)}}function l(s,n){return n&&n.key!=null?String(n.key):r(s)}function r(s){if(s&&typeof s=="object"){let n=t.get(s);return n===void 0&&(n=`#${i++}`,t.set(s,n)),n}return String(s)}const t=new WeakMap;let i=0}),Be("packages/core/src/model/shadow.js",function(e,H){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return o}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=2e5,D=20,F=1e3,Z=50;function Y(a){return Math.min(F,Math.max(Z,Math.floor(a)))}const B=Object.freeze(["updates","updatedAt","sinceUpdate","delta","deltaPercent","rate","history","firstValue","streak","rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag","specStatus","rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta","fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),z=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),G=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),P=.6745,O=3.5,b=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),c=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),d=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function l(a,f){if(!f)return null;const w=Number.isFinite(Number(f.lower))?Number(f.lower):null,m=Number.isFinite(Number(f.upper))?Number(f.upper):null;if(w===null&&m===null||!Number.isFinite(a))return null;if(w!==null&&a<w||m!==null&&a>m)return b.FAIL;const v=Number.isFinite(Number(f.warnLower))?Number(f.warnLower):null,h=Number.isFinite(Number(f.warnUpper))?Number(f.warnUpper):null;return v!==null&&a<v||h!==null&&a>h?b.WARN:b.PASS}function r(a,f,w){if(!f||typeof f!="object")return null;if(f.kind!=="time")return f.kind!==void 0&&L(`shadow.history.window.kind:${a}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${f.kind}' is not honoured (a plain count is already what 'depth' means, and a session has no span to divide into buckets), so it reported the original, unwindowed history.`),null;const m=f.minutes!=null?Number(f.minutes)*6e4:Number(f.span);if(!(m>0))return L(`shadow.history.window.span:${a}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const v=Math.max(2,Math.floor(w)||D);return{span:m,bucketMs:Math.max(1,Math.floor(m/v))}}class t{#e;#t=new Map;#n=new Map;#r=new Map;#s=new Map;#i=new Map;#o=new Map;#l=0;#a;#c;#u;#f;#d=new Map;#h=null;#p=null;#m=null;constructor(f){this.#e=f.colId,this.#a=Math.max(2,f.depth||D),this.#c=Math.max(1,f.max||X),this.#u=f.now||(()=>Date.now()),this.#f=r(this.#e,f.historyWindow,this.#a),this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#f}observe(f,w){const m=u(w);if(m===null)return;if(!this.#n.has(f)){this.#p=null,this.#m=null,this.#g(),this.#t.set(f,m),this.#n.set(f,m),this.#r.set(f,0),this.#s.set(f,this.#u()),this.#i.set(f,[m]),this.#f&&this.#d.set(f,[m]),this.#o.set(f,0);return}const v=this.#n.get(f);if(v===m)return;this.#p=null,this.#m=null,this.#n.set(f,m),this.#r.set(f,(this.#r.get(f)||0)+1),this.#s.set(f,this.#u());const h=this.#i.get(f)||[];h.push(m),h.length>this.#a&&h.splice(0,h.length-this.#a),this.#i.set(f,h);const p=Math.sign(m-v),g=this.#o.get(f)||0;this.#o.set(f,Math.sign(g)===p?g+p:p)}#g(){if(this.#n.size<this.#c)return;const f=this.#n.keys().next().value;f!==void 0&&(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#s.delete(f),this.#i.delete(f),this.#d.delete(f),this.#o.delete(f),this.#l++)}rebase(){for(const[f,w]of this.#n)this.#t.set(f,w);this.#p=null,this.#m=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#s.clear(),this.#i.clear(),this.#d.clear(),this.#o.clear(),this.#l=0,this.#p=null,this.#m=null,this.#f&&(this.#h=Math.floor(this.#u()/this.#f.bucketMs))}retain(f){const w=f instanceof Set?f:new Set(f);let m=0;for(const v of[...this.#n.keys()])w.has(v)||(this.#t.delete(v),this.#n.delete(v),this.#r.delete(v),this.#s.delete(v),this.#i.delete(v),this.#d.delete(v),this.#o.delete(v),m++);return m&&(this.#p=null,this.#m=null),m}advanceHistoryWindow(f=this.#u()){const w=this.#f;if(!w)return 0;const m=Math.floor(f/w.bucketMs),v=m-this.#h;if(!(v>0))return 0;const h=Math.min(v,this.#a);for(const[p,g]of this.#d){const k=this.#n.get(p);for(let y=0;y<h;y++)g.push(k);g.length>this.#a&&g.splice(0,g.length-this.#a)}return this.#h=m,v}read(f,w,m,v){switch(f){case"updates":return this.#r.has(w)?this.#r.get(w):0;case"updatedAt":{const h=this.#s.get(w);return h===void 0?null:new Date(h)}case"sinceUpdate":{const h=this.#s.get(w);return h===void 0?null:this.#u()-h}case"firstValue":return this.#t.has(w)?this.#t.get(w):null;case"delta":return this.#n.has(w)?this.#n.get(w)-this.#t.get(w):null;case"deltaPercent":{if(!this.#n.has(w))return null;const h=this.#t.get(w);return h?(this.#n.get(w)-h)/Math.abs(h)*100:null}case"rate":{const h=this.#i.get(w),p=this.#s.get(w);if(!h||h.length<2||p===void 0)return null;const g=this.#u()-p,k=h[h.length-1]-h[h.length-2];return g>0?k/g*1e3:k}case"history":return this.#f?this.#d.has(w)?[...this.#d.get(w)]:null:this.#i.has(w)?[...this.#i.get(w)]:null;case"streak":return this.#o.has(w)?this.#o.get(w):0;case"specStatus":return this.#n.has(w)?l(this.#n.get(w),v):null;default:return c.includes(f)?this.#j(f,w,m,v):null}}#b(f){if(f){if(this.#m&&this.#m.only===f)return this.#m.view;const w=this.#y(f);return this.#m={only:f,view:w},w}return this.#p?this.#p:(this.#p=this.#y(null),this.#p)}#y(f){const w=[];for(const[N,W]of this.#n)f&&!f.has(N)||w.push(W);const m=w.sort((N,W)=>N-W);let v=0,h=0,p=0,g=0;for(const N of m){g+=N,v++;const W=N-h;h+=W/v,p+=W*(N-h)}const k=[];for(const[N,W]of this.#t)f&&!f.has(N)||k.push(W);const y=v?i(m):0,T=m.map(N=>Math.abs(N-y)).sort((N,W)=>N-W),j=v?i(T):0;return{sorted:m,baseline:k.sort((N,W)=>N-W),sum:g,mean:v?h:0,sd:v>1?Math.sqrt(p/(v-1)):0,median:y,mad:j}}#j(f,w,m,v){if(!this.#n.has(w)||m&&!m.has(w))return null;const h=this.#n.get(w),p=this.#b(m),g=p.sorted.length;if(!g)return null;switch(f){case"rank":return g-n(p.sorted,h)+1;case"rankAsc":return s(p.sorted,h)+1;case"rankChange":{if(!this.#t.has(w)||!p.baseline.length)return null;const k=p.baseline.length-n(p.baseline,this.#t.get(w))+1,y=g-n(p.sorted,h)+1;return k-y}case"percentile":return n(p.sorted,h)/g*100;case"quartile":{const k=n(p.sorted,h)/g;return Math.min(4,Math.max(1,Math.ceil(k*4)))}case"zScore":return p.sd?(h-p.mean)/p.sd:null;case"anomalyScore":return p.mad?P*(h-p.median)/p.mad:null;case"anomalyFlag":{if(!p.mad)return null;const k=v&&Number.isFinite(Number(v.threshold))?Number(v.threshold):O;return Math.abs(P*(h-p.median)/p.mad)>k}case"shareOfTotal":return p.sum?h/p.sum*100:null;default:return null}}}function i(a){const f=a.length;if(!f)return 0;const w=(f-1)*.5,m=Math.floor(w),v=Math.ceil(w);return m===v?a[m]:a[m]+(w-m)*(a[v]-a[m])}function s(a,f){let w=0,m=a.length;for(;w<m;){const v=w+m>>1;a[v]<f?w=v+1:m=v}return w}function n(a,f){let w=0,m=a.length;for(;w<m;){const v=w+m>>1;a[v]<=f?w=v+1:m=v}return w}function u(a){if(a==null||a==="")return null;if(a instanceof Date){const w=a.getTime();return Number.isFinite(w)?w:null}const f=typeof a=="number"?a:Number(a);return Number.isFinite(f)?f:null}function o(a){const f=[];for(const w of a||[]){const m=w.shadow;if(!m)continue;const v=typeof m=="string"?{kind:m}:m,h=v.kind;B.includes(h)&&(z.includes(h)||G.includes(h)||f.push({colId:w.id||w.field,of:v.of||w.field||w.id,kind:h,depth:v.depth,historyWindow:h==="history"?v.window:void 0}))}return f}}),Be("packages/core/src/columns/model.js",function(e,H){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return Ae}});const te=H("packages/core/src/internal/merge.js"),L=te.expand,X=te.merge,D=te.toArray,F=H("packages/core/src/internal/warn.js"),Z=F.fail,Y=F.warnOnce,B=H("packages/core/src/internal/paths.js"),z=B.getPath,G=B.pathGetter,P=B.pathSetter,b=H("packages/core/src/internal/text.js").humanise,c=H("packages/core/src/internal/predicates.js"),d=c.isFunction,l=c.isObject,t=H("packages/core/src/internal/uid.js").uid,s=H("packages/core/src/format/index.js").compileFormat,n=H("packages/core/src/columns/datatypes.js"),u=n.comparatorFor,o=n.createTypeRegistry,a=n.storageKind,f=H("packages/core/src/columns/infer.js"),w=f.inferColumnType,m=f.DEFAULT_SAMPLE,v=H("packages/core/src/columns/graph.js"),h=v.buildGraph,p=v.affectedBy,k=H("packages/core/src/columns/lookup.js").createLookup,y=H("packages/core/src/columns/value.js"),T=y.compileDisplay,j=y.ValuePipeline,N=y.warnImpureUse,R=H("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,x=Object.freeze({geometry:"geometry",list:"list"}),A={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},$={centre:"center"},I=new Set(["start","center","end","left","right"]);function M(be){if(typeof be!="string")return;const re=be.toLowerCase();return $[re]?$[re]:I.has(re)?re:void 0}function S(be){if(typeof be!="string")return;const re=be.toLowerCase();return re==="center"||re==="centre"?"middle":re==="top"||re==="middle"||re==="bottom"?re:void 0}const E=["cell","layout","header"];function U(be){if(!l(be))return{};const re={...be},fe=(pe,Oe)=>{if(be[pe]===void 0)return;const ve=L(be[pe],Oe);ve&&E.includes(pe)&&!l(be[pe])&&delete ve.enabled,re[pe]=ve};return fe("sort","direction"),fe("filter","type"),fe("cell","render"),fe("edit","editor"),fe("layout","width"),fe("group","index"),fe("pivot","index"),fe("header","render"),fe("facet","strategy"),re}function K(be,re){const fe={...be||{}},pe=l(re)&&l(re.layout)&&re.layout.width!==void 0;return fe.fit==="content"&&!pe&&delete fe.width,fe}const q=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","diff","edit","export","facet","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),_=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function J(be,re,fe,pe){const Oe=fe==="columnGroup"?"column group":"column";for(const ve of Object.keys(be))if(!re.has(ve)){if(ve==="timeZone"&&fe==="column"){Y("column.timeZone",`\`timeZone\` is not a column option, so it had no effect on column "${pe}". A date column stores, displays, sorts and filters in the grid-level \`timeZone\` (else the viewer's); set \`timeZone\` on the grid, not the column.`);continue}Y(`${fe}.unknown:${ve}`,`'${ve}' is not a configuration key this grid recognises, so it had no effect on ${Oe} "${pe}". Check the spelling against the reference.`)}}function ee(be){l(be.cell)&&be.cell.autoHeight!==void 0&&Y("column.cell.autoHeight",`\`cell.autoHeight\` is not a column option, so it had no effect on column "${be.id||be.field||"(unnamed)"}". Rows grow to fit with the grid-level \`autoHeight\`; \`cell.wrap\` lets this column's text wrap.`)}function ne(be,re){const fe=re&&d(be.defaultsFor)?be.defaultsFor(re):null,pe={...be.defaults||{},...l(fe)?fe:{}},Oe={};return pe.align&&(Oe.align=pe.align,Oe.cell={align:pe.align},Oe.header={align:pe.align}),pe.filter&&(Oe.filter=pe.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:pe.filter}),pe.editor&&(Oe.edit=pe.editor==="none"?{editor:null}:{editor:pe.editor}),pe.total&&(Oe.total=pe.total),pe.render&&(Oe.cell={...Oe.cell||{},render:pe.render}),be.export&&(Oe.export={...be.export}),Oe}function oe(be){if(typeof be=="string")return be.trim()?[be.trim()]:[];if(!Array.isArray(be))return[];const re=[];for(const fe of be){if(typeof fe!="string")continue;const pe=fe.trim();pe&&!re.includes(pe)&&re.push(pe)}return re}class ie{#e=new Map;#t=[];#n=[];#r=new WeakMap;#s;#i;#o;#l;#a;#c;#u(re,fe,pe){const Oe=this.#f(re,fe,pe);if(typeof Oe!="string"||!this.#d)return Oe??null;const ve=fe&&fe.totals&&fe.totals.implement;if(ve&&d(ve[Oe])){const he=ve[Oe];return he.totalName=Oe,he}const $e=this.#d.totalFn?.(Oe);return d($e)?$e:Oe}#f(re,fe,pe){if(typeof re!="string")return re;const Oe=fe&&fe.totals&&fe.totals.supported;if(!Array.isArray(Oe)||Oe.includes(re))return re;const ve=Oe.length?Oe.join(", "):"none";return Z(`column "${pe}" is typed ${fe.name||"a type"}, for which the total "${re}" is not meaningful. Supported: ${ve}. Aggregating it anyway would produce a confident wrong number.`),re}#d;#h;#p;#m;#g;#b;#y=!1;#j;#w;constructor(re={}){this.#i=U(re.columnDefaults||{}),this.#o=re.columnPresets||{},this.#a=re.locale,this.#l=re.timeZone,this.#c=S(re.verticalAlign),this.#d=re.registry||null,this.#h=re.grid||null,this.#p=re.context,this.#j=re.sampleSize??m,this.#w=re.onChange||null,this.#b=d(re.rowKey)?re.rowKey:void 0,this.#s=o(re.dataTypes,this.#d);const{leaves:fe,groups:pe}=Ae(re.columns||[]);this.#n=pe;for(const Oe of fe){Oe.facet!==void 0&&this.#r.set(Oe.def,Oe.facet);const ve=this.#O(Oe.def,null);if(ve.groupPath=Oe.path,this.#e.has(ve.id)){Y(`columns.duplicate:${ve.id}`,`two columns resolve to the id '${ve.id}', so the second is ignored. An id defaults to the column's field, so declare an explicit \`id\` when two columns read the same field.`);continue}Oe.column=ve,this.#e.set(ve.id,ve),this.#t.push(ve.id)}this.#E(re.stored||null)}#O(re,fe){J(re,q,"column",re.id||re.field||"(unnamed)"),ee(re);const pe=U(re),Oe=D(re.preset),ve=Oe.map(it=>{const mt=this.#o[it];return mt?U(mt):(Y(`preset:${it}`,`unknown column preset "${it}"; ignoring`),{})}),$e=this.#S(pe,ve,fe),he=this.#s.get($e)||this.#s.get("text");if(!this.#s.has($e)&&re.type){const it=x[$e];Y(`type:${$e}`,`unknown data type "${$e}"; falling back to "text"`+(it?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${it}'.`:""))}const ye=d(he.items)?this.#T(pe,ve,re.id||re.field||"(unnamed)"):null;let Se=A;Se=X(Se,this.#i),re.type!==!1&&(Se=X(Se,ne(he,ye)));for(const it of ve)Se=X(Se,it);this.#r.has(re)&&(Se=X(Se,U({facet:this.#r.get(re)}))),Se=X(Se,pe);const Ie=Se.edit;Ie&&Ie.editor&&Ie.enabled!==!0&&!d(Ie.enabled)&&(re.edit||{}).editor&&Y(`column.editor-not-enabled:${re.id||re.field}`,`column '${re.id||re.field}' names the editor '${Ie.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const we=re.id||re.field||t("col");if(re.shadow&&!d(Se.value&&Se.value.compute)){const it=typeof re.shadow=="string"?{kind:re.shadow}:re.shadow,mt=it.of||re.field||we,kt=R.includes(it.kind),St=kt?it.model||it:null,Pt=kt&&St?[...Array.isArray(St.predictors)?St.predictors:[],St.response].filter(Boolean):null;Se.value={...Se.value||{},deps:Pt&&Pt.length?Pt:it.orderBy&&it.orderBy!==mt?[mt,it.orderBy]:[mt],pure:!1,compute:(Nt,Ft)=>{const Lt=Ft.grid&&Ft.grid.statistics;if(!Lt)return null;const Ut=Ft.row&&Ft.row.key||Lt.keyOf(Ft.data);if(!Ut)return null;if(kt){if(!d(Lt.fitShadow))return null;const ft=it.model?{...it.model,threshold:it.threshold}:it;return Lt.fitShadow(it.kind,Ut,ft)}return Lt.shadow(mt,it.kind,Ut,it.scope,it)}}}if(re.running&&!d(Se.value&&Se.value.compute)){const it=typeof re.running=="string"?{kind:re.running}:re.running,mt=it.of||re.field||we;Se.value={...Se.value||{},deps:[mt],pure:!1,compute:(kt,St)=>{const Pt=St.grid&&St.grid.statistics;if(!Pt||!d(Pt.running))return null;const Nt=St.row&&St.row.key||Pt.keyOf(St.data);return Nt?Pt.running(mt,it.kind||"total",Nt):null}},re.sort===void 0&&(Se.sort={...Se.sort||{},enabled:!1})}const Fe=re.field??(d(Se.value&&Se.value.compute)?null:re.id??null),He=d(Se.value&&Se.value.compute),Ke={id:we,field:Fe,shadow:re.shadow||null,running:re.running||null,spec:re.spec||null,validation:re.validation||null,volatile:!!(re.shadow||re.running),title:Se.title??b(Fe||we),type:he.name,dataType:he,itemType:ye,nullable:Se.nullable!==!1,align:M(pe.cell&&pe.cell.align||pe.align||Se.cell&&Se.cell.align||Se.align||he.defaults&&he.defaults.align)||"start",verticalAlign:S(pe.cell&&pe.cell.verticalAlign||pe.verticalAlign||Se.cell&&Se.cell.verticalAlign||Se.verticalAlign)||this.#c,rowSpan:d(Se.rowSpan)?Se.rowSpan:null,colSpan:d(Se.colSpan)?Se.colSpan:null,value:{pure:!0,...Se.value||{}},cell:{...Se.cell||{}},edit:{...Se.edit||{}},sort:{...Se.sort||{}},filter:{...Se.filter||{}},group:{enabled:!1,index:-1,explode:!1,...Se.group||{}},pivot:{enabled:!1,index:-1,...Se.pivot||{}},total:this.#u(Se.total,he,re.id||re.field||"(unnamed)"),groupTotal:Se.groupTotal===void 0?null:this.#u(Se.groupTotal,he,re.id||re.field||"(unnamed)"),grandTotal:Se.grandTotal===void 0?null:this.#u(Se.grandTotal,he,re.id||re.field||"(unnamed)"),tags:oe(Se.tags),typeOptions:Se.typeOptions??null,...l(Se[$e])?{[$e]:Se[$e]}:{},layout:K(Se.layout,pe),header:{...Se.header||{}},contextMenu:Se.contextMenu===void 0?null:Se.contextMenu,facet:{...Se.facet||{}},export:{...Se.export||{}},allowGroup:Se.allowGroup!==!1,allowPivot:Se.allowPivot!==!1,allowTotal:Se.allowTotal!==!1,quickFilter:Se.quickFilter!==!1,def:re,format:Se.format,presets:Oe,inferred:fe!=null&&!re.type,computed:He,diff:re.diff===void 0?void 0:!!re.diff,read:Fe?G(Fe):null,write:Fe?P(Fe):null};Ke.cell.align=M(pe.cell&&pe.cell.align)||Ke.align,Ke.header.align=M(pe.header&&pe.header.align)||Ke.align;const nt=Se.lookup||null;return Ke.lookup=nt?k({id:we,lookup:nt},{locale:this.#a,onChange:()=>{this.#w&&this.#w("lookup",{colId:we})}}):null,Ke.group.explode&&Ke.lookup&&Ke.lookup.multiple&&Y(`explode:${we}`,`column "${we}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#v(Ke),Ke}#v(re){re.formatter=s(re.format,re.dataType,this.#a,this.#l,re.id),re.formatValue=T(re,{locale:this.#a,grid:this.#h,context:this.#p}),re.itemCompare=re.itemType?u(re.itemType,this.#a):null,re.compare=d(re.value.compare)?re.value.compare:re.lookup?re.lookup.comparator():d(re.dataType.compareFor)?re.dataType.compareFor(re):u(re.dataType,this.#a),re.excel=re.formatter&&re.formatter.ooxml||re.dataType&&re.dataType.excel||"General",re.storeKind=a(re.dataType,!!(re.lookup&&re.lookup.multiple))}#T(re,fe,pe){let Oe=l(re.typeOptions)?re.typeOptions:null;for(let ye=fe.length-1;!Oe&&ye>=0;ye--)l(fe[ye].typeOptions)&&(Oe=fe[ye].typeOptions);!Oe&&l(this.#i.typeOptions)&&(Oe=this.#i.typeOptions);const ve=Oe&&Oe.of!==void 0?Oe.of:"text",$e=typeof ve=="string"?this.#s.get(ve):void 0;return $e&&!d($e.items)&&$e.storage!=="object"?$e:(Y(`type:of:${String(ve)}`,`column "${pe}" names "${String(ve)}" as its item type (typeOptions.of), which is not ${$e?"a scalar data type":"a known data type"}; its items are read as text.`),this.#s.get("text"))}#S(re,fe,pe){if(re.type===!1)return"text";if(re.type)return re.type;for(let Oe=fe.length-1;Oe>=0;Oe--)if(fe[Oe].type)return fe[Oe].type;if(this.#i.type)return this.#i.type;if(re.shadow){const Oe=typeof re.shadow=="string"?re.shadow:re.shadow.kind;if(Oe==="fitInfluence")return"boolean";if(Oe==="fitPredicted"||Oe==="fitResidual"||Oe==="fitStdResidual"||Oe==="fitLeverage"||Oe==="fitCooksD"||Oe==="tsTrend"||Oe==="tsSeasonal"||Oe==="tsResidual"||Oe==="tsCoverage"||Oe==="tsSmoothed"||Oe==="tsSmoothingAlpha"||Oe==="tsSmoothingBeta")return"number"}return pe||(re.lookup?"lookup":"text")}#E(re){const fe=this.all();this.#m=h(fe),this.#g?this.#g.setGraph(this.#m):this.#g=new j({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#p,stored:re||null,rowKey:this.#b});const pe=this.#g;for(const Oe of fe)Oe.getValue=(ve,$e)=>pe.value(Oe,ve,$e)}all(){return this.#t.map(re=>this.#e.get(re))}visible(){return this.all().filter(re=>!re.layout.hidden)}get(re){return this.#e.get(re)}groups(){const re=fe=>{const pe=[];for(const Oe of fe)Array.isArray(Oe.columns)?pe.push({...Oe,columns:re(Oe.columns)}):Oe.column&&pe.push(Oe.column);return pe};return re(this.#n)}graph(){return this.#m}pipeline(){return this.#g}types(){return this.#s}affectedBy(re){return p(this.#m,re)}value(re,fe,pe){return this.#g.value(re,fe,pe)}text(re,fe,pe){return this.#g.text(re,fe,pe)}checkImpure(re,fe){N(this.#e.get(re),fe)}setLocale(re){this.#a=re;for(const fe of this.all())fe.lookup&&fe.lookup.setLocale(re),this.#v(fe);this.#w&&this.#w("locale",{locale:re})}infer(re){const fe={};if(this.#y||!Array.isArray(re)||re.length===0)return fe;this.#y=!0;let pe=!1;for(const Oe of this.all()){const ve=Oe.def;if(ve.type!==void 0||!Oe.field||Oe.computed||Oe.lookup||this.#M(Oe))continue;const $e=Oe.read||(Se=>z(Se,Oe.field)),he=w(Oe.id,re,$e,this.#s,{sampleSize:this.#j});if(he===Oe.type)continue;fe[Oe.id]=he;const ye=this.#O(ve,he);ye.groupPath=Oe.groupPath,ye.layout={...ye.layout,...ae(Oe.layout)},this.#e.set(Oe.id,ye),je(this.#n,Oe.id,ye),pe=!0}return pe&&this.#E(null),fe}redecorate(re,fe,pe={}){const Oe=this.#e.get(re);if(!Oe){Y(`redecorate:${re}`,`columns.decorate('${re}', …): no column with id '${re}'.`);return}const ve=Oe.def||{},$e={...l(ve.cell)?ve.cell:{}};$e.decoration=fe??void 0,pe&&"variant"in pe&&($e.variant=pe.variant);const he={...ve,cell:$e};this.#r.has(ve)&&this.#r.set(he,this.#r.get(ve));const ye=this.#O(he,Oe.type);return ye.groupPath=Oe.groupPath,ye.layout={...ye.layout,...ae(Oe.layout)},Oe.lookup&&Oe.lookup!==ye.lookup&&d(Oe.lookup.destroy)&&Oe.lookup.destroy(),this.#e.set(re,ye),je(this.#n,re,ye),this.#E(null),this.#w&&this.#w("decorate",{colId:re}),ye}destroy(){for(const re of this.#e.values())re.lookup&&d(re.lookup.destroy)&&re.lookup.destroy()}#M(re){for(const fe of re.presets){const pe=this.#o[fe];if(pe&&pe.type)return!0}return!!this.#i.type}#P(re){return!re.computed&&d(re.dataType&&re.dataType.toStorage)}storeReader(re){if(re.computed)return fe=>this.#g.value(re,fe,null);if(this.#P(re)){const fe=re.dataType.toStorage,pe={timeZone:this.#l,colId:re.id,itemType:re.itemType||null};return Oe=>fe(re.read(Oe),pe)}return re.read}storeValue(re,fe){if(!(!re||re.computed)&&d(re.read))return this.storeReader(re)(fe)}storeSchema(){const re=[];for(const fe of this.all()){if(fe.computed&&fe.value.pure===!1||!fe.computed&&!fe.field)continue;const pe=this.storeReader(fe);let Oe=null;!fe.computed&&!this.#P(fe)&&typeof fe.field=="string"&&!fe.lookup&&(Oe=fe.field);const ve={id:fe.id,kind:fe.storeKind,nullable:fe.nullable,read:pe};Oe!==null&&(ve.field=Oe),fe.lookup&&(ve.dictionary=fe.lookup.dictionary()),re.push(ve)}return re}state(){return this.all().map(re=>({id:re.id,width:re.layout.width,flex:re.layout.flex||void 0,hidden:!!re.layout.hidden,headerWrap:re.header?.wrap===!0?!0:void 0,headerOrientation:re.header?.orientation==="vertical"?"vertical":void 0,pin:re.layout.pin??null,sort:re.sort.direction??null,sortIndex:re.sort.direction?re.sort.order??0:null,groupIndex:re.group.enabled?re.group.index??0:null,pivotIndex:re.pivot.enabled?re.pivot.index??0:null,total:typeof re.total=="string"?re.total:null,groupTotal:typeof re.groupTotal=="string"?re.groupTotal:void 0,grandTotal:typeof re.grandTotal=="string"?re.grandTotal:void 0,decoration:re.cell&&re.cell.decoration!=null?ce(re.cell.decoration):void 0,variant:re.cell&&re.cell.variant!=null?ce(re.cell.variant):void 0}))}applyState(re,fe={}){const pe={applied:[],skipped:[]},Oe=Array.isArray(re)?re:re&&re.columns||[],ve=!Array.isArray(re)&&re&&re.columnOrder||null;for(const he of Oe){if(!he||!he.id){pe.skipped.push({key:"?",reason:"no id"});continue}let ye=this.#e.get(he.id);if(!ye){pe.skipped.push({key:he.id,reason:"unknown column"});continue}if(Object.hasOwn(he,"decoration")||Object.hasOwn(he,"variant")){const Se=ye.cell?ye.cell.decoration:void 0,Ie=he.decoration??null,we=Object.hasOwn(he,"variant"),Fe=we&&!de(ye.cell?ye.cell.variant:void 0,he.variant);(!de(Se,Ie)||Fe)&&(this.redecorate(he.id,Ie,we?{variant:he.variant??void 0}:{}),ye=this.#e.get(he.id)||ye)}he.width!=null&&(ye.layout.width=he.width),he.flex!=null&&(ye.layout.flex=he.flex),he.hidden!=null&&(ye.layout.hidden=!!he.hidden),he.headerWrap!==void 0&&(ye.header.wrap=!!he.headerWrap),he.headerOrientation!==void 0&&(ye.header.orientation=he.headerOrientation==="vertical"?"vertical":"horizontal"),he.pin!==void 0&&(ye.layout.pin=he.pin),he.sort!==void 0&&(ye.sort.direction=he.sort),he.sortIndex!=null&&(ye.sort.order=he.sortIndex),he.groupIndex!=null&&(ye.group.enabled=!0,ye.group.index=he.groupIndex),he.pivotIndex!=null&&(ye.pivot.enabled=!0,ye.pivot.index=he.pivotIndex),he.total!==void 0&&(ye.total=he.total),he.groupTotal!==void 0&&(ye.groupTotal=he.groupTotal),he.grandTotal!==void 0&&(ye.grandTotal=he.grandTotal),pe.applied.push(he.id)}const $e=ve||(fe&&fe.keepOrder?[]:Oe.map(he=>he&&he.id).filter(Boolean));if($e.length){const he=$e.filter(Se=>this.#e.has(Se)),ye=this.#t.filter(Se=>!he.includes(Se));this.#t=[...he,...ye]}return this.#w&&this.#w("state",pe),pe}move(re,fe){this.#N(re,fe)&&(this.#L(),this.#w&&this.#w("move",{id:re,to:fe}))}reorder(re){const fe={applied:[],skipped:[]},pe=[];let Oe=0;for(const ve of Array.isArray(re)?re:[]){const $e=Oe++;this.#N(ve,$e)&&(fe.applied.push(ve),pe.push({id:ve,to:$e}))}if(!pe.length)return fe;if(this.#L(),this.#w)for(const ve of pe)this.#w("move",ve);return fe}#N(re,fe){const pe=this.#t.indexOf(re);if(pe===-1||Math.max(0,Math.min(Number(fe)||0,this.#t.length-1))===pe)return!1;const ve=this.#e.get(re);if(ve.layout.movable===!1||ve.layout.lockPosition)return Y(`move:${re}`,`column "${re}" is not movable; the move was ignored`),!1;const $e=this.#R(re,fe);return $e?(Y(`move.married:${$e}`,`band "${$e}" declares marryChildren, so its columns stay together; the move was ignored`),!1):(this.#t.splice(pe,1),this.#t.splice(Math.max(0,Math.min(fe,this.#t.length)),0,re),!0)}#R(re,fe){if(!this.#n||!this.#n.length)return null;const pe=this.#t.filter(he=>he!==re),Oe=Math.max(0,Math.min(fe,pe.length)),ve=(he,ye)=>{if(Array.isArray(he.columns)){for(const Ie of he.columns)ve(Ie,ye);return ye}const Se=he.column?he.column.id:he.id;return Se&&ye.push(Se),ye},$e=he=>{for(const ye of he){if(!Array.isArray(ye.columns))continue;if(ye.marryChildren===!0){const Ie=ve(ye,[]),we=Ie.includes(re),Fe=Ie.map(He=>pe.indexOf(He)).filter(He=>He>=0);if(Fe.length){const He=Math.min(...Fe),Ke=Math.max(...Fe);if(we?Oe<He||Oe>Ke+1:Oe>He&&Oe<=Ke)return ye.id}}const Se=$e(ye.columns);if(Se)return Se}return null};return $e(this.#n)}#L(){const re=new Map(this.#t.map((Oe,ve)=>[Oe,ve])),fe=Oe=>{if(!Array.isArray(Oe.columns)){const $e=Oe.column?Oe.column.id:Oe.id;return re.has($e)?re.get($e):1/0}let ve=1/0;for(const $e of Oe.columns)ve=Math.min(ve,fe($e));return ve},pe=Oe=>{Oe.sort((ve,$e)=>fe(ve)-fe($e));for(const ve of Oe)Array.isArray(ve.columns)&&pe(ve.columns)};pe(this.#n)}#U(re){const fe=pe=>{for(let Oe=0;Oe<pe.length;Oe++){const ve=pe[Oe];if(Array.isArray(ve.columns)){const $e=fe(ve.columns);if($e)return $e}else if(ve.column&&ve.column.id===re)return pe.splice(Oe,1)[0]}return null};return fe(this.#n)}#G(re){const fe=[];for(let pe=re.length-1;pe>=0;pe--){const Oe=re[pe];Array.isArray(Oe.columns)&&(fe.push(...this.#G(Oe.columns)),Oe.columns.length===0&&(fe.push(Oe.id),re.splice(pe,1)))}return fe}#x(){const re=(fe,pe,Oe)=>{for(const ve of fe)Array.isArray(ve.columns)?re(ve.columns,[...pe,ve.id]):ve.column&&(ve.column.groupPath=pe)};re(this.#n,[])}#F(re){const fe=new Set(re),pe=this.#t.filter(he=>fe.has(he));if(!pe.length)return;const Oe=Math.min(...pe.map(he=>this.#t.indexOf(he))),ve=this.#t.slice(0,Oe).filter(he=>!fe.has(he)),$e=this.#t.slice(Oe).filter(he=>!fe.has(he));this.#t=[...ve,...pe,...$e]}#Y(re){const fe=[],pe=Oe=>{if(Array.isArray(Oe.columns))for(const ve of Oe.columns)pe(ve);else Oe.column&&fe.push(Oe.column.id)};return pe(re),fe}#I(re){const fe=pe=>{for(const Oe of pe){if(!Array.isArray(Oe.columns))continue;if(Oe.id===re)return{node:Oe,parent:pe};const ve=fe(Oe.columns);if(ve)return ve}return null};return fe(this.#n)}groupColumns(re,fe={}){const pe=D(re).filter(ye=>this.#e.has(ye));if(!pe.length)return Y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const ye of pe)if(this.#e.get(ye).layout.lockPosition)return Y(`columns.group.locked:${ye}`,`column "${ye}" is position-locked and cannot be grouped.`),null;const Oe=fe.groupId?this.#I(fe.groupId):null;if(fe.groupId&&!Oe)return Y(`columns.group.unknown:${fe.groupId}`,`no band "${fe.groupId}" to add to; nothing was grouped.`),null;let ve=null;if(!Oe&&fe.id!=null&&(ve=String(fe.id),this.#I(ve)||this.#e.has(ve)))return Y(`columns.group.idtaken:${ve}`,`band id "${ve}" is already in use; nothing was grouped.`),null;const $e=pe.map(ye=>this.#U(ye)).filter(Boolean);if(!$e.length)return null;let he;if(Oe)Oe.node.columns.push(...$e),he=Oe.node.id;else{const ye={id:ve||t("grp"),title:fe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:$e},Se=Number.isInteger(fe.at)?Math.max(0,Math.min(fe.at,this.#n.length)):this.#n.length;this.#n.splice(Se,0,ye),he=ye.id}return this.#G(this.#n),this.#F(pe),this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"formed",groupId:he,ids:pe}),he}ungroupColumn(re){const fe=this.#e.get(re);if(!fe){Y(`columns.ungroup.unknown:${re}`,`no column "${re}" to ungroup.`);return}const pe=fe.groupPath||[];if(!pe.length)return;const Oe=pe[pe.length-1],ve=this.#I(Oe);if(!ve)return;const $e=this.#U(re);if(!$e)return;const he=ve.parent.indexOf(ve.node);ve.parent.splice(he+1,0,$e);const ye=this.#G(this.#n),Se=this.#Y(ve.node);if(Se.length){this.#F(Se);const Ie=Math.max(...Se.map(Fe=>this.#t.indexOf(Fe))),we=this.#t.filter(Fe=>Fe!==re);we.splice(Ie+1,0,re),this.#t=we}this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"removed",id:re,dissolved:ye})}renameGroup(re,fe){const pe=this.#I(re);if(!pe){Y(`columns.group.rename:${re}`,`no band "${re}" to rename.`);return}pe.node.title=String(fe??""),this.#w&&this.#w("columngroup",{action:"renamed",groupId:re,title:pe.node.title})}dissolveGroup(re){const fe=this.#I(re);if(!fe){Y(`columns.group.dissolve:${re}`,`no band "${re}" to dissolve.`);return}const pe=fe.parent.indexOf(fe.node);fe.parent.splice(pe,1,...fe.node.columns),this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"dissolved",groupId:re})}moveGroup(re,fe){const pe=this.#I(re);if(!pe){Y(`columns.group.move:${re}`,`no band "${re}" to move.`);return}const Oe=pe.parent,ve=Oe.indexOf(pe.node);ve!==-1&&(Oe.splice(ve,1),Oe.splice(Math.max(0,Math.min(fe,Oe.length)),0,pe.node),this.#K(),this.#x(),this.#w&&this.#w("columngroup",{action:"moved",groupId:re,to:fe}))}#K(){const re=[],fe=Oe=>{for(const ve of Oe)Array.isArray(ve.columns)?fe(ve.columns):ve.column&&re.push(ve.column.id)};fe(this.#n);const pe=new Set(re);this.#t=[...re,...this.#t.filter(Oe=>!pe.has(Oe))]}groupTree(){const re=pe=>pe.map(Oe=>Array.isArray(Oe.columns)?{id:Oe.id,title:Oe.title||"",collapsible:!!Oe.collapsible,openByDefault:Oe.openByDefault!==!1,columns:re(Oe.columns)}:Oe.column?Oe.column.id:null).filter(Oe=>Oe!==null),fe=re(this.#n);return fe.some(pe=>pe&&typeof pe=="object")?fe:[]}applyGroupTree(re){if(!Array.isArray(re))return;const fe=new Set,pe=ve=>{const $e=[];for(const he of ve)if(he&&typeof he=="object"&&Array.isArray(he.columns)){const ye=pe(he.columns);if(!ye.length)continue;$e.push({id:he.id||t("grp"),title:he.title||"",collapsible:he.collapsible===!0,openByDefault:he.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:ye})}else if(typeof he=="string"){const ye=this.#e.get(he);ye&&!fe.has(he)&&(fe.add(he),$e.push({column:ye,path:[]}))}return $e},Oe=pe(re);for(const ve of this.#t){if(fe.has(ve))continue;const $e=this.#e.get(ve);$e&&Oe.push({column:$e,path:[]})}this.#n=Oe,this.#x(),this.#L(),this.#w&&this.#w("columngroup",{action:"applied"})}show(re){this.#H(re,!1)}hide(re){this.#H(re,!0)}#H(re,fe){const pe=[];for(const Oe of D(re)){const ve=this.#e.get(Oe);if(ve){if(fe&&ve.layout.lockVisible){Y(`lockVisible:${Oe}`,`column "${Oe}" is \`layout.lockVisible\` and cannot be hidden`);continue}ve.layout.hidden!==fe&&(ve.layout.hidden=fe,pe.push(Oe))}}pe.length&&this.#w&&this.#w("visible",{ids:pe,hidden:fe})}pin(re,fe){const pe=this.#e.get(re);pe&&(pe.layout.pin=fe??null,this.#w&&this.#w("pin",{id:re,side:pe.layout.pin}))}pinMany(re){const fe={};for(const[Oe,ve]of re){const $e=this.#e.get(Oe);$e&&($e.layout.pin=ve??null,fe[Oe]=$e.layout.pin)}const pe=Object.keys(fe);pe.length&&this.#w&&this.#w("pin",{ids:pe,pins:fe})}#z(re,fe){const pe=re.layout.min??0,Oe=re.layout.max;let ve=Math.max(pe,fe);return Oe!=null&&(ve=Math.min(Oe,ve)),re.layout.width=ve,re.layout.flex=0,ve}resize(re,fe){const pe=this.#e.get(re);if(!pe)return;if(pe.layout.resizable===!1){Y(`resize:${re}`,`column "${re}" is not resizable; the resize was ignored`);return}const Oe=this.#z(pe,fe);this.#w&&this.#w("resize",{id:re,width:Oe})}resizeMany(re){const fe={};for(const[Oe,ve]of re){const $e=this.#e.get(Oe);if($e){if($e.layout.resizable===!1){Y(`resize:${Oe}`,`column "${Oe}" is not resizable; the resize was ignored`);continue}fe[Oe]=this.#z($e,ve)}}const pe=Object.keys(fe);pe.length&&this.#w&&this.#w("resize",{ids:pe,widths:fe})}}function ae(be){const re={};return be.width!=null&&(re.width=be.width),be.hidden!=null&&(re.hidden=be.hidden),be.pin!==void 0&&(re.pin=be.pin),re}function ce(be){if(be===null||typeof be!="object")return be;try{return structuredClone(be)}catch{}try{return JSON.parse(JSON.stringify(be))}catch{return be}}function de(be,re){const fe=be??null,pe=re??null;if(fe===pe)return!0;if(fe===null||pe===null)return!1;if(typeof fe!="object"||typeof pe!="object")return fe===pe;try{return JSON.stringify(fe)===JSON.stringify(pe)}catch{return!1}}function Ae(be){const re=[],fe=(Oe,ve,$e)=>{const he=[];for(const ye of Oe){if(!l(ye)){Z("a column definition must be an object");continue}if(Array.isArray(ye.columns)){J(ye,_,"columnGroup",ye.title||ye.id||"(unnamed)");const Se={id:ye.id||t("grp"),title:ye.title||"",collapsible:ye.collapsible===!0,openByDefault:ye.openByDefault!==!1,showWhen:ye.showWhen||"always",marryChildren:ye.marryChildren===!0,header:ye.header||{},def:ye,columns:[]};Se.columns=fe(ye.columns,[...ve,Se.id],ye.facet!==void 0?ye.facet:$e),he.push(Se)}else{const Se={def:ye,path:ve,facet:$e};re.push(Se),he.push(Se)}}return he},pe=fe(be,[],void 0);return{leaves:re,groups:pe}}function je(be,re,fe){for(const pe of be){if(pe.columns){if(je(pe.columns,re,fe))return!0;continue}if(pe.column&&pe.column.id===re)return pe.column=fe,!0}return!1}}),Be("packages/core/src/columns/autogroup.js",function(e,H){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return Y}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="__lattice_group",D=240,F=.5;function Z(B){const{columns:z,groupBy:G}=B,P=G.map(c=>z.get(c)).filter(Boolean),O=P.length?P.map(c=>c.title||c.id).join(" > "):"Group",b=B.config&&B.config.autoGroupColumnWidth||D;return{id:X,field:null,title:O,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:G.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:b,min:120,pin:B.config&&B.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(c,d){return d&&d.group?d.groupValue:null},formatValue(c,d){if(!d||!d.group)return"";if(d.grandTotal)return B.config&&B.config.grandTotalLabel||"Total";const l=P[Math.min(d.level||0,P.length-1)];return l&&typeof l.formatValue=="function"?l.formatValue(c,d):c==null?"":String(c)}}}function Y(B,z,G){!B.length||G<100||z<G*F||L(`grouping.cardinality:${B.join(",")}`,`grouping by ${B.join(", ")} produced ${z} groups for ${G} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),Be("packages/core/src/columns/selectcolumn.js",function(e,H){"use strict";Object.defineProperty(e,"SELECT_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createSelectionColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const te="__lattice_select",L=44;function X(F){const Z=F.selection||{},Y=F.config&&F.config.selectionColumnWidth||L;return{id:te,field:null,title:"",type:"boolean",dataType:{base:"boolean"},nullable:!1,align:"center",generated:!0,control:!0,value:{pure:!0},cell:{render:"checkbox",props:{mode:"selection"},align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Y,min:Y,max:Y,pin:F.config&&F.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(B,z){return z?z.selected:!1},formatValue(){return""}}}const D=X}),Be("packages/core/src/columns/rownumbercolumn.js",function(e,H){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/internal/predicates.js").isFunction,X="__lattice_rownumber",D=40,F=9,Z=22;function Y(G){const P=String(Math.max(1,Math.trunc(Math.abs(G))||1)).length;return Math.max(D,P*F+Z)}function B(G){const P=G.rowNumbers,O=P&&typeof P=="object"?P:{},b=Number.isFinite(O.start)?O.start:1,c=Number.isFinite(O.width)?O.width:Y((G.maxNumber||0)+b),d=L(G.rank)?G.rank:()=>null;return{id:X,field:null,title:typeof O.title=="string"?O.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:c,min:c,max:c,pin:"start",hidden:!1,resizable:O.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(l,r){const t=d(r);return t==null?null:t-1+b},formatValue(l){return l==null?"":String(l)}}}const z=B}),Be("packages/core/src/model/detail.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F=240,Z=10;function Y(G){if(!G)return null;const P=G===!0?{}:G;return P.enabled===!1?null:!L(P.rows)&&!P.render?(D("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:P.render||null,config:P.config||null,rows:L(P.rows)?P.rows:null,height:P.height??F,cacheLimit:Number.isFinite(P.cacheLimit)?Math.max(0,P.cacheLimit):Z,isMaster:L(P.isMaster)?P.isMaster:null,target:P.target||null,onCreate:L(P.onCreate)?P.onCreate:null,path:typeof P.path=="string"?P.path:null}}class B{#e;#t=new Set;#n;#r=0;constructor(P){this.#e=P.config,this.#n=L(P.onChange)?P.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(P){if(!P||P.group||P.detail)return!1;const O=this.#e.isMaster;return O?!!O(P.data,P):!0}isOpen(P){return this.#t.has(P)}keys(){return[...this.#t]}activeKey(){for(const P of this.#t)return P;return null}heightOf(P){const O=this.#e.height;return L(O)?Number(O(P))||F:O==="auto"?F:Number(O)||F}open(P){return this.#t.has(P)?!1:(this.inline||this.#t.clear(),this.#t.add(P),this.#s(),!0)}close(P){return this.#t.delete(P)?(this.#s(),!0):!1}toggle(P){return this.#t.has(P)?(this.close(P),!1):(this.open(P),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#s())}prune(P){if(!this.#t.size||!L(P))return;let O=!1;for(const b of[...this.#t])P(b)||(this.#t.delete(b),O=!0);O&&this.#s()}signature(){return`${this.#r}`}set(P){this.#t.clear();const O=Array.isArray(P)?P:[];for(const b of this.inline?O:O.slice(0,1))this.#t.add(b);this.#s()}#s(){this.#r++,this.#n()}}const z=B}),Be("packages/core/src/compute/special.js",function(e,H){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"studentTQuantile",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"regularizedGammaP",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return l}});const te=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),L=3e-12,X=1e-300;function D(r){if(r<.5)return Math.log(Math.PI/Math.sin(Math.PI*r))-D(1-r);const t=r-1;let i=.9999999999998099;const s=t+7.5;for(let n=0;n<te.length;n++)i+=te[n]/(t+n+1);return .5*Math.log(2*Math.PI)+(t+.5)*Math.log(s)-s+Math.log(i)}function F(r,t,i){const s=r+t,n=r+1,u=r-1;let o=1,a=1-s*i/n;Math.abs(a)<X&&(a=X),a=1/a;let f=a;for(let w=1;w<=300;w++){const m=2*w;let v=w*(t-w)*i/((u+m)*(r+m));a=1+v*a,Math.abs(a)<X&&(a=X),o=1+v/o,Math.abs(o)<X&&(o=X),a=1/a,f*=a*o,v=-(r+w)*(s+w)*i/((r+m)*(n+m)),a=1+v*a,Math.abs(a)<X&&(a=X),o=1+v/o,Math.abs(o)<X&&(o=X),a=1/a;const h=a*o;if(f*=h,Math.abs(h-1)<L)break}return f}function Z(r,t,i){if(!(r>0)||!(t>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(D(r+t)-D(r)-D(t)+r*Math.log(i)+t*Math.log(1-i));return i<(r+1)/(r+t+2)?s*F(r,t,i)/r:1-s*F(t,r,1-i)/t}function Y(r){if(!(r>0)||!(r<1))return r===0?-1/0:r===1?1/0:Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],n=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],u=.02425;let o,a,f;r<u?(o=Math.sqrt(-2*Math.log(r)),f=(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1)):r<=1-u?(o=r-.5,a=o*o,f=(((((t[0]*a+t[1])*a+t[2])*a+t[3])*a+t[4])*a+t[5])*o/(((((i[0]*a+i[1])*a+i[2])*a+i[3])*a+i[4])*a+1)):(o=Math.sqrt(-2*Math.log(1-r)),f=-(((((s[0]*o+s[1])*o+s[2])*o+s[3])*o+s[4])*o+s[5])/((((n[0]*o+n[1])*o+n[2])*o+n[3])*o+1));const m=(.5*B(-f/Math.SQRT2)-r)*Math.sqrt(2*Math.PI)*Math.exp(f*f/2);return f-m/(1+f*m/2)}function B(r){const t=Math.abs(r),i=2/(2+t),s=4*i-2,n=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let u=0,o=0,a;for(let w=n.length-1;w>0;w--)a=o,o=s*o-u+n[w],u=a;const f=i*Math.exp(-t*t+.5*(n[0]+s*o)-u);return r>=0?f:2-f}function z(r){return .5*B(-r/Math.SQRT2)}function G(r,t){if(!(t>0)||!Number.isFinite(r))return Number.NaN;const i=.5*Z(t/2,.5,t/(t+r*r));return r>0?1-i:i}function P(r,t){if(!(r>0)||!(r<1)||!(t>0))return Number.NaN;if(t>1e7)return Y(r);let i=-1e4,s=1e4,n=Y(r);const u=D(t/2)+D(.5)-D((t+1)/2);for(let o=0;o<60;o++){const a=G(n,t);a<r?i=n:s=n;const f=Math.exp(-((t+1)/2)*Math.log(1+n*n/t)-u)/Math.sqrt(t),w=f>0?(a-r)/f:0;if(Math.abs(w)<1e-12)break;const m=n-w;if(n=m>i&&m<s&&Number.isFinite(m)?m:(i+s)/2,s-i<1e-12)break}return n}function O(r,t){let i=r,s=1/r,n=s;for(let u=0;u<300&&(i+=1,n*=t/i,s+=n,!(Math.abs(n)<Math.abs(s)*L));u++);return s*Math.exp(-t+r*Math.log(t)-D(r))}function b(r,t){let i=t+1-r,s=1/X,n=1/i,u=n;for(let o=1;o<=300;o++){const a=-o*(o-r);i+=2,n=a*n+i,Math.abs(n)<X&&(n=X),s=i+a/s,Math.abs(s)<X&&(s=X),n=1/n;const f=n*s;if(u*=f,Math.abs(f-1)<L)break}return Math.exp(-t+r*Math.log(t)-D(r))*u}function c(r,t){return!(r>0)||!(t>=0)||!Number.isFinite(t)?Number.NaN:t===0?0:t<r+1?O(r,t):1-b(r,t)}function d(r,t){return t>0?c(t/2,r/2):Number.NaN}function l(r,t){const i=d(r,t);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Be("packages/core/src/compute/linalg.js",function(e,H){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function te(Y){const B=Y.length,z=Array.from({length:B},()=>new Array(B).fill(0));for(let G=0;G<B;G++)for(let P=0;P<=G;P++){let O=Y[G][P];for(let b=0;b<P;b++)O-=z[G][b]*z[P][b];if(G===P){if(!(O>0))return null;z[G][P]=Math.sqrt(O)}else z[G][P]=O/z[P][P]}return z}function L(Y,B){const z=Y.length,G=new Array(z).fill(0);for(let O=0;O<z;O++){let b=B[O];for(let c=0;c<O;c++)b-=Y[O][c]*G[c];G[O]=b/Y[O][O]}const P=new Array(z).fill(0);for(let O=z-1;O>=0;O--){let b=G[O];for(let c=O+1;c<z;c++)b-=Y[c][O]*P[c];P[O]=b/Y[O][O]}return P}function X(Y){const B=Y.length,z=Array.from({length:B},()=>new Array(B).fill(0));for(let G=0;G<B;G++){const P=new Array(B).fill(0);P[G]=1;const O=L(Y,P);for(let b=0;b<B;b++)z[b][G]=O[b]}return z}function D(Y,B,z){const G=Y.length,P=G?Y[0].length:0,O=Array.from({length:P},()=>new Array(P).fill(0)),b=new Array(P).fill(0);for(let c=0;c<G;c++){const d=z?z[c]:1,l=Y[c];for(let r=0;r<P;r++){const t=d*l[r];b[r]+=t*B[c];for(let i=r;i<P;i++)O[r][i]+=t*l[i]}}for(let c=0;c<P;c++)for(let d=0;d<c;d++)O[c][d]=O[d][c];return{xtwx:O,xtwy:b}}function F(Y,B){return Y.map(z=>z.reduce((G,P,O)=>G+P*B[O],0))}function Z(Y,B){let z=0;for(let G=0;G<Y.length;G++){let P=0;for(let O=0;O<Y.length;O++)P+=B[G][O]*Y[O];z+=Y[G]*P}return z}}),Be("packages/core/src/compute/sketch.js",function(e,H){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return O}});class te{#e=0;#t=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#e}add(c){if(!Number.isFinite(c))return;this.#e++;const d=c-this.#t;this.#t+=d/this.#e,this.#n+=d*(c-this.#t)}merge(c){if(c.#e===0)return;if(this.#e===0){this.#e=c.#e,this.#t=c.#t,this.#n=c.#n;return}const d=this.#e+c.#e,l=c.#t-this.#t;this.#t+=l*(c.#e/d),this.#n+=c.#n+l*l*(this.#e*c.#e/d),this.#e=d}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const c=this.variance();return c===null?null:Math.sqrt(c)}stddevP(){const c=this.varianceP();return c===null?null:Math.sqrt(c)}}class L{#e=[];#t=0;#n;#r;constructor(c,d=Math.random){if(!(c>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(c),this.#r=d}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(c){if(!Number.isFinite(c))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(c);return}const d=Math.floor(this.#r()*this.#t);d<this.#n&&(this.#e[d]=c)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let c=0;for(const d of this.#e)c+=d;return c/this.#e.length}quantile(c){const d=this.#e.length;if(!d)return null;const l=this.#e.slice().sort((s,n)=>s-n);if(d===1)return l[0];const r=(d-1)*Math.min(1,Math.max(0,c)),t=Math.floor(r),i=Math.ceil(r);return t===i?l[t]:l[t]+(r-t)*(l[i]-l[t])}}function X(b){return b^=b>>>16,b=Math.imul(b,2246822507),b^=b>>>13,b=Math.imul(b,3266489909),b^=b>>>15,b>>>0}function D(b){if(typeof b=="number"){const l=new DataView(new ArrayBuffer(8));return l.setFloat64(0,b===0?0:b),X(l.getUint32(0)^l.getUint32(4))}const c=typeof b=="string"?b:String(b);let d=2166136261;for(let l=0;l<c.length;l++)d^=c.charCodeAt(l),d=Math.imul(d,16777619);return X(d)}class F{#e;#t;#n;constructor(c=14){const d=Math.floor(c);if(d<4||d>16)throw new RangeError("HLL precision must be 4..16");this.#e=d,this.#t=1<<d,this.#n=new Uint8Array(this.#t)}static errorBoundFor(c=14){const d=1<<Math.floor(c),l=1.04/Math.sqrt(d);return Object.freeze({kind:"probabilistic",metric:"relative",value:l,statement:`distinct count within ~${(l*100).toFixed(2)}% relative standard error (m=${d} buckets)`})}errorBound(){return F.errorBoundFor(this.#e)}add(c){const d=D(c),l=d&this.#t-1,r=d>>>this.#e|1<<32-this.#e;let t=1,i=r;for(;(i&1)===0;)t++,i>>>=1;t>this.#n[l]&&(this.#n[l]=t)}count(){const c=this.#t,d=32-this.#e,l=new Float64Array(d+2);for(let i=0;i<c;i++)l[this.#n[i]]++;let r=c*B(1-l[d+1]/c);for(let i=d;i>=1;i--)r=.5*(r+l[i]);r+=c*Y(l[0]/c);const t=Z*c*c/r;return Math.round(t)}}const Z=.5/Math.log(2);function Y(b){if(b===1)return 1/0;let c=1,d=b,l;do b*=b,l=d,d+=b*c,c+=c;while(d!==l);return d}function B(b){if(b===0||b===1)return 0;let c=1,d=1-b,l;do b=Math.sqrt(b),l=d,c*=.5,d-=(1-b)**2*c;while(d!==l);return d/3}class z{#e=new Map;#t;#n=0;constructor(c){if(!(c>0))throw new RangeError("Space-Saving capacity must be positive");this.#t=Math.floor(c)}errorBoundFor(c){const d=c/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:d,statement:`each count overestimates the truth by at most N/m = ${d.toFixed(2)} (N=${c}, m=${this.#t})`})}get seen(){return this.#n}add(c){this.#n++;const d=this.#e.get(c);if(d){d.count++;return}if(this.#e.size<this.#t){this.#e.set(c,{count:1,error:0});return}let l,r=1/0;for(const[t,i]of this.#e)i.count<r&&(r=i.count,l=t);this.#e.delete(l),this.#e.set(c,{count:r+1,error:r})}top(c=this.#t){return[...this.#e.entries()].map(([l,r])=>({item:l,count:r.count,error:r.error})).sort((l,r)=>r.count-l.count).slice(0,Math.max(0,Math.floor(c)))}}class G{#e;#t=[[]];#n=0;#r;#s;constructor(c=200,d=Math.random){this.#e=Math.max(8,Math.floor(c)),this.#r=d,this.#s=2/3}static errorBoundFor(c=200){const d=1/Math.max(8,Math.floor(c));return Object.freeze({kind:"probabilistic",metric:"rank",value:d,statement:`queried quantile's true rank within ~${(d*100).toFixed(2)}% of N of the requested rank (k=${c})`})}errorBound(){return G.errorBoundFor(this.#e)}get count(){return this.#n}#i(c){const l=this.#t.length-1-c,r=Math.ceil(this.#e*this.#s**l);return Math.max(2,r)}add(c){Number.isFinite(c)&&(this.#n++,this.#t[0].push(c),this.#t[0].length>=this.#i(0)&&this.#o(0))}#o(c){const d=this.#t[c];d.sort((t,i)=>t-i),c+1>=this.#t.length&&this.#t.push([]);const l=this.#t[c+1],r=this.#r()<.5?0:1;for(let t=r;t<d.length;t+=2)l.push(d[t]);this.#t[c]=[];for(let t=0;t<this.#t.length;t++)if(this.#t[t].length>=this.#i(t)){this.#o(t);return}}#l(){const c=[];for(let d=0;d<this.#t.length;d++){const l=1<<d;for(const r of this.#t[d])c.push({v:r,w:l})}return c}quantile(c){const d=this.#l();if(!d.length)return null;d.sort((i,s)=>i.v-s.v);let l=0;for(const i of d)l+=i.w;const r=Math.min(1,Math.max(0,c))*l;let t=0;for(const i of d)if(t+=i.w,t>=r)return i.v;return d[d.length-1].v}rank(c){let d=0;for(let l=0;l<this.#t.length;l++){const r=1<<l;for(const t of this.#t[l])t<=c&&(d+=r)}return d}}const P=Object.freeze({distinct:F.errorBoundFor(14),median:G.errorBoundFor(200),p25:G.errorBoundFor(200),p75:G.errorBoundFor(200),p90:G.errorBoundFor(200),p95:G.errorBoundFor(200),p99:G.errorBoundFor(200),iqr:G.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),O={Welford:te,Reservoir:L,HyperLogLog:F,SpaceSaving:z,KLL:G,hash32:D,SKETCH_BOUNDS:P}}),Be("packages/core/src/compute/statistics.js",function(e,H){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return he}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return we}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return He}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return it}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return dt}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return me}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return Ue}});const te=H("packages/core/src/compute/handle.js"),L=te.presenceReader,X=te.valueReader,D=H("packages/core/src/compute/special.js"),F=D.studentTQuantile,Z=D.studentT,Y=D.normalQuantile,B=D.normalCdf,z=D.chiSquareUpperTail,G=H("packages/core/src/compute/linalg.js"),P=G.cholesky,O=G.choleskySolve,b=G.choleskyInverse,c=G.normalEquations,d=G.quadForm,r=H("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,t=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:r.distinct}),median:Object.freeze({sketch:"KLL",bound:r.median}),p25:Object.freeze({sketch:"KLL",bound:r.p25}),p75:Object.freeze({sketch:"KLL",bound:r.p75}),p90:Object.freeze({sketch:"KLL",bound:r.p90}),p95:Object.freeze({sketch:"KLL",bound:r.p95}),p99:Object.freeze({sketch:"KLL",bound:r.p99}),iqr:Object.freeze({sketch:"KLL",bound:r.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:r.topK})});function n(ge){const Pe=ge==="sum"||ge==="avg"||ge==="countValues"||ge==="min"||ge==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,ge)?i[ge]:null,ke=Object.prototype.hasOwnProperty.call(s,ge)?s[ge]:null;return{stat:ge,exact:Pe,approximate:ke}}function u(ge,Pe){const ke=Pe.length,Ee=new Float64Array(ke);let Ce=0;if(ge&&(ge.kind==="float64"||ge.kind==="int32")){const ze=ge.values,Ve=L(ge);for(let Qe=0;Qe<ke;Qe++){const Ne=Pe[Qe];if(Ve&&Ve(Ne)!==1)continue;const Ge=ze[Ne];Number.isNaN(Ge)||(Ee[Ce++]=Ge)}return Ee.subarray(0,Ce)}const xe=X(ge);for(let ze=0;ze<ke;ze++){const Ve=xe(Pe[ze]);if(Ve==null||Ve==="")continue;const Qe=typeof Ve=="number"?Ve:Number(Ve);Number.isFinite(Qe)&&(Ee[Ce++]=Qe)}return Ee.subarray(0,Ce)}function o(ge,Pe){const ke=new Map,Ee=X(ge);let Ce=0;for(let xe=0;xe<Pe.length;xe++){const ze=Ee(Pe[xe]);if(ze==null||ze===""||typeof ze=="number"&&Number.isNaN(ze))continue;const Ve=typeof ze=="object"?String(ze):ze;ke.set(Ve,(ke.get(Ve)||0)+1),Ce++}const Re=[...ke.values()].sort((xe,ze)=>ze-xe);return{counts:Re,total:Ce,distinct:Re.length}}function a(ge){return ge.total>0?ge.counts.map(Pe=>Pe/ge.total):[]}function f(ge,Pe){const ke=o(ge,Pe);if(!ke.total)return null;let Ee=0;for(const Ce of a(ke))Ee+=Ce*Ce;return Ee}function w(ge,Pe){const ke=o(ge,Pe);if(!ke.total)return null;let Ee=0;for(const Ce of a(ke))Ce>0&&(Ee-=Ce*Math.log2(Ce));return Ee}function m(ge,Pe){const ke=o(ge,Pe);if(!ke.total||ke.distinct<2)return ke.total?1:null;let Ee=0;for(const Ce of a(ke))Ce>0&&(Ee-=Ce*Math.log2(Ce));return Ee/Math.log2(ke.distinct)}function v(ge,Pe,ke=3){const Ee=o(ge,Pe);if(!Ee.total)return null;const Ce=Math.max(1,Math.floor(ke));let Re=0;for(let xe=0;xe<Math.min(Ce,Ee.counts.length);xe++)Re+=Ee.counts[xe];return Re/Ee.total}function h(ge,Pe){const ke=u(ge,Pe),Ee=ke.length;if(!Ee)return null;const Ce=ke.slice().sort();if(Ce[0]<0)return null;let Re=0,xe=0;for(let ze=0;ze<Ee;ze++)Re+=Ce[ze],xe+=(ze+1)*Ce[ze];return Re===0?0:2*xe/(Ee*Re)-(Ee+1)/Ee}function p(ge){let Pe=0,ke=0,Ee=0;for(let Ce=0;Ce<ge.length;Ce++){const Re=ge[Ce];Pe++;const xe=Re-ke;ke+=xe/Pe,Ee+=xe*(Re-ke)}return{n:Pe,mean:ke,m2:Ee}}function g(ge,Pe){const ke=ge.length;if(!ke)return NaN;if(ke===1)return ge[0];const Ee=(ke-1)*Math.min(1,Math.max(0,Pe)),Ce=Math.floor(Ee),Re=Math.ceil(Ee);return Ce===Re?ge[Ce]:ge[Ce]+(Ee-Ce)*(ge[Re]-ge[Ce])}function k(ge,Pe){if(!ge.length)return NaN;const ke=ge.slice().sort();return g(ke,Pe)}function y(ge,Pe){const ke=X(ge);let Ee=0,Ce=0,Re=0;for(let xe=0;xe<Pe.length;xe++){const ze=ke(Pe[xe]);if(ze==null||ze==="")continue;const Ve=String(ze).toUpperCase();Ve==="PASS"?Ee++:Ve==="FAIL"?Ce++:Ve==="WARN"&&Re++}return{pass:Ee+Re,fail:Ce,warn:Re,judged:Ee+Re+Ce}}const T=Object.freeze({hhi:(ge,Pe)=>f(ge,Pe),entropy:(ge,Pe)=>w(ge,Pe),evenness:(ge,Pe)=>m(ge,Pe),top3Share:(ge,Pe)=>v(ge,Pe,3),top10Share:(ge,Pe)=>v(ge,Pe,10),gini:(ge,Pe)=>h(ge,Pe),trimmedMean:(ge,Pe)=>x(u(ge,Pe),.1),winsorizedMean:(ge,Pe)=>A(u(ge,Pe),.1),robustOutliers:(ge,Pe)=>$(u(ge,Pe),3.5),jarqueBera:(ge,Pe)=>I(u(ge,Pe)),variance:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>1?Ee/(ke-1):null},varianceP:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>0?Ee/ke:null},stddev:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>1?Math.sqrt(Ee/(ke-1)):null},stddevP:(ge,Pe)=>{const{n:ke,m2:Ee}=p(u(ge,Pe));return ke>0?Math.sqrt(Ee/ke):null},median:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.5):null},p25:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.25):null},p75:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.75):null},p90:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.9):null},p95:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.95):null},p99:(ge,Pe)=>{const ke=u(ge,Pe);return ke.length?k(ke,.99):null},iqr:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;const Ee=ke.slice().sort();return g(Ee,.75)-g(Ee,.25)},mad:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;const Ee=k(ke,.5),Ce=new Float64Array(ke.length);for(let Re=0;Re<ke.length;Re++)Ce[Re]=Math.abs(ke[Re]-Ee);return k(Ce,.5)},range:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=1/0,Ce=-1/0;for(let Re=0;Re<ke.length;Re++)ke[Re]<Ee&&(Ee=ke[Re]),ke[Re]>Ce&&(Ce=ke[Re]);return Ce-Ee},distinct:(ge,Pe)=>{const ke=X(ge),Ee=new Set;for(let Ce=0;Ce<Pe.length;Ce++){const Re=ke(Pe[Ce]);Re==null||Re===""||Ee.add(Re instanceof Date?Re.getTime():Re)}return Ee.size},mode:(ge,Pe)=>{const ke=X(ge),Ee=new Map;for(let xe=0;xe<Pe.length;xe++){const ze=ke(Pe[xe]);if(ze==null||ze==="")continue;const Ve=ze instanceof Date?ze.getTime():ze;Ee.set(Ve,(Ee.get(Ve)||0)+1)}let Ce=null,Re=1;for(const[xe,ze]of Ee)ze>Re&&(Re=ze,Ce=xe);return Ce},skewness:(ge,Pe)=>{const ke=u(ge,Pe),{n:Ee,mean:Ce,m2:Re}=p(ke);if(Ee<3||Re<=0)return null;const xe=Math.sqrt(Re/(Ee-1));let ze=0;for(let Ve=0;Ve<ke.length;Ve++)ze+=((ke[Ve]-Ce)/xe)**3;return Ee/((Ee-1)*(Ee-2))*ze},kurtosis:(ge,Pe)=>{const ke=u(ge,Pe),{n:Ee,mean:Ce,m2:Re}=p(ke);if(Ee<4||Re<=0)return null;const xe=Math.sqrt(Re/(Ee-1));let ze=0;for(let Ne=0;Ne<ke.length;Ne++)ze+=((ke[Ne]-Ce)/xe)**4;const Ve=Ee*(Ee+1)/((Ee-1)*(Ee-2)*(Ee-3)),Qe=3*(Ee-1)**2/((Ee-2)*(Ee-3));return Ve*ze-Qe},geomean:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=0;for(let Ce=0;Ce<ke.length;Ce++){if(ke[Ce]<=0)return null;Ee+=Math.log(ke[Ce])}return Math.exp(Ee/ke.length)},harmean:(ge,Pe)=>{const ke=u(ge,Pe);if(!ke.length)return null;let Ee=0;for(let Ce=0;Ce<ke.length;Ce++){if(ke[Ce]===0)return null;Ee+=1/ke[Ce]}return ke.length/Ee},sumSquares:(ge,Pe)=>{const ke=u(ge,Pe);let Ee=0;for(let Ce=0;Ce<ke.length;Ce++)Ee+=ke[Ce]*ke[Ce];return Ee},passRate:(ge,Pe)=>{const{pass:ke,judged:Ee}=y(ge,Pe);return Ee?ke/Ee:null},failureCount:(ge,Pe)=>y(ge,Pe).fail}),j=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function N(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe);let Re=0,xe=0;for(let ze=0;ze<ke.length;ze++){const Ve=ke[ze],Qe=Number(Ee(Ve)),Ne=Number(Ce(Ve));!Number.isFinite(Qe)||!Number.isFinite(Ne)||(Re+=Qe*Ne,xe+=Ne)}return xe===0?null:Re/xe}function W(ge,Pe,ke){const Ee=X(ge);let Ce=null,Re=ke?-1/0:1/0;for(let xe=0;xe<Pe.length;xe++){const ze=Pe[xe],Ve=Number(Ee(ze));Number.isFinite(Ve)&&(ke?Ve>Re:Ve<Re)&&(Re=Ve,Ce=ze)}return Ce}function R(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe);let Re=0,xe=0,ze=0,Ve=0,Qe=0,Ne=0;for(let Ze=0;Ze<ke.length;Ze++){const lt=ke[Ze],ot=Number(Ee(lt)),st=Number(Ce(lt));!Number.isFinite(ot)||!Number.isFinite(st)||(Re++,xe+=ot,ze+=st,Ve+=ot*ot,Qe+=st*st,Ne+=ot*st)}if(Re<2)return null;const Ge=Re*Ne-xe*ze,qe=Math.sqrt((Re*Ve-xe*xe)*(Re*Qe-ze*ze));if(qe===0)return null;const Je=Ge/qe;return Math.max(-1,Math.min(1,Je))}function x(ge,Pe=.1){const ke=ge.length;if(!ke)return null;const Ee=Array.from(ge).sort((ze,Ve)=>ze-Ve),Ce=Math.floor(ke*Math.min(.49,Math.max(0,Pe))),Re=Ee.slice(Ce,ke-Ce);if(!Re.length)return g(Ee,.5);let xe=0;for(const ze of Re)xe+=ze;return xe/Re.length}function A(ge,Pe=.1){const ke=ge.length;if(!ke)return null;const Ee=Array.from(ge).sort((Ve,Qe)=>Ve-Qe),Ce=Math.floor(ke*Math.min(.49,Math.max(0,Pe))),Re=Ee[Ce],xe=Ee[ke-1-Ce];let ze=0;for(const Ve of Ee)ze+=Math.min(xe,Math.max(Re,Ve));return ze/ke}function $(ge,Pe=3.5){if(!ge.length)return null;const Ee=Array.from(ge).sort((Ve,Qe)=>Ve-Qe),Ce=g(Ee,.5),Re=Ee.map(Ve=>Math.abs(Ve-Ce)).sort((Ve,Qe)=>Ve-Qe),xe=g(Re,.5);if(xe===0)return null;let ze=0;for(const Ve of Ee)Math.abs(.6745*(Ve-Ce)/xe)>Pe&&ze++;return ze}function I(ge){const Pe=ge.length;if(Pe<8)return null;let ke=0;for(const Ve of ge)ke+=Ve;ke/=Pe;let Ee=0,Ce=0,Re=0;for(const Ve of ge){const Qe=Ve-ke;Ee+=Qe*Qe,Ce+=Qe*Qe*Qe,Re+=Qe*Qe*Qe*Qe}if(Ee/=Pe,Ce/=Pe,Re/=Pe,Ee===0)return null;const xe=Ce/Ee**1.5,ze=Re/(Ee*Ee)-3;return Pe/6*(xe*xe+ze*ze/4)}function M(ge,Pe,ke){const Ee=[];let Ce=0;for(let Ve=0;Ve<ge.length;Ve++){const Qe=Number(ge[Ve]),Ne=Number(Pe[Ve]);!Number.isFinite(Qe)||!Number.isFinite(Ne)||Ne<=0||(Ee.push([Qe,Ne]),Ce+=Ne)}if(!Ee.length||Ce<=0)return null;if(Ee.sort((Ve,Qe)=>Ve[0]-Qe[0]),Ee.length===1)return Ee[0][0];const Re=[];let xe=0;for(const[,Ve]of Ee)Re.push((xe+Ve/2)/Ce),xe+=Ve;const ze=Math.max(0,Math.min(1,ke));if(ze<=Re[0])return Ee[0][0];if(ze>=Re[Re.length-1])return Ee[Ee.length-1][0];for(let Ve=1;Ve<Re.length;Ve++){if(ze>Re[Ve])continue;const Qe=Re[Ve]-Re[Ve-1],Ne=Qe>0?(ze-Re[Ve-1])/Qe:0;return Ee[Ve-1][0]+(Ee[Ve][0]-Ee[Ve-1][0])*Ne}return Ee[Ee.length-1][0]}function S(ge,Pe,ke){const Ee=X(ge),Ce=X(Pe),Re=new Float64Array(ke.length),xe=new Float64Array(ke.length);let ze=0;for(let Ve=0;Ve<ke.length;Ve++){const Qe=ke[Ve],Ne=Number(Ee(Qe)),Ge=Number(Ce(Qe));!Number.isFinite(Ne)||!Number.isFinite(Ge)||(Re[ze]=Ne,xe[ze]=Ge,ze++)}return{xs:Re.subarray(0,ze),ys:xe.subarray(0,ze),n:ze}}function E(ge,Pe,ke,Ee=!1){const{xs:Ce,ys:Re,n:xe}=S(ge,Pe,ke);if(xe<2)return null;let ze=0,Ve=0;for(let Ne=0;Ne<xe;Ne++)ze+=Ce[Ne],Ve+=Re[Ne];ze/=xe,Ve/=xe;let Qe=0;for(let Ne=0;Ne<xe;Ne++)Qe+=(Ce[Ne]-ze)*(Re[Ne]-Ve);return Qe/(Ee?xe:xe-1)}function U(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2)return null;let xe=0,ze=0;for(let ot=0;ot<Re;ot++)xe+=Ee[ot],ze+=Ce[ot];xe/=Re,ze/=Re;let Ve=0,Qe=0,Ne=0;for(let ot=0;ot<Re;ot++){const st=Ee[ot]-xe,Ot=Ce[ot]-ze;Ve+=st*st,Qe+=st*Ot,Ne+=Ot*Ot}if(Ve===0)return null;const Ge=Qe/Ve,qe=ze-Ge*xe,Je=Ne===0?1:Math.max(0,Math.min(1,Qe*Qe/(Ve*Ne))),Ze=Math.max(0,Ne-Ge*Qe),lt=Re>2?Math.sqrt(Ze/(Re-2)/Ve):0;return{slope:Ge,intercept:qe,r2:Je,stdError:lt,n:Re}}const K=new Set(["ols","wls","robust"]),q=new Set(["quantile"]),_=new Set(["ridge","lasso","elasticnet","mixed","gls"]),J=1.345;function ee(ge,Pe,ke){const{xtwx:Ee,xtwy:Ce}=c(ge,Pe,ke),Re=P(Ee);if(!Re)return null;const xe=O(Re,Ce),ze=b(Re),Ve=ne(ge,xe),Qe=Pe.map((Ne,Ge)=>Ne-Ve[Ge]);return{beta:xe,cov:ze,fitted:Ve,residuals:Qe}}function ne(ge,Pe){return ge.map(ke=>ke.reduce((Ee,Ce,Re)=>Ee+Ce*Pe[Re],0))}function oe(ge,Pe){const ke=ge.length,Ee=ge.map(Qe=>Qe[Pe]),Ce=ge.map(Qe=>[1,...Qe.filter((Ne,Ge)=>Ge!==Pe)]),Re=ee(Ce,Ee,null);if(!Re)return 1;const xe=Ee.reduce((Qe,Ne)=>Qe+Ne,0)/ke;let ze=0,Ve=0;for(let Qe=0;Qe<ke;Qe++)ze+=Re.residuals[Qe]**2,Ve+=(Ee[Qe]-xe)**2;return Ve===0?1:Math.max(0,Math.min(1,1-ze/Ve))}function ie(ge){const Pe=[...ge].sort((Ce,Re)=>Ce-Re),ke=ae(Pe),Ee=ge.map(Ce=>Math.abs(Ce-ke)).sort((Ce,Re)=>Ce-Re);return ae(Ee)/.6745}function ae(ge){const Pe=ge.length;if(!Pe)return 0;const ke=Math.floor(Pe/2);return Pe%2?ge[ke]:(ge[ke-1]+ge[ke])/2}function ce(ge,Pe,ke={}){const Ee=ke.method||"ols";if(_.has(Ee))throw new Error(`[lattice] regression method "${Ee}" is out of scope; use ols, wls or robust.`);if(q.has(Ee))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!K.has(Ee))throw new Error(`[lattice] unknown regression method "${Ee}"; use ols, wls or robust.`);const Ce=Array.isArray(Pe)?Pe.length:0,Re=Ce&&Array.isArray(ge[0])?ge[0].length:0,xe=Re+1;if(!(Ce>xe))return null;for(let Mt=0;Mt<Ce;Mt++){if(!Number.isFinite(Pe[Mt])||!Array.isArray(ge[Mt])||ge[Mt].length!==Re)return null;for(let xt=0;xt<Re;xt++)if(!Number.isFinite(ge[Mt][xt]))return null}let ze=null;if(Ee==="wls"){if(ze=ke.weights,!Array.isArray(ze)||ze.length!==Ce)return null;for(let Mt=0;Mt<Ce;Mt++)if(!(ze[Mt]>0)||!Number.isFinite(ze[Mt]))return null}const Ve=ge.map(Mt=>[1,...Mt]);let Qe,Ne=null;if(Ee==="robust"){if(Qe=ee(Ve,Pe,null),!Qe)return null;for(let Mt=0;Mt<50;Mt++){const xt=ie(Qe.residuals);if(!(xt>0))break;const _t=Qe.residuals.map(Jt=>{const qt=Math.abs(Jt/xt);return qt<=J?1:J/qt}),Yt=ee(Ve,Pe,_t);if(!Yt)return null;const Qt=Yt.beta.reduce((Jt,qt,sn)=>Math.max(Jt,Math.abs(qt-Qe.beta[sn])),0);if(Qe=Yt,Ne=_t,Qt<1e-10)break}}else if(Qe=ee(Ve,Pe,ze),!Qe)return null;const Ge=Ee==="robust"?Ne:ze,{beta:qe,cov:Je,fitted:Ze,residuals:lt}=Qe;let ot=0,st=0,Ot=0;for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1;ot+=xt*lt[Mt]**2,st+=xt,Ot+=xt*Pe[Mt]}const At=Ot/st;let Rt=0;for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1;Rt+=xt*(Pe[Mt]-At)**2}const We=Ce-xe,gt=ot/We,ct=Rt===0?1:Math.max(0,Math.min(1,1-ot/Rt)),bt=1-(1-ct)*(Ce-1)/We,Et=Array.isArray(ke.names)&&ke.names.length===Re?ke.names:ge[0].map((Mt,xt)=>`x${xt+1}`),ht=St(ke.confidence),ut=We>0?F(1-(1-ht)/2,We):1/0,Tt=qe.map((Mt,xt)=>{const _t=Math.sqrt(Math.max(0,gt*Je[xt][xt])),Yt=_t>0?Mt/_t:Mt===0?0:1/0,Qt=Number.isFinite(Yt)?2*(1-Z(Math.abs(Yt),We)):0,Jt=Number.isFinite(ut)?ut*_t:null;return{name:xt===0?"(intercept)":Et[xt-1],estimate:Mt,stdError:_t,t:Yt,p:Math.max(0,Math.min(1,Qt)),lower:Jt===null?null:Mt-Jt,upper:Jt===null?null:Mt+Jt}}),Ht=new Array(Ce),Xt=new Array(Ce);for(let Mt=0;Mt<Ce;Mt++){const xt=Ge?Ge[Mt]:1,_t=Math.max(0,Math.min(1,xt*d(Ve[Mt],Je)));Ht[Mt]=_t;const Yt=(1-_t)**2;Xt[Mt]=Yt>0&&gt>0?lt[Mt]**2/(xe*gt)*(_t/Yt):null}const mn=ge[0].map((Mt,xt)=>{if(Re<2)return 1;const _t=oe(ge,xt);return _t>=1?1/0:1/(1-_t)});let fn=null;{const Mt=lt.map(_t=>_t*_t),xt=ee(Ve,Mt,null);if(xt){const _t=Mt.reduce((en,gn)=>en+gn,0)/Ce;let Yt=0,Qt=0;for(let en=0;en<Ce;en++)Yt+=xt.residuals[en]**2,Qt+=(Mt[en]-_t)**2;const Jt=Qt===0?0:Math.max(0,Math.min(1,1-Yt/Qt)),qt=Ce*Jt,sn=z(qt,Re);fn={statistic:qt,df:Re,p:sn,heteroscedastic:sn<.05}}}let ln=null;if(Re===1){const Mt=ge.map((xt,_t)=>_t).sort((xt,_t)=>ge[xt][0]-ge[_t][0]);ln={confidence:ht,points:Mt.map(xt=>{const _t=Ve[xt],Yt=Math.sqrt(Math.max(0,gt*d(_t,Je)));return{x:ge[xt][0],yhat:Ze[xt],lower:Ze[xt]-ut*Yt,upper:Ze[xt]+ut*Yt}})}}return{method:Ee,coefficients:Tt,r2:ct,adjR2:bt,n:Ce,df:We,sigma2:gt,fitted:Ze,residuals:lt,leverage:Ht,cooksD:Xt,vif:mn,heteroscedasticity:fn,band:ln,weights:Ge?[...Ge]:null}}function de(ge){const Pe=ge.length,ke=Array.from({length:Pe},(Re,xe)=>xe).sort((Re,xe)=>ge[Re]-ge[xe]),Ee=new Float64Array(Pe);let Ce=0;for(;Ce<Pe;){let Re=Ce;for(;Re+1<Pe&&ge[ke[Re+1]]===ge[ke[Ce]];)Re++;const xe=(Ce+Re)/2+1;for(let ze=Ce;ze<=Re;ze++)Ee[ke[ze]]=xe;Ce=Re+1}return Ee}const Ae=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function je(ge){const Pe=[.01,.05,.1],ke=[Ae["1%"],Ae["5%"],Ae["10%"]];if(ge<=ke[0]){const Re=(Math.log(Pe[1])-Math.log(Pe[0]))/(ke[1]-ke[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Pe[0])+Re*(ge-ke[0]))))}if(ge>=ke[2]){const Re=(Math.log(Pe[2])-Math.log(Pe[1]))/(ke[2]-ke[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Pe[2])+Re*(ge-ke[2]))))}const Ee=ge<ke[1]?0:1,Ce=(ge-ke[Ee])/(ke[Ee+1]-ke[Ee]);return Math.exp(Math.log(Pe[Ee])+Ce*(Math.log(Pe[Ee+1])-Math.log(Pe[Ee])))}function be(ge,Pe,ke,Ee){const Ce=ke-Ee,Re=Ee+3,xe=new Array(Ce),ze=new Array(Ce);let Ve=!0,Qe=Ee;for(let Ze=0;Ze<Ce;Ze++){const lt=Ee+Ze,ot=new Float64Array(Re);ot[0]=1,ot[1]=Ze+1,ot[2]=ge[lt];for(let st=1;st<=Ee;st++)ot[2+st]=Pe[lt-st];for(let st=1;st<Re;st++)Number.isFinite(ot[st])||(Qe=Math.min(Qe,st-3));xe[Ze]=ot,ze[Ze]=Pe[lt],Number.isFinite(ze[Ze])||(Ve=!1)}if(!Ve)return 0;const{xtwx:Ne,xtwy:Ge}=c(xe,ze,null);let qe=0,Je=1/0;for(let Ze=0;Ze<=Qe;Ze++){const lt=Ze+3;if(!(Ce>lt))continue;const ot=new Array(lt);for(let ct=0;ct<lt;ct++)ot[ct]=Ne[ct].slice(0,lt);const st=P(ot);if(!st)continue;const Ot=O(st,Ge.slice(0,lt));let At=0;for(let ct=0;ct<Ce;ct++){const bt=xe[ct];let Et=0;for(let ht=0;ht<lt;ht++)Et+=bt[ht]*Ot[ht];At+=(ze[ct]-Et)**2}const We=At/(Ce-lt)*(Ce-lt);if(!(We>0))continue;const gt=Ce*Math.log(We/Ce)+2*lt;gt<Je&&(Je=gt,qe=Ze)}return qe}function re(ge,Pe={}){const ke=[];for(let Je=0;Je<ge.length;Je++){const Ze=Number(ge[Je]);Number.isFinite(Ze)&&ke.push(Ze)}const Ee=ke.length,Ce=Ee-1;if(Ee<8||Ce<6)return null;const Re=new Array(Ce);for(let Je=0;Je<Ce;Je++)Re[Je]=ke[Je+1]-ke[Je];let xe=Number.isFinite(Pe.maxlag)?Math.floor(Pe.maxlag):Math.ceil(12*(Ee/100)**.25);xe=Math.max(0,Math.min(xe,Math.floor((Ce-5)/2)));const ze=(Je,Ze)=>{const lt=[],ot=[];for(let st=Ze;st<Ce;st++){const Ot=[st-Ze+1,ke[st]];for(let At=1;At<=Je;At++)Ot.push(Re[st-At]);lt.push(Ot),ot.push(Re[st])}return ce(lt,ot,{method:"ols"})},Ve=be(ke,Re,Ce,xe),Qe=ze(Ve,Ve);if(!Qe||!Qe.coefficients[2])return null;const Ne=Qe.coefficients[2].t,Ge=je(Ne),qe=Ne<Ae["5%"];return{statistic:Ne,usedLag:Ve,nobs:Ce-Ve,criticalValues:{...Ae},pValue:Ge,pApproximate:!0,stationary:qe,verdict:qe?"stationary":"non-stationary",regression:"ct"}}function fe(ge,Pe={}){const ke=[];for(let qe=0;qe<ge.length;qe++){const Je=Number(ge[qe]);Number.isFinite(Je)&&ke.push(Je)}const Ee=ke.length;if(Ee<3)return null;let Ce=Number.isFinite(Pe.maxlag)?Math.floor(Pe.maxlag):Math.min(10,Ee-1);Ce=Math.max(1,Math.min(Ce,Ee-1));let Re=0;for(const qe of ke)Re+=qe;Re/=Ee;const xe=ke.map(qe=>qe-Re);let ze=0;for(const qe of xe)ze+=qe*qe;ze/=Ee;const Ve=new Array(Ce+1).fill(0);Ve[0]=1;for(let qe=1;qe<=Ce;qe++){let Je=0;for(let Ze=qe;Ze<Ee;Ze++)Je+=xe[Ze]*xe[Ze-qe];Ve[qe]=ze>0?Je/Ee/ze:0}const Qe=new Array(Ce+1).fill(0);Qe[0]=1;let Ne=[];for(let qe=1;qe<=Ce;qe++){let Je=Ve[qe];for(let st=1;st<qe;st++)Je-=Ne[st-1]*Ve[qe-st];let Ze=1;for(let st=1;st<qe;st++)Ze-=Ne[st-1]*Ve[st];const lt=Ze!==0?Je/Ze:0,ot=new Array(qe);for(let st=1;st<qe;st++)ot[st-1]=Ne[st-1]-lt*Ne[qe-1-st];ot[qe-1]=lt,Qe[qe]=lt,Ne=ot}const Ge=1.96/Math.sqrt(Ee);return{acf:Ve,pacf:Qe,bounds:{upper:Ge,lower:-Ge},n:Ee,nlags:Ce,approximate:!0}}function pe(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2)return null;const xe=de(Ee),ze=de(Ce);let Ve=0,Qe=0;for(let Je=0;Je<Re;Je++)Ve+=xe[Je],Qe+=ze[Je];Ve/=Re,Qe/=Re;let Ne=0,Ge=0,qe=0;for(let Je=0;Je<Re;Je++){const Ze=xe[Je]-Ve,lt=ze[Je]-Qe;Ne+=Ze*lt,Ge+=Ze*Ze,qe+=lt*lt}return Ge===0||qe===0?null:Math.max(-1,Math.min(1,Ne/Math.sqrt(Ge*qe)))}function Oe(ge,Pe,ke){const{xs:Ee,ys:Ce,n:Re}=S(ge,Pe,ke);if(Re<2||Re>t)return null;let xe=0,ze=0,Ve=0,Qe=0;for(let qe=0;qe<Re;qe++)for(let Je=qe+1;Je<Re;Je++){const Ze=Math.sign(Ee[qe]-Ee[Je]),lt=Math.sign(Ce[qe]-Ce[Je]),ot=Ze*lt;ot>0?xe++:ot<0?ze++:Ze===0&&lt===0||(Ze===0?Ve++:Qe++)}const Ne=xe+ze+Qe,Ge=xe+ze+Ve;return Ne===0||Ge===0?null:(xe-ze)/Math.sqrt(Ne*Ge)}function ve(ge,Pe={}){const ke=ge.length;if(ke<2)return null;const Ee=ge[0],Ce=ge[ke-1],Re=[];for(let st=1;st<ke;st++){const Ot=ge[st-1];Ot!==0&&Re.push((ge[st]-Ot)/Math.abs(Ot))}let xe=null;if(Re.length>1){let st=0;for(const At of Re)st+=At;st/=Re.length;let Ot=0;for(const At of Re)Ot+=(At-st)**2;xe=Math.sqrt(Ot/(Re.length-1))}const ze=Number(Pe.periodsPerYear)>0?Number(Pe.periodsPerYear):null;let Ve=ge[0],Qe=0,Ne=0,Ge=0,qe=0;for(let st=1;st<ke;st++){if(ge[st]>Ve){Ve=ge[st],Qe=st;continue}if(Ve<=0)continue;const Ot=(Ve-ge[st])/Ve;Ot>Ne&&(Ne=Ot,Ge=Qe,qe=st)}let Je=null;if(ke>2){let st=0;for(let Rt=0;Rt<ke;Rt++)st+=ge[Rt];st/=ke;let Ot=0,At=0;for(let Rt=0;Rt<ke;Rt++){const We=ge[Rt]-st;At+=We*We,Rt>0&&(Ot+=We*(ge[Rt-1]-st))}Je=At>0?Ot/At:null}let Ze=0,lt=0;for(const st of Re)st>0?Ze++:st<0&&lt++;let ot=null;if(Ee>0&&Ce>0){const st=(Ce/Ee)**(1/(ke-1))-1;ot=ze?(1+st)**ze-1:st}return{n:ke,first:Ee,last:Ce,change:Ce-Ee,changePercent:Ee===0?null:(Ce-Ee)/Math.abs(Ee)*100,volatility:xe,annualisedVolatility:xe!==null&&ze?xe*Math.sqrt(ze):null,growth:ot,maxDrawdown:Ne,maxDrawdownFrom:Ge,maxDrawdownTo:qe,autocorrelation:Je,upDays:Ze,downDays:lt}}const $e=1.128,he=3.267;function ye(ge){const Pe=ge.length;if(Pe<2)return null;const ke=[];for(let Ce=1;Ce<Pe;Ce++)ke.push(Math.abs(ge[Ce]-ge[Ce-1]));const Ee=ke.reduce((Ce,Re)=>Ce+Re,0)/ke.length;return{ranges:ke,centre:Ee,upper:he*Ee,lower:0}}function Se(ge){const Pe=ge.length;if(Pe<2)return null;let ke=0;for(let Ce=1;Ce<Pe;Ce++)ke+=Math.abs(ge[Ce]-ge[Ce-1]);const Ee=ke/(Pe-1);return{sigma:Ee/$e,meanRange:Ee}}function Ie(ge,Pe){const ke=ge.length;if(ke<2||!Pe)return null;const Ee=Number.isFinite(Number(Pe.lower))?Number(Pe.lower):null,Ce=Number.isFinite(Number(Pe.upper))?Number(Pe.upper):null;if(Ee===null&&Ce===null)return null;let Re=0;for(let Ze=0;Ze<ke;Ze++)Re+=ge[Ze];Re/=ke;let xe=0;for(let Ze=0;Ze<ke;Ze++)xe+=(ge[Ze]-Re)**2;const ze=Math.sqrt(xe/(ke-1)),Ve=Se(ge),Qe=Ve?Ve.sigma:null,Ne=Ze=>{if(!Ze||Ze<=0)return{index:null,k:null};const ot=Ee!==null&&Ce!==null?(Ce-Ee)/(6*Ze):null,st=Ce!==null?(Ce-Re)/(3*Ze):1/0,Ot=Ee!==null?(Re-Ee)/(3*Ze):1/0;return{index:ot,k:Math.min(st,Ot)}},Ge=Ne(Qe),qe=Ne(ze);let Je=0;for(let Ze=0;Ze<ke;Ze++){if(Ee!==null&&ge[Ze]<Ee){Je++;continue}Ce!==null&&ge[Ze]>Ce&&Je++}return{n:ke,mean:Re,lower:Ee,upper:Ce,target:Number.isFinite(Number(Pe.target))?Number(Pe.target):null,sigmaWithin:Qe,sigmaOverall:ze,cp:Ge.index,cpk:Ge.k,pp:qe.index,ppk:qe.k,outOfSpec:Je,defectRate:ke?Je/ke:null}}function we(ge){const Pe=ge.length;if(Pe<2)return null;const ke=Se(ge);if(!ke||!(ke.sigma>0))return null;let Ee=0;for(let Ce=0;Ce<Pe;Ce++)Ee+=ge[Ce];return Ee/=Pe,{centre:Ee,sigma:ke.sigma,upper:Ee+3*ke.sigma,lower:Ee-3*ke.sigma}}function Fe(ge,Pe){if(!Pe||!(Pe.sigma>0))return[];const ke=ge.length,{centre:Ee,sigma:Ce}=Pe,Re=ze=>(ge[ze]-Ee)/Ce,xe=[];for(let ze=0;ze<ke;ze++){if(Math.abs(Re(ze))>3&&xe.push({index:ze,rule:1,description:"beyond three sigma"}),ze>=2)for(const Ve of[1,-1]){let Qe=0;for(let Ne=ze-2;Ne<=ze;Ne++)Re(Ne)*Ve>2&&Qe++;if(Qe>=2){xe.push({index:ze,rule:2,description:"two of three past two sigma"});break}}if(ze>=4)for(const Ve of[1,-1]){let Qe=0;for(let Ne=ze-4;Ne<=ze;Ne++)Re(Ne)*Ve>1&&Qe++;if(Qe>=4){xe.push({index:ze,rule:3,description:"four of five past one sigma"});break}}if(ze>=7)for(const Ve of[1,-1]){let Qe=!0;for(let Ne=ze-7;Ne<=ze;Ne++)if(Re(Ne)*Ve<=0){Qe=!1;break}if(Qe){xe.push({index:ze,rule:4,description:"eight in a row on one side"});break}}}return xe}function He(ge,Pe){if(!Pe||!(Pe.sigma>0))return[];const ke=ge.length,{centre:Ee,sigma:Ce}=Pe,Re=Ve=>(ge[Ve]-Ee)/Ce,xe=(Ve,Qe,Ne,Ge)=>{for(const qe of[1,-1]){let Je=0;for(let Ze=Ve;Ze<=Qe;Ze++)Re(Ze)*qe>Ne&&Je++;if(Je>=Ge)return!0}return!1},ze=[];for(let Ve=0;Ve<ke;Ve++){if(Math.abs(Re(Ve))>3&&ze.push({index:Ve,rule:1,description:"beyond three sigma"}),Ve>=8)for(const Qe of[1,-1]){let Ne=!0;for(let Ge=Ve-8;Ge<=Ve;Ge++)if(Re(Ge)*Qe<=0){Ne=!1;break}if(Ne){ze.push({index:Ve,rule:2,description:"nine in a row on one side"});break}}if(Ve>=5)for(const Qe of[1,-1]){let Ne=!0;for(let Ge=Ve-4;Ge<=Ve;Ge++)if((ge[Ge]-ge[Ge-1])*Qe<=0){Ne=!1;break}if(Ne){ze.push({index:Ve,rule:3,description:Qe>0?"six rising":"six falling"});break}}if(Ve>=13){let Qe=!0;for(let Ne=Ve-12;Ne<=Ve;Ne++){const Ge=ge[Ne]-ge[Ne-1],qe=ge[Ne+1<=Ve?Ne+1:Ne]-ge[Ne];if(Ne+1>Ve)break;if(Ge===0||qe===0||Ge>0==qe>0){Qe=!1;break}}Qe&&ze.push({index:Ve,rule:4,description:"fourteen alternating"})}if(Ve>=2&&xe(Ve-2,Ve,2,2)&&ze.push({index:Ve,rule:5,description:"two of three past two sigma"}),Ve>=4&&xe(Ve-4,Ve,1,4)&&ze.push({index:Ve,rule:6,description:"four of five past one sigma"}),Ve>=14){let Qe=!0;for(let Ne=Ve-14;Ne<=Ve;Ne++)if(Math.abs(Re(Ne))>=1){Qe=!1;break}Qe&&ze.push({index:Ve,rule:7,description:"fifteen within one sigma"})}if(Ve>=7){let Qe=!0;for(let Ne=Ve-7;Ne<=Ve;Ne++)if(Math.abs(Re(Ne))<=1){Qe=!1;break}Qe&&ze.push({index:Ve,rule:8,description:"eight beyond one sigma"})}}return ze}const Ke=Object.freeze(["westernElectric","nelson"]);function nt(ge,Pe,ke="westernElectric"){return String(ke)==="nelson"?He(ge,Pe):Fe(ge,Pe)}function it(ge,Pe,ke){let Ee=0;for(let Ce=0;Ce<ge.length;Ce++)(ge[Ce]<Pe||ge[Ce]>ke)&&Ee++;return Ee}function mt(ge,Pe,ke,Ee=20){const Ce=ge.length;if(!Ce)return[];const Re=ge[0],xe=ge[Ce-1];if(xe===Re)return[{from:Re,to:xe,count:Ce}];const ze=ke-Pe,Ve=1.5*ze;let Qe=ze>0?Math.max(Re,Pe-Ve):Re,Ne=ze>0?Math.min(xe,ke+Ve):xe;Ne>Qe||(Qe=Re,Ne=xe);const Ge=ze>0?2*ze/Math.cbrt(Ce):(Ne-Qe)/(Math.ceil(Math.log2(Ce))+1),qe=Ge>0?Math.min(Ee,Math.max(1,Math.ceil((Ne-Qe)/Ge))):1,Je=(Ne-Qe)/qe,Ze=[];for(let lt=0;lt<qe;lt++)Ze.push({from:Qe+lt*Je,to:Qe+(lt+1)*Je,count:0});for(let lt=0;lt<Ce;lt++){const ot=Math.min(qe-1,Math.max(0,Math.floor((ge[lt]-Qe)/Je)));Ze[ot].count++}return Ze[0].from=Re,Ze[qe-1].to=xe,Ze}const kt=.95;function St(ge){const Pe=Number(ge);return Number.isFinite(Pe)&&Pe>0&&Pe<1?Pe:kt}function Pt(ge,Pe=kt){const ke=ge.length;if(ke<2)return null;let Ee=0;for(let Ne=0;Ne<ke;Ne++)Ee+=ge[Ne];const Ce=Ee/ke;let Re=0;for(let Ne=0;Ne<ke;Ne++){const Ge=ge[Ne]-Ce;Re+=Ge*Ge}const xe=Math.sqrt(Re/(ke-1)),ze=St(Pe),Qe=F(1-(1-ze)/2,ke-1)*xe/Math.sqrt(ke);return{mean:Ce,lower:Ce-Qe,upper:Ce+Qe,margin:Qe,n:ke,confidence:ze}}function Nt(ge,Pe,ke=kt){const Ee=Number(ge),Ce=Number(Pe);if(!(Ce>0)||!(Ee>=0)||Ee>Ce)return null;const Re=St(ke),xe=Y(1-(1-Re)/2),ze=Ee/Ce,Ve=xe*xe,Qe=1+Ve/Ce,Ne=(ze+Ve/(2*Ce))/Qe,Ge=xe/Qe*Math.sqrt(ze*(1-ze)/Ce+Ve/(4*Ce*Ce));return{proportion:ze,lower:Math.max(0,Ne-Ge),upper:Math.min(1,Ne+Ge),n:Ce,confidence:Re}}function Ft(ge,Pe=kt){if(!ge||!(ge.n>2)||!Number.isFinite(ge.stdError))return null;const ke=St(Pe),Ce=F(1-(1-ke)/2,ge.n-2)*ge.stdError;return{slope:ge.slope,lower:ge.slope-Ce,upper:ge.slope+Ce,margin:Ce,confidence:ke}}function Lt(ge,Pe,ke=kt){const Ee=Number(ge),Ce=Number(Pe);if(!Number.isFinite(Ee)||!(Ce>1))return null;const Re=St(ke),ze=Y(1-(1-Re)/2)*Math.sqrt(1/(9*Ce)+Ee*Ee/(2*(Ce-1)));return{index:Ee,lower:Ee-ze,upper:Ee+ze,margin:ze,n:Ce,confidence:Re}}function Ut(ge,Pe){return!ge||!(ge.sd>0)||!Number.isFinite(Pe)||!Number.isFinite(ge.mean)?null:(Pe-ge.mean)/ge.sd}function ft(ge){return Number.isFinite(ge)?Math.min(1,Math.max(0,2*B(Math.abs(ge)/2)-1)):0}function dt(ge,Pe){const ke=new Map,Ee=X(ge);let Ce=0;for(let Re=0;Re<Pe.length;Re++){const xe=Ee(Pe[Re]);if(xe==null||xe===""||typeof xe=="number"&&Number.isNaN(xe))continue;const ze=xe instanceof Date?xe.getTime():typeof xe=="object"?String(xe):xe;ke.set(ze,(ke.get(ze)||0)+1),Ce++}return{map:ke,total:Ce}}function wt(ge,Pe,ke,Ee){if(!(Pe>0)||!(Ee>0))return null;let Ce=0;const Re=new Set(ge.keys());for(const xe of ke.keys())Re.add(xe);for(const xe of Re){const ze=(ge.get(xe)||0)/Pe,Ve=(ke.get(xe)||0)/Ee;Ce+=Math.abs(ze-Ve)}return Ce/2}const rt=10;function me(ge,Pe,ke){if(ke&&ke.numeric){const ze=u(ge,Pe),{n:Ve,mean:Qe}=p(ze),Ne=Ve>0?Ut({mean:ke.mean,sd:ke.sd},Qe):null;return{measure:"standardizedMeanDifference",magnitude:Ne,distance:Ne===null?0:ft(Ne),direction:Ne===null?0:Math.sign(Ne),subsetN:Ve,populationN:ke.n||0,reliable:Ve>=rt}}const{map:Ce,total:Re}=dt(ge,Pe),xe=wt(Ce,Re,ke.map,ke.total);return{measure:"categoricalTotalVariation",magnitude:xe,distance:xe===null?0:xe,direction:0,subsetN:Re,populationN:ke.total||0,reliable:Re>=rt}}function Te(ge,Pe){if(ge&&(ge.kind==="float64"||ge.kind==="int32"))return!0;const ke=X(ge);let Ee=0,Ce=0;for(let Re=0;Re<Pe.length&&Ee<200;Re++){const xe=ke(Pe[Re]);if(xe==null||xe==="")continue;if(xe instanceof Date)return!1;Ee++;const ze=typeof xe=="number"?xe:Number(xe);Number.isFinite(ze)&&Ce++}return Ee===0?!1:Ce/Ee>=.9}function Ue(ge,Pe){if(Te(ge,Pe)){const Ce=u(ge,Pe),{n:Re,mean:xe,m2:ze}=p(Ce);return{numeric:!0,mean:xe,sd:Re>0?Math.sqrt(ze/Re):0,n:Re}}const{map:ke,total:Ee}=dt(ge,Pe);return{numeric:!1,map:ke,total:Ee}}}),Be("packages/core/src/compute/total.js",function(e,H){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return p}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F=H("packages/core/src/compute/handle.js"),Z=F.presenceReader,Y=F.valueComparator,B=F.valueReader,z=H("packages/core/src/compute/statistics.js"),G=z.STAT_FNS,P=z.STAT_LABELS;function O(g){return!!g&&(g.kind==="float64"||g.kind==="int32")}function b(g,k){const y=k.length;let T=0;if(O(g)){const N=g.values,W=Z(g);if(!W){for(let R=0;R<y;R++){const x=N[k[R]];Number.isNaN(x)||(T+=x)}return T}for(let R=0;R<y;R++){const x=k[R];if(W(x)===1){const A=N[x];Number.isNaN(A)||(T+=A)}}return T}const j=B(g);for(let N=0;N<y;N++){const W=u(j(k[N]));W!==null&&(T+=W)}return T}b.kernel=!0;function c(g,k){const y=k.length;let T=0;if(O(g)){const N=g.values,W=Z(g);if(!W){for(let R=0;R<y;R++)Number.isNaN(N[k[R]])||T++;return T}for(let R=0;R<y;R++){const x=k[R];W(x)===1&&!Number.isNaN(N[x])&&T++}return T}const j=B(g);for(let N=0;N<y;N++){const W=j(k[N]);W!=null&&!(typeof W=="number"&&Number.isNaN(W))&&T++}return T}c.kernel=!0;function d(g,k){return k.length}d.kernel=!0;function l(g,k){const y=c(g,k);return y===0?null:b(g,k)/y}l.kernel=!0;function r(g,k,y,T){const j=k.length;if(O(g)){const x=g.values,A=Z(g);let $=null;if(!A){for(let I=0;I<j;I++){const M=x[k[I]];Number.isNaN(M)||($===null||(y<0?M<$:M>$))&&($=M)}return $}for(let I=0;I<j;I++){const M=k[I];if(A(M)===0)continue;const S=x[M];Number.isNaN(S)||($===null||(y<0?S<$:S>$))&&($=S)}return $}const N=B(g),W=Y(T);let R=null;for(let x=0;x<j;x++){const A=N(k[x]);A==null||typeof A=="number"&&Number.isNaN(A)||(R===null||(y<0?W(A,R)<0:W(A,R)>0))&&(R=A)}return R}function t(g,k,y){return r(g,k,-1,y&&y.locale)}t.kernel=!0;function i(g,k,y){return r(g,k,1,y&&y.locale)}i.kernel=!0;function s(g,k){return k.length===0?null:B(g)(k[0])}s.kernel=!0;function n(g,k){return k.length===0?null:B(g)(k[k.length-1])}n.kernel=!0;function u(g){if(typeof g=="number")return Number.isNaN(g)?null:g;if(g==null||g===""||typeof g=="boolean")return null;if(g instanceof Date)return g.getTime();const k=Number(g);return Number.isNaN(k)?null:k}const o={sum:b,min:t,max:i,avg:l,count:d,first:s,last:n,countValues:c,...G},a=Object.freeze({...P,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function f(g){return g?typeof g=="string"?a[g]||g:"Total":""}const w=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(g){const k=g&&g.dataType&&g.dataType.totals&&g.dataType.totals.supported;if(Array.isArray(k))return k.slice();const y=w.filter(T=>T in o);for(const T of Object.keys(o))y.includes(T)||y.push(T);return y}function v(g,k){return typeof k!="string"?!0:m(g).includes(k)}function h(g,k){const y=B(g),T=[];for(let j=0;j<k.length;j++){const N=y(k[j]);N!=null&&T.push(N)}return T}function p(g,k,y,T){const j=k||[];if(typeof y=="string"){const N=o[y];return N?N(g,j,T):(D(`total:${y}`,`unknown total function "${y}"; register it in config.totalFns`),null)}return L(y)?y.kernel===!0?y(g,j,T):y(h(g,j),T||{}):null}}),Be("packages/core/src/compute/windowed.js",function(e,H){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/compute/sketch.js").Welford;class X{#e;#t;#n=[];#r;#s;constructor(B,z=0,G=Date.now){if(B!=="count"&&B!=="time"&&B!=="session")throw new RangeError(`unknown window kind: ${B}`);if((B==="count"||B==="time")&&!(z>0))throw new RangeError(`a ${B} window needs a positive span`);this.#e=B,this.#t=Math.floor(z),this.#r=G,this.#s=G()}get size(){return this.#n.length}push(B,z=this.#r()){Number.isFinite(B)&&(this.#n.push({t:z,v:B}),this.#i(z))}#i(B){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const z=B-this.#t;for(;this.#n.length&&this.#n[0].t<z;)this.#n.shift()}}spec(){const B=this.#e==="session"?this.#r()-this.#s:this.#t;return{kind:this.#e,span:B,size:this.#n.length}}values(){return this.#n.map(B=>B.v)}aggregate(){const B=this.spec();if(!this.#n.length)return{over:B,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const z=new L;let G=0,P=1/0,O=-1/0;for(const{v:b}of this.#n)G+=b,b<P&&(P=b),b>O&&(O=b),z.add(b);return{over:B,count:this.#n.length,sum:G,mean:z.mean(),min:P,max:O,variance:z.variance(),stddev:z.stddev()}}reduce(B){const z=this.aggregate(),G={sum:z.sum,avg:z.mean,mean:z.mean,min:z.min,max:z.max,count:z.count,variance:z.variance,stddev:z.stddev};if(!(B in G))throw new RangeError(`unknown windowed aggregate: ${B}`);return{value:G[B],over:z.over}}}const D=Object.freeze(["count","time","session"]);function F(Y,B=Date.now){const z=Y.kind==="time"&&Y.minutes!=null?Y.minutes*6e4:Y.span??0;return new X(Y.kind,z,B)}const Z={Window:X,WINDOW_KINDS:D,openWindow:F}}),Be("packages/core/src/compute/rolling.js",function(e,H){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const L=H("packages/core/src/compute/windowed.js").openWindow,D=H("packages/core/src/compute/sketch.js").KLL,F=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(o,a,f,w){if(o.kind==="count"){const m=Math.max(1,Math.floor(o.span||0));return{coverage:Math.min(1,a/m),partial:a<m}}if(o.kind==="time"){const m=o.minutes!=null?o.minutes*6e4:o.span||0;if(!(m>0))return{coverage:1,partial:!1};const v=f-w;return{coverage:Math.min(1,v/m),partial:v<m}}return{coverage:null,partial:!1}}function Y(o,a){const f=L(a),w=new Map,m=o.length?o[0].at:0;for(let v=0;v<o.length;v++){const{key:h,at:p,value:g}=o[v];Number.isFinite(g)&&f.push(g,p);const k=f.aggregate(),y=Z(a,k.count,p,m);h!=null&&w.set(String(h),{sum:k.sum,avg:k.mean,min:k.min,max:k.max,count:k.count,coverage:y.coverage,partial:y.partial})}return w}function B(o){const a=new Map;let f=0;for(const{key:w,value:m}of o)Number.isFinite(m)&&(f+=m),w!=null&&a.set(String(w),f);return a}function z(o,a=1){const f=new Map,w=Math.max(1,Math.floor(a));for(let m=0;m<o.length;m++){const{key:v,value:h}=o[m];if(v==null)continue;const p=m>=w?o[m-w].value:null,g=Number.isFinite(h)?h:null,k=Number.isFinite(p)?p:null;f.set(String(v),g!==null&&k!==null?g-k:null)}return f}const G=4096;function P(o){let a=o>>>0;return()=>{a+=1831565813;let f=a;return f=Math.imul(f^f>>>15,f|1),f^=f+Math.imul(f^f>>>7,f|61),((f^f>>>14)>>>0)/4294967296}}function O(o,a){const f=o.length;if(f===1)return o[0];const w=(f-1)*a,m=Math.floor(w),v=Math.ceil(w);return m===v?o[m]:o[m]+(w-m)*(o[v]-o[m])}function b(o,a,f={}){const w=Math.min(1,Math.max(0,f.q==null?.5:f.q)),m=Math.max(1,Math.floor(f.cap==null?G:f.cap)),v=P(f.seed==null?2654435769:f.seed),h=new Map,p=o.length?o[0].at:0;if(a.kind==="session"){const k=new D(200,v);let y=0;for(const{key:T,value:j}of o)Number.isFinite(j)&&(k.add(j),y++),T!=null&&h.set(String(T),{value:y?k.quantile(w):null,approx:y>0,count:y,coverage:null,partial:!1});return h}const g=L(a);for(const{key:k,at:y,value:T}of o){Number.isFinite(T)&&g.push(T,y);const j=g.values(),N=j.length;let W=null,R=!1;if(N)if(N<=m)W=O([...j].sort((A,$)=>A-$),w);else{const A=new D(200,v);for(const $ of j)A.add($);W=A.quantile(w),R=!0}const x=Z(a,N,y,p);k!=null&&h.set(String(k),{value:W,approx:R,count:N,coverage:x.coverage,partial:x.partial})}return h}function c(o,a){const f=o.length,w=new Array(f).fill(null),m=Math.floor(a/2),v=a%2===0;for(let h=0;h<f;h++){if(h-m<0||h+m>=f)continue;let p=0,g=!0;if(v)for(let k=-m;k<=m;k++){const y=o[h+k];if(!Number.isFinite(y)){g=!1;break}p+=k===-m||k===m?y*.5:y}else for(let k=-m;k<=m;k++){const y=o[h+k];if(!Number.isFinite(y)){g=!1;break}p+=y}g&&(w[h]=p/a)}return w}function d(o,a){const f=new Map,w=Math.floor(Number(a&&a.period));if(!(w>=2))return f;const m=a&&a.model==="multiplicative",v=o.length,h=o.map(R=>Number.isFinite(R.value)?R.value:null),p=c(h,w),g=new Array(v).fill(null);for(let R=0;R<v;R++){const x=p[R],A=h[R];x===null||A===null||(m?x!==0&&(g[R]=A/x):g[R]=A-x)}const k=new Array(w).fill(0),y=new Array(w).fill(0);for(let R=0;R<v;R++){if(g[R]===null)continue;const x=R%w;k[x]+=g[R],y[x]+=1}const T=m?1:0,j=k.map((R,x)=>y[x]?R/y[x]:T),N=j.reduce((R,x)=>R+x,0)/w,W=m?j.map(R=>N!==0?R/N:1):j.map(R=>R-N);for(let R=0;R<v;R++){const{key:x}=o[R];if(x==null)continue;const A=p[R],$=W[R%w],I=h[R];let M=null;A!==null&&I!==null&&(M=m?A*$!==0?I/(A*$):null:I-A-$),f.set(String(x),{trend:A,seasonal:I===null?null:$,residual:M,coverage:A===null?0:1,partial:A===null})}return f}function l(o,a,f,w=80){const m=(Math.sqrt(5)-1)/2;let v=a,h=f,p=h-m*(h-v),g=v+m*(h-v),k=o(p),y=o(g);for(let T=0;T<w;T++)k<y?(h=g,g=p,y=k,p=h-m*(h-v),k=o(p)):(v=p,p=g,k=y,g=v+m*(h-v),y=o(g));return(v+h)/2}const r=1e-4,t=1-1e-4;function i(o,a){const f=o.length,w=new Array(f).fill(null),m=new Array(f).fill(null);let v=null,h=0;for(let p=0;p<f;p++){const g=o[p];if(!Number.isFinite(g)){v!==null&&(m[p]=v,w[p]=v);continue}if(v===null){v=g,m[p]=g,w[p]=g;continue}m[p]=v,h+=(g-v)**2,v=a*g+(1-a)*v,w[p]=v}return{smoothed:w,fitted:m,sse:h}}function s(o,a,f){const w=o.length,m=new Array(w).fill(null),v=new Array(w).fill(null);let h=null,p=null,g=0;for(let k=0;k<w;k++){const y=o[k];if(!Number.isFinite(y)){h!==null&&(h+=p,m[k]=h);continue}if(h===null){h=y,m[k]=y;continue}if(p===null){p=y-h;const N=h+p;v[k]=N,g+=(y-N)**2;const W=h;h=a*y+(1-a)*(W+p),p=f*(h-W)+(1-f)*p,m[k]=h;continue}const T=h+p;v[k]=T,g+=(y-T)**2;const j=h;h=a*y+(1-a)*(j+p),p=f*(h-j)+(1-f)*p,m[k]=h}return{smoothed:m,fitted:v,sse:g}}function n(o,a={}){const f=new Map,w=a.method==="holt",m=o.map(T=>Number.isFinite(T.value)?T.value:null),v=m.filter(T=>T!==null).length,h=T=>Math.min(t,Math.max(r,T)),p=()=>{for(const{key:T}of o)T!=null&&f.set(String(T),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return f};if(v<(w?2:1))return p();let g=Number.isFinite(a.alpha)?h(a.alpha):null,k=w&&Number.isFinite(a.beta)?h(a.beta):null;if(w){if(g===null||k===null){let T=g===null?.5:g,j=k===null?.5:k;for(let N=0;N<6;N++)g===null&&(T=l(W=>s(m,W,j).sse,r,t)),k===null&&(j=l(W=>s(m,T,W).sse,r,t));g=g===null?T:g,k=k===null?j:k}}else g===null&&(g=l(T=>i(m,T).sse,r,t));const y=w?s(m,g,k):i(m,g);for(let T=0;T<o.length;T++){const{key:j}=o[T];j!=null&&f.set(String(j),{smoothed:y.smoothed[T],fitted:y.fitted[T],alpha:g,beta:w?k:null,sse:y.sse})}return f}const u={ROLLING_WINDOW_FIELDS:F,QUANTILE_SPAN_CAP:G,rollingWindow:Y,rollingQuantile:b,cumulativeToDate:B,periodOverPeriod:z,seasonalDecompose:d,exponentialSmoothing:n}}),Be("packages/core/src/compute/compare.js",function(e,H){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return c}});const te=H("packages/core/src/compute/statistics.js"),L=te.numbers,X=te.moments,D=te.frequencyMap,F=te.categoricalDistance,Z=te.normalTotalVariation,Y=te.isNumericColumn,B=te.SUBSET_RELIABILITY_FLOOR,z=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function G(d,l){if(!d||!l||!(d.n>0)||!(l.n>0)||!Number.isFinite(d.mean)||!Number.isFinite(l.mean))return null;const r=(d.n*d.sd*d.sd+l.n*l.sd*l.sd)/(d.n+l.n);return r>0?(d.mean-l.mean)/Math.sqrt(r):null}function P(d,l){const r=L(d,l),{n:t,mean:i,m2:s}=X(r),n=t>0?Math.sqrt(s/t):0;return{mean:i,sd:n,n:t}}function O(d,l,r,t){return Y(d,l)&&Y(r,t)}function b(d,l,r,t){if(O(d,l,r,t)){const u=P(d,l),o=P(r,t),a=G(u,o);return{measure:z.numeric,magnitude:a,distance:a===null?0:Z(a),direction:a===null?0:Math.sign(a),nA:u.n,nB:o.n,reliable:u.n>=B&&o.n>=B}}const i=D(d,l),s=D(r,t),n=F(i.map,i.total,s.map,s.total);return{measure:z.categorical,magnitude:n,distance:n===null?0:n,direction:0,nA:i.total,nB:s.total,reliable:i.total>=B&&s.total>=B}}function c(d,l,r={}){const t=new Set(d.columns),i=new Set(l.columns),s=d.columns.filter(f=>i.has(f)),n=Array.isArray(r.columns)&&r.columns.length?s.filter(f=>r.columns.includes(f)):s,u=d.indices(),o=l.indices(),a=[];for(const f of n){const w=d.handle(f),m=l.handle(f);if(!w||!m)continue;const v=b(w,u,m,o);a.push({column:f,name:d.name&&d.name(f)||l.name&&l.name(f)||f,measure:v.measure,magnitude:v.magnitude,distance:v.distance,direction:v.direction,nA:v.nA,nB:v.nB,reliable:v.reliable})}return a.sort((f,w)=>w.distance-f.distance||Math.abs(w.magnitude||0)-Math.abs(f.magnitude||0)),{ranked:a,nA:u.length,nB:o.length,unmatched:{onlyA:d.columns.filter(f=>!i.has(f)),onlyB:l.columns.filter(f=>!t.has(f))},measures:z}}}),Be("packages/core/src/compute/anomaly.js",function(e,H){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return u}});const L=H("packages/core/src/compute/statistics.js").quantileSorted,D=H("packages/core/src/compute/special.js").logGamma,F=.6745,Z=3.5,Y=1.5,B=.975,z=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function G(o){if(!o.length)return null;const f=Array.from(o,Number).sort((h,p)=>h-p),w=L(f,.5),m=f.map(h=>Math.abs(h-w)).sort((h,p)=>h-p),v=L(m,.5);return{median:w,mad:v}}function P(o,a={}){const f=Number.isFinite(a.threshold)?a.threshold:Z,w=o.length,m=new Array(w).fill(null),v=new Array(w).fill(!1),h=[];for(let k=0;k<w;k++){const y=Number(o[k]);Number.isFinite(y)&&h.push(y)}if(!h.length)return{median:null,mad:null,threshold:f,scores:m,flags:v,flagged:0};const p=G(h);if(p.mad===0)return{median:p.median,mad:0,threshold:f,scores:m,flags:v,flagged:0};let g=0;for(let k=0;k<w;k++){const y=Number(o[k]);if(!Number.isFinite(y))continue;const T=F*(y-p.median)/p.mad;m[k]=T,Math.abs(T)>f&&(v[k]=!0,g++)}return{median:p.median,mad:p.mad,threshold:f,scores:m,flags:v,flagged:g}}function O(o,a={}){const f=Number.isFinite(a.k)?a.k:Y,w=[];for(let g=0;g<o.length;g++){const k=Number(o[g]);Number.isFinite(k)&&w.push(k)}if(!w.length)return null;const m=w.sort((g,k)=>g-k),v=L(m,.25),h=L(m,.75),p=h-v;return{q1:v,q3:h,iqr:p,lower:v-f*p,upper:h+f*p,k:f}}function b(o,a){if(a<=0)return 0;const f=D(o);if(a<o+1){let k=o,y=1/o,T=y;for(let j=0;j<1e3&&(k+=1,T*=a/k,y+=T,!(Math.abs(T)<Math.abs(y)*1e-15));j++);return y*Math.exp(-a+o*Math.log(a)-f)}const w=1e-300;let m=a+1-o,v=1/w,h=1/m,p=h;for(let k=1;k<1e3;k++){const y=-k*(k-o);m+=2,h=y*h+m,Math.abs(h)<w&&(h=w),v=m+y/v,Math.abs(v)<w&&(v=w),h=1/h;const T=h*v;if(p*=T,Math.abs(T-1)<1e-15)break}return 1-Math.exp(-a+o*Math.log(a)-f)*p}function c(o,a){return o<=0?0:b(a/2,o/2)}function d(o,a=B){if(!(a>0)||!(a<1))return NaN;let f=0,w=Math.max(1,o);for(;c(w,o)<a;)w*=2;for(let m=0;m<200;m++){const v=(f+w)/2;if(c(v,o)<a?f=v:w=v,w-f<1e-10)break}return(f+w)/2}function l(o){const a=o.length,f=o.map((w,m)=>{const v=w.slice();for(let h=0;h<a;h++)v.push(m===h?1:0);return v});for(let w=0;w<a;w++){let m=w;for(let h=w+1;h<a;h++)Math.abs(f[h][w])>Math.abs(f[m][w])&&(m=h);if(Math.abs(f[m][w])<1e-12)return null;if(m!==w){const h=f[m];f[m]=f[w],f[w]=h}const v=f[w][w];for(let h=0;h<2*a;h++)f[w][h]/=v;for(let h=0;h<a;h++){if(h===w)continue;const p=f[h][w];if(p!==0)for(let g=0;g<2*a;g++)f[h][g]-=p*f[w][g]}}return f.map(w=>w.slice(a))}function r(o,a){const f=o.length,w=new Array(a).fill(0);for(const h of o)for(let p=0;p<a;p++)w[p]+=h[p];for(let h=0;h<a;h++)w[h]/=f;const m=Array.from({length:a},()=>new Array(a).fill(0));for(const h of o)for(let p=0;p<a;p++){const g=h[p]-w[p];for(let k=p;k<a;k++)m[p][k]+=g*(h[k]-w[k])}const v=f>1?f-1:1;for(let h=0;h<a;h++)for(let p=h;p<a;p++)m[h][p]/=v,m[p][h]=m[h][p];return{mean:w,cov:m}}function t(o,a={}){const f=Number.isFinite(a.p)?a.p:B,w=Number.isFinite(a.ridge)?a.ridge:1e-6,m=o.length;if(!m)return null;const v=o[0].length;if(!v)return null;const h=new Array(m).fill(null),p=new Array(m).fill(null),g=new Array(m).fill(!1),k=[],y=[];for(let $=0;$<m;$++){const I=o[$];let M=I.length===v;const S=new Array(v);for(let E=0;M&&E<v;E++){const U=Number(I[E]);Number.isFinite(U)?S[E]=U:M=!1}M&&(k.push($),y.push(S))}const T=v,j=d(T,f);if(y.length<=v)return{center:[],df:T,cutoff:j,singular:!0,used:y.length,distances:h,squared:p,flags:g,flagged:0};const{mean:N,cov:W}=r(y,v);let R=l(W),x=!1;if(!R){x=!0;let $=0;for(let S=0;S<v;S++)$+=W[S][S];const I=$/v*w||w,M=W.map((S,E)=>S.map((U,K)=>E===K?U+I:U));if(R=l(M),!R)return{center:N,df:T,cutoff:j,singular:!0,used:y.length,distances:h,squared:p,flags:g,flagged:0}}let A=0;for(let $=0;$<y.length;$++){const I=y[$],M=new Array(v);for(let U=0;U<v;U++)M[U]=I[U]-N[U];let S=0;for(let U=0;U<v;U++){let K=0;for(let q=0;q<v;q++)K+=R[U][q]*M[q];S+=M[U]*K}S<0&&(S=0);const E=k[$];p[E]=S,h[E]=Math.sqrt(S),S>j&&(g[E]=!0,A++)}return{center:N,df:T,cutoff:j,singular:x,used:y.length,distances:h,squared:p,flags:g,flagged:A}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function n(o,a={}){const f=a.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",w=Number.isFinite(a.windowLen)&&a.windowLen>=1?Math.floor(a.windowLen):i,m=Number.isFinite(a.threshold)?a.threshold:Z,v=Number.isFinite(a.k)?a.k:Y,h=Number.isFinite(a.minPeriods)&&a.minPeriods>=1?Math.floor(a.minPeriods):w,p=o.length,g=new Array(p).fill(null),k=new Array(p).fill(!1);let y=0;for(let T=0;T<p;T++){const j=Number(o[T]);if(!Number.isFinite(j))continue;const N=Math.max(0,T-w+1),W=[];for(let R=N;R<=T;R++){const x=Number(o[R]);Number.isFinite(x)&&W.push(x)}if(!(W.length<h))if(f==="rollingIqr"){const R=O(W,{k:v});if(!R)continue;(j<R.lower||j>R.upper)&&(k[T]=!0,y++)}else{const R=G(W);if(!R||R.mad===0)continue;const x=F*(j-R.median)/R.mad;g[T]=x,Math.abs(x)>m&&(k[T]=!0,y++)}}return{method:f,windowLen:w,minPeriods:h,threshold:m,k:v,scores:g,flags:k,flagged:y}}function u(o={}){const a=o||{},f=a.field;if(typeof f!="string"||!f)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const w=a.method||"modifiedZScore";if(!(z.includes(w)||s.includes(w))||w==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${w}'`);const v=typeof a.orderBy=="string"?a.orderBy:null,h=a.latest===!0,p=s.includes(w),g=k=>Number(k==null?NaN:k[f]);return k=>{const y=Array.isArray(k)?k.slice():[...k];v&&y.sort((R,x)=>{const A=R?.[v],$=x?.[v];return A===$?0:A==null?-1:$==null?1:A<$?-1:1});const T=y.map(g);let j,N;if(p)({flags:j,scores:N}=n(T,{method:w,windowLen:a.windowLen,threshold:a.threshold,k:a.k,minPeriods:a.minPeriods}));else if(w==="iqr"){const R=O(T,{k:a.k});j=T.map(x=>R?Number.isFinite(x)&&(x<R.lower||x>R.upper):!1),N=T.map(()=>null)}else({flags:j,scores:N}=P(T,{threshold:a.threshold}));if(h){const R=j.length-1;return R<0||!j[R]?!1:{method:w,field:f,flagged:[{row:y[R],score:N[R]}]}}const W=[];for(let R=0;R<j.length;R++)j[R]&&W.push({row:y[R],score:N[R]});return W.length?{method:w,field:f,flagged:W}:!1}}}),Be("packages/core/src/compute/forecast.js",function(e,H){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const te=H("packages/core/src/compute/special.js"),L=te.normalQuantile,X=te.studentTQuantile,F=H("packages/core/src/internal/warn.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),Y=1e-4,B=1-1e-4;function z(a){const f=[];for(let w=0;w<a.length;w++){const m=a[w];if(m!==null&&typeof m=="object"){const v=Number.isFinite(m.at)?m.at:w,h=Number.isFinite(m.value)?m.value:null;f.push({at:v,value:h})}else f.push({at:w,value:Number.isFinite(m)?Number(m):null})}return f}function G(a){const f=a.filter(p=>p.value!==null),w=f[0],m=f[f.length-1],v=m.at-w.at,h=f.length>1&&v>0?v/(f.length-1):1;return{lastAt:m.at,step:h}}function P(a){return Math.min(B,Math.max(Y,a))}function O(a,f=Y,w=B,m=80){const v=(Math.sqrt(5)-1)/2;let h=f,p=w,g=p-v*(p-h),k=h+v*(p-h),y=a(g),T=a(k);for(let j=0;j<m;j++)y<T?(p=k,k=g,T=y,g=p-v*(p-h),y=a(g)):(h=g,g=k,y=T,k=h+v*(p-h),T=a(k));return(h+p)/2}function b(a,f){let w=null,m=0,v=0;for(let h=0;h<a.length;h++){const p=a[h];if(p!==null){if(w===null){w=p;continue}m+=(p-w)**2,v+=1,w=f*p+(1-f)*w}}return{level:w,sse:m,m:v}}function c(a,f,w){let m=null,v=null,h=0,p=0;for(let g=0;g<a.length;g++){const k=a[g];if(k===null){m!==null&&v!==null&&(m+=v);continue}if(m===null){m=k;continue}v===null&&(v=k-m);const y=m+v;h+=(k-y)**2,p+=1;const T=m;m=f*k+(1-f)*(T+v),v=w*(m-T)+(1-w)*v}return{level:m,trend:v,sse:h,m:p}}function d(a,f,w,m,v){const h=a.length;if(h<2*f)return null;const p=x=>{let A=0,$=0;for(let I=x;I<x+f&&I<h;I++)a[I]!==null&&(A+=a[I],$+=1);return $?A/$:null},g=p(0),k=p(f);if(g===null||k===null)return null;let y=g,T=(k-g)/f;const j=new Array(f).fill(0);for(let x=0;x<f;x++)j[x]=a[x]===null?0:a[x]-y;const N=j.reduce((x,A)=>x+A,0)/f;for(let x=0;x<f;x++)j[x]-=N;let W=0,R=0;for(let x=f;x<h;x++){const A=x%f,$=j[A],I=a[x];if(I===null){y+=T;continue}const M=y+T+$;W+=(I-M)**2,R+=1;const S=y;y=w*(I-$)+(1-w)*(y+T),T=m*(y-S)+(1-m)*T,j[A]=v*(I-y)+(1-v)*$}return{level:y,trend:T,season:j,phase:(h-1)%f,sse:W,count:R}}function l(a,f,w){let m=1;for(const h of f)m+=h*h;const v=Math.sqrt(a*m);return{se:v,margin:w*v}}function r(a,f={}){if(!a||typeof a.length!="number"||a.length===0)return null;const w=Z.includes(f.method)?f.method:"linear",m=Math.max(1,Math.floor(Number(f.horizon)||1)),v=Number.isFinite(f.confidence)&&f.confidence>0&&f.confidence<1?f.confidence:.95,h=1-(1-v)/2,p=z(a),g=p.map(W=>W.value),k=g.filter(W=>W!==null),y=k.length,{lastAt:T,step:j}=y?G(p):{lastAt:0,step:1},N=W=>T+W*j;return w==="linear"?t(p,y,m,v,h,N):w==="movingAverage"?i(k,y,m,v,h,f,N):w==="ses"?s(g,y,m,v,h,f,N):w==="holt"?n(g,y,m,v,h,f,N):u(g,y,m,v,h,f,N)}function t(a,f,w,m,v,h){if(f<2)return null;let p=0,g=0;for(const I of a)I.value!==null&&(p+=I.at,g+=I.value);p/=f,g/=f;let k=0,y=0,T=0;for(const I of a){if(I.value===null)continue;const M=I.at-p,S=I.value-g;k+=M*M,y+=M*S,T+=S*S}if(k===0)return null;const j=y/k,N=g-j*p,W=T===0?1:Math.max(0,Math.min(1,y*y/(k*T))),R=Math.max(0,T-j*y),x=f>2?Math.sqrt(R/(f-2)):null,A=f>2?X(v,f-2):null,$=[];for(let I=1;I<=w;I++){const M=h(I),S=N+j*M;let E=null,U=null,K=null,q=null,_=null;if(x!==null){const J=1/f+(M-p)**2/k,ee=x*Math.sqrt(1+J),ne=x*Math.sqrt(J);_=ee,E=S-A*ee,U=S+A*ee,K=S-A*ne,q=S+A*ne}$.push({step:I,at:M,mean:S,lower:E,upper:U,lowerMean:K,upperMean:q,se:_})}return{method:"linear",horizon:w,confidence:m,n:f,sigma:x,r2:W,params:{slope:j,intercept:N},points:$}}function i(a,f,w,m,v,h,p){if(f<1)return null;const g=Math.max(1,Math.min(f,Math.floor(Number(h.windowLen)||f))),k=a.slice(f-g);let y=0;for(const x of k)y+=x;const T=y/g;let j=null,N=null;if(g>1){let x=0;for(const $ of k)x+=($-T)**2;j=Math.sqrt(x/(g-1))*Math.sqrt(1+1/g),N=X(v,g-1)}const W=j===null?null:N*j,R=[];for(let x=1;x<=w;x++)R.push({step:x,at:p(x),mean:T,lower:W===null?null:T-W,upper:W===null?null:T+W,se:j});return{method:"movingAverage",horizon:w,confidence:m,n:f,sigma:j===null?null:j,params:{windowLen:g},points:R}}function s(a,f,w,m,v,h,p){if(f<1)return null;let g=Number.isFinite(h.alpha)?P(h.alpha):null;g===null&&(g=O(N=>b(a,N).sse));const k=b(a,g),y=L(v),T=k.m>0?k.sse/k.m:null,j=[];for(let N=1;N<=w;N++){const W=k.level;let R=null,x=null,A=null;if(T!==null){const $=[];for(let M=1;M<N;M++)$.push(g);const I=l(T,$,y);A=I.se,R=W-I.margin,x=W+I.margin}j.push({step:N,at:p(N),mean:W,lower:R,upper:x,se:A})}return{method:"ses",horizon:w,confidence:m,n:f,sigma:T===null?null:Math.sqrt(T),params:{alpha:g},points:j}}function n(a,f,w,m,v,h,p){if(f<2)return null;let g=Number.isFinite(h.alpha)?P(h.alpha):null,k=Number.isFinite(h.beta)?P(h.beta):null;if(g===null||k===null){let R=g===null?.5:g,x=k===null?.5:k;for(let A=0;A<6;A++)g===null&&(R=O($=>c(a,$,x).sse)),k===null&&(x=O($=>c(a,R,$).sse));g=g===null?R:g,k=k===null?x:k}const y=c(a,g,k),T=L(v),j=y.m>0?y.sse/y.m:null,N=g*k,W=[];for(let R=1;R<=w;R++){const x=y.level+R*y.trend;let A=null,$=null,I=null;if(j!==null){const M=[];for(let E=1;E<R;E++)M.push(g+E*N);const S=l(j,M,T);I=S.se,A=x-S.margin,$=x+S.margin}W.push({step:R,at:p(R),mean:x,lower:A,upper:$,se:I})}return{method:"holt",horizon:w,confidence:m,n:f,sigma:j===null?null:Math.sqrt(j),params:{alpha:g,beta:k},points:W}}function u(a,f,w,m,v,h,p){const g=Math.floor(Number(h.period));if(!(g>=2))return F("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(f<2*g)return null;let k=Number.isFinite(h.alpha)?P(h.alpha):null,y=Number.isFinite(h.beta)?P(h.beta):null,T=Number.isFinite(h.gamma)?P(h.gamma):null;const j=(I,M,S)=>{const E=d(a,g,I,M,S);return E?E.sse:1/0};if(k===null||y===null||T===null){let I=k===null?.5:k,M=y===null?.5:y,S=T===null?.5:T;for(let E=0;E<8;E++)k===null&&(I=O(U=>j(U,M,S))),y===null&&(M=O(U=>j(I,U,S))),T===null&&(S=O(U=>j(I,M,U)));k=k===null?I:k,y=y===null?M:y,T=T===null?S:T}const N=d(a,g,k,y,T);if(!N)return null;const W=L(v),R=N.count>0?N.sse/N.count:null,x=k*y,A=T*(1-k),$=[];for(let I=1;I<=w;I++){const M=N.season[(N.phase+I)%g],S=N.level+I*N.trend+M;let E=null,U=null,K=null;if(R!==null){const q=[];for(let J=1;J<I;J++)q.push(k+J*x+(J%g===0?A:0));const _=l(R,q,W);K=_.se,E=S-_.margin,U=S+_.margin}$.push({step:I,at:p(I),mean:S,lower:E,upper:U,se:K})}return{method:"holtWinters",horizon:w,confidence:m,n:f,sigma:R===null?null:Math.sqrt(R),params:{alpha:k,beta:y,gamma:T,period:g},points:$}}const o={FORECAST_METHODS:Z,forecast:r}}),Be("packages/core/src/compute/hypothesis.js",function(e,H){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return W}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/compute/handle.js").valueReader,F=H("packages/core/src/compute/statistics.js"),Z=F.numbers,Y=F.moments,B=F.frequencyMap,z=F.categoricalDistance,G=F.isNumericColumn,P=F.jarqueBera,O=F.proportionInterval,b=F.SUBSET_RELIABILITY_FLOOR,d=H("packages/core/src/compute/compare.js").pooledStandardMeanDifference,l=H("packages/core/src/compute/special.js"),r=l.studentT,t=l.studentTQuantile,i=l.normalCdf,s=l.normalQuantile,n=l.chiSquareUpperTail,u=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),o=.05,a=2e6;function f(R){const x=Number(R);return Number.isFinite(x)&&x>0&&x<1?x:.95}function w(R){const{n:x,mean:A,m2:$}=Y(R);return{mean:A,sd:x>0?Math.sqrt($/x):0,n:x}}function m(R,x){const A=R.length;if(A<2)return 0;let $=0;for(let I=0;I<A;I++){const M=R[I]-x;$+=M*M}return $/(A-1)}function v(R,x){return{name:"pooledStandardMeanDifference",value:d(w(R),w(x))}}function h(R,x,A){const $=R.length,I=x.length;if($<2||I<2)return null;const M=f(A),{mean:S}=Y(R),{mean:E}=Y(x),U=m(R,S),K=m(x,E),q=U/$+K/I;if(!(q>0))return null;const _=Math.sqrt(q),J=(S-E)/_,ee=U/$*(U/$)/($-1),ne=K/I*(K/I)/(I-1),oe=q*q/(ee+ne),ie=Math.min(1,Math.max(0,2*(1-r(Math.abs(J),oe)))),ae=S-E,ce=t(1-(1-M)/2,oe)*_;return{test:u.WELCH,statistic:J,statisticName:"t",df:oe,pValue:ie,interval:{estimate:ae,lower:ae-ce,upper:ae+ce,confidence:M,method:"welch-t (difference of means)"},effectSize:v(R,x),nA:$,nB:I,reliable:$>=b&&I>=b,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function p(R){const x=R.length;if(x===0)return Number.NaN;const A=x>>1;return x%2?R[A]:(R[A-1]+R[A])/2}function g(R,x,A){const $=R.length,I=x.length,M=$*I;if(M===0||M>a)return null;const S=new Float64Array(M);let E=0;for(let ee=0;ee<$;ee++)for(let ne=0;ne<I;ne++)S[E++]=R[ee]-x[ne];S.sort();const U=p(S),K=Math.sqrt($*I*($+I+1)/12),q=s(1-(1-A)/2);let _=Math.round(M/2-q*K);_>=0||(_=0);const J=Math.floor((M-1)/2);return _>J&&(_=J),{estimate:U,lower:S[_],upper:S[M-1-_],confidence:A,method:"hodges-lehmann (normal approximation)"}}function k(R,x,A){const $=R.length,I=x.length;if($<1||I<1)return null;const M=f(A),S=$+I,E=new Array(S);for(let ie=0;ie<$;ie++)E[ie]={v:R[ie],g:0};for(let ie=0;ie<I;ie++)E[$+ie]={v:x[ie],g:1};E.sort((ie,ae)=>ie.v-ae.v);let U=0,K=0,q=0;for(;q<S;){let ie=q;for(;ie<S&&E[ie].v===E[q].v;)ie++;const ae=ie-q,ce=(q+1+ie)/2;for(let de=q;de<ie;de++)E[de].g===0&&(U+=ce);K+=ae*ae*ae-ae,q=ie}const _=U-$*($+1)/2,J=$*I/2,ee=$*I/12*(S+1-K/(S*(S-1)));let ne=1;if(ee>0){const ie=Math.max(0,Math.abs(_-J)-.5);ne=Math.min(1,2*i(-ie/Math.sqrt(ee)))}const oe=g(R,x,M);return{test:u.MANN_WHITNEY,statistic:_,statisticName:"U",df:null,pValue:ne,interval:oe,effectSize:v(R,x),nA:$,nB:I,reliable:$>=b&&I>=b,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function y(R,x,A,$,I){const M=O(R,x,I),S=O(A,$,I);if(!M||!S)return null;const E=M.proportion-S.proportion,U=E-Math.sqrt((M.proportion-M.lower)**2+(S.upper-S.proportion)**2),K=E+Math.sqrt((M.upper-M.proportion)**2+(S.proportion-S.lower)**2);return{lower:U,upper:K}}function T(R,x,A,$,I,M={}){if(!(x>0)||!($>0))return null;const S=new Set([...R.keys(),...A.keys()]),E=S.size;if(E<2)return null;const U=x+$;let K=0;for(const ne of S){const oe=R.get(ne)||0,ie=A.get(ne)||0,ae=oe+ie,ce=x*ae/U,de=$*ae/U;ce>0&&(K+=(oe-ce)*(oe-ce)/ce),de>0&&(K+=(ie-de)*(ie-de)/de)}const q=E-1,_=n(K,q);let J=null;M.category!==void 0&&S.has(M.category)?J=M.category:E===2&&([J]=[...S]);let ee=null;if(J!==null){const ne=y(R.get(J)||0,x,A.get(J)||0,$,f(I));ne&&(ee={estimate:(R.get(J)||0)/x-(A.get(J)||0)/$,lower:ne.lower,upper:ne.upper,confidence:f(I),method:"newcombe (difference in this category's share)",category:J})}return{test:u.CHI_SQUARE,statistic:K,statisticName:"chiSquare",df:q,pValue:_,interval:ee,effectSize:{name:"categoricalTotalVariation",value:z(R,x,A,$)},nA:x,nB:$,reliable:x>=b&&$>=b,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function j(R){return R==null||R===""||typeof R=="number"&&Number.isNaN(R)?null:R instanceof Date?R.getTime():typeof R=="object"?String(R):R}function N(R,x,A){if(A===u.WELCH||A===u.MANN_WHITNEY)return{test:A,chosenBy:"override",reason:`caller override: ${A}`};const $=P(R),I=P(x),M=$===null?null:Math.exp(-$/2),S=I===null?null:Math.exp(-I/2);return M!==null&&M<o||S!==null&&S<o?{test:u.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${o})`}:{test:u.WELCH,chosenBy:"auto",reason:M!==null||S!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function W(R,x,A,$={}){if(!R||!x)return null;const I=f($.confidence),M=D(x);let S;if(Array.isArray($.groups)&&$.groups.length===2)S=[j($.groups[0]),j($.groups[1])];else{const{map:ie}=B(x,A),ae=[...ie.entries()].sort((ce,de)=>de[1]-ce[1]).slice(0,2).map(ce=>ce[0]);if(ae.length<2)return L("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;S=ae}const[E,U]=S;if(E===null||U===null||E===U)return L("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const K=[],q=[];for(let ie=0;ie<A.length;ie++){const ae=j(M(A[ie]));ae===E?K.push(A[ie]):ae===U&&q.push(A[ie])}if(K.length===0||q.length===0)return L("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const _=$.test&&$.test!=="auto"?String($.test):null,J=G(R,K.concat(q));let ee,ne,oe;if(_===u.CHI_SQUARE||!_&&!J){ne=_?"override":"auto",oe=_?"caller override: chiSquare":"column family: categorical";const ie=B(R,K),ae=B(R,q);ee=T(ie.map,ie.total,ae.map,ae.total,I,{category:$.category})}else{if((_===u.WELCH||_===u.MANN_WHITNEY)&&!J)return L("compareGroups:numeric-override",`[lattice] compareGroups: ${_} needs a numeric column, but the column is not numeric.`),null;const ie=Z(R,K),ae=Z(R,q),ce=N(ie,ae,_);ne=ce.chosenBy,oe=ce.reason,ee=ce.test===u.MANN_WHITNEY?k(ie,ae,I):h(ie,ae,I)}return ee?{...ee,chosenBy:ne,reason:oe,groups:[E,U]}:(L("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Be("packages/core/src/columns/detailcolumn.js",function(e,H){"use strict";Object.defineProperty(e,"DETAIL_COLUMN_ID",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"createDetailColumn",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const te="__lattice_detail",L=36;function X(F){const Z=F.config&&F.config.detailColumnWidth||L;return{id:te,field:null,title:"",type:"text",dataType:{base:"text"},nullable:!0,align:"center",generated:!0,control:!0,detailExpander:!0,value:{pure:!0},cell:{render:"detailExpander",align:"center"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:Z,min:Z,max:Z,pin:F.config&&F.config.detailColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(Y,B){return!!(B&&B.expanded)},formatValue(){return""}}}const D=X}),Be("packages/core/src/columns/treecolumn.js",function(e,H){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isFunction,X="__lattice_tree",D=260;function F(Y){const B=Y.tree||{},z=Y.config&&Y.config.treeColumnWidth||D,G=()=>(Y.columns&&L(Y.columns.visible)?Y.columns.visible():[]).find(c=>!c.generated)||null,P=(b,c)=>{if(c&&c.group)return c.groupValue;if(L(B.label))return B.label(b,c);if(typeof B.label=="string")return b==null?null:b[B.label];const d=G();return d&&L(d.getValue)?d.getValue(b,c):null},O=()=>{if(B.title)return B.title;const b=typeof B.label=="string"?Y.columns&&L(Y.columns.get)?Y.columns.get(B.label):null:G();return b&&(b.title||b.id)||"Hierarchy"};return{id:X,get title(){return O()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:z,min:140,pin:Y.config&&Y.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(b,c){return P(b,c)},formatValue(b,c){if(c&&c.grandTotal)return Y.config&&Y.config.grandTotalLabel||"Total";if(b==null)return"";if(!B.label){const d=G();if(d&&L(d.formatValue))return d.formatValue(b,c)}return String(b)}}}const Z=F}),Be("packages/core/src/columns/pivotcolumns.js",function(e,H){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return F}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="__lattice_pivot",D=500;function F(z){const{pivot:G,valueColumns:P,config:O}=z,b=G&&G.paths||[],c=z.separator||O&&O.pivot&&O.pivot.separator||" | ",d=O&&O.pivot&&O.pivot.maxColumns||D;if(!b.length||!P.length)return{tree:[],leaves:[],error:null};const l=Z(O),r=b.length*P.length+(l?P.length:0);if(r>d){const s=`pivot would generate ${r} columns, above the limit of ${d}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return L(`pivot.maxColumns:${r}`,s),{tree:[],leaves:[],error:s}}const t=[],i=[];for(const s of b){const n=[];for(const u of P){const o=B(s,u,c);n.push(o),i.push(o)}n.length===1?(n[0].title=String(s),t.push(n[0])):t.push({id:`${X}:group:${s}`,title:String(s),columns:n,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(l){const s=P.map(u=>Y(u,O));i.push(...s);const n=O&&O.pivot&&O.pivot.totalsLabel||"Total";if(s.length===1)s[0].title=n,l==="before"?t.unshift(s[0]):t.push(s[0]);else{const u={id:`${X}:group:__totals`,title:n,columns:s,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};l==="before"?t.unshift(u):t.push(u)}}return{tree:t,leaves:i,error:null}}function Z(z){const G=z&&z.pivot&&z.pivot.groupTotals;return G==="before"||G==="after"?G:null}function Y(z,G){return{id:`${X}:__total${G&&G.pivot&&G.pivot.separator||" | "}${z.id}`,field:null,title:z.title||z.id,type:z.type,dataType:z.dataType,nullable:!0,align:z.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:z.id,total:!0},value:{pure:!0},cell:{align:z.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:z.total,lookup:null,layout:{width:z.layout&&z.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(P,O){const b=O&&O.totals;return b&&Object.hasOwn(b,z.id)?b[z.id]:null},formatValue(P,O){return P==null?"":z.formatValue?z.formatValue(P,O):String(P)}}}function B(z,G,P){return{id:`${X}:${z}${P}${G.id}`,field:null,title:G.title||G.id,type:G.type,dataType:G.dataType,nullable:!0,align:G.align,generated:!0,pivot:{enabled:!1,index:0,path:z,sourceId:G.id},value:{pure:!0},cell:{align:G.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:G.total,lookup:null,layout:{width:G.layout&&G.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(O,b){return O==null?"":G.formatValue?G.formatValue(O,b):String(O)}}}}),Be("packages/core/src/compute/group.js",function(e,H){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return O}});const te=H("packages/core/src/compute/handle.js"),L=te.dictSize,X=te.identity,D=te.presenceReader,F=te.rowCount,Z=te.valueReader,Y="",B="\0",z=1<<20;function G(b,c,d,l){const r=b.length,t=b.map(a=>Z(a)),i=Array.isArray(l)&&l.some(Boolean),s=i?t.map((a,f)=>l[f]?w=>l[f](a(w)):a):t;if(!i&&r>0&&b.every(a=>a&&a.kind==="dictionary"&&a.dict)){const a=b.map(w=>L(w.dict)+1);let f=1;for(let w=0;w<r;w++)f*=a[w];if(f<=Number.MAX_SAFE_INTEGER){const w=b.map(p=>p.values),m=b.map(p=>D(p)),v=p=>{let g=0;for(let k=0;k<r;k++){const y=m[k],T=y&&y(p)===0?a[k]-1:w[k][p];g=g*a[k]+T}return g},h=new Float64Array(d);for(let p=0;p<d;p++)h[p]=v(c[p]);return{packed:h,strings:null,product:f,readers:s,keyOf:v}}}const u=a=>{let f="";for(let w=0;w<r;w++){const m=s[w](a);f+=(w===0?"":Y)+(m==null?B:String(m))}return f},o=new Array(d);for(let a=0;a<d;a++)o[a]=u(c[a]);return{packed:null,strings:o,product:1/0,readers:s,keyOf:u}}function P(b,c,d,l){const r=new Uint32Array(l+1);for(let n=0;n<d;n++)r[c[n]+1]++;for(let n=0;n<l;n++)r[n+1]+=r[n];const t=new Uint32Array(d),i=r.slice(0,l);for(let n=0;n<d;n++)t[i[c[n]]++]=b[n];const s=new Array(l);for(let n=0;n<l;n++)s[n]=t.subarray(r[n],r[n+1]);return s}function O(b,c,d={}){const l=b||[],r=c||X(F(l[0],d)),t=r.length;if(l.length===0||t===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:n,readers:u}=G(l,r,t,d.project),o=new Uint32Array(t);let a=0,f=null;if(i&&n<=Math.max(1024,Math.min(z,t*4))){const h=n,p=new Int32Array(h).fill(-1);for(let g=0;g<t;g++)p[i[g]]=0;for(let g=0;g<h;g++)p[g]===0&&(p[g]=a++);for(let g=0;g<t;g++)o[g]=p[i[g]];f=new Float64Array(a);for(let g=0;g<h;g++)p[g]>=0&&(f[p[g]]=g)}else if(i){const h=new Map;for(let p=0;p<t;p++){const g=i[p];let k=h.get(g);k===void 0&&(k=a++,h.set(g,k)),o[p]=k}f=new Float64Array(a);for(const[p,g]of h)f[g]=p}else{const h=new Map;for(let p=0;p<t;p++){const g=s[p];let k=h.get(g);k===void 0&&(k=a++,h.set(g,k)),o[p]=k}}const w=P(r,o,t,a),m=new Array(a);for(let h=0;h<a;h++){const p=w[h][0],g=new Array(u.length);for(let k=0;k<u.length;k++)g[k]=u[k](p);m[h]=g}const v={keys:m,buckets:w};return f&&(v.packed=f),v}}),Be("packages/core/src/compute/pivot.js",function(e,H){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/compute/handle.js").valueComparator,Z=H("packages/core/src/compute/group.js").packKeys,B=H("packages/core/src/compute/total.js").total,z="|",G="/",P=2e3;function O(n,u,o){return`${n}${z}${u}${z}${o}`}function b(n,u){let o="";for(let a=0;a<n.length;a++){const f=n[a];o+=(a===0?"":u)+(f==null?"":String(f))}return o}function c(n,u,o={}){const a=o.separator||G,f=u.length,{keyOf:w,readers:m}=Z(n,u,0),v=new Map,h=[],p=[];for(let W=0;W<f;W++){const R=u[W],x=w(R);if(v.has(x))continue;v.set(x,h.length),p.push(x);const A=new Array(m.length);for(let $=0;$<m.length;$++)A[$]=m[$](R);h.push(A)}const g=D(o.locale),k=h.map((W,R)=>R);k.sort((W,R)=>{const x=h[W],A=h[R];for(let $=0;$<x.length;$++){const I=d(x[$],A[$],g);if(I!==0)return I}return W-R});const y=new Array(k.length),T=new Array(k.length),j=new Map;for(let W=0;W<k.length;W++){const R=k[W];y[W]=h[R],T[W]=b(h[R],a),j.set(p[R],W)}return{keys:y,paths:T,idOf:W=>{const R=j.get(w(W));return R===void 0?-1:R}}}function d(n,u,o){const a=n==null,f=u==null;return a||f?a&&f?0:a?1:-1:o(n,u)}function l(n){const u=n.values||n.totals||[];if(u.length&&typeof u[0]=="object"&&u[0]!==null)return u.filter(w=>w&&w.handle);const o=typeof n.handle=="function"?n.handle:null;if(!o)return u.length&&L("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const a=typeof n.totalOf=="function"?n.totalOf:null,f=[];for(const w of u){const m=o(w);m&&f.push({colId:w,handle:m,fn:a?a(w):"sum"})}return f}function r(n,u,o){if(Array.isArray(n)){const a=o||{};return{...a,pivotHandles:n,order:u||null,groups:a.groups||null}}return n||{}}function t(n,u,o){const a=r(n,u,o),f=a.separator||G,w=l(a),m=a.maxColumns===void 0?P:a.maxColumns,v=a.groups&&a.groups.buckets?a.groups:null,h=v?v.buckets:[a.order||new Uint32Array(0)],p=a.groupPaths||(v?v.keys.map(x=>b(x,f)):[""]),g=s(h),{keys:k,paths:y,idOf:T}=c(a.pivotHandles||[],g,a),j=y.length*Math.max(1,w.length),N=i(y,w,f);if(m&&j>m){const x=new Map;return{keys:k,paths:y,fields:N,groupPaths:p,columns:j,values:x,cells:x,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${j} columns, above pivot.maxColumns of ${m}. Narrow the pivot columns or raise the limit.`,columns:j,maxColumns:m}}}const W=new Map,R=y.length;for(let x=0;x<h.length;x++){const A=h[x],$=p[x]===void 0?"":p[x],I=A.length;if(I===0)continue;const M=new Int32Array(I),S=new Uint32Array(R+1);for(let K=0;K<I;K++){const q=T(A[K]);M[K]=q,q>=0&&S[q+1]++}for(let K=0;K<R;K++)S[K+1]+=S[K];const E=new Uint32Array(I),U=S.slice(0,R);for(let K=0;K<I;K++){const q=M[K];q>=0&&(E[U[q]++]=A[K])}for(let K=0;K<R;K++){const q=S[K],_=S[K+1];if(_===q)continue;const J=E.subarray(q,_);for(let ee=0;ee<w.length;ee++){const ne=w[ee],oe=B(ne.handle,J,ne.fn,a.totalContext||{locale:a.locale});W.set(O($,y[K],ne.colId),oe)}}}return{keys:k,paths:y,fields:N,groupPaths:p,columns:j,values:W,cells:W,error:null}}function i(n,u,o){if(u.length===0)return n.slice();const a=[];for(const f of n)for(const w of u)a.push(`${f}${o}${w.colId}`);return a}function s(n){if(n.length===1)return n[0]||new Uint32Array(0);let u=0;for(const f of n)u+=f?f.length:0;const o=new Uint32Array(u);let a=0;for(const f of n)!f||f.length===0||(o.set(f,a),a+=f.length);return o}}),Be("packages/core/src/store/bitset.js",function(e,H){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return L}});const te=8;class L{static#e=new Uint8Array(256);static{for(let D=1;D<256;D++)L.#e[D]=L.#e[D>>1]+(D&1)}#t;#n;constructor(D=0){const F=Math.max(0,D|0);this.#n=F,this.#t=new Uint8Array(Math.ceil(F/te))}get size(){return this.#n}get words(){return this.#t}get bytes(){return this.#t?this.#t.byteLength:0}get(D){return D<0||D>=this.#n?0:this.#t[D>>3]>>(D&7)&1}set(D){return D>=0&&D<this.#n&&(this.#t[D>>3]|=1<<(D&7)),this}clear(D){return D>=0&&D<this.#n&&(this.#t[D>>3]&=~(1<<(D&7))),this}assign(D,F){return F?this.set(D):this.clear(D)}fill(D=!1){return this.#t.fill(D?255:0),D&&this.#r(),this}grow(D){const F=Math.max(0,D|0);if(F<=this.#n)return this;const Z=Math.ceil(F/te);if(Z>this.#t.length){const Y=new Uint8Array(Z);Y.set(this.#t),this.#t=Y}return this.#n=F,this}count(){const D=this.#t,F=L.#e;let Z=0;for(let Y=0;Y<D.length;Y++)Z+=F[D[Y]];return Z}and(D){const F=D instanceof L?D.words:D,Z=this.#t,Y=Math.min(Z.length,F.length);for(let B=0;B<Y;B++)Z[B]&=F[B];for(let B=Y;B<Z.length;B++)Z[B]=0;return this}or(D){const F=D instanceof L?D.words:D,Z=this.#t,Y=Math.min(Z.length,F.length);for(let B=0;B<Y;B++)Z[B]|=F[B];return this}not(){const D=this.#t;for(let F=0;F<D.length;F++)D[F]=~D[F]&255;return this.#r(),this}clone(){const D=new L(this.#n);return D.words.set(this.#t.subarray(0,D.words.length)),D}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const D=this.#n&7;if(D===0)return;const F=this.#n>>3;F<this.#t.length&&(this.#t[F]&=(1<<D)-1)}static from(D){const F=Array.isArray(D)?D:Array.from(D),Z=new L(F.length);for(let Y=0;Y<F.length;Y++)F[Y]&&Z.set(Y);return Z}}}),Be("packages/core/src/store/dictionary.js",function(e,H){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D}});const te=H("packages/core/src/internal/compare.js"),L=te.collator,X=te.defaultCompare;class D{#e;#t=new Map;#n=0;#r=null;#s=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let Y=0;Y<Z.length;Y++){const B=Z[Y];this.#t.has(B)||(this.#t.set(B,this.#e.length),this.#e.push(B))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let Y=0;Y<this.#e.length;Y++){const B=this.#e[Y];typeof B=="string"&&(Z+=B.length*2),Z+=16}return Z}codeOf(Z){const Y=this.#t.get(Z);if(Y!==void 0)return Y;const B=this.#e.length;return this.#e.push(Z),this.#t.set(Z,B),this.#n++,B}lookup(Z){const Y=this.#t.get(Z);return Y===void 0?-1:Y}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const Y=Z||"";if(this.#r&&this.#s===this.#n&&this.#i===Y)return this.#r;const B=this.#e.length,z=new Array(B);for(let b=0;b<B;b++)z[b]=b;const G=L(Z).compare,P=this.#e;z.sort((b,c)=>this.#o(P[b],P[c],G));const O=new Uint32Array(B);for(let b=0;b<B;b++)O[z[b]]=b;return this.#r=O,this.#s=this.#n,this.#i=Y,O}#o(Z,Y,B){return typeof Z=="string"&&typeof Y=="string"?B(Z,Y):X(Z,Y)}}}),Be("packages/core/src/store/multivalue.js",function(e,H){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return te}});class te{#e;#t;#n=0;#r=0;constructor(X={}){const D=Math.max(1,X.rows??16),F=Math.max(1,X.values??D);this.#e=new Int32Array(F),this.#t=new Uint32Array(D+1)}get values(){return this.#e}get offsets(){return this.#t}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#e.byteLength+this.#t.byteLength}count(X){return X<0||X>=this.#n?0:this.#t[X+1]-this.#t[X]}at(X){return X<0||X>=this.#n?this.#e.subarray(0,0):this.#e.subarray(this.#t[X],this.#t[X+1])}has(X,D){if(X<0||X>=this.#n)return!1;const F=this.#e,Z=this.#t[X+1];for(let Y=this.#t[X];Y<Z;Y++)if(F[Y]===D)return!0;return!1}hasAny(X,D){for(let F=0;F<D.length;F++)if(this.has(X,D[F]))return!0;return!1}hasAll(X,D){for(let F=0;F<D.length;F++)if(!this.has(X,D[F]))return!1;return!0}hasNone(X,D){return!this.hasAny(X,D)}push(X){const D=this.#n,F=X.length;this.#s(D+1),this.#i(this.#r+F);const Z=this.#r;for(let Y=0;Y<F;Y++)this.#e[Z+Y]=X[Y]|0;return this.#r+=F,this.#n=D+1,this.#t[D]=Z,this.#t[D+1]=this.#r,D}write(X,D){if(X===this.#n){this.push(D);return}if(X<0||X>this.#n)return;const F=this.#t[X],Z=this.#t[X+1],Y=D.length;if(Z-F===Y){for(let B=0;B<Y;B++)this.#e[F+B]=D[B]|0;return}this.#o(X,D)}compact(X,D,F){const Z=this.#e,Y=this.#t,B=this.#n,z=new Int32Array(Math.max(1,this.#r)),G=new Uint32Array(D+1);let P=0;for(let O=0;O<B;O++){if(X[O]===F)continue;const b=Y[O],c=Y[O+1];G[X[O]]=P;for(let d=b;d<c;d++)z[P++]=Z[d];G[X[O]+1]=P}this.#e=z,this.#t=G,this.#n=D,this.#r=P}release(){this.#e=new Int32Array(0),this.#t=new Uint32Array(1),this.#n=0,this.#r=0}#s(X){if(X+1<=this.#t.length)return;let D=this.#t.length-1;for(;D<X;)D=D*2||16;const F=new Uint32Array(D+1);F.set(this.#t),this.#t=F}#i(X){if(X<=this.#e.length)return;let D=this.#e.length;for(;D<X;)D=D*2||16;const F=new Int32Array(D);F.set(this.#e),this.#e=F}#o(X,D){const F=this.#e,Z=this.#t,Y=this.#n,B=D.length-(Z[X+1]-Z[X]),z=new Int32Array(Math.max(1,this.#r+B)),G=new Uint32Array(Z.length);let P=0;for(let O=0;O<Y;O++){if(G[O]=P,O===X)for(let b=0;b<D.length;b++)z[P++]=D[b]|0;else for(let b=Z[O];b<Z[O+1];b++)z[P++]=F[b];G[O+1]=P}this.#e=z,this.#t=G,this.#r=P}}}),Be("packages/core/src/compute/sort.js",function(e,H){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return R}});const te=H("packages/core/src/compute/handle.js"),L=te.bitReader,X=te.dictRanks,D=te.dictSize,F=te.identity,Z=te.isMissing,Y=te.presenceReader,B=te.rowCount,z=te.valueComparator,G=te.valueReader,P=new Uint32Array(0),O=new ArrayBuffer(8),b=new Float64Array(O),c=new Uint32Array(O),d=(b[0]=-1,(c[1]&2147483648)!==0?1:0),l=d===1?0:1;function r(A,$){b[0]=A;let I=c[d],M=c[l];(I&2147483648)!==0?(I=~I>>>0,M=~M>>>0):I=(I^2147483648)>>>0,$[0]=M,$[1]=I}function t(A,$,I,M){if(M<2)return A;const S=new Uint32Array(256*8);for(let ne=0;ne<M;ne++){const oe=$[ne],ie=I[ne];S[oe&255]++,S[256+(oe>>>8&255)]++,S[512+(oe>>>16&255)]++,S[768+(oe>>>24&255)]++,S[1024+(ie&255)]++,S[1280+(ie>>>8&255)]++,S[1536+(ie>>>16&255)]++,S[1792+(ie>>>24&255)]++}let E=A,U=$,K=I,q=new Uint32Array(M),_=new Uint32Array(M),J=new Uint32Array(M);const ee=new Uint32Array(256);for(let ne=0;ne<8;ne++){const oe=ne<<8,ie=(ne&3)<<3,ae=ne>=4;let ce=!1;for(let je=0;je<256;je++)if(S[oe+je]===M){ce=!0;break}if(ce)continue;let de=0;for(let je=0;je<256;je++)ee[je]=de,de+=S[oe+je];for(let je=0;je<M;je++){const be=U[je],re=K[je],fe=(ae?re:be)>>>ie&255,pe=ee[fe]++;q[pe]=E[je],_[pe]=be,J[pe]=re}let Ae=E;E=q,q=Ae,Ae=U,U=_,_=Ae,Ae=K,K=J,J=Ae}return E}function i(A,$,I){if(I<2)return A;const M=new Uint32Array(256*4);for(let _=0;_<I;_++){const J=$[_];M[J&255]++,M[256+(J>>>8&255)]++,M[512+(J>>>16&255)]++,M[768+(J>>>24&255)]++}let S=A,E=$,U=new Uint32Array(I),K=new Uint32Array(I);const q=new Uint32Array(256);for(let _=0;_<4;_++){const J=_<<8,ee=_<<3;let ne=!1;for(let ae=0;ae<256;ae++)if(M[J+ae]===I){ne=!0;break}if(ne)continue;let oe=0;for(let ae=0;ae<256;ae++)q[ae]=oe,oe+=M[J+ae];for(let ae=0;ae<I;ae++){const ce=E[ae],de=q[ce>>>ee&255]++;U[de]=S[ae],K[de]=ce}let ie=S;S=U,U=ie,ie=E,E=K,K=ie}return S}function s(A,$,I,M){const S=new Uint32Array(M+1);for(let K=0;K<I;K++)S[$[K]]++;let E=0;for(let K=0;K<=M;K++){const q=S[K];S[K]=E,E+=q}const U=new Uint32Array(I);for(let K=0;K<I;K++)U[S[$[K]]++]=A[K];return U}function n(A,$,I,M){return I<2?A:M<=65536||M<=I*2?s(A,$,I,M):i(A,$,I)}function u(A,$){return A.length===$&&A.byteOffset===0?A:Uint32Array.prototype.slice.call(A,0,$)}function o(A,$,I=!1){const M=$||F(A.length),S=M.length;if(S<2)return Uint32Array.from(M);const E=new Uint32Array(S),U=new Uint32Array(S),K=new Uint32Array(S),q=new Uint32Array(S),_=new Uint32Array(2);let J=0,ee=0;for(let ie=0;ie<S;ie++){const ae=M[ie],ce=A[ae];if(Number.isNaN(ce)){q[ee++]=ae;continue}r(ce,_),I?(U[J]=~_[0]>>>0,K[J]=~_[1]>>>0):(U[J]=_[0],K[J]=_[1]),E[J++]=ae}const ne=t(E.subarray(0,J),U.subarray(0,J),K.subarray(0,J),J);if(ee===0)return u(ne,J);const oe=new Uint32Array(S);return oe.set(ne.subarray(0,J),0),oe.set(q.subarray(0,ee),J),oe}function a(A,$,I=!1){const M=$||F(A.length),S=M.length;if(S<2)return Uint32Array.from(M);const E=Uint32Array.from(M),U=new Uint32Array(S);for(let K=0;K<S;K++){const q=(A[E[K]]^2147483648)>>>0;U[K]=I?~q>>>0:q}return u(i(E,U,S),S)}function f(A,$,I={}){const M=$||F(B(A,I)),S=M.length;if(S<2)return Uint32Array.from(M);const E=X(A.dict,I.locale),U=A.values,K=Y(A),q=Math.max(D(A.dict),E.length),_=q,J=Uint32Array.from(M),ee=new Uint32Array(S),ne=!!I.descending;for(let oe=0;oe<S;oe++){const ie=J[oe];let ae=K&&K(ie)===0?_:E[U[ie]];ae===void 0&&(ae=_),ee[oe]=ne?_-ae:ae}return u(n(J,ee,S,q+1),S)}function w(A,$,I){const M=$.length;let S=Uint32Array.from($);if(M<2)return S;let E=new Uint32Array(M);for(let U=1;U<M;U<<=1){for(let q=0;q<M;q+=U<<1){const _=Math.min(q+U,M),J=Math.min(q+(U<<1),M);let ee=q,ne=_,oe=q;for(;ee<_&&ne<J;)E[oe++]=I(A[S[ee]],A[S[ne]])<=0?S[ee++]:S[ne++];for(;ee<_;)E[oe++]=S[ee++];for(;ne<J;)E[oe++]=S[ne++]}const K=S;S=E,E=K}return S}function m(A,$,I){const M=L(A.values),S=$.length,E=new Uint32Array(S),U=I?1:0;let K=0;for(let q=0;q<S;q++)M($[q])===U&&(E[K++]=$[q]);for(let q=0;q<S;q++)M($[q])!==U&&(E[K++]=$[q]);return E}function v(A,$){const I=A.values,M=A.kind;if((M==="object"||M===void 0)&&(Array.isArray(I)||ArrayBuffer.isView(I))&&!A.presence)return I;const E=G(A),U=new Array(B(A)||0);for(let K=0;K<$.length;K++){const q=$[K];U[q]=E(q)}return U}function h(A,$){for(let I=0;I<$.length;I++)if(typeof A[$[I]]!="string")return!1;return!0}function p(A,$,I,M,S){const E=A.length,U=Uint32Array.from(A);if(E<2||M<1)return U;const K=new Uint32Array(E),q=M-1;for(let _=0;_<E;_++){const J=I[$[_]];K[_]=S?q-J:J}return u(n(U,K,E,M),E)}function g(A,$,I){const M=z(I),S=new Array($);for(let U=0;U<$;U++)S[U]=U;S.sort((U,K)=>M(A[U],A[K])||U-K);const E=new Uint32Array($);for(let U=0;U<$;U++)E[S[U]]=U;return E}function k(A,$,I){const M=$.length,S=new Map,E=[],U=new Uint32Array(M);for(let _=0;_<M;_++){const J=A[$[_]];let ee=S.get(J);ee===void 0&&(ee=E.length,S.set(J,ee),E.push(J)),U[_]=ee}const K=E.length,q=g(E,K,I.locale);return p($,U,q,K,!!I.descending)}function y(A,$,I){const M=v(A,$);if($.length>=2&&h(M,$)){const U=A.stringRank;return U&&U.version===A.version&&U.usable($,M,I.locale)?U.sort($,I):k(M,$,I)}const S=z(I.locale),E=I.descending?(U,K)=>S(K,U):S;return w(M,$,E)}function T(A,$,I){const M=v(A,$),S=I.compare,U=!!I.descending?(K,q)=>-S(K,q,void 0,void 0,!0):(K,q)=>S(K,q,void 0,void 0,!1);return w(M,$,U)}function j(A,$){const I=$.length,M=Y(A),S=A.values,E=A.kind==="float64"&&!!S,U=A.kind==="object"||A.kind==="multi"||A.kind===void 0;if(!M&&!E&&!U)return{present:$,absent:P};const K=new Uint32Array(I),q=new Uint32Array(I);let _=0,J=0;if(M&&E)for(let ee=0;ee<I;ee++){const ne=$[ee];M(ne)===1&&!Number.isNaN(S[ne])?K[_++]=ne:q[J++]=ne}else if(E&&!M)for(let ee=0;ee<I;ee++){const ne=$[ee];Number.isNaN(S[ne])?q[J++]=ne:K[_++]=ne}else if(M&&!U)for(let ee=0;ee<I;ee++){const ne=$[ee];M(ne)===1?K[_++]=ne:q[J++]=ne}else{const ee=G(A);for(let ne=0;ne<I;ne++){const oe=$[ne];Z(ee(oe))?q[J++]=oe:K[_++]=oe}}return J===0?{present:$,absent:P}:{present:K.subarray(0,_),absent:q.subarray(0,J)}}function N(A,$,I){if($.length===0)return A;const M=new Uint32Array(A.length+$.length);return I?(M.set($,0),M.set(A,$.length)):(M.set(A,0),M.set($,A.length)),M}function W(A,$,I={}){const M=$||F(B(A,I));if(!A||M.length<2)return Uint32Array.from(M);const{present:S,absent:E}=j(A,M);if(S.length===0)return Uint32Array.from(M);const U=!!I.descending;let K;if(typeof I.compare=="function")K=T(A,S,I);else switch(A.kind){case"float64":K=o(A.values,S,U);break;case"int32":K=a(A.values,S,U);break;case"dictionary":K=f(A,S,I);break;case"bitset":K=m(A,S,U);break;default:K=y(A,S,I);break}return N(K,E,!!I.nullsFirst)}function R(A,$,I,M={}){const S=$||[],E=S.length&&(S[0].handle||x(A,S[0].col))||A&&A[0];let U=I||F(B(E,M));for(let K=S.length-1;K>=0;K--){const q=S[K],_=q.handle||x(A,q.col)||A&&A[K];_&&(U=W(_,U,{descending:q.descending!==void 0?!!q.descending:q.dir==="desc",nullsFirst:!!q.nullsFirst,locale:q.locale!==void 0?q.locale:M.locale,compare:q.compare}))}return U instanceof Uint32Array?U:Uint32Array.from(U)}function x(A,$){if(!(!A||$===void 0)){for(let I=0;I<A.length;I++)if(A[I]&&A[I].id===$)return A[I]}}}),Be("packages/core/src/store/stringrank.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return F}});const te=H("packages/core/src/compute/sort.js"),L=te.collateStringRanks,X=te.rankSortStrings,D=1e5;class F{#e=[];#t=new Map;#n;#r=0;#s=0;#i=-1;#o;#l=!1;#a=null;#c=-1;#u="\0";constructor(Y=D){this.#o=Y>0?Y:D,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(Y){this.#i=Y}get generation(){return this.#s}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let Y=this.#n.byteLength;const B=this.#e;for(let z=0;z<B.length;z++)Y+=B[z].length*2+24;return Y}#f(Y,B){const z=this.#t.get(Y);if(z!==void 0)return z;if(this.#l)return-1;if(B&&this.#e.length>=this.#o)return this.#l=!0,-1;const G=this.#e.length;return this.#e.push(Y),this.#t.set(Y,G),this.#s++,G}build(Y,B){const z=B|0;this.#e=[],this.#t=new Map,this.#s=0,this.#l=!1,this.#a=null,this.#c=-1,this.#n=new Uint32Array(z);for(let G=0;G<z;G++){const P=Y[G],O=typeof P=="string"?this.#f(P,!1):-1;this.#n[G]=O<0?0:O}this.#r=z}append(Y,B,z){const G=(B|0)+(z|0);if(G>this.#n.length){const P=new Uint32Array(G);P.set(this.#n.subarray(0,this.#r)),this.#n=P}for(let P=B|0;P<G;P++){const O=Y[P],b=typeof O=="string"?this.#f(O,!0):-1;this.#n[P]=b<0?0:b}this.#r=Math.max(this.#r,G)}ranks(Y){const B=Y||"";if(this.#a&&this.#c===this.#s&&this.#u===B)return this.#a;const z=L(this.#e,this.#e.length,Y);return this.#a=z,this.#c=this.#s,this.#u=B,z}usable(Y,B,z){if(this.#l||this.#e.length===0)return!1;const G=this.#n,P=this.#e,O=this.#r;for(let b=0;b<Y.length;b++){const c=Y[b];if(c>=O||P[G[c]]!==B[c])return!1}return!0}sort(Y,B){const z=this.ranks(B.locale),G=this.#e.length,P=Y.length,O=new Uint32Array(P),b=this.#n;for(let c=0;c<P;c++)O[c]=b[Y[c]];return X(Y,O,z,G,!!B.descending)}}}),Be("packages/core/src/store/columnstore.js",function(e,H){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return m}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/paths.js").pathGetter,B=H("packages/core/src/store/bitset.js").Bitset,G=H("packages/core/src/store/dictionary.js").Dictionary,O=H("packages/core/src/store/multivalue.js").MultiValue,c=H("packages/core/src/store/stringrank.js").StringRankIndex,d=4294967295,l=1024,r=5e3,t=.2,i=new Set(["float64","int32","bitset","dictionary","object","multi"]);function s(v){return v==null}function n(v){if(typeof v=="number")return v;if(v instanceof Date)return v.getTime();if(typeof v=="boolean")return v?1:0;const h=Number(v);return Number.isNaN(h)&&typeof v=="string"?Date.parse(v):h}function u(v){const h=n(v);return Number.isFinite(h)?h|0:0}function o(v){return s(v)?[]:Array.isArray(v)?v:[v]}function a(v,h){switch(v.kind){case"float64":case"int32":return v.buf[h];case"bitset":return v.bits.get(h)===1;case"dictionary":return v.dict.valueOf(v.buf[h]);case"multi":{const p=v.mv.at(h),g=new Array(p.length);for(let k=0;k<p.length;k++)g[k]=v.dict.valueOf(p[k]);return g}default:return v.buf[h]}}function f(v,h){switch(v.kind){case"float64":case"int32":return v.values[h];case"bitset":return(v.values[h>>3]&1<<(h&7))!==0;case"dictionary":return(v.table||[])[v.values[h]];case"multi":{const p=v.offsets[h],g=v.offsets[h+1],k=v.table||[],y=new Array(g-p);for(let T=p;T<g;T++)y[T-p]=k[v.values[T]];return y}default:return v.values[h]}}class w{#e;#t;#n;#r;#s;#i;#o;#l=!1;#a=null;#c=null;#u=null;#f=null;#d=null;#h;#p;#m=-1;#g=null;#b=0;#y=0;#j=null;#w=null;#O=!1;constructor(h,p){this.#e=h.id;const g=i.has(h.kind)?h.kind:"object";h.kind&&!i.has(h.kind)&&L(`store.kind.${h.id}`,`column "${h.id}" declares unknown storage kind "${h.kind}"; falling back to object`),this.#n=g,this.#t=g,this.#r=h.nullable!==!1,this.#o=h.dictionary??null,this.#i=p,this.#s=D(h.read)?h.read:Z(h.field||h.id),this.#h=h.stringRankIndex!=="off",this.#p=typeof h.stringRankMaxDistinct=="number"?h.stringRankMaxDistinct:0,this.#j=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#O?null:this.#l?this.#t==="bitset"?this.#c.words:this.#t==="multi"?this.#u.values:this.#a:this.#P().values}get presence(){return this.#O||!this.#r?null:this.#l?this.#g:this.#P().presence}get dict(){return this.#O||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#f:null}get stringRank(){if(this.#O||!this.#h||this.kind!=="object")return null;const h=this.values,p=this.#i.physical();if(!h||p===0)return null;if(this.#d===null){if(typeof h[0]!="string")return null;const g=new c(this.#v());return g.build(h,p),g.version=this.#y,this.#d=g,this.#m=this.#y,g.capped?null:g}return this.#d.length<p&&this.#d.append(h,this.#d.length,p-this.#d.length),this.#d.version=this.#y,this.#m=this.#y,this.#d.capped?null:this.#d}#v(){return this.#p}#T(){this.#d=null,this.#m=-1}get offsets(){return this.#O||!this.#l||this.#t!=="multi"?null:this.#u.offsets}get version(){return this.#y}get bytes(){let h=0;return this.#a&&(h+=this.#a.byteLength??this.#a.length*8),this.#c&&(h+=this.#c.bytes),this.#u&&(h+=this.#u.bytes),this.#g&&(h+=this.#g.bytes),this.#f&&(h+=this.#f.bytes),this.#j&&(h+=this.#j.size*24),h}get(h){if(!this.#O&&!(h<0||h>=this.#i.physical())){if(!this.#l)return this.#M(h);if(this.#r&&this.#g.get(h)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[h];case"bitset":return this.#c.get(h)===1;case"dictionary":return this.#f.valueOf(this.#a[h]);case"multi":{const p=this.#u.at(h),g=new Array(p.length);for(let k=0;k<p.length;k++)g[k]=this.#f.valueOf(p[k]);return g}default:return this.#a[h]}}}set(h,p){this.#O||(this.#l?this.#E(h,p):this.#j.set(h,p===void 0?null:p),this.#d&&this.#T(),this.#y++)}read(h){return this.#s(h)}appendColumn(h,p,g){if(this.#O||g<=0)return;if(!this.#l){this.#y++;return}const k=this.#s,y=this.#r,T=this.#g;let j=!1;switch(this.#t){case"float64":{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]);if(typeof R=="number"){y&&T.set(p+W),N[p+W]=R;continue}const x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?NaN:n(R)}break}case"int32":{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?0:u(R)}break}case"bitset":{const N=this.#c;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N.assign(p+W,!x&&!!R)}break}case"dictionary":{const N=this.#a,W=this.#f;for(let R=0;R<g;R++){const x=k(h[R]),A=x==null;y?T.assign(p+R,!A):A&&(j=!0),N[p+R]=A?0:W.codeOf(x)}break}case"multi":{const N=this.#u,W=this.#f;for(let R=0;R<g;R++){const x=k(h[R]),A=x==null;y?T.assign(p+R,!A):A&&(j=!0);const $=o(x),I=new Array($.length);for(let M=0;M<$.length;M++)I[M]=W.codeOf($[M]);N.write(p+R,I)}break}default:{const N=this.#a;for(let W=0;W<g;W++){const R=k(h[W]),x=R==null;y?T.assign(p+W,!x):x&&(j=!0),N[p+W]=x?null:R}break}}j&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#t==="object"&&(this.#d.append(this.#a,p,g),this.#d.version=this.#y+1,this.#m=this.#y+1),this.#y++}appendPacked(h,p,g){if(this.#O||g<=0||!h)return;if(!this.#l){this.#y++;return}const k=this.#g,y=h.presence;if(k)if(y)for(let j=0;j<g;j++)k.assign(p+j,(y[j>>3]&1<<(j&7))!==0);else for(let j=0;j<g;j++)k.set(p+j);const T=h.kind===this.#t;if(T&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(h.values,p),this.#y++;return}if(T&&this.#t==="bitset"){const j=h.values;for(let N=0;N<g;N++)this.#c.assign(p+N,(j[N>>3]&1<<(N&7))!==0);this.#y++;return}if(T&&this.#t==="dictionary"){const j=h.table||[],N=new Uint32Array(j.length);for(let A=0;A<j.length;A++)N[A]=this.#f.codeOf(j[A]);const W=h.values,R=this.#a,x=k;for(let A=0;A<g;A++){if(x&&(y&&(y[A>>3]&1<<(A&7))===0)){R[p+A]=0;continue}R[p+A]=N[W[A]]??0}this.#y++;return}if(T&&this.#t==="multi"){const j=h.table||[],N=new Uint32Array(j.length);for(let x=0;x<j.length;x++)N[x]=this.#f.codeOf(j[x]);const W=h.values,R=h.offsets;for(let x=0;x<g;x++){const A=R[x],$=R[x+1],I=new Array($-A);for(let M=A;M<$;M++)I[M-A]=N[W[M]]??0;this.#u.write(p+x,I)}this.#y++;return}for(let j=0;j<g;j++){const N=y?(y[j>>3]&1<<(j&7))===0:h.kind==="object"?h.values[j]===null:!1;this.#E(p+j,N?null:f(h,j))}this.#y++}touch(){this.#y++}columnarise(h,p){if(this.#l||this.#O)return;const g=new Array(p);for(let k=0;k<p;k++)g[k]=this.#M(k);this.#t=this.#n,this.#l=!0,this.#S(h);for(let k=0;k<p;k++)this.#E(k,g[k]);this.#j.clear(),this.#w=null,this.#T(),this.#y++}grow(h){if(!(!this.#l||this.#O||h<=this.#b)){switch(this.#t){case"float64":case"int32":case"dictionary":{const p=new this.#a.constructor(h);p.set(this.#a),this.#a=p;break}case"bitset":this.#c.grow(h);break;case"multi":break;default:this.#a.length=h;break}this.#g&&this.#g.grow(h),this.#b=h,this.#y++}}convert(h){if(this.#O||!i.has(h)||(this.#n=h,!this.#l||h===this.#t))return!1;const p={kind:this.#t,buf:this.#a,bits:this.#c,mv:this.#u,dict:this.#f},g=this.#i.physical(),k=this.#g;this.#t=h,this.#S(this.#b);for(let y=0;y<g;y++){const T=k!==null&&k.get(y)===0;T&&h!=="multi"||this.#E(y,T?null:a(p,y))}return this.#T(),this.#y++,!0}compact(h,p,g){if(!this.#O){if(this.#T(),!this.#l){const k=this.#j;if(k.size){const y=new Map;for(const[T,j]of k)h[T]!==d&&y.set(h[T],j);this.#j=y}this.#w=null,this.#y++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const k=this.#a;for(let y=0;y<p;y++)h[y]!==d&&(k[h[y]]=k[y]);if(this.#t==="object")for(let y=g;y<p;y++)k[y]=void 0;break}case"bitset":{const k=this.#c;for(let y=0;y<p;y++)h[y]!==d&&k.assign(h[y],k.get(y)===1);for(let y=g;y<p;y++)k.clear(y);break}case"multi":this.#u.compact(h,g,d);break;default:break}if(this.#g){const k=this.#g;for(let y=0;y<p;y++)h[y]!==d&&k.assign(h[y],k.get(y)===1);for(let y=g;y<p;y++)k.clear(y)}this.#y++}}release(){this.#O||(this.#O=!0,this.#a=null,this.#c&&this.#c.release(),this.#c=null,this.#u&&this.#u.release(),this.#u=null,this.#g&&this.#g.release(),this.#g=null,this.#f=null,this.#d=null,this.#j=new Map,this.#w=null,this.#b=0,this.#y++)}#S(h){const p=Math.max(1,h);switch(this.#a=null,this.#c=null,this.#u=null,this.#t){case"float64":this.#a=new Float64Array(p);break;case"int32":this.#a=new Int32Array(p);break;case"bitset":this.#c=new B(p);break;case"dictionary":this.#a=new Uint32Array(p),this.#f=this.#f??new G(this.#o??[]);break;case"multi":this.#u=new O({rows:p,values:p}),this.#f=this.#f??new G(this.#o??[]);break;default:this.#a=new Array(p);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#f=null),this.#r&&(this.#g?this.#g.grow(p):this.#g=new B(p)),this.#b=p}#E(h,p){const g=s(p);switch(this.#r?this.#g.assign(h,!g):g&&L(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[h]=g?NaN:n(p);break;case"int32":this.#a[h]=g?0:u(p);break;case"bitset":this.#c.assign(h,!g&&!!p);break;case"dictionary":this.#a[h]=g?0:this.#f.codeOf(p);break;case"multi":{const k=o(p),y=new Array(k.length);for(let T=0;T<k.length;T++)y[T]=this.#f.codeOf(k[T]);this.#u.write(h,y);break}default:this.#a[h]=g?null:p;break}}#M(h){if(this.#j.has(h))return this.#j.get(h);const p=this.#s(this.#i.rowAt(h));return p===void 0?null:p}#P(){if(this.#w&&this.#w.version===this.#y)return this.#w;const h=this.#i.physical(),p=new Array(h),g=this.#r?new B(h):null;for(let k=0;k<h;k++){const y=this.#M(k);p[k]=y,g&&!s(y)&&g.set(k)}return this.#w={version:this.#y,values:p,presence:g},this.#w}}class m{#e;#t=new Map;#n=[];#r=[];#s=0;#i=0;#o=0;#l=0;#a=new B(0);#c=!1;#u=!0;#f;#d;#h;#p=!1;constructor(h,p={}){this.#e=Array.isArray(h)?h:[],this.#d=Math.max(1,p.initialCapacity??l),this.#u=p.retainSource!==!1,this.#f=this.#u?p.columnarBelow??r:0,this.#h=p.compactRatio??t;const g={rowAt:k=>this.#r[k],physical:()=>this.#s};for(const k of this.#e){if(!k||!k.id)continue;if(this.#t.has(k.id)){L(`store.dup.${k.id}`,`duplicate column id "${k.id}" in the store schema; ignoring the second`);continue}const y=new w(k,g);this.#t.set(k.id,y),this.#n.push(y)}this.#f<=0&&this.#b()}get count(){return this.#o}get physical(){return this.#s}get capacity(){return this.#c?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#c}get destroyed(){return this.#p}get bytes(){let h=this.#a.bytes+this.#r.length*8;for(const p of this.#n)h+=p.bytes;return h}append(h){const p=this.#s;if(this.#p||!h)return{from:p,to:p};const g=h.length|0;if(g===0)return{from:p,to:p};if(this.#u)for(let y=0;y<g;y++)this.#r[p+y]=h[y];if(this.#s=p+g,this.#o+=g,this.#a.grow(this.#s),!this.#c){if(this.#s>=this.#f)this.#b();else for(const y of this.#n)y.touch();return{from:p,to:this.#s}}this.#m(this.#s);const k=this.#n;for(let y=0;y<k.length;y++)k[y].appendColumn(h,p,g);return{from:p,to:this.#s}}appendPacked(h,p){const g=this.#s;if(this.#p||!h)return{from:g,to:g};const k=h.count|0;if(k===0)return{from:g,to:g};if(this.#u&&p)for(let T=0;T<k;T++)this.#r[g+T]=p[T];this.#s=g+k,this.#o+=k,this.#a.grow(this.#s),this.#c||this.#b(),this.#m(this.#s);const y=new Map;for(const T of h.columns)y.set(T.id,T);for(const T of this.#n){const j=y.get(T.id);j?T.appendPacked(j,g,k):T.grow(this.#i)}return{from:g,to:this.#s}}source(h){if(this.#u)return this.#r[h];if(!(h<0||h>=this.#s))return this.#g(h)}setSource(h,p){this.#p||h<0||h>=this.#s||this.#u&&(this.#r[h]=p)}get(h,p){const g=this.#t.get(h);return g?g.get(p):void 0}set(h,p,g){if(this.#p||p<0||p>=this.#s)return;const k=this.#t.get(h);if(!k){L(`store.set.${h}`,`set() on unknown column "${h}"`);return}k.set(p,g)}remove(h){return this.#p||h<0||h>=this.#s||this.#a.get(h)===1?!1:(this.#a.set(h),this.#l++,this.#o--,!0)}live(h){return h<0||h>=this.#s?!1:this.#a.get(h)===0}compact(h={}){if(this.#p||this.#l===0||!h.force&&this.#l/this.#s<this.#h)return null;const p=this.#s,g=new Uint32Array(p);let k=0;for(let y=0;y<p;y++)g[y]=this.#a.get(y)===1?d:k++;for(const y of this.#n)y.compact(g,p,k);if(this.#u){const y=this.#r;for(let T=0;T<p;T++)g[T]!==d&&(y[g[T]]=y[T]);y.length=k}return this.#s=k,this.#o=k,this.#l=0,this.#a=new B(Math.max(this.#i,k)),g}column(h){return this.#t.get(h)}columns(){return this.#n.slice()}liveIndices(){const h=new Uint32Array(this.#o);if(this.#l===0){for(let g=0;g<this.#s;g++)h[g]=g;return h}let p=0;for(let g=0;g<this.#s;g++)this.#a.get(g)===0&&(h[p++]=g);return h}convert(h,p){const g=this.#t.get(h);return g?g.convert(p):!1}destroy(){if(!this.#p){this.#p=!0;for(const h of this.#n)h.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#s=0,this.#o=0,this.#l=0,this.#i=0}}#m(h){if(h<=this.#i)return;let p=this.#i||this.#d;for(;p<h;)p*=2;for(const g of this.#n)g.grow(p);this.#a.grow(p),this.#i=p}#g(h){const p={};for(const g of this.#n)p[g.id]=g.get(h);return p}#b(){if(this.#c)return;let h=this.#d;for(;h<this.#s;)h*=2;this.#c=!0,this.#i=h,this.#a.grow(h);for(const p of this.#n)p.columnarise(h,this.#s)}}}),Be("packages/core/src/store/pool.js",function(e,H){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return F}});const te=64,L=8;function X(Y){let B=te;for(;B<Y;)B*=2;return B}class D{#e=new Map;#t=new WeakSet;#n;#r=0;#s={acquired:0,reused:0,released:0};constructor(B={}){this.#n=B.limit??L}get bytes(){return this.#r}mask(B){const z=new Uint8Array(this.#i(B),0,B);return z.fill(0),z}indices(B){return new Uint32Array(this.#i(B*4),0,B)}release(B){if(!B||!B.buffer)return!1;const z=B.buffer;if(!this.#t.has(z))return!1;this.#t.delete(z),this.#s.released++;const G=z.byteLength;let P=this.#e.get(G);return P||this.#e.set(G,P=[]),P.length>=this.#n||(P.push(z),this.#r+=G),!0}releaseAll(B){for(const z of B)this.release(z)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#s,retained:this.#r}}#i(B){const z=X(B),G=this.#e.get(z);this.#s.acquired++;let P;return G&&G.length?(P=G.pop(),this.#r-=z,this.#s.reused++):P=new ArrayBuffer(z),this.#t.add(P),P}}function F(){return Z??=new D,Z}let Z=null}),Be("packages/core/src/compute/sortspec.js",function(e,H){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return F}});function te(Z){return{locale:Z===void 0?void 0:String(Z),numeric:!0,sensitivity:"variant"}}function L(Z){return!!Z&&typeof Z.compare!="function"}function X(Z){if(!Z)return!0;for(let Y=0;Y<Z.length;Y++)if(!L(Z[Y]))return!1;return!0}function D(Z,Y){const B=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,z=Z.locale!==void 0?Z.locale:Y;return{col:B,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:te(z)}}function F(Z,Y){const B=Z||[],z=new Array(B.length);for(let G=0;G<B.length;G++)z[G]=D(B[G],Y);return z}}),Be("packages/core/src/compute/facet.js",function(e,H){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const te=H("packages/core/src/compute/handle.js"),L=te.presenceReader,X=te.valueReader,D=te.dictSize,F=te.dictValue,Z=Object.freeze(["equal","quantile","log"]),Y=Object.freeze(["hour","day","week","month","quarter","year"]),B=20,z=50,G=1e4;function P(g,k){if(!g)return"none";const y=k;if(y&&(y.multi===!0||typeof y.items=="function"))return"category";const T=k&&k.base;if(T==="date"||T==="datetime"||T==="time"||T==="dateString")return"date";switch(g.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return T==="number"?"numeric":T==="boolean"?"boolean":T==="text"?"category":"none"}}function O(g){const k=g.values,y=g.kind;if((y==="float64"||y==="int32")&&k)return j=>k[j];const T=X(g);return j=>b(T(j))}function b(g){if(typeof g=="number")return g;if(g instanceof Date)return g.getTime();if(g==null||g==="")return NaN;if(typeof g=="boolean")return g?1:0;if(typeof g=="string"){const k=Number(g);if(Number.isFinite(k))return k;const y=Date.parse(g);return Number.isFinite(y)?y:NaN}return NaN}function c(g,k,y,T=z){if(!g)return{cardinality:0,exact:!0};if(g.dict)return{cardinality:D(g.dict),exact:!0};if(g.kind==="bitset")return{cardinality:2,exact:!0};const j=X(g),N=k?k.length:y,W=new Set;for(let R=0;R<N;R++){const x=j(k?k[R]:R);if(x!=null&&(W.add(x),W.size>T))return{cardinality:W.size,exact:!1}}return{cardinality:W.size,exact:!0}}const d=36e5,l=864e5;function r(g,k=B){const y=Number.isFinite(g)&&g>0?g:0,T=Math.max(1,k)*2;return y/d<=T?"hour":y/l<=T?"day":y/(7*l)<=T?"week":y/(30*l)<=T?"month":y/(91*l)<=T?"quarter":"year"}function t(g,k){if(!Number.isFinite(g))return NaN;const y=new Date(g);switch(k){case"hour":return y.setMinutes(0,0,0),y.getTime();case"day":return y.setHours(0,0,0,0),y.getTime();case"week":{y.setHours(0,0,0,0);const T=(y.getDay()+6)%7;return y.setDate(y.getDate()-T),y.getTime()}case"month":return y.setDate(1),y.setHours(0,0,0,0),y.getTime();case"quarter":return y.setMonth(Math.floor(y.getMonth()/3)*3,1),y.setHours(0,0,0,0),y.getTime();default:return y.setMonth(0,1),y.setHours(0,0,0,0),y.getTime()}}function i(g,k){const y=new Date(g);switch(k){case"hour":y.setHours(y.getHours()+1);break;case"day":y.setDate(y.getDate()+1);break;case"week":y.setDate(y.getDate()+7);break;case"month":y.setMonth(y.getMonth()+1);break;case"quarter":y.setMonth(y.getMonth()+3);break;default:y.setFullYear(y.getFullYear()+1);break}return y.getTime()}function s(g,k,y){const T=O(g),j=L(g),N=k?k.length:y;let W=1/0,R=-1/0,x=0,A=0;for(let $=0;$<N;$++){const I=k?k[$]:$;if(j&&!j(I)){x++;continue}const M=T(I);if(!Number.isFinite(M)){x++;continue}M<W&&(W=M),M>R&&(R=M),A++}return{min:W,max:R,nulls:x,finite:A}}function n(g,k,y,T){const j=O(g),N=L(g),W=k?k.length:y,R=W>T?W/T:1,x=[];for(let $=0;$<W;$+=R){const I=k?k[Math.floor($)]:Math.floor($);if(N&&!N(I))continue;const M=j(I);Number.isFinite(M)&&x.push(M)}const A=Float64Array.from(x);return A.sort(),A}function u(g,k,y,T={}){const j=T.kind||P(g,T.type);return j==="none"||!g?{kind:"none",buckets:[],suppressed:"type"}:j==="boolean"?o(g,k,y):j==="category"?a(g,k,y,T):f(g,k,y,j,T)}function o(g,k,y){const T=L(g);let j=0;if(T){const W=k?k.length:y;for(let R=0;R<W;R++)T(k?k[R]:R)||j++}const N=[{value:!1,label:"false"},{value:!0,label:"true"}];return j>0&&N.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:N}}function a(g,k,y,T){const j=T.cardinalityLimit??z,{cardinality:N}=c(g,k,y,j);if(N>j&&(T.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:N};const W=X(g),R=k?k.length:y,x=new Map;let A=0;for(let E=0;E<R;E++){const U=W(k?k[E]:E);if(U==null||U===""){A++;continue}if(Array.isArray(U)){if(!U.length){A++;continue}for(const K of U)x.set(K,(x.get(K)||0)+1);continue}x.set(U,(x.get(U)||0)+1)}let $=[...x.entries()];T.order==="alpha"?$.sort((E,U)=>String(E[0]).localeCompare(String(U[0]))):$.sort((E,U)=>U[1]-E[1]);let I=0,M=0;if($.length>j){M=$.length-j;for(let E=j;E<$.length;E++)I+=$[E][1];$=$.slice(0,j)}const S=$.map(([E])=>({value:E,label:String(E)}));return I>0&&S.push({remainder:!0,label:`Other (${M} values)`}),A>0&&S.push({null:!0,label:"Empty"}),{kind:"category",buckets:S,cardinality:N}}function f(g,k,y,T,j){const{min:N,max:W,nulls:R,finite:x}=s(g,k,y);if(!x)return{kind:T,buckets:R?[{null:!0,label:"Empty"}]:[],empty:!0};const A=Math.max(1,Math.floor(j.buckets||B));let $=[];if(T==="date"){const M=Y.includes(j.granularity)?j.granularity:r(W-N,A);let S=t(N,M);for(;S<=W&&$.length<4096;){const E=i(S,M);if(!(E>S))break;$.push({from:S,to:E}),S=E}return{kind:T,buckets:w($,R),granularity:M}}const I=Z.includes(j.strategy)?j.strategy:"equal";if(I==="quantile"){const M=n(g,k,y,G);if(M.length){const S=[M[0]];for(let E=1;E<A;E++){const U=M[Math.min(M.length-1,Math.floor(E/A*M.length))];U>S[S.length-1]&&S.push(U)}S.push(W);for(let E=0;E<S.length-1;E++)$.push({from:S[E],to:S[E+1]})}}else if(I==="log"&&N>0){const M=Math.log10(N),E=(Math.log10(W)-M)/A||1;for(let U=0;U<A;U++)$.push({from:10**(M+U*E),to:10**(M+(U+1)*E)})}if(!$.length){const M=(W-N)/A||1;for(let S=0;S<A;S++)$.push({from:N+S*M,to:N+(S+1)*M})}return $[$.length-1].to=W,{kind:T,buckets:w($,R),strategy:I,min:N,max:W}}function w(g,k){return k>0?[...g,{null:!0,label:"Empty"}]:g}function m(g,k,y,T,j){const N=T&&T.buckets||[],W=j&&j.length>=N.length?j.subarray(0,N.length):new Uint32Array(N.length);if(W.fill(0),!g||!N.length)return W;const R=N.length-1,x=!!N[R]&&N[R].null===!0,A=k?k.length:y;if(T.kind==="boolean"){const E=X(g);for(let U=0;U<A;U++){const K=E(k?k[U]:U);if(K==null){x&&W[R]++;continue}W[K?1:0]++}return W}if(T.kind==="category"){const E=new Map;for(let q=0;q<N.length;q++)!N[q].null&&!N[q].remainder&&E.set(N[q].value,q);const U=N.findIndex(q=>q.remainder),K=X(g);for(let q=0;q<A;q++){const _=K(k?k[q]:q);if(_==null||_===""){x&&W[R]++;continue}if(Array.isArray(_)){if(!_.length){x&&W[R]++;continue}for(const ee of _){const ne=E.get(ee);ne!==void 0?W[ne]++:U>=0&&W[U]++}continue}const J=E.get(_);J!==void 0?W[J]++:U>=0&&W[U]++}return W}const $=x?N.length-1:N.length,I=new Float64Array($+1);for(let E=0;E<$;E++)I[E]=N[E].from;I[$]=$?N[$-1].to:0;const M=O(g),S=L(g);for(let E=0;E<A;E++){const U=k?k[E]:E;if(S&&!S(U)){x&&W[R]++;continue}const K=M(U);if(!Number.isFinite(K)){x&&W[R]++;continue}const q=v(I,$,K);q>=0&&W[q]++}return W}function v(g,k,y){if(!k||y<g[0])return-1;if(y>=g[k])return y===g[k]?k-1:-1;let T=0,j=k-1;for(;T<j;){const N=T+j+1>>>1;y>=g[N]?T=N:j=N-1}return T}function h(g,k,y,T={}){const j=T.bounds||u(g,T.boundsIndices??k,y,T);return{bounds:j,counts:m(g,k,y,j)}}const p=h}),Be("packages/core/src/compute/pivotmatrix.js",function(e,H){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return t}});const L=H("packages/core/src/compute/handle.js").valueComparator,D=H("packages/core/src/compute/total.js").total,Z=H("packages/core/src/compute/group.js").packKeys,Y=H("packages/core/src/compute/pivot.js"),B=Y.joinPath,z=Y.DEFAULT_PATH_SEPARATOR,G=Y.DEFAULT_MAX_COLUMNS,P="";function O(i,s,n={}){const u=n.separator||z,o=i||[],a=s instanceof Uint32Array?s:Uint32Array.from(s||[]),f=a.length;if(o.length===0)return{tuples:[[]],paths:[P],buckets:[a]};const{keyOf:w,readers:m}=Z(o,a,0),v=new Map,h=[],p=[],g=[];for(let W=0;W<f;W++){const R=a[W],x=w(R);let A=v.get(x);if(A===void 0){A=h.length,v.set(x,A),p.push(x);const $=new Array(m.length);for(let I=0;I<m.length;I++)$[I]=m[I](R);h.push($),g.push([])}g[A].push(R)}const k=L(n.locale),y=h.map((W,R)=>R);y.sort((W,R)=>{const x=h[W],A=h[R];for(let $=0;$<x.length;$++){const I=b(x[$],A[$],k);if(I!==0)return I}return W-R});const T=new Array(y.length),j=new Array(y.length),N=new Array(y.length);for(let W=0;W<y.length;W++){const R=y[W];T[W]=h[R],j[W]=B(h[R],u),N[W]=Uint32Array.from(g[R])}return{tuples:T,paths:j,buckets:N}}function b(i,s,n){const u=i==null,o=s==null;return u||o?u&&o?0:u?1:-1:n(i,s)}function c(i,s,n){const u=[];for(let o=0;o<i.length;o++)n.has(i[o])&&u.push(i[o]);return Uint32Array.from(u)}function d(i,s,n,u){return{value:s.length?D(i,s,n,u):null,leaves:s,count:s.length}}function l(i){const s=i&&i.opts||{},n=s.separator||z,u=s.totalContext||{locale:s.locale},o=(i.measures||[]).filter(j=>j&&j.handle),a=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),f=O(i.rowHandles||[],a,{...s,separator:n}),w=O(i.columnHandles||[],a,{...s,separator:n}),m=s.maxColumns===void 0?G:s.maxColumns,v=w.paths.length*Math.max(1,o.length),h=new Map;if(m&&v>m)return{rowAxis:f,columnAxis:w,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:v,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${v} columns, above pivot.maxColumns of ${m}. Narrow the pivot columns or raise the limit.`,columns:v,maxColumns:m}};const p=new Map,g=new Map,k=new Map,y=new Map,T=w.buckets.map(j=>new Set(j));for(let j=0;j<w.paths.length;j++){const N=w.buckets[j],W=w.paths[j];for(const R of o)k.set(t(W,R.colId),d(R.handle,N,R.fn,u))}for(let j=0;j<f.paths.length;j++){const N=f.buckets[j],W=f.paths[j];for(const R of o)g.set(t(W,R.colId),d(R.handle,N,R.fn,u));for(let R=0;R<w.paths.length;R++){const x=c(N,w.buckets[R],T[R]);if(x.length===0)continue;const A=w.paths[R];for(const $ of o)p.set(r(W,A,$.colId),d($.handle,x,$.fn,u))}}for(const j of o)y.set(j.colId,d(j.handle,a,j.fn,u));return{rowAxis:f,columnAxis:w,measures:o.map(j=>({colId:j.colId,fn:j.fn})),body:p,rowMargin:g,columnMargin:k,grand:y,columns:v,error:null}}function r(i,s,n){return`${i}\0${s}\0${n}`}function t(i,s){return`${i}\0${s}`}}),Be("packages/core/src/compute/reference.js",function(e,H){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return l}});const L=H("packages/core/src/internal/paths.js").getPath,X=H("packages/core/src/compute/handle.js"),D=X.isMissing,F=X.valueComparator,Y=H("packages/core/src/compute/filter.js").testValue,B="",z="\0";function G(i,s){const n=s.includes(".")?L(i,s):i?.[s];return n===void 0?null:n}function P(i,s,n={}){const u=s||[];let o=i.map((a,f)=>f);if(u.length===0)return o;for(let a=u.length-1;a>=0;a--)o=O(i,o,u[a],n);return o}function O(i,s,n,u){const o=n.locale!==void 0?n.locale:u.locale,a=F(o),f=n.descending!==void 0?!!n.descending:n.dir==="desc",w=[],m=[];for(const p of s){const g=G(i[p],n.col);D(g)?m.push(p):w.push(p)}const v=new Map;for(let p=0;p<w.length;p++)v.set(w[p],p);const h=(p,g)=>{const k=G(i[p],n.col),y=G(i[g],n.col);let T;return typeof n.compare=="function"?(T=n.compare(k,y,i[p],i[g],f),f&&(T=-T)):T=f?a(y,k):a(k,y),T!==0?T:v.get(p)-v.get(g)};return w.sort(h),n.nullsFirst?m.concat(w):w.concat(m)}function b(i,s,n={}){const u=[];for(let o=0;o<i.length;o++)c(i[o],s,n,o)&&u.push(o);return u}function c(i,s,n,u){if(!s)return!0;if(Array.isArray(s.conditions)){const o=s.conditions.filter(f=>f!=null);if(o.length===0)return!0;if(s.op==="or")return o.some(f=>c(i,f,n,u));const a=o.every(f=>c(i,f,n,u));return s.op==="not"?!a:a}return s.col===void 0&&typeof n.custom=="function"?!!n.custom(s,i,u):Y(G(i,s.col),s,n.locale)}function d(i,s,n,u){const o=n||i.map((m,v)=>v),a=new Map,f=[],w=[];for(const m of o){const v=s.map((g,k)=>{const y=G(i[m],g);return u&&u[k]?u[k](y):y}),h=v.map(g=>g==null?z:String(g)).join(B);let p=a.get(h);p===void 0&&(p=f.length,a.set(h,p),f.push(v),w.push([])),w[p].push(m)}return{keys:f,buckets:w}}function l(i,s,n={}){const u=F(n.locale),o=i.filter(f=>!D(f)),a=o.map(r).filter(f=>f!==null);switch(s){case"count":return i.length;case"countValues":return o.length;case"sum":return a.reduce((f,w)=>f+w,0);case"avg":return o.length===0?null:a.reduce((f,w)=>f+w,0)/o.length;case"min":return o.length===0?null:o.reduce((f,w)=>u(w,f)<0?w:f);case"max":return o.length===0?null:o.reduce((f,w)=>u(w,f)>0?w:f);case"first":return i.length===0?null:t(i[0]);case"last":return i.length===0?null:t(i[i.length-1]);default:return null}}function r(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function t(i){return i===void 0?null:i}}),Be("packages/core/src/compute/index.js",function(e,H){"use strict";const te=H("packages/core/src/compute/sort.js");Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return te.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return te.sortMulti}}),Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return te.radixSortFloat64}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return te.radixSortInt32}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return te.rankSortDictionary}}),Object.defineProperty(e,"mergeSortComparator",{enumerable:!0,get:function(){return te.mergeSortComparator}}),Object.defineProperty(e,"collateStringRanks",{enumerable:!0,get:function(){return te.collateStringRanks}}),Object.defineProperty(e,"rankSortStrings",{enumerable:!0,get:function(){return te.rankSortStrings}});const L=H("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return L.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return L.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return L.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return L.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return L.describeSort}});const X=H("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const D=H("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return D.packKeys}});const F=H("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return F.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return F.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return F.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return F.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return F.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return F.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return F.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return F.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return F.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return F.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return F.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return F.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return F.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return F.QUANTILE_SAMPLE}});const Z=H("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const Y=H("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return Y.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return Y.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return Y.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return Y.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return Y.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return Y.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return Y.DEFAULT_MAX_COLUMNS}});const B=H("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return B.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return B.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return B.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return B.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return B.GRAND_PATH}});const z=H("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return z.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return z.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return z.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return z.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return z.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return z.referenceValue}});const G=H("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return G.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return G.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return G.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return G.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return G.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return G.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return G.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return G.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return G.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return G.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return G.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return G.isMissing}});const P=H("packages/core/src/compute/sketch.js");Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return P.Welford}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return P.Reservoir}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return P.HyperLogLog}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return P.SpaceSaving}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return P.KLL}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return P.hash32}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return P.SKETCH_BOUNDS}});const O=H("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return O.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return O.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return O.openWindow}});const b=H("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return b.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return b.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return b.maintenanceOf}});const c=H("packages/core/src/compute/anomaly.js");Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ANOMALY_METHODS}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return c.modifiedZScores}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return c.iqrFences}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return c.mahalanobis}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return c.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return c.rollingAnomalies}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return c.anomalyCondition}});const d=H("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return d.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return d.forecast}})}),Be("packages/core/src/source/rows.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return d}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/internal/predicates.js").isFunction,F=32,Z="\0";function Y(l){return new B(l)}class B{#e;#t;constructor(r){this.#e=D(r&&r.rowKey)?r.rowKey:null;const t=r&&r.config?r.config.rowHeight:void 0;this.#t=typeof t=="number"||D(t)?t:F}get keyed(){return this.#e!==null}keyOf(r,t){if(this.#e){const i=this.#e(r);if(i!=null)return String(i)}else L("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(r){return D(this.#t)?Number(this.#t(r))||F:this.#t}leaf(r,t,i=0,s=null){const n={key:this.keyOf(r,t),data:r,level:i,parent:s,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return n.height=this.heightOf(n),n}group(r){const t={key:c(r.keyPath||r.path),data:null,level:r.level,parent:r.parent||null,children:[],group:!0,expanded:r.expanded!==!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.column,groupValue:r.value,groupPath:r.path,hasChildren:r.hasChildren!==!1};return r.totals&&(t.totals=r.totals),t.height=this.heightOf(t),t}footer(r){const t={key:`${r.key}${Z}footer`,data:null,level:r.level,parent:r,group:!0,footer:!0,expanded:!1,leafCount:r.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:r.groupColumn,groupValue:r.groupValue,groupPath:r.groupPath,hasChildren:!1,totals:r.totals};return t.height=this.heightOf(t),t}detail(r,t){return{key:`${r.key}${Z}detail`,data:r.data,level:r.level+1,parent:r,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:r.key}}grandTotal(r,t){const i={key:`${Z}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:r};return i.height=this.heightOf(i),i}skeleton(r,t=0,i=!1){const s={key:`${Z}pending${Z}${r}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:r,selected:!1,physical:null,pending:!0};return i&&(s.loadError=!0),s.height=this.heightOf(s),s}}function z(l,r,t,i){return{key:`${Z}pinned${Z}${t}${Z}${r}`,data:l,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function G(l,r){return new Proxy([],{get(t,i,s){if(i==="length")return l();if(typeof i=="string"){const n=Number(i);if(Number.isInteger(n)&&n>=0)return r(n)}return Reflect.get(t,i,s)},has(t,i){if(typeof i=="string"){const s=Number(i);if(Number.isInteger(s)&&s>=0)return s<l()}return Reflect.has(t,i)}})}function P(l){return l==null?"":String(l)}const O="";function b(l){if(l==null)return O;const r=String(l);return r.startsWith(O)?O+r:r}function c(l){const r=l||[];let t="g";for(let i=0;i<r.length;i++)t+=Z+b(r[i]);return t}function d(l){const r=new Array(l.length),t=[];for(let i=0;i<l.length;i++)t.push(l[i]),r[i]=c(t);return r}}),Be("packages/core/src/source/handles.js",function(e,H){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return Z}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce;class F{#e;#t;#n;#r=new Map;#s=0;constructor(B,z,G){this.#e=B,this.#t=z,this.#n=L(G)?G:()=>!1}get store(){const B=this.#e.store;return B&&L(B.column)?B:null}invalidate(){this.#s++}handle(B){const z=this.store;if(z){const b=z.column(B);if(b)return b}const G=this.#r.get(B);if(G&&G.builtAt===this.#s)return G.handle;const P=this.#i(B);if(!P)return;if(z&&this.#n()){D(`source.dropped.${B}`,`column "${B}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const O=this.#o(P);return this.#r.set(B,{handle:O,builtAt:this.#s}),O}#i(B){const z=this.#e.columns;return z&&L(z.get)?z.get(B):void 0}#o(B){const z=this.#t()||[],G=z.length,P=new Array(G),O=L(B.getValue)?c=>B.getValue(c):c=>c?.[B.field||B.id];for(let c=0;c<G;c++)P[c]=z[c]===void 0?void 0:O(z[c]);const b=this.#s;return{id:B.id,kind:"object",nullable:!1,values:P,presence:null,dict:null,offsets:null,get(c){return P[c]},version:b}}}function Z(Y,B,z){return new F(Y,B,z)}}),Be("packages/core/src/compute/incremental.js",function(e,H){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAGNITUDE_LIMIT",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"isIncremental",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RunningTotal",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const L=H("packages/core/src/store/columnstore.js").toFloat,X=Object.freeze(["sum","avg","countValues","min","max"]),D=Object.freeze(["float64"]),F=1e15;function Z(G,P){return typeof G!="string"||!X.includes(G)?!1:!!P&&D.includes(P.kind)}function Y(G){if(G==null)return null;const P=L(G);return Number.isNaN(P)?null:P}class B{#e;#t=0;#n=0;#r=0;#s=1/0;#i=-1/0;#o=!1;#l=!1;constructor(P){this.#e=P}get valid(){return this.#o&&!this.#l}get fn(){return this.#e}seed(P){this.#a();for(let O=0;O<P.length;O++){const b=Y(P[O]);b!==null&&this.#c(b)}this.#o=!0}seedColumn(P,O,b){this.#a();for(let c=0;c<b.length;c++){const d=b[c];if(O&&O(d)===0)continue;const l=P[d];Number.isNaN(l)||this.#c(l)}this.#o=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#s=1/0,this.#i=-1/0,this.#l=!1}#c(P){if(!Number.isFinite(P)){this.#l=!0;return}const O=this.#t+P;this.#n+=Math.abs(this.#t)>=Math.abs(P)?this.#t-O+P:P-O+this.#t,this.#t=O,this.#r++,P<this.#s&&(this.#s=P),P>this.#i&&(this.#i=P)}#u(P){const O=this.#t-P;this.#n+=Math.abs(this.#t)>=Math.abs(P)?this.#t-O-P:-P-O+this.#t,this.#t=O,this.#r--}update(P,O){if(!this.#o)return!1;const b=Y(P),c=Y(O);return b===null&&c===null?!0:b!==null&&!Number.isFinite(b)||c!==null&&!Number.isFinite(c)?!1:this.#e==="min"||this.#e==="max"?b===null||c===null?!1:this.#e==="min"?c<this.#s?(this.#s=c,!0):b>this.#s:c>this.#i?(this.#i=c,!0):b<this.#i:Math.abs(this.#t)>F?!1:(b!==null&&this.#u(b),c!==null&&this.#c(c),!0)}value(){switch(this.#e){case"countValues":return this.#r;case"avg":return this.#r?(this.#t+this.#n)/this.#r:null;case"min":return this.#r?this.#s:null;case"max":return this.#r?this.#i:null;default:return this.#t+this.#n}}invalidate(){this.#o=!1}}const z=B}),Be("packages/core/src/source/filterwire.js",function(e,H){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"normaliseFilterSet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"buildFilterSet",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"wireFilters",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return k}});const L=H("packages/core/src/internal/warn.js").warnOnce,X="source.remote.hostFilter",D="source.where.pageRelative";function F(j,N){!Array.isArray(j)||!j.length||L(D,`filters.where (${j.join(", ")}) runs over the rows the ${N} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(j){const N=(j||{}).config;!N||!N.hostFilter||L(X,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const Y="source.where.notApplied";function B(j,N){L(`${Y}:${j}`,`filters.where("${j}") is registered but the ${N} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const z="source.where.overThreshold";function G(j,N,W,R){!Array.isArray(j)||!j.length||L(`${z}:${N}`,`filters.where (${j.join(", ")}) is not applied to the ${N} pushdown source:`,W===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${W.toLocaleString()} rows, at or past the whereRowLimit of ${R.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const P=new Map;function O(j){let N=P.get(j);return N||(N=new Intl.DateTimeFormat("en-US",{timeZone:j,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),P.set(j,N)),N}function b(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function c(j,N){const W=O(N).formatToParts(new Date(j)),R={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const x of W)x.type==="year"?R.y=+x.value:x.type==="month"?R.m=+x.value:x.type==="day"?R.d=+x.value:x.type==="hour"?R.h=+x.value%24:x.type==="minute"?R.mi=+x.value:x.type==="second"&&(R.s=+x.value);return R}function d(j,N){const W=c(j,N);return Date.UTC(W.y,W.m-1,W.d,W.h,W.mi,W.s)-Math.floor(j/1e3)*1e3}function l(j,N,W,R){const x=Date.UTC(j,N-1,W),A=x-d(x,R);return x-d(A,R)}function r(j,N,W){const R=new Date(Date.UTC(j.y,j.m-1,j.d+N));return l(R.getUTCFullYear(),R.getUTCMonth()+1,R.getUTCDate(),W)}const t=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(j,N){if(typeof j!="string")return null;const W=j.trim().toLowerCase().replace(/[\s_-]+/g,""),R=/^last(\d*|n)days?$/.exec(W);if(R){const x=R[1]==="n"?"":R[1],A=Number(x||N);return!Number.isFinite(A)||A<=0?null:{kind:"lastNDays",n:Math.floor(A)}}switch(W){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function s(j,N={}){const W=i(j,N.n);if(!W)return null;const R=N.tz||b(),x=N.now instanceof Date?N.now.getTime():typeof N.now=="number"?N.now:Date.now(),A=c(x,R),$=l(A.y,A.m,A.d,R),I=r(A,1,R);let M=$,S=I;switch(W.kind){case"today":break;case"yesterday":M=r(A,-1,R),S=$;break;case"lastNDays":S=N.includeToday?I:$,M=r(A,N.includeToday?-(W.n-1):-W.n,R);break;case"thisWeek":{const E=Number.isFinite(N.weekStartsOn)?Number(N.weekStartsOn):1,K=(new Date(Date.UTC(A.y,A.m-1,A.d)).getUTCDay()-E+7)%7;M=r(A,-K,R),S=r(A,-K+7,R);break}case"thisMonth":M=l(A.y,A.m,1,R),S=l(A.m===12?A.y+1:A.y,A.m===12?1:A.m+1,1,R);break;case"thisQuarter":case"quarterToDate":{const E=Math.floor((A.m-1)/3)*3+1;M=l(A.y,E,1,R),S=W.kind==="quarterToDate"?I:E===10?l(A.y+1,1,1,R):l(A.y,E+3,1,R);break}case"thisYear":case"yearToDate":M=l(A.y,1,1,R),S=W.kind==="yearToDate"?I:l(A.y+1,1,1,R);break;default:return null}return{from:new Date(M).toISOString(),to:new Date(S).toISOString(),bounds:"[)",tz:R,relative:W.kind==="lastNDays"?`last${W.n}Days`:W.kind,n:W.n}}function n(j){if(!j||typeof j!="object")return null;const N=j.value;if(N&&typeof N=="object"&&!Array.isArray(N)&&"relative"in N)return{token:String(N.relative),n:typeof N.n=="number"?N.n:void 0};if(j.op==="relative"&&typeof j.value=="string")return{token:j.value,n:void 0};const W=j.meta;return W&&typeof W.relative=="string"&&j.value===void 0?{token:W.relative,n:typeof W.n=="number"?W.n:void 0}:null}function u(){return`Known tokens: ${t.filter(N=>N!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function o(j){const N=n(j);return N?i(N.token,N.n)!==null:!1}function a(j,N={}){const W=n(j);if(!W)return j;const R=s(W.token,{...N,n:W.n});return R?{...j,type:j.type||"date",op:"between",value:[R.from,R.to],bounds:j.bounds||R.bounds,meta:{...j.meta||{},relative:R.relative,tz:R.tz}}:(L(`source.relative.${W.token}`,`unknown relative date token "${W.token}"; sending the condition unresolved.`,u()),j)}function f(j){return!!j&&typeof j=="object"&&Array.isArray(j.conditions)}function w(j,N){if(j){if(f(j)){for(const W of j.conditions)w(W,N);return}N(j)}}function m(j,N){if(!j)return null;if(!f(j))return N(j);const W=j;let R=!1;const x=[];for(const A of W.conditions){const $=m(A,N);$!==A&&(R=!0),$&&x.push($)}return!R&&x.length===W.conditions.length?j:x.length?{...W,conditions:x}:null}function v(j){if(!j)return null;if(!f(j))return j;const N=j,W=[];for(const R of N.conditions){const x=v(R);x&&W.push(x)}return W.length?{op:N.op,conditions:W}:null}function h(j){const N=v(j);return N?f(N)&&N.op==="and"?N:{op:"and",conditions:[N]}:null}function p(j){const N=(j||[]).filter(Boolean);return N.length?{op:"and",conditions:N}:null}function g(j,N={}){const W=m(j,R=>a(R,N));return h(W)}function k(j){const N=y(j.filters??null);return JSON.stringify([N,j.sort??null,j.quick??"",j.groupBy??null,j.pivotBy??null,T(j.context)])}function y(j){if(!j)return null;if(f(j)){const R=j;return{op:R.op,conditions:R.conditions.map(y)}}const N=j,W=N.meta&&typeof N.meta.relative=="string"?N.meta.relative:n(N)?.token;return{col:N.col,op:N.op,bounds:N.bounds??null,caseSensitive:N.caseSensitive??!1,value:W?`rel:${W}`:N.value??null}}function T(j){if(j==null)return null;try{return JSON.parse(JSON.stringify(j))}catch{return L("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Be("packages/core/src/source/tree.js",function(e,H){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return c}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F="",Z="\0tree:";function Y(d,l){return{physical:d,key:l,level:0,children:[],value:void 0}}function B(d,l){const r=[],t=new Map;for(let i=0;i<d.length;i++){const s=d[i],n=l.pathOf(s),u=Array.isArray(n)?n.map(a=>String(a)):[];if(!u.length){const a=Y(s,l.keyOf(s));r.push(a);continue}let o=null;for(let a=0;a<u.length;a++){const f=u.slice(0,a+1).join(F),w=a===u.length-1;let m=t.get(f);m&&w&&m.physical===-1&&(m.physical=s,m.key=l.keyOf(s)),m||(m=Y(w?s:-1,w?l.keyOf(s):Z+f),m.level=a,m.value=u[a],t.set(f,m),o?o.children.push(m):r.push(m)),o=m}}return{roots:r,nodes:t}}function z(d,l){const r=new Map,t=[];for(let u=0;u<d.length;u++){const o=d[u],a=l.keyOf(o),f=Y(o,a);r.set(a,f);const w=l.parentOf(o);w!=null&&w!==""&&t.push({node:f,parent:String(w)})}let i=null;const s=new Map;for(const{node:u,parent:o}of t){const a=r.get(o);if(a){s.set(u.key,a);continue}l.orphans&&l.orphans!=="root"&&(i||(i=Y(-1,`${Z}orphans`),i.value=l.orphans),s.set(u.key,i))}const n=[];for(const u of r.values()){const o=s.get(u.key);o?o.children.push(u):n.push(u)}return i&&i.children.length&&n.push(i),{roots:G(n,r,l.orphans,i),nodes:r}}function G(d,l,r,t){const i=new Set,s=[...d];for(;s.length;){const f=s.pop();if(!i.has(f.key)){i.add(f.key);for(const w of f.children)s.push(w)}}const n=[];for(const f of l.values())i.has(f.key)||n.push(f);if(!n.length)return d;const u=!!r&&r!=="root";D("tree.cycle",`tree.parentKey produced ${n.length} row(s) inside a parent cycle; `+(u?`they are shown under "${r}".`:"they are shown at the root."));for(const f of n)f.children=f.children.filter(w=>i.has(w.key));if(!u)return[...d,...n];let o=t;const a=[...d];return o||(o=Y(-1,`${Z}orphans`),o.value=r,a.push(o)),o.children.push(...n),a}function P(d){let l=0;const r=(t,i)=>{for(const s of t)s.level=i,i>l&&(l=i),s.children.length&&r(s.children,i+1)};return r(d,0),l}function O(d,l){if(!d||typeof d!="object")return null;const r=d.path,t=d.parentKey,i=L(d.hasChildren)?s=>!!d.hasChildren(l.dataAt(s)):null;if(L(r))return{mode:"path",pathOf:s=>r(l.dataAt(s)),keyOf:l.keyOf,declaresChildren:i};if(t!=null){const s=L(t)?t:n=>n?.[t];return{mode:"parentKey",parentOf:n=>s(l.dataAt(n)),keyOf:l.keyOf,orphans:d.orphans||"root",declaresChildren:i}}return D("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function b(d,l){const r=l.mode==="path"?B(d,l):z(d,l),t=P(r.roots);return{...r,depth:t}}function c(d,l){const r=new Map,t=i=>{for(let s=0;s<i.length;s++){const n=i[s];if(n.physical>=0){const u=l?l(n.physical):!1,o=u&&n.children.length===0;r.set(n.physical,{level:n.level,posinset:s+1,setsize:i.length,hasChildren:n.children.length>0||u,lazy:o})}n.children.length&&t(n.children)}};return t(d),r}}),Be("packages/core/src/source/settle.js",function(e,H){"use strict";Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return L}});const te=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function L(X){const D=X&&typeof X=="object"?X.reason:null;return typeof D=="string"&&te.includes(D)}}),Be("packages/core/src/source/memory.js",function(e,H){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return K}});const L=H("packages/core/src/internal/lru.js").Lru,X=H("packages/core/src/internal/warn.js"),D=X.warnOnce,F=X.fail,Y=H("packages/core/src/internal/predicates.js").isFunction,z=H("packages/core/src/internal/compare.js").defaultCompare,P=H("packages/core/src/internal/merge.js").mergeRow,O=H("packages/core/src/source/rows.js"),b=O.createRowFactory,c=O.groupKey,d=O.groupPathElement,l=O.groupPrefixKeys,r=O.lazyRowView,i=H("packages/core/src/source/handles.js").createHandleProvider,s=H("packages/core/src/compute/incremental.js"),n=s.RunningTotal,u=s.isIncremental,a=H("packages/core/src/compute/handle.js").presenceReader,f=H("packages/core/src/source/filterwire.js"),w=f.querySignature,m=f.mapConditions,v=f.resolveRelativeCondition,h=H("packages/core/src/source/tree.js"),p=h.buildTree,g=h.resolveTree,k=h.indexTree,y=H("packages/core/src/source/settle.js"),T=y.PIPELINE_SETTLE_REASONS,j=y.isPipelineSettle,N=Object.freeze(["filter","sort","group","total","pivot","flatten"]),W=Object.freeze([]);function R(q,_){if(!q)return null;const J=_==="grand"?q.grandTotal:q.groupTotal;return J??q.total}function x(q){return!!q&&!q.running}function A(q){if(q)return q.value&&Y(q.value.compare)?q.value.compare:Y(q.compare)?q.compare:void 0}function $(q){const _=q&&q.dataType;return!_||!Y(_.items)?null:{items:_.items,type:q.itemType&&q.itemType.name||"text"}}function I(q){return!!q&&(typeof q=="object"||typeof q=="function")&&Y(q.then)}const M=new Uint32Array(0),S=4096;function E(q,_){return new K(q,_)}function U(q,_){if(_==="regex")try{const J=new RegExp(q,"iu");return ee=>J.test(ee)}catch{return J=>J.includes(q)}if(_==="fuzzy"){const J=[...q].filter(ee=>ee!==" ");return J.length?ee=>{let ne=0;for(let oe=0;oe<ee.length&&ne<J.length;oe++)ee[oe]===J[ne]&&ne++;return ne===J.length}:()=>!0}if(_==="words"){const J=q.split(/\s+/).filter(Boolean);return J.length?ee=>J.every(ne=>ee.includes(ne)):()=>!0}return J=>J.includes(q)}class K{mode="memory";#e;#t;#n;#r=!1;#s=null;#i;#o;#l=new Map;#a=!1;#c=0;#u=0;#f=new Map;#d=new Map;#h;#p=null;#m=K.#g();static#g(){return{slots:[],groupHeadings:W,unnumbered:W,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#b=new Map;#y=null;#j=new Map;#w=-1;#O=[];#v=new Map;#T=-1;#S=[];#E=null;#M=null;#P=null;#N=null;#R=null;#L=null;#U=null;#G=null;#x=Symbol("unset");#F=new Map;#Y=null;get#I(){return this.#m.slots}set#I(_){this.#m.slots=_}get#K(){return this.#m.inlineLeaves}set#K(_){this.#m.inlineLeaves=_}get#H(){return this.#m.groupHeadings}set#H(_){this.#m.groupHeadings=_}get#z(){return this.#m.unnumbered}set#z(_){this.#m.unnumbered=_}get#fe(){return this.#m.pivot}set#fe(_){this.#m.pivot=_}constructor(_,J){this.#t=_||{mode:"memory"},this.#e=J||{};const ee=this.#e.config||{};this.#n=this.#t.rows||ee.rows||[],this.#i=b(this.#e),this.#o=i(this.#e,()=>this.#n,()=>this.#r),this.#h=new L(Number(ee.rowCacheSize)||S);for(const ne of N)this.#l.set(ne,{key:null,result:null,id:0,computed:!1})}count(){this.#D();const _=this.#ne();return _?_.length:this.#I.length}#ne(){const _=Number(this.#_("pageSize",0))||0;if(_<=0)return null;const J=this.#I.length,ee=Math.max(1,Math.ceil(J/_)),oe=Math.min(Math.max(0,Number(this.#_("page",0))||0),ee-1)*_;return{offset:oe,length:Math.max(0,Math.min(_,J-oe))}}pageInfo(){this.#D();const _=Number(this.#_("pageSize",0))||0,J=this.#I.length;if(_<=0)return{page:0,pageSize:0,total:J,pageCount:1};const ee=Math.max(1,Math.ceil(J/_));return{page:Math.min(Math.max(0,Number(this.#_("page",0))||0),ee-1),pageSize:_,total:J,pageCount:ee}}totalCount(){return this.#ue().length}matchCount(){return this.#D(),this.#m.matchCount}at(_){this.#D();const J=this.#ne();if(J)return _<0||_>=J.length?void 0:this.#Le(J.offset+_,_);if(!(_<0||_>=this.#I.length))return this.#Le(_,_)}byKey(_){this.#D(),this.#p||this.#Ce();const J=this.#p.get(_);if(J!==void 0)return this.#je(J);for(let ee=0;ee<this.#I.length;ee++){const ne=this.#I[ee];if(typeof ne!="number"&&ne&&ne.key===_)return this.#Le(ee)}}loaded(_){return _>=0&&_<this.count()}hint(_,J){}display(){return this.#D(),this.#Y||(this.#Y=this.#Nt()),this.#Y}invalidateQuickText(){this.#F.clear(),this.invalidate("filter")}invalidate(_){const J=N.indexOf(_);J<0&&F(`unknown pipeline stage "${_}"; expected one of ${N.join(", ")}`);for(let ee=J;ee<N.length;ee++){const ne=this.#l.get(N[ee]);ne.key=null,ne.computed=!1}this.#Y=null}apply(_){const J=[],ee={added:[],updated:[],removed:[],rejected:J};if(!_)return ee;let ne=!1;const oe=new Set;if(_.remove&&_.remove.length)for(const ie of _.remove){const ae=this.#de(ie);if(ae===void 0){J.push({operation:"remove",id:this.#ye(ie),reason:"unknown-id"});continue}ee.removed.push(this.#i.keyOf(this.#r?this.#ae(ae):this.#n[ae],ae)),this.#r||(this.#n[ae]=void 0),this.#h.delete(ae),this.#F.delete(ae),ne=!0}if(_.update&&_.update.length){const ie=this.#j.size||this.#Ke()?this.#Ze():null,ae=this.#v.size?this.#kt():null,ce=ae&&ae.length?this.#Ze():null;for(const de of _.update){const Ae=this.#de(de);if(Ae===void 0){J.push({operation:"update",id:this.#Pe(de),reason:"unknown-id"});continue}const je=this.#r?this.#s&&this.#s.has(Ae)?this.#s.get(Ae):this.#ae(Ae):this.#n[Ae],be=P(je,de);for(const re of this.#te(je,be))oe.add(re);if(this.#r||(this.#n[Ae]=be),ie&&this.#Tt(ie,Ae,je,be),ce&&this.#lt(ae,ce,Ae,je,be),this.#p){const re=this.#i.keyOf(je,Ae),fe=this.#i.keyOf(be,Ae);re!==fe&&(this.#p.delete(re),this.#p.set(fe,Ae))}this.#h.delete(Ae),this.#F.delete(Ae),ee.updated.push(this.#je(Ae))}}if(_.add&&_.add.length&&this.#r){typeof _.at=="number"&&_.at<this.#Ne()&&(this.#h.clear(),this.#F.clear()),this.#p=null;for(const ie of _.add){const ae=this.#se(this.#Pe(ie));ae!==void 0&&ee.added.push(this.#je(ae))}ne=!0}else if(_.add&&_.add.length){const ie=typeof _.at=="number"?_.at:this.#n.length,ae=this.#n.length;let ce=_.add===this.#n?_.add.slice():_.add;if(this.#i.keyed){const de=[];for(const Ae of ce){const je=this.#Pe(Ae);if(this.#de(je)!==void 0){J.push({operation:"add",id:je,reason:"duplicate-id"});continue}de.push(Ae)}de.length!==ce.length&&(ce=de)}if(!ce.length)return ee;if(ie>=ae)for(let de=0;de<ce.length;de++)this.#n.push(ce[de]);else this.#n.splice(ie,0,...ce),this.#h.clear(),this.#F.clear();for(let de=0;de<ce.length;de++)ee.added.push(this.#je(ie>=ae?ae+de:ie+de));ne=!0}return this.#c++,ne&&(this.#p=null,this.#nt()),this.#o.invalidate(),this.#Y=null,ne||this.#X(oe)?(this.#u++,this.invalidate("filter")):this.invalidate("total"),this.#Qe("rows:changed",{companion:!0,added:ee.added.length,updated:ee.updated.length,removed:ee.removed.length}),this.#s=null,ee}groupHeadingsAt(_){this.#D();const J=this.#H;if(!J.length||!Number.isInteger(_)||_<0)return W;let ee=0,ne=J.length-1,oe=-1;for(;ee<=ne;){const ae=ee+ne>>1;J[ae].at<=_?(oe=ae,ee=ae+1):ne=ae-1}if(oe<0)return W;const ie=[];for(let ae=J[oe].row;ae;ae=ae.parent)ie.push(ae);return ie.reverse(),ie}unnumberedRowCount(_){this.#D();const J=this.#z;if(!J.length||!Number.isInteger(_)||_<0)return 0;let ee=0,ne=J.length-1,oe=-1;for(;ee<=ne;){const ie=ee+ne>>1;J[ie].at<=_?(oe=ie,ee=ie+1):ne=ie-1}return oe+1}moveRow(_,J){if(this.#r)return D("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const ee=this.#n;if(!Number.isInteger(_)||!Number.isInteger(J)||_<0||_>=ee.length)return!1;const ne=Math.max(0,Math.min(ee.length-1,J));if(ne===_)return!1;const[oe]=ee.splice(_,1);return ee.splice(ne,0,oe),this.#c++,this.#u++,this.#p=null,this.#h.clear(),this.#F.clear(),this.#nt(),this.#o.invalidate(),this.#Y=null,this.invalidate("filter"),this.#Qe("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(_){this.#pe(),this.#c++,this.#u++,this.#p=null,this.#F.clear(),this.#h.clear(),this.#nt(),this.#o.invalidate(),this.invalidate("filter"),this.#Qe("model:changed",{reason:"reload"})}destroy(){this.#pe(),this.#h.clear(),this.#F.clear(),this.#p=null,this.#I=[],this.#K=null,this.#Y=null,this.#nt();for(const _ of N)this.#l.set(_,{key:null,result:null,id:0,computed:!1})}#pe(){for(const{controller:_}of this.#b.values())try{_.abort()}catch{}this.#b.clear()}setRows(_){this.#n=_||[],this.#r=!1,this.#c++,this.#u++,this.#p=null,this.#F.clear(),this.#h.clear(),this.#nt(),this.#o.invalidate(),this.invalidate("filter")}notePriorRows(_){this.#s=_||null}releaseSource(){this.#r=!0,this.#n=[],this.#p=null,this.#h.clear(),this.#F.clear(),this.#o.invalidate()}data(){if(!this.#r)return this.#n;const _=this.#e.store;if(!_||!Y(_.source))return this.#n;const J=_.physical||0,ee=new Array(J);for(let ne=0;ne<J;ne++)ee[ne]=_.live&&!_.live(ne)?void 0:_.source(ne);return ee}#Ie(){const _=this.#_("detail",null);return!_||!Y(_.isOpen)||_.inline===!1?null:_}#Oe(){const _=(this.#e.config||{}).tree;return this.#x!==_&&(this.#x=_,this.#G=g(_,{dataAt:J=>this.#ae(J),keyOf:J=>this.#i.keyOf(this.#ae(J),J)})),this.#G}#me(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#me())return null;this.#D();const _=this.#m.grand;return _?this.#i.grandTotal(_,this.#et(this.#m.grandLeaves)):null}pivot(){return this.#D(),this.#fe}pivotMatrix(){this.#D();const _=this.#m.groupLeaves,J=(this.#e.compute||{}).pivotMatrix;if(!Y(J))return null;const ee=this.#_("groupBy",[]),ne=this.#_("pivotBy",[]);if(!ee.length&&!ne.length)return D("pivotView.no-dimension","pivotView is on but the grid has no pivot dimension, so there is no matrix to draw. Put a column on the pivot (its `pivot` setting, or `pivotBy` in the query) for the columns across the top, and group by a column for the rows down the side."),null;const oe=this.#Ze().map(ae=>({colId:ae.id,handle:this.#o.handle(ae.id),fn:R(ae,"group")})).filter(ae=>ae.handle&&ae.fn),ie=this.#e.config||{};return J({rowHandles:ee.map(ae=>this.#o.handle(ae)).filter(Boolean),columnHandles:ne.map(ae=>this.#o.handle(ae)).filter(Boolean),measures:oe,leaves:_||new Uint32Array(0),opts:{locale:ie.locale,separator:(ie.pivot||{}).separator,maxColumns:(ie.pivot||{}).maxColumns}})}keysForLeaves(_){const J=[];if(!_)return J;for(let ee=0;ee<_.length;ee++){const ne=this.#je(_[ee]);ne&&ne.key!=null&&J.push(String(ne.key))}return J}leavesOf(_){this.#D();const J=this.#l.get("group"),ee=J&&J.result;if(!ee||!ee.nodes)return[];const ne=ee.nodes.get(_);if(!ne)return[];const oe=[],ie=ae=>{const ce=ae.row&&ae.row.children;if(ce&&ce.length){for(const de of ce){const Ae=ee.nodes.get(de.key);Ae&&ie(Ae)}return}if(ae.leaves)for(let de=0;de<ae.leaves.length;de++)oe.push(this.#je(ae.leaves[de]))};return ie(ne),oe}#ye(_){return typeof _=="string"?_:this.#Pe(_)}#Pe(_){try{return this.#i.keyOf(_,-1)}catch{return"(unkeyed)"}}#de(_){if(typeof _=="string")return this.#se(_);if(this.#i.keyed){const ee=this.#i.keyOf(_,-1),ne=this.#se(ee);if(ne!==void 0)return ne}if(this.#r)return;const J=this.#n.indexOf(_);return J>=0?J:void 0}#se(_){return this.#p||this.#Ce(),this.#p.get(_)}#Ce(){this.#p=new Map;const _=this.#Ne(),J=this.#e.store,ee=J&&Y(J.live)?ne=>J.live(ne):null;for(let ne=0;ne<_;ne++){if(ee&&!ee(ne))continue;const oe=this.#ae(ne);oe!==void 0&&this.#p.set(this.#i.keyOf(oe,ne),ne)}}#te(_,J){const ee=[];for(const ne of this.#W())this.#Ue(ne)&&this.#J(ne,_,J,new Set)&&ee.push(ne);return ee}#J(_,J,ee,ne){if(ne.has(_))return!1;ne.add(_);const oe=this.#Ue(_);if(!oe)return!1;const ie=oe.value&&oe.value.deps;return Array.isArray(ie)&&ie.length?ie.some(ae=>this.#J(String(ae),J,ee,ne)):Y(oe.getValue)?!Object.is(oe.getValue(J),oe.getValue(ee)):!1}#W(){const _=new Set;for(const ee of this.#_("sort",[]))_.add(ee.col);for(const ee of this.#_("groupBy",[]))_.add(ee);const J=ee=>{if(ee){if(Array.isArray(ee.conditions)){ee.conditions.forEach(J);return}ee.col&&_.add(ee.col)}};return J(this.#_("filters",null)),[..._]}#X(_){if(!_.size)return!1;if(this.#_("quick",""))return!0;for(const J of this.#W())if(_.has(J))return!0;return!1}#D(){if(!this.#a){this.#a=!0;try{this.#Me()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#Me(){const _=this.#B("filter",()=>this.#V(),()=>this.#Re()),J=this.#q(_),ee=this.#B("group",()=>this.#ge(),()=>this.#Ye(J)),ne=this.#B("total",()=>this.#we(),()=>this.#Ve(ee));this.#B("pivot",()=>this.#k(),()=>this.#jt(ee)),this.#B("flatten",()=>this.#Se(),()=>this.#Ge(ee)),this.#Be(ee,ne)}#q(_){const J=this.#l.get("sort"),ee=this.#ie();if(J.computed&&J.key===ee&&!this.#b.has("sort"))return J.result;const ne=this.#b.get("sort");return ne&&ne.key===ee?J.result:J.result&&this.#Ee(_)?(this.#Te(_,ee),J.result):this.#B("sort",()=>ee,()=>this.#Fe(_))}#re(){if(this.#y===null){const _=this.#e.pipelineWorker,J=Y(_)?_():null;this.#y=J||!1}return this.#y||null}#ve(){const _=this.#_("sort",[]);if(!Array.isArray(_)||!_.length)return null;const J=(this.#e.config||{}).locale,ee=[],ne=[];for(const oe of _){const ie=this.#Ue(oe.col);if(ie&&ie.running)continue;if(ie&&ie.value&&Y(ie.value.compare))return null;const ae=this.#o.handle(oe.col);if(!ae)return null;ee.push({col:oe.col,descending:oe.dir==="desc",nullsFirst:!!oe.nullsFirst,locale:J}),ne.push(ae)}return ee.length?{entries:ee,handles:ne,locale:J}:null}#Ee(_){if(this.#ce())return!1;const J=this.#re();if(!J)return!1;const ee=Number(J.threshold);return Number.isFinite(ee)&&_.length<ee?!1:!!this.#ve()}#Te(_,J){const ee=this.#re(),ne=ee&&this.#ve();if(!ne){this.#B("sort",()=>J,()=>this.#Fe(_));return}const oe=new AbortController;this.#b.set("sort",{key:J,controller:oe});const ie=ne.entries.length===1?ee.sortColumn(ne.handles[0],_,{descending:ne.entries[0].descending,nullsFirst:ne.entries[0].nullsFirst,locale:ne.locale,signal:oe.signal,key:"sort"}):ee.sortMulti(ne.handles,ne.entries.map((ae,ce)=>({...ae,handle:ne.handles[ce]})),_,{signal:oe.signal,key:"sort"});if(!I(ie)){this.#b.delete("sort"),this.#B("sort",()=>J,()=>ie);return}ie.then(ae=>this.#le(J,ae),ae=>this.#he("sort",J,ae))}#le(_,J){const ee=this.#b.get("sort");if(!(!ee||ee.key!==_)){if(this.#ie()!==_){this.#b.delete("sort");return}this.#b.delete("sort"),this.#B("sort",()=>_,()=>J),this.#Y=null,this.#D(),this.#Qe("model:changed",{reason:T[0]})}}#he(_,J,ee){const ne=this.#b.get(_);if(!(!ne||ne.key!==J)&&(this.#b.delete(_),!(ee&&ee.name==="AbortError")&&_==="sort"&&this.#ie()===J)){const oe=this.#B("filter",()=>this.#V(),()=>this.#Re());this.#B("sort",()=>J,()=>this.#Fe(oe)),this.#Y=null,this.#D(),D("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",ee),this.#Qe("model:changed",{reason:T[1]})}}#Be(_,J){const ee=_&&_.leaves?_.leaves.length:this.#m.slots.length;this.#m.matchCount=ee,this.#m.grand=J&&J.grand||null,this.#m.grandLeaves=_&&_.leaves?_.leaves.length:0,this.#m.groupLeaves=_&&_.leaves?_.leaves:null}#B(_,J,ee){const ne=this.#l.get(_),oe=J();return ne.computed&&ne.key===oe||(ne.result=ee(),ne.key=oe,ne.computed=!0,ne.id++,_==="flatten"&&(this.#Y=null)),ne.result}#C(_){return this.#l.get(_).id}#V(){const _=(this.#e.config||{}).hostFilter,J=_&&Y(_.active)&&_.active()?1:0,ee=this.#_("where",null),ne=ee?ee.version:0,oe=this.#gt("filter.sig",`${this.#ut()}`,()=>w({filters:this.#_("filters",null),quick:this.#_("quick",""),quickMode:this.#_("quickMode","contains")}));return`${this.#u}|${oe}|${J}|${ne}`}#ie(){const _=this.#ce();return`${this.#C("filter")}|${JSON.stringify(this.#_("sort",[]))}`+(_?`|manual:${_.version}`:"")}#ce(){const _=this.#_("rowOrder",null);return _&&Array.isArray(_.keys)?_:null}#oe(_,J){this.#p||this.#Ce();const ee=this.#p,ne=this.#Ne(),oe=J.keys.length,ie=new Float64Array(ne);for(let ae=0;ae<ne;ae++)ie[ae]=oe+ae;for(let ae=0;ae<oe;ae++){const ce=ee.get(J.keys[ae]);ce!==void 0&&(ie[ce]=ae)}return Uint32Array.from(_).sort((ae,ce)=>ie[ae]-ie[ce])}orderedKeys(){this.#p||this.#Ce();const _=this.#p,J=new Map;for(const[ae,ce]of _)J.set(ce,ae);const ee=Uint32Array.from([...J.keys()]).sort(),ne=this.#ce(),oe=ne?this.#oe(ee,ne):this.#Fe(ee),ie=new Array(oe.length);for(let ae=0;ae<oe.length;ae++)ie[ae]=J.get(oe[ae]);return ie}#ge(){const _=this.#_("pivotBy",[]).length>0?"p":"u";return`${this.#C("sort")}|${JSON.stringify(this.#_("groupBy",[]))}|${_}`}#we(){const _=this.#Xe()?"f":"a",J=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#C("group")}|${JSON.stringify(this.#_("totals",[]))}|${_}${J}|${this.#c}`}#k(){return`${this.#C("group")}|${JSON.stringify(this.#_("pivotBy",[]))}`}#Se(){const J=this.#ze()||!this.#me()?this.#C("total"):"x",ee=`${this.#ut()}`,ne=this.#gt("flatten.keys",ee,()=>{const ie=this.#_("expanded",null);return ie?[...ie].sort().join(""):"*"}),oe=this.#gt("flatten.detail",ee,()=>{const ie=this.#_("detail",null);return ie&&Y(ie.signature)?ie.signature():""});return`${J}|${this.#C("pivot")}|${ne}|${oe}`}#ze(){const _=this.#_("groupBy",[]);return Array.isArray(_)&&_.length>0}stageState(){const _=[];for(const[J,ee]of this.#l){const ne=ee.result;_.push({stage:J,materialised:!!ee.computed,bytes:ne&&typeof ne.byteLength=="number"?ne.byteLength:null,rows:ne&&typeof ne.length=="number"?ne.length:null,rebuilds:ee.id})}return _}facetIndices(_){return this.#Re(_||null)}facetRows(_){const J=this.facetIndices(_),ee=[];for(let ne=0;ne<J.length;ne++){const oe=this.#je(J[ne]);oe&&ee.push(oe)}return ee}invalidateRows(){this.#h.clear(),this.#F.clear(),this.#Y=null}invalidateHandles(){this.#o.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#ue()}filteredIndices(){const _=this.#l.get("filter");if(_&&_.computed&&_.key===this.#V())return _.result||this.#ue();this.#D();const J=this.#l.get("filter");return(J&&J.computed?J.result:null)||this.#ue()}unfilteredRows(){const _=this.#ue(),J=[];for(let ee=0;ee<_.length;ee++){const ne=this.#je(_[ee]);ne&&J.push(ne)}return J}#Re(_=null){const J=this.#ue(),ee=this.#_("filters",null),ne=_?this.#st("pruneColumn")(ee,_):ee,oe=this.#it(ne),ie=String(this.#_("quick","")||"").trim().toLowerCase(),ae=ie?U(ie,String(this.#_("quickMode","contains")||"contains")):null,ce=(this.#e.config||{}).hostFilter,de=!!(ce&&Y(ce.active)&&ce.active()),Ae=this.#_("where",null),je=!!(Ae&&Ae.active);if(!oe&&!ie&&!de&&!je)return J;let be=null;oe&&(be=this.#st("evaluateFilters")(oe,{handle:Oe=>this.#o.handle(Oe),count:this.#Ne(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:Oe=>$(this.#Ue(Oe))}));const re=new Uint32Array(J.length);let fe=0;for(let pe=0;pe<J.length;pe++){const Oe=J[pe];if(!(be&&!be[Oe])&&!(ae&&!this.#ct(Oe,ae))){if(de||je){const ve=this.#je(Oe);if(de&&!ce.passes(ve)||je&&!Ae.passes(ve.data,ve.key))continue}re[fe++]=Oe}}if(be){const pe=(this.#e.compute||{}).releaseMask;Y(pe)&&pe({pool:this.#e.pool},be)}return re.subarray(0,fe)}handleFor(_){return this.#o.handle(_)}#Fe(_){const J=this.#ce();if(J)return this.#oe(_,J);const ee=this.#_("sort",[]).filter(ie=>{const ae=this.#Ue(ie.col);return!ae||!ae.running?!0:(D(`source.sort.running.${ie.col}`,`sort ignores "${ie.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!ee.length)return _;const ne=(this.#e.config||{}).locale;if(ee.length===1){const ie=ee[0],ae=this.#o.handle(ie.col);if(!ae)return D(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`),_;const ce=this.#Ue(ie.col);return this.#st("sortColumn")(ae,_,{descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ne,compare:A(ce)})}const oe=[];for(const ie of ee){const ae=this.#o.handle(ie.col);if(!ae){D(`source.sort.${ie.col}`,`sort ignores unknown column "${ie.col}".`);continue}oe.push({handle:ae,descending:ie.dir==="desc",nullsFirst:ie.nullsFirst,locale:ne,compare:A(this.#Ue(ie.col))})}return oe.length?this.#st("sortMulti")(oe.map(ie=>ie.handle),oe,_):_}#Ye(_){const J=this.#_("groupBy",[]),ee=this.#Oe();if(ee&&!J.length){const pe=p(_,ee);return this.#L=k(pe.roots,ee.declaresChildren),{roots:null,leaves:_,nodes:new Map,tree:pe}}if(this.#L=null,ee&&J.length&&D("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!J.length)return{roots:null,leaves:_,nodes:new Map};const ne=(this.#e.config||{}).timeZone,oe=[],ie=[];let ae=!1;for(const pe of J){const Oe=this.#o.handle(pe);if(!Oe){D(`source.group.${pe}`,`grouping ignores unknown column "${pe}".`);continue}oe.push(Oe);const ve=this.#Ue(pe),$e=ve&&ve.dataType;if($e&&Y($e.groupProjector)){const he=ve.typeOptions&&ve.typeOptions.timeZone||ne||void 0,ye=$e.groupProjector(ve,he);ie.push(ye||null),ye&&(ae=!0)}else ie.push(null)}if(!oe.length)return{roots:null,leaves:_,nodes:new Map};const{keys:ce,buckets:de}=this.#st("groupByColumns")(oe,_,{locale:(this.#e.config||{}).locale,project:ae?ie:void 0}),Ae=this.#_("pivotBy",[]).length>0,je=[],be=new Map;for(let pe=0;pe<de.length;pe++){const Oe=ce[pe];let ve=null;const $e=[];for(let he=0;he<Oe.length;he++){$e.push(d(Oe[he]));const ye=c($e),Se=he===Oe.length-1;let Ie=be.get(ye);if(!Ie){const we=this.#i.group({path:[...$e],column:J[he],value:Oe[he],level:he,parent:ve,expanded:Ae&&Se?!1:this.#pt(ye,{key:ye,column:J[he],value:Oe[he],level:he,path:[...$e]}),hasChildren:!(Ae&&Se)});Ie={row:we,leaves:null},be.set(ye,Ie),ve?ve.children.push(we):je.push(we)}Ie.row.leafCount+=de[pe].length,he===Oe.length-1&&(Ie.leaves=de[pe]),ve=Ie.row}}const re=this.#_("sort",[])||[],fe=(pe,Oe)=>{if(!pe||pe.length<2){if(pe)for(const ye of pe)fe(ye.children,Oe+1);return}const ve=J[Oe],$e=re.find(ye=>ye.col===ve),he=$e&&$e.dir==="desc"?-1:1;pe.sort((ye,Se)=>he*z(ye.groupValue,Se.groupValue));for(const ye of pe)fe(ye.children,Oe+1)};return fe(je,0),{roots:je,leaves:_,nodes:be,keys:ce,buckets:de}}#_e(_,J){const ee=new Map,ne=new Map,oe=ie=>{const ae=ie.physical>=0?[ie.physical]:[];for(const ce of ie.children)ae.push(...oe(ce));if(ie.children.length){const ce=this.#rt(J,Uint32Array.from(ae),null);ie.physical>=0?ee.set(ie.physical,ce):ne.set(ie.key,ce)}return ae};for(const ie of _.roots)oe(ie);return{byPhysical:ee,byKey:ne}}#Ve(_){const J=this.#Ze();if(!J.length)return this.#M=null,this.#P=null,{grand:null};const ee={id:this.#C("group"),columns:J.map(re=>re.id).join("")},ne=this.#M&&this.#M.id===ee.id&&this.#M.columns===ee.columns,oe=this.#Ke()&&ne?this.#E:null,ie=oe?J.filter(re=>oe.has(re.id)):J,ae=ne?this.#P:null,ce=this.#Xe()?null:this.#tt(),de=this.#be(J),Ae=re=>{const fe=_.nodes.get(re.key);let pe=fe&&fe.leaves?fe.leaves:null;if(re.children&&re.children.length){const $e=re.children.map(Ae);let he=0;for(const Ie of $e)he+=Ie.length;const ye=new Uint32Array(he);let Se=0;for(const Ie of $e)ye.set(Ie,Se),Se+=Ie.length;pe=ye}pe=pe||new Uint32Array(0);const Oe=ce?ce.get(re.key)||M:pe,ve=this.#at(re,oe?ie:J,Oe,de);return re.totals=oe?{...re.totals,...ve}:ve,pe};if(_.roots&&ie.length)for(const re of _.roots)Ae(re);if(this.#U=_.tree?this.#_e(_.tree,J):null,this.#M=ee,this.#E=this.#Ke()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#O.length=0,this.#P=null,{grand:null};const be=ce?this.#qe():_.leaves;return this.#P=this.#We(J,be,oe,ae),{grand:this.#P}}#We(_,J,ee,ne){const oe={},ie=this.#C("group");ie!==this.#w&&(this.#St(),this.#w=ie);const ae=this.#O;this.#O=[];for(const ce of _){if(!x(ce))continue;const de=this.#o.handle(ce.id);if(!de)continue;const Ae=R(ce,"grand");if(!u(Ae,de)){if(ee&&!ee.has(ce.id)&&ne&&ce.id in ne){oe[ce.id]=ne[ce.id];continue}oe[ce.id]=this.#rt([ce],J,null,"grand")[ce.id];continue}let je=this.#j.get(ce.id);if((!je||je.fn!==Ae)&&(je=new n(Ae),this.#j.set(ce.id,je)),je.valid){let be=!0;for(const re of ae)if(re.colId===ce.id&&!je.update(re.before,re.after)){be=!1;break}if(be){oe[ce.id]=je.value();continue}je.invalidate()}je.seedColumn(de.values,a(de),J),oe[ce.id]=je.valid?je.value():this.#rt([ce],J,null,"grand")[ce.id]}return oe}#be(_){const J=this.#C("group");J!==this.#T&&(this.#v.clear(),this.#T=J);const ee=new Map;for(const oe of _){if(!x(oe))continue;const ie=this.#o.handle(oe.id),ae=R(oe,"group");u(ae,ie)&&ee.set(oe.id,{fn:ae})}if(!ee.size)return this.#S.length=0,ee;const ne=this.#S;this.#S=[];for(const oe of ne){const{beforeKeys:ie,afterKeys:ae,colDeltas:ce}=oe,de=ie.length?new Set(ie):null,Ae=ae.length?new Set(ae):null;for(const{colId:je,before:be,after:re}of ce)if(ee.has(je)){for(const fe of ie)Ae&&Ae.has(fe)||this.#ke(fe,je,be,null);for(const fe of ae)de&&de.has(fe)||this.#ke(fe,je,null,re);for(const fe of ie)Ae&&!Ae.has(fe)||this.#ke(fe,je,be,re)}}return ee}#ke(_,J,ee,ne){const oe=this.#v.get(_),ie=oe&&oe.get(J);!ie||!ie.valid||ie.update(ee,ne)||ie.invalidate()}#at(_,J,ee,ne){if(!ne||!ne.size)return this.#rt(J,ee,_);const oe={};let ie=null,ae=this.#v.get(_.key);for(const ce of J){const de=ne.get(ce.id);if(!de){(ie||(ie=[])).push(ce);continue}const Ae=this.#o.handle(ce.id);if(!Ae)continue;ae||(ae=new Map,this.#v.set(_.key,ae));let je=ae.get(ce.id);if((!je||je.fn!==de.fn)&&(je=new n(de.fn),ae.set(ce.id,je)),je.valid||je.seedColumn(Ae.values,a(Ae),ee),je.valid){oe[ce.id]=je.value();continue}(ie||(ie=[])).push(ce)}return ie&&Object.assign(oe,this.#rt(ie,ee,_)),oe}#Tt(_,J,ee,ne){const oe=!this.#Xe()||this.#Ot(J);for(const ie of _){const ae=ie.getValue;if(!Y(ae))continue;const ce=ae(ee),de=ae(ne);Object.is(ce,de)||(this.#E&&this.#E.add(ie.id),oe&&this.#j.has(ie.id)&&this.#O.push({colId:ie.id,before:ce,after:de}))}}#kt(){const _=this.#_("groupBy",[]),J=[];for(const ee of _){const ne=this.#Ue(ee);ne&&J.push(ne)}return J}#ee(_,J){const ee=new Array(_.length);for(let ne=0;ne<_.length;ne++){const oe=_[ne].getValue;ee[ne]=d(Y(oe)?oe(J):void 0)}return ee}#lt(_,J,ee,ne,oe){if(this.#Xe()&&!this.#Ot(ee))return;const ie=l(this.#ee(_,ne)),ae=l(this.#ee(_,oe)),ce=ie.length!==ae.length||ie.some((Ae,je)=>Ae!==ae[je]),de=[];for(const Ae of J){const je=Ae.getValue;if(!Y(je))continue;const be=je(ne),re=je(oe);!ce&&Object.is(be,re)||de.push({colId:Ae.id,before:be,after:re})}!de.length&&!ce||this.#S.push({beforeKeys:ie,afterKeys:ae,colDeltas:de})}#Ot(_){const J=this.#l.get("filter"),ee=J&&J.computed?J.result:null;if(!ee)return!0;let ne=0,oe=ee.length-1;for(;ne<=oe;){const ie=ne+oe>>1,ae=ee[ie];if(ae===_)return!0;ae<_?ne=ie+1:oe=ie-1}return!1}#Xe(){return(this.#e.config||{}).totalFilteredOnly!==!1}#et(_){return this.#Xe()?_:this.#qe().length}#qe(){return(!this.#N||this.#N.version!==this.#u)&&(this.#N={version:this.#u,indices:this.#ue()}),this.#N.indices}#tt(){const _=this.#_("groupBy",[]),J=`${this.#u}|${JSON.stringify(_)}`;if(this.#R&&this.#R.key===J)return this.#R.map;const ee=new Map,ne=[];for(const oe of _){const ie=this.#o.handle(oe);ie&&ne.push(ie)}if(ne.length){const oe=this.#qe(),{keys:ie,buckets:ae}=this.#st("groupByColumns")(ne,oe,{locale:(this.#e.config||{}).locale}),ce=new Map;for(let de=0;de<ae.length;de++){const Ae=ie[de],je=[];for(let be=0;be<Ae.length;be++){je.push(d(Ae[be]));const re=c(je);let fe=ce.get(re);fe||(fe=[],ce.set(re,fe));for(let pe=0;pe<ae[de].length;pe++)fe.push(ae[de][pe])}}for(const[de,Ae]of ce)ee.set(de,Uint32Array.from(Ae))}return this.#R={key:J,map:ee},ee}#Ke(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#nt(){this.#St(),this.#A(),this.#E=null,this.#M=null,this.#P=null}#St(){this.#j.clear(),this.#O.length=0,this.#w=-1}#A(){this.#v.clear(),this.#S.length=0,this.#T=-1}#jt(_){const J=this.#_("pivotBy",[]);if(!J.length)return this.#fe=null,null;const ee=(this.#e.compute||{}).pivot;if(!Y(ee))return D("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#fe=null,null;const ne=J.map(ie=>this.#o.handle(ie)).filter(Boolean),oe=this.#Ze();return this.#fe=ee(ne,_.leaves,{groups:_.keys&&_.buckets?{keys:_.keys,buckets:_.buckets}:null,totals:oe.map(ie=>ie.id),handle:ie=>this.#o.handle(ie),totalOf:ie=>R(oe.find(ae=>ae.id===ie),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#fe}#Ge(_){const J=this.#l.get("total").result,ee=!!(this.#e.config||{}).groupFooter,ne=this.#Ie();if(_.tree)return this.#At(_,J,ne);if(!_.roots&&!ne){if(J&&J.grand&&!this.#me()){const Ae=this.#i.grandTotal(J.grand,this.#et(_.leaves.length));if(this.#K===_.leaves&&Array.isArray(this.#I))this.#I[this.#I.length-1]=Ae;else{const je=Array.from(_.leaves);je.push(Ae),this.#I=je,this.#K=_.leaves}this.#z=[{at:this.#I.length-1}]}else this.#K=null,this.#I=_.leaves,this.#z=W;return this.#H=W,this.#I}const oe=[],ie=[],ae=[],ce=Ae=>{if(oe.push(Ae),!ne)return;const je=this.#je(Ae);!je||!ne.isOpen(je.key)||(je.master=!0,je.expanded=!0,ae.push({at:oe.length}),oe.push(this.#i.detail(je,ne.heightOf(je))))};if(!_.roots){for(let Ae=0;Ae<_.leaves.length;Ae++)ce(_.leaves[Ae]);return J&&J.grand&&!this.#me()&&(ae.push({at:oe.length}),oe.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#K=null,this.#H=W,this.#z=ae.length?ae:W,this.#I=oe,oe}const de=(Ae,je,be)=>{if(Ae.expanded=Ae.hasChildren===!1?!1:this.#pt(Ae.key,{key:Ae.key,column:Ae.groupColumn,value:Ae.groupValue,level:Ae.level,path:Ae.groupPath}),Ae.posinset=je+1,Ae.setsize=be,ie.push({at:oe.length,row:Ae}),ae.push({at:oe.length}),oe.push(Ae),!!Ae.expanded){if(Ae.children&&Ae.children.length)for(let re=0;re<Ae.children.length;re++)de(Ae.children[re],re,Ae.children.length);else{const re=_.nodes.get(Ae.key),fe=re&&re.leaves?re.leaves:null;if(fe)for(let pe=0;pe<fe.length;pe++)ce(fe[pe])}ee&&Ae.totals&&(ae.push({at:oe.length}),oe.push(this.#i.footer(Ae)))}};for(let Ae=0;Ae<_.roots.length;Ae++)de(_.roots[Ae],Ae,_.roots.length);return J&&J.grand&&!this.#me()&&(ae.push({at:oe.length}),oe.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#H=ie,this.#z=ae,this.#I=oe,oe}#ue(){const _=this.#e.store;if(_&&Y(_.liveIndices))return _.liveIndices();const J=new Uint32Array(this.#n.length);let ee=0;for(let ne=0;ne<this.#n.length;ne++)this.#n[ne]!==void 0&&(J[ee++]=ne);return J.subarray(0,ee)}#Ne(){const _=this.#e.store;return _&&typeof _.physical=="number"?_.physical:this.#n.length}#ae(_){const J=this.#e.store;return J&&Y(J.source)?J.source(_):this.#n[_]}#Le(_,J=_){const ee=this.#I[_];if(typeof ee!="number")return ee.index=J,ee;const ne=this.#je(ee);return ne.index=J,ne}#je(_){let J=this.#h.get(_);J||(J=this.#i.leaf(this.#ae(_),_),this.#h.set(_,J));const ee=this.#L?this.#L.get(_):null;if(ee){J.level=ee.level,J.posinset=ee.posinset,J.setsize=ee.setsize,J.hasChildren=ee.hasChildren,J.expanded=ee.hasChildren&&!ee.lazy&&this.#pt(J.key);const ne=this.#U?this.#U.byPhysical.get(_):void 0;ne?J.totals=ne:J.totals&&(J.totals=null)}else J.hasChildren&&(J.level=0,J.hasChildren=!1,J.expanded=!1,J.posinset=void 0,J.setsize=void 0);return J}#At(_,J,ee){const ne=[],oe=[],ie=ce=>{if(ce.leafCount!==void 0)return ce.leafCount;let de=ce.physical>=0?1:0;for(const Ae of ce.children)de+=ie(Ae);return ce.leafCount=de,de},ae=ce=>{const de=this.#pt(ce.key);if(ce.physical>=0){if(ne.push(ce.physical),ee&&ee.isOpen(this.#je(ce.physical).key)){const Ae=this.#je(ce.physical);oe.push({at:ne.length}),ne.push(this.#i.detail(Ae,ee.heightOf(Ae)))}}else ne.push(this.#i.group({path:[ce.key],column:null,value:ce.value,level:ce.level,parent:null,expanded:de,hasChildren:ce.children.length>0,leafCount:ie(ce),totals:this.#U?this.#U.byKey.get(ce.key):void 0}));if(de)for(const Ae of ce.children)ae(Ae)};for(const ce of _.tree.roots)ae(ce);return J&&J.grand&&!this.#me()&&(oe.push({at:ne.length}),ne.push(this.#i.grandTotal(J.grand,this.#et(_.leaves.length)))),this.#K=null,this.#H=W,this.#z=oe.length?oe:W,this.#I=ne,ne}#Nt(){return r(()=>this.count(),_=>this.at(_))}#ct(_,J){let ee=this.#F.get(_);if(ee===void 0){const ne=this.#ae(_),oe=this.#ot(),ie=[],ae=this.#e.columnHidden;for(const ce of oe){if(ce.quickFilter===!1||Y(ae)&&ae(ce.id))continue;const de=ce.value&&Y(ce.value.quickFilterText)?ce.value.quickFilterText({value:void 0,data:ne,row:null,column:ce,colId:ce.id,grid:null,context:this.#_("context",null)}):null,Ae=de??(Y(ce.formatValue)?ce.formatValue(Y(ce.getValue)?ce.getValue(ne):void 0):"");Ae!=null&&Ae!==""&&ie.push(String(Ae))}ee=ie.join(" ").toLowerCase(),this.#F.set(_,ee)}return J(ee)}#Ze(){const _=this.#_("totals",[]),J=_&&_.length?new Set(_):null;return this.#ot().filter(ee=>J?J.has(ee.id):!!(ee.total||ee.groupTotal||ee.grandTotal))}#rt(_,J,ee,ne="group"){const oe={},ie=(this.#e.compute||{}).total;for(const ae of _){if(!x(ae))continue;const ce=this.#o.handle(ae.id);if(!ce)continue;const de=R(ae,ne);if(de)if(Y(de)){const Ae=new Array(J.length);for(let je=0;je<J.length;je++)Ae[je]=ce.get(J[je]);oe[ae.id]=de(Ae,{row:ee,column:ae,grid:this.#e.grid||null,context:this.#_("context",null),valueAt:(je,be)=>{const re=this.#o.handle(je);return re&&be>=0&&be<J.length?re.get(J[be]):null}})}else Y(ie)&&(oe[ae.id]=ie(ce,J,de))}return oe}#it(_){if(!_)return _;const J=this.#e.config||{},ee={tz:J.timeZone,weekStartsOn:J.weekStartsOn};return m(_,ne=>{const oe=v(ne,ee),ie=this.#Ue(oe&&oe.col),ae=ie&&ie.type==="datetime";if(oe&&oe.type)return oe.type==="datetime"&&!oe.timeZone&&ie?{...oe,timeZone:J.timeZone||void 0}:oe;if(ae)return{...oe,type:"datetime",timeZone:J.timeZone||void 0};const ce=ie&&(ie.dataType?.base||ie.type);return ce?{...oe,type:ce}:oe})}#pt(_,J){const ee=this.#_("expanded",null);return ee?Y(ee.has)?ee.has(_,J):Array.prototype.includes.call(ee,_):!0}#_(_,J){if(_==="context"||!Y(this.#e.stateVersion))return this.#Mt(_,J);const ee=this.#mt(_),ne=this.#f.get(_);if(ne&&ne.version===ee)return ne.value;const oe=this.#Mt(_,J);return this.#f.set(_,{version:ee,value:oe}),oe}#Mt(_,J){const ee=this.#e.state;if(ee&&Y(ee[_])){const ne=ee[_]();return ne??J}return J}#ut(){const _=this.#e.stateVersion;return Y(_)?_():0}#xt(){const _=this.#e.columnsVersion,J=this.#e.permissionsVersion;return`${Y(_)?_():0}|${Y(J)?J():0}`}#mt(_){return _==="totals"?this.#xt():`${this.#ut()}`}#gt(_,J,ee){if(!Y(this.#e.stateVersion))return ee();const ne=this.#d.get(_);if(ne&&ne.version===J)return ne.key;const oe=ee();return this.#d.set(_,{version:J,key:oe}),oe}#st(_){const J=(this.#e.compute||{})[_];return Y(J)||F(`ctx.compute.${_} is required by the memory source pipeline`),J}#ot(){const _=this.#e.columns;return _&&Y(_.all)?_.all():[]}#Ue(_){const J=this.#e.columns;return J&&Y(J.get)?J.get(_):void 0}#Qe(_,J){const ee=this.#e.emit;Y(ee)&&ee(_,J)}}}),Be("packages/core/src/source/abort.js",function(e,H){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return F}});class te extends Error{constructor(Y,B="superseded"){super(`[lattice] request ${Y?`"${Y}" `:""}${B}`),this.name="SupersededError",this.superseded=!0,this.key=Y}}class L{#e;constructor(Y,B,z,G){this.#e=Y,this.key=B,this.controller=z,this.signal=z.signal,this.seq=G}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(Y){this.signal.aborted||this.controller.abort(new te(this.key,Y)),this.#e.settle(this)}}class X{#e=new Map;#t=0;begin(Y="",B="superseded"){const z=this.#e.get(Y);z&&!z.signal.aborted&&z.controller.abort(new te(Y,B));const G=new L(this,Y,new AbortController,++this.#t);return this.#e.set(Y,G),G}tokenFor(Y){return this.#e.get(Y)}pending(Y=""){const B=this.#e.get(Y);return!!B&&!B.signal.aborted}get size(){return this.#e.size}settle(Y){this.#e.get(Y.key)===Y&&this.#e.delete(Y.key)}abort(Y="",B="superseded"){const z=this.#e.get(Y);z&&z.abort(B)}abortAll(Y="superseded"){for(const B of[...this.#e.values()])B.abort(Y);this.#e.clear()}}function D(){return new X}function F(Z){if(!Z||typeof Z!="object")return!1;const Y=Z;return Y.superseded===!0||Y.name==="AbortError"||Y.name==="SupersededError"}}),Be("packages/core/src/source/blockcache.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_PAGE_SIZE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_MAX_CACHED_PAGES",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return D}});const te=100,L=32;class X{constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class D{#e=new Map;#t;#n;#r=0;#s=-1;constructor(Z={}){this.#t=Math.max(1,Math.floor(Number(Z.pageSize)||te)),this.#n=Math.max(1,Math.floor(Number(Z.maxCachedPages)||L))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const Y=this.#e.get(Z);return!!Y&&Y.state==="pending"}loaded(Z){const Y=this.#e.get(Z);return!!Y&&Y.state==="loaded"}begin(Z,Y){let B=this.#e.get(Z);return B||(B=new X(Z)),B.state="pending",B.token=Y,B.error=null,this.#i(Z,B),B}fill(Z,Y){const B=this.#e.get(Z)||new X(Z);B.rows=Y,B.state="loaded",B.token=null,this.#i(Z,B)}failed(Z,Y){const B=this.#e.get(Z)||new X(Z);B.state="error",B.error=Y,B.token=null,this.#i(Z,B)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const Y=this.blockOf(Z),B=this.#e.get(Y);if(!(!B||B.state!=="loaded"||!B.rows))return this.#i(Y,B),B.rows[Z-Y*this.#t]}rowLoaded(Z){const Y=this.blockOf(Z),B=this.#e.get(Y);return!!B&&B.state==="loaded"&&!!B.rows&&Z-Y*this.#t<B.rows.length}erroredAt(Z){const Y=this.#e.get(this.blockOf(Z));return!!Y&&Y.state==="error"}loadedExtent(){let Z=0;for(const Y of this.#e.values()){if(Y.state!=="loaded"||!Y.rows)continue;const B=Y.id*this.#t+Y.rows.length;B>Z&&(Z=B)}return Z}fillOf(Z){const Y=this.#e.get(Z);return Y&&Y.state==="loaded"&&Y.rows?Y.rows.length:null}protect(Z,Y){this.#r=this.blockOf(Math.max(0,Z)),this.#s=this.blockOf(Math.max(0,Y))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[Y,B]of this.#e){if(this.#e.size-Z.length<=this.#n)break;Y>=this.#r&&Y<=this.#s||B.state!=="pending"&&Z.push(Y)}for(const Y of Z)this.#e.delete(Y);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,Y){this.#e.delete(Z),this.#e.set(Z,Y)}}}),Be("packages/core/src/source/pagewindow.js",function(e,H){"use strict";Object.defineProperty(e,"pageWindow",{enumerable:!0,get:function(){return te}});function te(L,X,D,F){const Z=Math.floor(Number(L)||0);if(Z<=0)return null;const Y=Math.max(0,Math.floor(Number(X)||0)),B=Math.max(0,Math.floor(Number(D)||0));if(F){const z=Math.max(1,Math.ceil(B/Z)),G=Math.min(Y,z-1),P=G*Z;return{page:G,pageSize:Z,offset:P,length:Math.max(0,Math.min(Z,B-P)),pageCount:z,total:B}}return{page:Y,pageSize:Z,offset:Y*Z,length:Z,pageCount:Math.max(Y+2,Math.ceil(B/Z)),total:null}}}),Be("packages/core/src/source/paged.js",function(e,H){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return w}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/warn.js").warnOnce,B=H("packages/core/src/internal/schedule.js").settleDebounce,z=H("packages/core/src/source/abort.js"),G=z.createAbortScope,P=z.isAbortError,O=H("packages/core/src/source/blockcache.js"),b=O.BlockCache,c=O.DEFAULT_PAGE_SIZE,d=O.DEFAULT_MAX_CACHED_PAGES,r=H("packages/core/src/source/rows.js").createRowFactory,t=H("packages/core/src/source/filterwire.js"),i=t.wireFilters,s=t.querySignature,n=t.warnHostFilterNotApplied,o=H("packages/core/src/source/pagewindow.js").pageWindow,a=120;function f(m,v){return new w(m,v)}class w{mode="paged";#e;#t;#n;#r=G();#s;#i;#o=new Map;#l=null;#a=null;#c=!1;#u=0;#f="";#d={start:0,end:0};#h;#p=!1;#m=0;#g="";constructor(v,h){this.#e=v||{mode:"paged"},this.#t=h||{},this.#n=new b({pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||d}),this.#s=r(this.#t),this.#i=new L(this.#n.pageSize*4),this.#h=B((p,g)=>this.#w(p,g),a),this.#f=this.#E(),D(this.#e.fetch)||Z("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),n(this.#t)}count(){const v=this.#y();return v?v.length:this.#b()}#b(){if(this.#T(),this.#l!==null)return this.#l;const v=Math.max(this.#u,this.#n.loadedExtent());return this.#c?v:v+this.#n.pageSize}matchCount(){return this.#b()}totalCount(){return this.#b()}pageInfo(){const v=this.#y();if(!v){const h=this.#b();return{page:0,pageSize:0,total:this.exact()?h:null,pageCount:1,counting:!1}}return{page:v.page,pageSize:v.pageSize,total:v.total,pageCount:v.pageCount,counting:v.total===null&&this.#r.size>0&&this.#u===0&&this.#n.loadedExtent()===0}}#y(){const v=this.#b(),h=o(this.#P("pageSize",0),this.#P("page",0),v,this.exact());if(!h)return this.#g="",null;const p=`${this.#m}:${h.offset}:${h.length}`;if(p!==this.#g&&!this.#p&&(this.#g=p,h.length>0)){const g=h.offset+h.length-1;this.#d={start:h.offset,end:g},this.#w(h.offset,g)}return h}at(v){const h=this.#y();if(h){if(v<0||v>=h.length)return;const p=this.#j(h.offset+v);return p&&(p.index=v),p}return this.#j(v)}#j(v){if(v<0||v>=this.#b())return;const h=this.#i.get(v);if(h&&(h.data!==null||!this.#n.rowLoaded(v)))return h;const p=this.#n.rowAt(v);if(p===void 0){const k=this.#s.skeleton(v,0,this.#n.erroredAt(v));return this.#i.set(v,k),k}const g=this.#s.leaf(p,v);return g.index=v,this.#i.set(v,g),this.#o.set(g.key,v),g}byKey(v){const h=this.#o.get(v);return h===void 0?void 0:this.#j(h)}loaded(v){const h=this.#y();return h?v>=0&&v<h.length&&this.#n.rowLoaded(h.offset+v):this.#n.rowLoaded(v)}loadedCount(){this.#T();let v=0;for(const h of this.#n.ids()){if(!this.#n.loaded(h))continue;const p=this.#n.fillOf(h);typeof p=="number"&&(v+=p)}return v}residentRows(){this.#T();const v=this.#y(),h=v?v.offset:0,p=v?v.offset+v.length:1/0,g=[],k=this.#n.ids().sort((y,T)=>y-T);for(const y of k){if(!this.#n.loaded(y))continue;const{start:T}=this.#n.rangeOf(y),j=this.#n.fillOf(y)||0;for(let N=T;N<T+j;N++){if(N<h||N>=p)continue;const W=this.#i.peek(N);if(W&&W.data!==null&&W.data!==void 0){g.push(W);continue}const R=this.#n.rowAt(N);if(R===void 0)continue;const x=this.#s.leaf(R,N);x.index=N,this.#i.set(N,x),this.#o.set(x.key,N),g.push(x)}}return g}hint(v,h){if(this.#p)return;const p=this.#T();let g=Math.max(0,Math.floor(v)),k=Math.max(g,Math.floor(h));const y=this.#y();if(y){if(y.length===0)return;g=y.offset,k=y.offset+y.length-1}this.#d={start:g,end:k},this.#n.protect(g,k);for(const T of this.#n.evict())this.#v(T);this.#h(g,k),p&&this.#h.flush()}#w(v,h){if(this.#p)return;this.#n.protect(v,h);const p=this.#n.blockOf(v),g=this.#n.blockOf(h);for(let k=p;k<=g&&!(this.#l!==null&&k*this.#n.pageSize>=this.#l);k++)this.#n.has(k)||this.#O(k)}apply(v){const h={added:[],updated:[],removed:[]};if(!v)return h;if(v.update)for(const p of v.update){const g=this.#s.keyOf(p,-1),k=this.#o.get(g);if(k===void 0)continue;const y=this.#s.leaf(p,k);y.index=k,this.#i.set(k,y),h.updated.push(y)}return(v.add&&v.add.length||v.remove&&v.remove.length)&&this.reload(),h}reload(v){this.#S("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#p=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#o.clear()}exact(){return this.#l!==null||this.#c}pending(){return this.#r.size}async#O(v){if(!D(this.#e.fetch))return;const h=this.#r.begin(`block:${v}`);this.#n.begin(v,h);const{start:p,end:g}=this.#n.rangeOf(v),k=this.#f;try{const y=await this.#e.fetch({range:{start:p,end:g},sort:this.#P("sort",[]),filters:i(this.#P("filters",null),this.#M()),quick:this.#P("quick","")||void 0,context:this.#P("context",null),signal:h.signal});if(!h.current||k!==this.#f||this.#p)return;h.settle();const T=y&&y.rows||[];this.#n.fill(v,T);for(let N=0;N<T.length;N++)this.#i.delete(p+N);const j=y&&typeof y.total=="number"?y.total:y&&typeof y.count=="number"?y.count:null;j!==null?(this.#l=j,this.#c=!0):T.length<this.#n.pageSize?(this.#c=!0,this.#l=p+T.length):this.#u=Math.max(this.#u,p+T.length),this.#N("model:changed",{reason:"page",block:v,from:p,to:p+T.length}),this.#N("rows:changed",{companion:!0,reason:"page",block:v,from:p,to:p+T.length}),this.#l!==null&&this.#l!==this.#a&&(this.#a=this.#l,this.#N("source:total",{total:this.#l,groupPath:[]}))}catch(y){if(h.settle(),P(y))return;this.#n.failed(v,y);for(let T=p;T<g;T++)this.#i.delete(T);this.#N("model:changed",{reason:"page-error",block:v,range:{start:p,end:g}}),this.#N("source:error",{error:y,block:v,range:{start:p,end:g}})}}#v(v){const{start:h,end:p}=this.#n.rangeOf(v);for(let g=h;g<p;g++){const k=this.#i.peek(g);k&&this.#o.delete(k.key),this.#i.delete(g)}}#T(){const v=this.#E();return v===this.#f?!1:(this.#f=v,this.#S("query"),!0)}#S(v){this.#r.abortAll(v),this.#n.clear(),this.#i.clear(),this.#o.clear(),this.#l=null,this.#a=null,this.#c=!1,this.#u=0,this.#m++,this.#N("model:changed",{reason:v})}#E(){return s({filters:this.#P("filters",null),sort:this.#P("sort",[]),quick:this.#P("quick",""),context:this.#P("context",null)})}#M(){const v=this.#t.config||{};return{tz:v.timeZone,weekStartsOn:v.weekStartsOn}}#P(v,h){const p=this.#t.state;if(p&&D(p[v])){const g=p[v]();return g??h}return h}#N(v,h){const p=this.#t.emit;D(p)&&p(v,h)}}}),Be("packages/core/src/source/aggregates.js",function(e,H){"use strict";Object.defineProperty(e,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"pushableAggregates",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"fillAggregateSql",{enumerable:!0,get:function(){return X}}),Object.defineProperty(e,"resolveAggregatesConfig",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"routeAggregate",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"resolveAggregatePlan",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"groupKeysPushable",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"pushdownDocRows",{enumerable:!0,get:function(){return z}});const te=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function L(){const G=new Set;for(const[P,O]of Object.entries(te))O.pushable&&G.add(P);return G}function X(G,P,O){let b=G.split("%c").join(P);return O!==void 0&&(b=b.split("%w").join(O)),b}function D(G){const P=G||{},O=P.default==="engine"||P.default==="engine-if-identical"?P.default:"client",b={};if(P.overrides&&typeof P.overrides=="object")for(const[c,d]of Object.entries(P.overrides))(d==="engine"||d==="client")&&(b[c]=d);return{default:O,overrides:b}}function F(G,P){const O=te[G];if(!O||!O.pushable)return"client";const b=P.overrides[G];return b==="engine"||b==="client"?b:P.default==="client"?"client":P.default==="engine-if-identical"?O.class==="identical"?"engine":"client":"engine"}function Z(G,P){const O=D(P),b=[],c=[];for(const d of G||[]){const l=te[d.fn],r=F(d.fn,O),t={id:d.id,col:d.col,fn:d.fn,class:l?l.class:"fallback"};d.weight!==void 0&&(t.weight=d.weight),d.params!==void 0&&(t.params=d.params),r==="engine"?b.push(t):(t.reason=l&&!l.pushable?l.note||"the engine cannot express this stat":"client by config",c.push(t))}return{engine:b,client:c,config:O}}const Y=/^[A-Za-z_][A-Za-z0-9_$]*$/;function B(G,P=[]){return(G||[]).every(b=>{if(typeof b=="string")return Y.test(b);if(!b||typeof b!="object")return!1;const c=b;return Array.isArray(P)&&P.includes(c.bucket)&&typeof c.col=="string"&&Y.test(c.col)&&typeof c.size=="number"&&Number.isFinite(c.size)&&c.size>0})}function z(){return Object.entries(te).map(([G,P])=>({stat:G,class:P.class,sql:P.sql?X(P.sql,"col",P.twoColumn?"weight":void 0):"",note:P.note||(P.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Be("packages/core/src/source/pushdown.js",function(e,H){"use strict";Object.defineProperty(e,"FOREGROUND_WAIT_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return q}});const L=H("packages/core/src/internal/compare.js").defaultCompare,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/merge.js").toArray,B=H("packages/core/src/internal/warn.js").warnOnce,z=H("packages/core/src/source/filterwire.js"),G=z.isGroup,P=z.warnWherePageRelative,O=z.warnWhereOverThreshold,b=z.wireFilters,c=H("packages/core/src/source/aggregates.js"),d=c.resolveAggregatePlan,l=c.groupKeysPushable,r=c.STAT_PUSHDOWN,i=H("packages/core/src/source/abort.js").SupersededError,s=1e3;function n(_){const J=_&&_.signal;if(!J||!J.aborted)return;const ee=J.reason;throw ee instanceof Error?ee:new i("","superseded before it was sent")}const u=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function o(_){if(!_||typeof _!="object")return!1;const J=_.returning==="row"||_.returning==="key"?_.returning:"none";return{append:_.append===!0,update:_.update===!0,delete:_.delete===!0,returning:J}}function a(_,J){if(!_||typeof J!="string")return;if(!J.includes("."))return _[J];let ee=_;for(const ne of J.split(".")){if(ee===null||typeof ee!="object")return;ee=ee[ne]}return ee}function f(_){if(_===!0)return!0;if(!_||typeof _!="object")return!1;const J=_;return J.enabled===!1?!1:J.enabled===!0||D(J.commit)}function w(_){const J={...u,..._||{}};return J.operators=new Set(J.operators||[]),J.mutate=o(J.mutate),J}function m(_,J){return!_||!_.op||!J.operators.size?!1:J.operators.has(_.op)}function v(_,J){if(!_)return{pushed:null,residual:null};if(!J.filter)return{pushed:null,residual:_};if(J.filter==="term"){if(G(_)){const ie=_.conditions||[];if(String(_.op)!=="and")return{pushed:null,residual:_};const ae=ie.findIndex(de=>!G(de)&&m(de,J));if(ae<0)return{pushed:null,residual:_};const ce=ie.filter((de,Ae)=>Ae!==ae);return{pushed:ie[ae],residual:ce.length?{op:"and",conditions:ce}:null}}return m(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_}}if(!G(_))return m(_,J)?{pushed:_,residual:null}:{pushed:null,residual:_};if(String(_.op)!=="and")return(_.conditions||[]).every(ae=>G(ae)?v(ae,J).residual===null:m(ae,J))?{pushed:_,residual:null}:{pushed:null,residual:_};const ee=[],ne=[];for(const ie of _.conditions||[]){if(G(ie)){if(J.filter==="flat"){ne.push(ie);continue}const ae=v(ie,J);ae.pushed&&ee.push(ae.pushed),ae.residual&&ne.push(ae.residual);continue}(m(ie,J)?ee:ne).push(ie)}const oe=ie=>ie.length===0?null:ie.length===1?ie[0]:{op:"and",conditions:ie};return{pushed:oe(ee),residual:oe(ne)}}const h="__lattice_leaves";function p(_){return _.aggregates?_.aggregates instanceof Set?_.aggregates:new Set(Z(_.aggregates)):new Set}function g(_){const J=p(_);return J.size?J.has("count")?_.filter!=="tree"||!_.operators||!_.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function k(_,J,ee,ne,oe,ie,ae){const ce=Array.isArray(_.groupBy)?_.groupBy:[],de=Array.isArray(_.groupPath)?_.groupPath:[],Ae=Array.isArray(_.groupValues)?_.groupValues:null;if(!J.group){const je=g(J);if(je)return je}return l(ce)?ee.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":ne?oe?ie?"a host `where` predicate can only run in the browser, over rows the engine grouped":ae?"fullDataset holds the whole matching set, so the grid groups it itself":!Ae||Ae.length!==de.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const y="pushdown:pivot-unsupported",T="pushdown:group-unsupported",j=Symbol("lattice.remote.ungroupedLevel");function N(_,J,ee,ne,oe,ie){const ae=Array.isArray(_.pivotBy)?_.pivotBy:[],ce=Array.isArray(_.groupBy)?_.groupBy:[],de=Array.isArray(_.groupPath)?_.groupPath:[],Ae=Array.isArray(_.groupValues)?_.groupValues:null;return J.pivot?l(ae)?ce.length&&!l(ce)?"a grouping key is not a plain column the engine can name in a GROUP BY":ee.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":ne?oe?ie?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!Ae||Ae.length!==de.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function W(_,J,ee=!1){const ne=v(_.filters||null,J),oe=[];ne.residual&&oe.push("filter");const ie=_.sort||[],ae=ie.length===0||J.sort==="multi"&&ie.length>=1||J.sort==="single"&&ie.length===1;!ae&&ie.length&&oe.push("sort");const ce=_.quick?String(_.quick):"",de=!ce||!!J.quick;de||oe.push("quick");const Ae=_.where&&_.where.active?_.where:null;Ae&&oe.push("where");const je={filters:ne.residual,sort:ae?null:ie,quick:de?"":ce,where:Ae},be=!!ee,re=Array.isArray(_.groupBy)&&_.groupBy.length>0,fe=re?k(_,J,ne,ae,de,Ae,be):"",pe=_.pivotMode!==!1&&Array.isArray(_.pivotBy)&&_.pivotBy.length>0,Oe=pe?N(_,J,ne,ae,de,Ae):"",ve=pe&&Oe==="";pe&&!ve&&oe.push("pivot");const $e=pe?ve&&re:re&&fe==="";re&&!pe&&!$e&&oe.push("group");const he=($e||ve)&&Array.isArray(_.groupValues)?_.groupValues.length:0,ye=$e||pe?!1:be||!!(je.filters||je.sort||je.quick||je.where)||!J.range;return{pushed:{..._,filters:ne.pushed,sort:ae?ie:[],quick:de?ce:"",range:ye?null:_.range},residual:je,needsAll:ye,unpushed:oe,full:be,grouped:$e,groupLevel:he,groupReason:pe?"":fe,pivoted:ve,pivotReason:Oe}}function R(_){const J=Array.isArray(_.totals)?_.totals:[],ee=_.totalFns&&typeof _.totalFns=="object"?_.totalFns:{},ne=[],oe=[];for(const ie of J){const ae=String(ie),ce=typeof ee[ae]=="string"?ee[ae]:null,de=ce?r[ce]:null;ce?!de||!de.pushable||!de.sql?oe.push({id:ae,fn:ce,class:de?de.class:"fallback",reason:de&&de.note?de.note:`the pushdown map cannot express "${ce}"`}):de.twoColumn?oe.push({id:ae,fn:ce,class:de.class,reason:`"${ce}" reduces two columns, and a grouped request carries no weight column`}):ne.push({id:ae,col:ae,fn:ce,class:de.class}):oe.push({id:ae,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:ne,client:oe}}const x=Object.freeze({items:_=>_==null?[]:Array.isArray(_)?_:[_]});function A(_,J,ee){if(!J)return _;let ne=_;if(J.filters&&D(ee.evaluateFilters)){const oe=ne,ie={count:ne.length,handle:de=>({id:de,get:Ae=>a(oe[Ae],de)}),itemwise:de=>oe.some(Ae=>Array.isArray(a(Ae,de)))?x:null},ae=ee.evaluateFilters(J.filters,ie),ce=[];for(let de=0;de<ne.length;de++)ae[de]&&ce.push(ne[de]);ne=ce}if(J.where&&J.where.active&&(J.whole||P(J.where.names,"pushdown"),ne=ne.filter(oe=>J.where.passes(oe))),J.quick){const oe=J.quick.toLowerCase();ne=ne.filter(ie=>{if(!ie||typeof ie!="object")return!1;for(const ae of Object.values(ie))if(ae!=null&&String(ae).toLowerCase().includes(oe))return!0;return!1})}if(J.sort&&J.sort.length&&D(ee.sortMulti)){const oe=[...new Set(J.sort.map(de=>de.col))],ie=ne,ae=oe.map(de=>({id:de,get:Ae=>a(ie[Ae],de)})),ce=ee.sortMulti(ae,J.sort.map(de=>({col:de.col,dir:de.dir})),Uint32Array.from({length:ne.length},(de,Ae)=>Ae),{});ne=Array.from(ce,de=>ie[de])}return ne}function $(_){return JSON.stringify({filters:_.filters||null,sort:_.sort||[],quick:_.quick||"",groupBy:_.groupBy||[],groupPath:_.groupPath||[],context:_.context??null})}function I(_){if(!_||typeof _!="object")return 16;let J="";try{J=JSON.stringify(_)}catch{return 200}return J.length*2+64}function M(_){const J=_||{};return{enabled:!!J.enabled,maxRows:Number.isFinite(J.maxRows)?J.maxRows:1e6,maxBytesEstimate:Number.isFinite(J.maxBytesEstimate)?J.maxBytesEstimate:512*1024*1024}}const S=5e4;function E(_){return Number.isFinite(_)&&_>=0?_:S}function U(_){return!!_&&D(_.then)}async function K(_){if(!_||_.total!==void 0||!U(_.pendingTotal))return _;const J=await _.pendingTotal,{pendingTotal:ee,...ne}=_;return typeof J=="number"?{...ne,total:J}:ne}function q(_={}){const J=_.adapter;if(!J||!D(J.execute))return B("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{..._,mode:"remote",fetch:async()=>({rows:[],total:0})};const ee=w(J.capabilities),ne=J.capabilities&&Object.getOwnPropertyDescriptor(J.capabilities,"operators");ne&&D(ne.get)&&Object.defineProperty(ee,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(J.capabilities.operators||[]),set:()=>{}});const oe=J.name||"adapter";let ie=null;const ae=()=>D(J.ready)?(ie||(ie=Promise.resolve(J.ready()).then(()=>{Object.assign(ee,w(J.capabilities))},ke=>{throw ie=null,ke})),ie):null,ce=M(_.fullDataset),de=!!_.allowPartialResults,Ae=E(_.whereRowLimit);let je=null;const be=_.aggregates;let re=null,fe=null,pe=null,Oe=null,ve=null,$e,he=null,ye=0,Se=null;const Ie=()=>!ce.enabled||!re?null:(Se!==re.key&&(ye++,Se=re.key),{rows:re.rows,version:ye}),we=async ke=>{const Ee=ke.where&&ke.where.active?ke.where:null;if(!Ee)return{request:ke,probe:null};const{where:Ce,...Re}=ke,xe=W(Re,ee,ce.enabled);if(xe.needsAll)return{request:ke,probe:null};const ze=$(xe.pushed);let Ve=null;return(!je||je.key!==ze)&&(ee.total?(n(ke),Ve=await K(await J.execute(xe.pushed,ke)),je={key:ze,size:Ve&&typeof Ve.total=="number"?Ve.total:null}):je={key:ze,size:null}),je.size!==null&&je.size<Ae?{request:ke,probe:null}:(O(Ee.names,oe,je.size,Ae),{request:Re,probe:Ve})},Fe=async(ke,Ee)=>{he=null;const Ce=R(ke.pushed);pe={engine:Ce.engine,client:Ce.client,groupBy:ke.pushed.groupBy},Ce.client.length&&B(`source.pushdown.group.totals.${oe}.${Ce.client.map(ze=>ze.id).join(".")}`,`the ${oe} adapter cannot compute the group subtotal for ${Ce.client.map(ze=>`"${ze.id}" (${ze.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Re=await J.executeGroupLevel(ke.pushed,Ce.engine,Ee)||{};let xe=Re.rows||[];return!ee.range&&Ee.range&&(xe=xe.slice(Ee.range.start,Ee.range.end)),it(Re),Re.total===void 0?{rows:xe}:{rows:xe,total:Re.total}},He=new Map,Ke=64,nt=async(ke,Ee)=>{he=null;const Ce=ke.pushed,Re=Ce.groupBy,xe=Array.isArray(Ce.groupValues)?Ce.groupValues:[],ze=xe.length,Ve=[...Ce.filters?[Ce.filters]:[],...Re.slice(0,ze).map((ht,ut)=>({col:ht,op:"eq",value:xe[ut]===void 0?null:xe[ut],caseSensitive:!0}))],Qe=Ve.length===0?null:Ve.length===1?Ve[0]:{op:"and",conditions:Ve},Ne=Ee.range?Ee.range.start:0;if(ze>=Re.length){const ht={...Ce,filters:Qe,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ut=await K(await J.execute(ht,Ee))||{};let Tt=ut.rows||[];return!ee.range&&Ee.range&&(Tt=Tt.slice(Ee.range.start,Ee.range.end)),typeof ut.total=="number"?{rows:Tt,total:ut.total}:{rows:Tt}}const Ge=Re[ze],qe=R(Ce),Je=p(ee),Ze=qe.engine.filter(ht=>Je.has(ht.fn)),lt=[...qe.engine.filter(ht=>!Je.has(ht.fn)).map(ht=>({id:ht.id,fn:ht.fn,class:ht.class,reason:`the ${oe} adapter does not compute "${ht.fn}"`})),...qe.client];pe={engine:Ze,client:lt,groupBy:Re},lt.length&&B(`source.pushdown.group.totals.${oe}.${lt.map(ht=>ht.id).join(".")}`,`the ${oe} adapter cannot compute the group subtotal for ${lt.map(ht=>`"${ht.id}" (${ht.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const ot=[...Ze.map(ht=>({id:ht.id,col:ht.col,fn:ht.fn})),{id:h,col:Ge,fn:"count"}],st={...Ce,filters:Qe,range:null},Ot=JSON.stringify([$(st),xe,Ge,ot]);let At=Ne>0?He.get(Ot):void 0;if(!At){for(At=Promise.resolve(J.executeGroupedAggregates(st,[Ge],ot)),He.delete(Ot),He.set(Ot,At);He.size>Ke;)He.delete(He.keys().next().value);At.catch(()=>{He.get(Ot)===At&&He.delete(Ot)})}const Rt=await At||[];n(Ee);const We=ht=>{const ut={};for(const Tt of Ze)ut[Tt.id]=ht?ht[Tt.id]:void 0;return ut},gt=(Ce.sort||[]).find(ht=>ht&&ht.col===Ge),ct=gt&&gt.dir==="desc"?-1:1,bt=Rt.filter(ht=>ht&&ht.level===1).map(ht=>({[Ge]:ht.keys[0]===void 0?null:ht.keys[0],leafCount:Number(ht.values&&ht.values[h])||0,totals:We(ht.values)})).sort((ht,ut)=>ct*L(ht[Ge],ut[Ge]));if(ze===0){const ht=Rt.find(Tt=>Tt&&Tt.level===0),ut=ht?Number(ht.values&&ht.values[h]):NaN;it({matchCount:Number.isFinite(ut)?ut:bt.reduce((Tt,Ht)=>Tt+Ht.leafCount,0),...ht?{grand:We(ht.values)}:{}})}const Et=Ee.range?Ee.range.end:bt.length;return{rows:bt.slice(Ne,Et),total:bt.length}},it=ke=>{typeof ke.matchCount=="number"&&(Oe=ke.matchCount,ve=ke.grand?{totals:ke.grand,leafCount:ke.matchCount}:null,$e===void 0&&D(J.unfilteredCount)&&($e=null,Promise.resolve(J.unfilteredCount()).then(Ee=>{$e=typeof Ee=="number"?Ee:null}).catch(Ee=>{B(`source.pushdown.group.unfiltered.${oe}`,`the ${oe} adapter could not count the unfiltered set (${Ee&&Ee.message?Ee.message:Ee}), so "N of M" falls back to the display count for its denominator.`)})))},mt=async(ke,Ee)=>{he=null;const Ce=R(ke.pushed);pe={engine:Ce.engine,client:Ce.client,groupBy:ke.pushed.groupBy,pivotBy:ke.pushed.pivotBy},Ce.client.length&&B(`source.pushdown.pivot.totals.${oe}.${Ce.client.map(Qe=>Qe.id).join(".")}`,`the ${oe} adapter cannot compute the pivot cells for ${Ce.client.map(Qe=>`"${Qe.id}" (${Qe.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Re=await J.executePivotLevel(ke.pushed,Ce.engine,Ee)||{};let xe=Re.rows||[];!ee.range&&Ee.range&&(xe=xe.slice(Ee.range.start,Ee.range.end)),it(Re);const ze=Re.pivot&&typeof Re.pivot=="object"?Re.pivot:{},Ve={cells:Array.isArray(ze.cells)?ze.cells:[],...Array.isArray(ze.axis)?{axis:ze.axis}:{}};return Re.total===void 0?{rows:xe,pivot:Ve}:{rows:xe,total:Re.total,pivot:Ve}},kt=ke=>{B(`source.pushdown.pivot.${oe}.${ke}`,`pushdown:pivot-unsupported: the ${oe} adapter cannot pivot this query because ${ke}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Ee=new Error(`[lattice] ${y}: the ${oe} adapter cannot pivot this query because ${ke}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Ee.code=y,Ee.reason=ke,Ee},St=(ke,Ee)=>{const Ce={key:Ee,state:"pending",value:null};return he=Ce,ke.then(Re=>(he===Ce&&(he={key:Ee,state:"settled",value:typeof Re=="number"?Re:null}),Re),Re=>{throw he===Ce&&(he={key:Ee,state:"failed",value:null}),Re})};let Pt=0,Nt=[];const Ft=()=>Pt===0?null:new Promise(ke=>{const Ee=setTimeout(ke,s);Nt.push(()=>{clearTimeout(Ee),ke()})});let Lt;const Ut=async ke=>{const Ee=ae();Ee&&await Ee;const Re=ke&&ke.pivotMode!==!1&&Array.isArray(ke.pivotBy)&&ke.pivotBy.length>0?{request:ke,probe:null}:await we(ke);n(ke);let xe=W(Re.request,ee,ce.enabled);if(ee.group&&xe.grouped&&!xe.pivoted&&!D(J.executeGroupLevel)&&(B(`source.pushdown.group.method.${oe}`,`the ${oe} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),xe=W(Re.request,{...ee,group:!1,aggregates:null},ce.enabled)),xe.pivoted&&!D(J.executePivotLevel)&&(xe=W(Re.request,{...ee,pivot:!1},ce.enabled),xe.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),xe.grouped&&!xe.pivoted&&!ee.group&&!D(J.executeGroupedAggregates)&&(B(`source.pushdown.group.aggregates.method.${oe}`,`the ${oe} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),xe=W(Re.request,{...ee,aggregates:null},ce.enabled)),fe=xe,xe.pivoted)return mt(xe,ke);if(xe.pivotReason&&kt(xe.pivotReason),xe.grouped)return ee.group?Fe(xe,ke):nt(xe,ke);const Ve=!!xe.groupReason&&!xe.full;Ve?B(`source.pushdown.group-unsupported.${oe}.${xe.groupReason}`,`pushdown:group-unsupported: the ${oe} adapter was not asked to group this query because ${xe.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):xe.groupReason&&B(`source.pushdown.group.${oe}.${xe.groupReason}`,`the ${oe} adapter was not asked to group this query because ${xe.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const Qe=ot=>Ve?{...ot,[j]:!0}:ot;if(!xe.needsAll){const ot=Re.probe||await J.execute(xe.pushed,ke),st=ot.rows||[];return U(ot.pendingTotal)&&ot.total===void 0?Qe({rows:st,pendingTotal:St(ot.pendingTotal,$(xe.pushed))}):(he=null,!ee.total&&ot.total===void 0?Qe({rows:st}):Qe({rows:st,total:ot.total??st.length}))}xe.unpushed.length&&B(`source.pushdown.residual.${oe}.${xe.unpushed.join(".")}`,`the ${oe} adapter cannot push ${xe.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const Ne=$(xe.pushed);if(!re||re.key!==Ne){const ot=await K(await J.execute(xe.pushed,ke));he=null;const st=ot.rows||[];if(xe.full){const Ot=typeof ot.total=="number"?Math.max(ot.total,st.length):st.length;if(Ot>ce.maxRows)throw new Error(`[lattice] fullDataset refused: the ${oe} adapter's matching set is ${Ot.toLocaleString()} rows, past the configured maxRows of ${ce.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const At=st.length*I(st[0]);if(At>ce.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${oe} adapter's matching set is an estimated ${Math.round(At/(1024*1024)).toLocaleString()} MB across ${st.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(ce.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof ot.total=="number"&&st.length<ot.total){const Ot=!!(xe.residual.filters||xe.residual.quick||xe.residual.sort&&xe.residual.sort.length);if(Ot&&!de)throw new Error(`[lattice] the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result, and the query has residual ${xe.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);Ot?B(`source.pushdown.partial.residual.${oe}`,`the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):B(`source.pushdown.partial.${oe}`,`the ${oe} adapter returned ${st.length} of ${ot.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}re={key:Ne,rows:st,total:typeof ot.total=="number"?ot.total:null}}let Ge=xe;if(xe.residual.where){const ot=re.total??re.rows.length;if(ot>=Ae){O(xe.residual.where.names,oe,ot,Ae);const{where:st,...Ot}=Re.request;Ge=W(Ot,ee,ce.enabled),fe=Ge}}const qe=re.total!==null&&re.rows.length>=re.total,Je=A(re.rows,{...Ge.residual,whole:qe},_.compute||{}),Ze=ke.range?ke.range.start:0,lt=ke.range?ke.range.end:Je.length;return Qe({rows:Je.slice(Ze,lt),total:Je.length})},ft=async(ke,Ee,Ce)=>{const xe=Ce&&Ce.waitForPage&&Lt&&D(Lt.pageForegroundIdle)?Lt.pageForegroundIdle():Ft();xe&&await xe;const ze=ae();ze&&await ze;const Ve=W(ke,ee,ce.enabled);fe=Ve;const Qe=d(Ee,be),Ne=Array.isArray(ke.groupBy)?ke.groupBy:[],Ge=Ne.length>0,qe=!Ve.residual.filters&&!Ve.residual.quick,Je=!Ge||l(Ne,ee.buckets);let Ze=Qe.engine,lt=Qe.client;if(ee.aggregates&&Ze.length){const At=ee.aggregates instanceof Set?ee.aggregates:new Set(Z(ee.aggregates)),Rt=Ze.filter(We=>!At.has(We.fn));Rt.length&&(Ze=Ze.filter(We=>At.has(We.fn)),lt=[...Rt.map(We=>({...We,reason:`the ${oe} adapter does not compute "${We.fn}"`})),...lt])}const ot=At=>{lt=[...Ze.map(Rt=>({...Rt,reason:At})),...lt],Ze=[]};Ze.length&&!qe?ot(Ve.residual.quick&&!Ve.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Ze.length&&!Je&&ot("a grouping key the engine cannot form forces all-client (no mixed provenance)");let st={},Ot;return Ze.length&&(D(Ge?J.executeGroupedAggregates:J.executeAggregates)?Ge?Ot=await J.executeGroupedAggregates(Ve.pushed,Ne,Ze)||[]:st=await J.executeAggregates(Ve.pushed,Ze)||{}:(B(`source.pushdown.aggregates.${oe}${Ge?".grouped":""}`,`the ${oe} adapter cannot compute ${Ge?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),ot(`adapter cannot compute ${Ge?"grouped ":""}aggregates`))),pe={engine:Ze,client:lt,...Ge?{groupBy:Ne}:{}},{values:st,engine:Ze,client:lt,...Ot!==void 0?{groups:Ot}:{}}},dt=async ke=>{Pt++;try{return await Ut(ke)}finally{if(Pt--,Pt===0&&Nt.length){const Ee=Nt;Nt=[];for(const Ce of Ee)Ce()}}},wt=f(_.edit),rt=_.edit&&typeof _.edit=="object"&&D(_.edit.commit);let me=_.edit;if(wt&&!rt)if(ee.mutate&&ee.mutate.update){const ke=Ee=>{if(!ee.mutate||!ee.mutate.update)throw new Error(`[lattice] the ${oe} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const Ce={kind:"update",key:String(Ee.key),patch:{[Ee.colId]:Ee.value}};return J.mutate(Ce,Ee.request||{})};me={..._.edit===!0?{}:_.edit,commit:ke}}else B(`source.pushdown.readonly.${oe}`,`edit is enabled but the ${oe} adapter declares mutate: ${ee.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const Te=wt&&ee.mutate&&(ee.mutate.append||ee.mutate.delete)?{append:ee.mutate.append===!0,remove:ee.mutate.delete===!0,returning:ee.mutate.returning,mutate:(ke,Ee)=>J.mutate(ke,Ee||{})}:null,Ue=async ke=>{const Ee=ae();Ee&&await Ee;const{range:Ce,signal:Re,export:xe,...ze}=ke||{},Ve={...ze,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:W(Ve,ee,ce.enabled),signal:Re}};async function*ge(ke,Ee={}){const{plan:Ce,signal:Re}=await Ue(ke),xe=Math.max(1,Math.floor(Number(Ee.pageSize))||5e3),ze={signal:Re,stream:!0};if(!Ce.needsAll)for(let Ne=0;;Ne+=xe){n(ze);const Ge=await J.execute({...Ce.pushed,range:{start:Ne,end:Ne+xe}},ze);Ge&&U(Ge.pendingTotal)&&Ge.pendingTotal.then(null,()=>{});const qe=Ge&&Ge.rows||[];if(qe.length&&(yield qe),qe.length<xe)return}n(ze);const Ve=await K(await J.execute({...Ce.pushed,range:void 0},ze)),Qe=A(Ve&&Ve.rows||[],{...Ce.residual,whole:!0},_.compute||{});for(let Ne=0;Ne<Qe.length;Ne+=xe)yield Qe.slice(Ne,Ne+xe)}return Lt={..._,edit:me,rowMutate:Te,mode:"remote",fetch:dt,foregroundIdle:Ft,aggregate:ft,countMatching:async ke=>{const{plan:Ee,signal:Ce}=await Ue(ke);if(!Ee.needsAll&&ee.total){n({signal:Ce});const xe=await K(await J.execute({...Ee.pushed,range:{start:0,end:0}},{signal:Ce}));if(xe&&typeof xe.total=="number")return xe.total}let Re=0;for await(const xe of ge(ke))Re+=xe.length;return Re},streamMatching:ge,capabilitiesOf:w,planQuery:W,wireFilters:b,resolveAggregatePlan:ke=>d(ke,be),STAT_PUSHDOWN:r,lastPlan:()=>fe?{...fe,...pe?{aggregates:pe}:{},...he?{total:{deferred:!0,state:he.state,value:he.value}}:{}}:null,fullFrame:Ie,counts:()=>({match:Oe,total:$e??null,pending:!!he&&he.state==="pending"}),grandTotals:()=>ve},Lt}}),Be("packages/core/src/source/remote.js",function(e,H){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return N}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return $}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,Z=H("packages/core/src/internal/warn.js").warnOnce,B=H("packages/core/src/internal/schedule.js").settleDebounce,z=H("packages/core/src/source/abort.js"),G=z.createAbortScope,P=z.isAbortError,O=H("packages/core/src/source/blockcache.js"),b=O.BlockCache,c=O.DEFAULT_PAGE_SIZE,d=O.DEFAULT_MAX_CACHED_PAGES,l=H("packages/core/src/source/rows.js"),r=l.createRowFactory,t=l.groupKey,i=H("packages/core/src/source/filterwire.js"),s=i.wireFilters,n=i.querySignature,u=i.warnHostFilterNotApplied,a=H("packages/core/src/source/pagewindow.js").pageWindow,w=H("packages/core/src/source/memory.js").MemorySource,v=H("packages/core/src/compute/handle.js").valueComparator,h=H("packages/core/src/compute/pivot.js"),p=h.pivotKey,g=h.joinPath,k=h.DEFAULT_PATH_SEPARATOR,T=H("packages/core/src/source/pushdown.js").UNGROUPED_LEVEL,j=1,N=120,W=1e3;function R(I,M,S){for(let E=0;E<Math.max(I.length,M.length);E++){const U=I[E],K=M[E],q=U==null,_=K==null;if(q||_){if(q&&_)continue;return q?1:-1}const J=S(U,K);if(J!==0)return J}return 0}function x(I,M){return new $(I,M)}class A{constructor(M,S,E,U){this.path=M,this.keyPath=U||M,this.values=[],this.level=S,this.key=t(this.keyPath),this.cache=new b(E),this.count=null,this.complete=!1,this.announced=null,this.counting=!1,this.failed=!1,this.children=new Map,this.row=null,this.flat=!1}}class ${mode="remote";#e;#t;#n;#r;#s=new Map;#i=new Set;#o=G();#l;#a;#c=new Map;#u=[];#f=null;#d="";#h;#p=!1;#m=!1;#g=[];#b=!1;#y=0;#j="";#w=null;#O=-1;constructor(M,S){this.#e=M||{mode:"remote"},this.#t=S||{},D(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#U(),this.unfilteredIndices=()=>this.#G(),this.handleFor=_=>this.#x(_),this.display=()=>this.#F(),this.grandTotalRow=()=>this.#I(),this.unfilteredRows=()=>this.#z(),this.facetIndices=_=>this.#Y(_));const E=this.#e.counts;D(E)&&(this.matchCount=()=>this.#K("match"),this.totalCount=()=>this.#K("total"));const U=this.#e.grandTotals;D(U)&&(this.grandTotalRow=()=>this.#H());const K=this.#e.foregroundIdle;D(K)&&(this.foregroundIdle=()=>this.#ye(K),this.#e.pageForegroundIdle=()=>this.#b?this.#ye(K):null);const q=this.#e;D(q.countMatching)&&D(q.streamMatching)&&(this.selectionQuery=()=>this.#fe(),this.countMatching=_=>q.countMatching(_),this.streamMatching=(_,J)=>q.streamMatching(_,J),this.loadedRows=()=>this.#ne(),this.resident=()=>this.#R()!==null),this.#n={pageSize:this.#e.pageSize||c,maxCachedPages:this.#e.maxCachedPages||d},this.#l=r(this.#t),this.#a=new L(this.#n.pageSize*4),this.#h=B((_,J)=>this.#P(_,J),N),this.#r=new A([],0,this.#n),this.#s.set(this.#r.key,this.#r),this.#d=this.#ve(),D(this.#e.fetch)||Z("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Be()}count(){const M=this.#S();return M?M.length:this.#v()}#v(){const M=this.#R();return M?M.count():(this.#q(),this.#te(this.#r))}#T(){if(this.#R())return!0;const M=S=>{if(S.count===null&&!S.complete)return!1;for(const E of S.children.values())if(this.#Ee(E.key)&&!M(E))return!1;return!0};return M(this.#r)}pageInfo(){const M=this.#S(),S=this.totalPending();if(!M){const E=this.#v();return{page:0,pageSize:0,total:this.#T()?E:null,pageCount:1,counting:S}}return{page:M.page,pageSize:M.pageSize,total:M.total,pageCount:M.pageCount,counting:S||M.total===null&&this.#o.size>0&&this.#r.cache.loadedExtent()===0}}#S(){const M=this.#v(),S=a(this.#C("pageSize",0),this.#C("page",0),M,this.#T());if(!S)return this.#j="",null;const E=`${this.#y}:${S.offset}:${S.length}`;return E!==this.#j&&!this.#p&&(this.#j=E,S.length>0&&!this.#R()&&this.#P(S.offset,S.offset+S.length-1)),S}at(M){const S=this.#S();if(S){if(M<0||M>=S.length)return;const E=this.#E(S.offset+M);return E&&(E.index=M),E}return this.#E(M)}#E(M){const S=this.#R();if(S)return S.at(M);if(this.#q(),M<0||M>=this.#v())return;const E=this.#W(this.#r,M);if(!E)return;const U=this.#X(E.node,E.local);return U&&(U.index=M),U||this.#l.skeleton(M,E.node.level,E.node.cache.erroredAt(E.local))}byKey(M){const S=this.#R();if(S)return S.byKey(M);const E=this.#c.get(M);if(!E)return;const U=E.lastIndexOf(":"),K=this.#s.get(E.slice(0,U));return K&&this.#X(K,Number(E.slice(U+1)))||void 0}loaded(M){const S=this.#S();if(S){if(M<0||M>=S.length)return!1;M+=S.offset}const E=this.#R();if(E)return E.loaded(M);if(M<0||M>=this.#v())return!1;const U=this.#W(this.#r,M);return!!U&&U.node.cache.rowLoaded(U.local)}hint(M,S){if(this.#p)return;this.#b=!0;const E=this.#q();let U=Math.max(0,Math.floor(M)),K=Math.max(U,Math.floor(S));const q=this.#S();if(q){if(q.length===0)return;U=q.offset,K=q.offset+q.length-1}for(const[_,J]of this.#M(U,K)){_.cache.protect(J.min,J.max);for(const ee of _.cache.evict())this.#Me(_,ee)}this.#h(U,K),E&&this.#h.flush()}#M(M,S){const E=this.#v(),U=new Map;for(let K=M;K<=S&&K<E;K++){const q=this.#W(this.#r,K);if(!q)continue;const _=U.get(q.node);_?(_.min=Math.min(_.min,q.local),_.max=Math.max(_.max,q.local)):U.set(q.node,{min:q.local,max:q.local})}return U.size||U.set(this.#r,{min:M,max:M}),U}#P(M,S){if(!this.#p)for(const[E,U]of this.#M(M,S)){E.cache.protect(U.min,U.max);const K=E.cache.blockOf(U.min),q=E.cache.blockOf(U.max);for(let _=K;_<=q&&!(E.count!==null&&_*E.cache.pageSize>=E.count);_++)E.cache.has(_)||this.#Ie(E,_)}}apply(M){const S={added:[],updated:[],removed:[]};if(!M)return S;if(M.update)for(const E of M.update){const U=this.#c.get(this.#l.keyOf(E,-1));if(!U)continue;this.#a.delete(U);const K=U.lastIndexOf(":"),q=this.#s.get(U.slice(0,K));if(!q)continue;const _=Number(U.slice(K+1)),J=q.cache.blockOf(_);if(!q.cache.loaded(J))continue;const{start:ee}=q.cache.rangeOf(J),ne=[];for(let ie=ee;ie<ee+q.cache.pageSize;ie++){const ae=q.cache.rowAt(ie);if(ae===void 0)break;ne.push(ie===_?E:ae)}q.cache.fill(J,ne);const oe=this.#X(q,_);oe&&S.updated.push(oe)}return(M.add&&M.add.length||M.remove&&M.remove.length)&&this.reload({keepExpanded:!0}),S}reload(M){this.#o.abortAll("reload"),this.#h.cancel(),M&&M.keepExpanded===!1&&this.#i.clear(),this.#re(),this.#V("model:changed",{reason:"reload"})}destroy(){this.#p=!0,this.#h.cancel(),this.#o.abortAll("destroyed"),this.#re(),this.#s.clear(),this.#i.clear(),this.#w&&D(this.#w.destroy)&&this.#w.destroy(),this.#w=null}expand(M){this.#i.has(M)||(this.#i.add(M),this.#V("group:toggled",{key:M,expanded:!0}),this.#V("model:changed",{reason:"expand",key:M}))}collapse(M){this.#i.delete(M)&&(this.#V("group:toggled",{key:M,expanded:!1}),this.#V("model:changed",{reason:"collapse",key:M}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#u}pivot(){this.#q();const M=this.#f;if(!M||!M.keys.size||!this.#C("pivotBy",[]).length)return null;if(!M.result){const S=v((this.#t.config||{}).locale),E=[...M.keys.entries()].sort((K,q)=>R(K[1],q[1],S)),U=E.map(([K])=>K);M.result={keys:E.map(([,K])=>K),paths:U,fields:this.#se(U),groupPaths:[],columns:U.length*Math.max(1,this.#Te().length),values:M.cells,cells:M.cells,error:null}}return M.result}invalidateHandles(){this.#w&&(D(this.#w.invalidateHandles)&&this.#w.invalidateHandles(),D(this.#w.invalidate)&&this.#w.invalidate("filter"))}#N(){const M=this.#e.fullFrame;return D(M)?M():null}#R(){const M=this.#N();return M?(this.#w||(this.#w=new w({mode:"memory"},this.#L())),M.version!==this.#O&&(this.#w.setRows(M.rows),this.#O=M.version),this.#w):null}#L(){const M=this.#t,S=M.state||{};return{...M,state:{...S,page:()=>0,pageSize:()=>0}}}#U(){const M=this.#R();return M?M.filteredIndices():new Uint32Array(0)}#G(){const M=this.#R();return M?M.unfilteredIndices():new Uint32Array(0)}#x(M){const S=this.#R();return S?S.handleFor(M):void 0}#F(){const M=this.#R();return M?M.display():[]}#Y(M){const S=this.#R();return S&&D(S.facetIndices)?S.facetIndices(M):new Uint32Array(0)}#I(){const M=this.#R();return M&&D(M.grandTotalRow)?M.grandTotalRow():null}#K(M){const S=this.#R();if(S){const q=M==="match"?S.matchCount:S.totalCount;if(D(q))return q.call(S)}const E=this.#e.counts,U=D(E)?E():null,K=U?U[M]:null;return typeof K=="number"?K:this.#v()}#H(){const M=this.#R();if(M&&D(M.grandTotalRow))return M.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const E=this.#e.grandTotals,U=D(E)?E():null;return!U||!U.totals?null:this.#l.grandTotal(U.totals,U.leafCount||0)}#z(){const M=this.#R();if(M&&D(M.unfilteredRows))return M.unfilteredRows();const S=[],E=this.count();for(let U=0;U<E;U++){const K=this.at(U);K&&S.push(K)}return S}#fe(){const M=this.#C("quick",""),S={protocol:j,groupPath:[],groupValues:[],groupBy:[],totals:[],totalFns:{},pivotBy:[],pivotMode:!1,filters:s(this.#C("filters",null),this.#B()),sort:this.#C("sort",[]),context:this.#C("context",null)};M&&(S.quick=M);const E=this.#C("where",null);return E&&E.active&&(S.where=E),S}#ne(){const M=this.#C("groupBy",[]).length,S=[];for(const E of this.#s.values())if(!(E.level!==M&&!E.flat))for(const U of E.cache.ids()){if(!E.cache.loaded(U))continue;const{start:K,end:q}=E.cache.rangeOf(U);for(let _=K;_<q&&E.cache.rowLoaded(_);_++){const J=this.#X(E,_);J&&!J.group&&S.push(J)}}return S}loadedCount(){const M=this.#R();if(M){const U=M.matchCount();return typeof U=="number"?U:M.count()}this.#q();const S=this.#C("groupBy",[]).length;let E=0;for(const U of this.#s.values())if(!(U.level!==S&&!U.flat))for(const K of U.cache.ids()){if(!U.cache.loaded(K))continue;const q=U.cache.fillOf(K);typeof q=="number"&&(E+=q)}return E}residentRows(){const M=this.#R();return M?M.display():this.#C("groupBy",[]).length>0?null:(this.#q(),this.#ne())}#pe(M,S,E){const{start:U,end:K}=M.cache.rangeOf(S),q=this.#C("groupBy",[]),_=this.#C("pivotBy",[]),J=this.#C("quick",""),ee=this.#Te(),ne={protocol:j,range:{start:U,end:K},groupPath:M.path,groupValues:M.values,groupBy:q,totals:ee,totalFns:this.#le(ee),pivotBy:_,pivotMode:_.length>0,filters:s(this.#C("filters",null),this.#B()),sort:this.#C("sort",[]),context:this.#C("context",null),signal:E};J&&(ne.quick=J);const oe=this.#C("where",null);return oe&&oe.active&&(ne.where=oe),ne}async#Ie(M,S){if(!D(this.#e.fetch))return;if(!this.#m){this.#m=!0;const q=this.#g;this.#g=[],queueMicrotask(()=>{for(const _ of q)_()})}const E=this.#o.begin(`${M.key}:${S}`);M.cache.begin(S,E);const U=this.#d,{start:K}=M.cache.rangeOf(S);try{const q=await this.#e.fetch(this.#pe(M,S,E.signal));if(!E.current||U!==this.#d||this.#p)return;E.settle();const _=q&&q.rows||[];if(!!(q&&q[T])&&!M.flat){M.flat=!0,M.children.clear();for(const[oe,ie]of[...this.#c])ie.startsWith(`${M.key}:`)&&(this.#a.delete(ie),this.#c.delete(oe))}M.cache.fill(S,_),M.failed=!1;for(let oe=0;oe<_.length;oe++)this.#a.delete(`${M.key}:${K+oe}`);const ee=q&&typeof q.count=="number"?q.count:q&&typeof q.total=="number"?q.total:null,ne=q&&D(q.pendingTotal?.then)?q.pendingTotal:null;ee!==null?(M.count=ee,M.complete=!0):_.length<M.cache.pageSize?(M.count=K+_.length,M.complete=!0):ne&&(M.counting=!0,M.announced=null),q&&Array.isArray(q.pivotFields)&&this.#Pe(q.pivotFields),q&&q.pivot&&typeof q.pivot=="object"&&this.#Ce(q.pivot),this.#V("model:changed",{reason:"page",groupPath:M.path,block:S}),this.#V("rows:changed",{companion:!0,reason:"page",groupPath:M.path,block:S}),this.#me(M),ne&&this.#Oe(M,ne,U)}catch(q){if(E.settle(),P(q))return;M.cache.failed(S,q),M.failed=!0;const{end:_}=M.cache.rangeOf(S);for(let J=K;J<_;J++)this.#a.delete(`${M.key}:${J}`);this.#V("model:changed",{reason:"page-error",groupPath:M.path,block:S}),this.#V("source:error",{error:q,groupPath:M.path,block:S})}}async#Oe(M,S,E){let U;try{U=await S}catch(K){if(E!==this.#d||this.#p)return;M.counting=!1,P(K)||(M.failed=!0),P(K)||this.#V("source:error",{error:K,groupPath:M.path});return}E!==this.#d||this.#p||(M.counting=!1,typeof U=="number"&&(M.count=U,M.complete=!0,this.#me(M),this.#V("model:changed",{reason:"total",count:U,groupPath:M.path})))}#me(M){typeof M.count!="number"||!M.complete||M.announced!==M.count&&(M.announced=M.count,this.#V("source:total",{total:M.count,groupPath:M.path}))}#ye(M){if(this.#p)return null;this.#q();const S=this.#m?null:new Promise(_=>{this.#g.push(_),setTimeout(_,W)}),E=M();if(!S&&!E)return null;const U=(async()=>{S&&await S;for(let _=M();_;_=M())await _})();let K;const q=new Promise(_=>{K=setTimeout(_,W)});return Promise.race([U,q]).then(()=>clearTimeout(K))}totalPending(){if(this.#r.failed)return!1;if(this.#r.counting===!0)return!0;if(this.#R())return!1;this.#q();const M=this.#r;return M.count===null&&!M.complete&&M.cache.loadedExtent()===0}totalFailed(){return this.#r.failed===!0}#Pe(M){M.length===this.#u.length&&M.every((S,E)=>S===this.#u[E])||(this.#u=M,this.#V("column:pivoted",{pivotFields:M,remote:!0}))}#de(){const M=this.#t.config||{};return M.pivot&&M.pivot.separator||k}#se(M){const S=this.#de(),E=this.#Te();if(!E.length)return M.slice();const U=[];for(const K of M)for(const q of E)U.push(`${K}${S}${q}`);return U}#Ce(M){const S=this.#de();this.#f||(this.#f={keys:new Map,cells:new Map,result:null});const E=this.#f;let U=!1;const K=_=>{const J=Array.isArray(_)?_:[_],ee=g(J,S);return E.keys.has(ee)||(E.keys.set(ee,J),U=!0),ee},q=this.#C("groupBy",[]).length>0;for(const _ of Array.isArray(M.axis)?M.axis:[])K(_);for(const _ of Array.isArray(M.cells)?M.cells:[]){if(!_||typeof _!="object")continue;const J=K(_.pivot);if(q&&!(Array.isArray(_.group)&&_.group.length))continue;const ee=g(Array.isArray(_.group)?_.group:[],S);for(const[ne,oe]of Object.entries(_.values||{}))E.cells.set(p(ee,J,ne),oe)}E.result=null,U&&this.#Pe((this.pivot()||{fields:[]}).fields)}#te(M){let S=this.#J(M);for(const E of M.children.values())this.#Ee(E.key)&&(S+=this.#te(E));return S}#J(M){if(M.count!==null)return M.count;const S=M.cache.loadedExtent();return M.complete?S:M.row&&M.row.leafCount>0?M.level>=this.#C("groupBy",[]).length?Math.max(S,M.row.leafCount):S===0?1:Math.min(S+M.cache.pageSize,Math.max(S,M.row.leafCount)):S+M.cache.pageSize}#W(M,S){let E=S,U=0;const K=[...M.children.entries()].filter(([,_])=>this.#Ee(_.key)).sort((_,J)=>_[0]-J[0]);for(const[_,J]of K){const ee=_-U+1;if(E<ee)return{node:M,local:U+E};E-=ee,U=_+1;const ne=this.#te(J);if(E<ne)return this.#W(J,E);E-=ne}const q=this.#J(M);return U+E<q?{node:M,local:U+E}:null}#X(M,S){const E=`${M.key}:${S}`,U=this.#a.get(E);if(U)return U;const K=M.cache.rowAt(S);if(K===void 0)return null;const q=this.#C("groupBy",[]);let _;if(M.level<q.length&&!M.flat){const J=q[M.level],ee=this.#f!==null&&M.level===q.length-1&&this.#C("pivotBy",[]).length>0,ne=this.#he(K,J),oe=ne==null,ie=[...M.path,oe?"":String(ne)],ae=[...M.keyPath,oe?null:String(ne)];if(_=this.#l.group({path:ie,keyPath:ae,column:J,value:ne,level:M.level,parent:M.row,leafCount:Number(K.leafCount)||0,expanded:ee?!1:this.#Ee(t(ae)),...ee?{hasChildren:!1}:{}}),_.totals=this.#D(K),_.data=K,!ee){let ce=this.#s.get(_.key);ce?ce.row=_:(ce=new A(ie,M.level+1,this.#n,ae),ce.row=_,this.#s.set(ce.key,ce)),ce.values=[...M.values,ne],M.children.set(S,ce)}}else _=this.#l.leaf(K,S,M.level,M.row);return this.#a.set(E,_),this.#c.set(_.key,E),_}#D(M){const S=M||{};if(S.totals&&typeof S.totals=="object")return S.totals;const E={};for(const U of this.#Te())Object.hasOwn(S,U)&&(E[U]=S[U]);return E}#Me(M,S){const{start:E,end:U}=M.cache.rangeOf(S);for(let K=E;K<U;K++){const q=`${M.key}:${K}`,_=this.#a.peek(q);_&&this.#c.delete(_.key),this.#a.delete(q)}}#q(){const M=this.#ve();return M===this.#d?!1:(this.#d=M,this.#o.abortAll("query"),this.#re(),this.#m=!1,this.#V("model:changed",{reason:"query"}),!0)}#re(){for(const M of this.#s.values())M.cache.clear(),M.count=null,M.complete=!1,M.announced=null,M.counting=!1,M.failed=!1,M.children.clear(),M.flat=!1;this.#a.clear(),this.#c.clear(),this.#y++,this.#f=null}#ve(){const M=this.#C("where",null);return`${n({filters:this.#C("filters",null),sort:this.#C("sort",[]),quick:this.#C("quick",""),groupBy:this.#C("groupBy",[]),pivotBy:this.#C("pivotBy",[]),context:this.#C("context",null)})}|${M?M.version:0}`}#Ee(M){const S=this.#C("expanded",null);return S?D(S.has)?S.has(M):Array.prototype.includes.call(S,M):this.#i.has(M)}#Te(){const M=this.#C("totals",[]);if(M&&M.length)return[...M];const S=this.#t.columns;return!S||!D(S.all)?[]:S.all().filter(E=>!!E.total).map(E=>E.id)}#le(M){const S=this.#t.columns,E={};if(!S||!D(S.get))return E;for(const U of M){const K=S.get(U);if(!K)continue;const q=K.groupTotal!=null?K.groupTotal:K.total;typeof q=="string"&&(E[U]=q)}return E}#he(M,S){const E=this.#t.columns,U=E&&D(E.get)?E.get(S):void 0;return U&&D(U.getValue)?U.getValue(M):M?.[S]}#Be(){u(this.#t)}#B(){const M=this.#t.config||{};return{tz:M.timeZone,weekStartsOn:M.weekStartsOn}}#C(M,S){const E=this.#t.state;if(E&&D(E[M])){const U=E[M]();return U??S}return S}#V(M,S){const E=this.#t.emit;D(E)&&E(M,S)}}}),Be("packages/core/src/source/gapbuffer.js",function(e,H){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return L}});const te=64;class L{#e;#t=0;#n=0;constructor(D=te){this.#e=new Uint32Array(Math.max(1,D)),this.#n=this.#e.length}static from(D,F=te){const Z=new L(D.length+Math.max(1,F));return Z.#e.set(D,0),Z.#t=D.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(D){return D<0||D>=this.length?0:D<this.#t?this.#e[D]:this.#e[D+(this.#n-this.#t)]}insert(D,F){const Z=D<0?0:D>this.length?this.length:D;this.#r(Z),this.#t===this.#n&&this.#s(),this.#e[this.#t++]=F}push(D){this.insert(this.length,D)}removeAt(D){return!Number.isInteger(D)||D<0||D>=this.length?!1:(this.#r(D),this.#n++,!0)}toArray(){const D=new Uint32Array(this.length);return D.set(this.#e.subarray(0,this.#t),0),D.set(this.#e.subarray(this.#n),this.#t),D}clear(){this.#t=0,this.#n=this.#e.length}#r(D){if(D!==this.#t)if(D<this.#t){const F=this.#t-D;this.#e.copyWithin(this.#n-F,D,this.#t),this.#t=D,this.#n-=F}else{const F=D-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+F),this.#t=D,this.#n+=F}}#s(){const D=this.#e.length-this.#n,F=new Uint32Array(Math.max(this.#e.length*2,this.#e.length+te));F.set(this.#e.subarray(0,this.#t),0),F.set(this.#e.subarray(this.#n),F.length-D),this.#e=F,this.#n=F.length-D}}}),Be("packages/core/src/store/ingest.js",function(e,H){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return s}});const te=H("packages/core/src/internal/schedule.js"),L=te.now,X=te.nextFrame,D=H("packages/core/src/internal/warn.js"),F=D.infoOnce,Z=D.warnOnce,B=H("packages/core/src/internal/predicates.js").isFunction,G=H("packages/core/src/internal/paths.js").pathGetter,O=H("packages/core/src/store/columnstore.js").ColumnStore,b=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function c(n,u={}){if(u.multi)return"multi";if(n.length===0)return"object";let o=0,a=0,f=0,w=0,m=0;for(let h=0;h<n.length;h++){const p=n[h];typeof p=="number"?o++:typeof p=="boolean"?a++:typeof p=="string"?f++:p instanceof Date?w++:Array.isArray(p)&&m++}const v=n.length;return o===v?"float64":a===v?"bitset":w===v?"float64":f===v?"text":m===v?"multi":"object"}function d(n,u,o){return u<=0||n<o*u?"dictionary":"object"}function l(n,u,o){const a=new Map,f=new Map;for(const j of n){if(j.computed)continue;const N=B(j.read)?j.read:G(j.field||j.id);f.set(j.id,N),a.set(j.id,N)}const w=u?.order??[],m=u?.fns??{},v=u?.deps??{},h=u?.wrapDeps??null,p=w.filter(j=>B(m[j])),g=p.some(j=>v[j]==="*");let k=new WeakMap;const y=j=>{const N={};if(g)for(const[W,R]of f)N[W]=R(j);for(const W of p){const R=v[W];let x;if(R==="*")x=N;else{x={};const A=R||[];for(let $=0;$<A.length;$++){const I=A[$];x[I]=I in N?N[I]:f.get(I)?.(j)}}N[W]=m[W](h?h(x,W):x,{data:j,row:null,column:null,grid:null,context:o})}return N},T=j=>{if(j===null||typeof j!="object"&&typeof j!="function")return y(j);let N=k.get(j);return N===void 0&&(N=y(j),k.set(j,N)),N};for(const j of p)a.set(j,N=>T(N)[j]);return{readers:a,reset(){k=new WeakMap}}}class r{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(u,o){this.spec=u,this.read=o,this.kind="object",this.inferred=!1,this.nullable=u.nullable!==!1}}class t{#e;#t=[];#n=null;#r;#s=0;#i;#o=!1;#l=!1;#a=0;#c;constructor(u,o={},a={}){this.#e=Array.isArray(u)?u:Array.from(u||[]),this.#i={...b,...a};const f=o.columns??[];this.#r=l(f,o.computed??null,o.context),this.#c=this.#e.length>=this.#i.columnarBelow,this.#u(f,o.computed??null),this.#n=new O(this.#t.map(w=>({id:w.spec.id,kind:w.kind,nullable:w.nullable,read:w.read,dictionary:w.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#o||this.#l}get progress(){return this.#s}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const u=L(),{chunkMs:o,chunkRows:a}=this.#i,f=this.#e.length;do{const w=Math.min(this.#s+a,f);this.#n.append(this.#e.slice(this.#s,w)),this.#f(this.#s,w),this.#s=w,this.#r.reset(),this.#h(!1)}while(this.#s<f&&L()-u<o);return this.#a+=L()-u,this.#i.onProgress?.({loaded:this.#s,total:f}),this.#s>=f?(this.#h(!0),this.#o=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,read:u.read,dictionary:u.spec.dictionary})),decisions:this.#t.map(u=>({id:u.spec.id,kind:u.kind,nullable:u.nullable,inferred:u.inferred,distinct:u.candidate||u.change?this.#d(u):null,change:u.change,reason:u.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#u(u,o){const a=this.#e,f=Math.min(this.#i.sampleSize,a.length),w=this.#i.dictionaryRatio,m=o?.pure instanceof Set?o.pure:new Set(o?.pure??o?.order??[]);for(const v of u){if(!v||!v.id)continue;if(v.computed&&(v.pure===!1||o&&!m.has(v.id))){Z(`ingest.impure.${v.id}`,`column "${v.id}" is an impure computed column and is not materialised into the store`);continue}const h=this.#r.readers.get(v.id)??(B(v.read)?v.read:G(v.field||v.id)),p=new r(v,h);if(v.kind)p.kind=v.kind,p.reason="declared by the caller";else if(v.dictionary)p.kind=v.multi?"multi":"dictionary",p.reason="value table supplied (lookup column)";else{const g=[];for(let y=0;y<f&&g.length<this.#i.sampleSize;y++){const T=h(a[y]);T!=null&&g.push(T)}p.inferred=!0;const k=c(g,{multi:v.multi});if(k==="text"){const y=new Set(g).size;p.kind=d(y,g.length,w),p.candidate=this.#c,p.reason=`sampled ${y} distinct in ${g.length}`}else p.kind=k,p.reason=`inferred from ${g.length} sampled values`,k==="object"&&g.length&&F(`ingest.mixed.${v.id}`,`column "${v.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);p.kind==="object"&&p.candidate&&(p.distinct=new Set(g))}this.#t.push(p)}}#f(u,o){const a=this.#e;for(const f of this.#t){if(!f.candidate||!f.distinct)continue;const w=f.distinct;for(let m=u;m<o;m++){const v=f.read(a[m]);v!=null&&w.add(v)}}}#d(u){if(u.distinct)return u.distinct.size;const o=this.#n.column(u.spec.id);return o?.dict?o.dict.size:0}#h(u){const o=this.#i.dictionaryRatio,a=this.#e.length;for(const f of this.#t){if(!f.candidate)continue;const w=this.#d(f);if(f.kind==="dictionary"&&w>=o*a){const m=this.#n.column(f.spec.id);f.distinct=new Set(m?.dict?m.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${w} distinct values is at or above ${o*100}% of ${a} rows`;continue}if(f.kind==="object"&&w>=o*a){f.candidate=!1,f.distinct=null,f.reason=`${w} distinct values is at or above ${o*100}% of ${a} rows`;continue}u&&f.kind==="object"&&w<o*a&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${w} distinct values is below ${o*100}% of ${a} rows`,f.distinct=null),u&&(f.candidate=!1)}}}async function i(n,u={},o={}){const a=new t(n,u,o),f=o.scheduler?.frame??X;for(;a.slice();)await new Promise(w=>{f(w)});return a.result()}function s(n,u={},o={}){const a=new t(n,u,{...o,chunkMs:1/0});for(;a.slice(););return a.result()}}),Be("packages/core/src/store/columnpack.js",function(e,H){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return d}});const L=H("packages/core/src/internal/paths.js").pathGetter,X=H("packages/core/src/store/ingest.js"),D=X.inferKind,F=X.decideText,Z=X.INGEST_DEFAULTS,B=H("packages/core/src/store/columnstore.js").toFloat,z=new Set(["float64","int32","bitset","dictionary","object","multi"]);function G(l){if(!Array.isArray(l)||l.length===0)return!1;for(const r of l)if(!r||typeof r.id!="string"||typeof r.field!="string"||r.field===""||r.kind&&!z.has(r.kind))return!1;return!0}function P(l){const r=B(l);return Number.isFinite(r)?r|0:0}function O(l){return l==null?[]:Array.isArray(l)?l:[l]}function b(l,r,t,i){if(l.kind)return l.kind;const s=[];for(let o=0;o<r.length&&s.length<Z.sampleSize;o++){const a=r[o];a!=null&&s.push(a)}const n=D(s,{multi:l.multi});if(n!=="text")return n;const u=new Set(s).size;return F(u,s.length,i)}function c(l,r,t={}){const i=r.length|0,s=t.dictionaryRatio??Z.dictionaryRatio,n=[];for(const u of l){const o=L(u.field||u.id),a=u.nullable!==!1,f=new Array(i);for(let p=0;p<i;p++){const g=o(r[p]);f[p]=g===void 0?null:g}const w=b(u,f,i,s),m=a?new Uint8Array(i+7>>3):null,v=p=>{m&&(m[p>>3]|=1<<(p&7))};let h;switch(w){case"float64":{const p=new Float64Array(i);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),p[g]=y?NaN:B(k)}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"int32":{const p=new Int32Array(i);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),p[g]=y?0:P(k)}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"bitset":{const p=new Uint8Array(i+7>>3);for(let g=0;g<i;g++){const k=f[g],y=k===null;y||v(g),!y&&k&&(p[g>>3]|=1<<(g&7))}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:null};break}case"dictionary":{const p=new Uint32Array(i),g=[],k=new Map;for(let y=0;y<i;y++){const T=f[y];if(T===null){p[y]=0;continue}v(y);let j=k.get(T);j===void 0&&(j=g.length,g.push(T),k.set(T,j)),p[y]=j}h={id:u.id,kind:w,nullable:a,values:p,presence:m,offsets:null,table:g};break}case"multi":{const p=[],g=new Map,k=new Uint32Array(i+1),y=[];for(let T=0;T<i;T++){const j=f[T];k[T]=y.length,j===null||v(T);const W=O(j);for(let R=0;R<W.length;R++){const x=W[R];let A=g.get(x);A===void 0&&(A=p.length,p.push(x),g.set(x,A)),y.push(A)}}k[i]=y.length,h={id:u.id,kind:w,nullable:a,values:Int32Array.from(y),presence:m,offsets:k,table:p};break}default:{const p=new Array(i);for(let g=0;g<i;g++){const k=f[g];k!==null&&v(g),p[g]=k}h={id:u.id,kind:"object",nullable:a,values:p,presence:m,offsets:null,table:null};break}}n.push(h)}return{count:i,columns:n}}function d(l){const r=[];if(!l||!Array.isArray(l.columns))return r;const t=i=>{ArrayBuffer.isView(i)&&i.buffer&&!r.includes(i.buffer)&&r.push(i.buffer)};for(const i of l.columns)t(i.values),t(i.presence),t(i.offsets);return r}}),Be("packages/core/src/source/stream.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return A}});const L=H("packages/core/src/internal/lru.js").Lru,D=H("packages/core/src/internal/predicates.js").isFunction,F=H("packages/core/src/internal/schedule.js"),Z=F.now,Y=F.nextFrame,B=F.cancelFrame,z=F.whenIdle,P=H("packages/core/src/internal/compare.js").defaultCompare,O=H("packages/core/src/internal/warn.js"),b=O.warnOnce,c=O.infoOnce,l=H("packages/core/src/internal/paths.js").getPath,r=H("packages/core/src/source/abort.js"),t=r.createAbortScope,i=r.isAbortError,s=H("packages/core/src/source/rows.js"),n=s.createRowFactory,u=s.lazyRowView,a=H("packages/core/src/source/gapbuffer.js").GapBuffer,w=H("packages/core/src/source/memory.js").createMemorySource,v=H("packages/core/src/source/filterwire.js").querySignature,p=H("packages/core/src/store/columnpack.js").isPortableSchema,g=25e4,k=Symbol("lattice.stream.storeBacked"),y=8,T=.1,j=1e3,N=50;function W($){return Math.min(j,Math.max(N,Math.floor($/4)))}function R($){if($ instanceof Date)return $.getTime();if(typeof $=="number")return Number.isFinite($)?$:NaN;if(typeof $=="string"){const I=$.trim();if(!I)return NaN;const M=Date.parse(I);return Number.isNaN(M)?Number(I):M}return NaN}function x($,I){return new A($,I)}class A{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#s=[];#i=null;#o;#l;#a=new Map;#c=t();#u={loaded:0,estimated:void 0};#f=null;#d=0;#h=0;#p=0;#m=0;#g=null;#b=null;#y=null;#j=!1;#w=!1;#O=!1;#v=!1;#T="";#S=0;#E=0;#M=0;#P=null;#N=1/0;#R=!1;#L=null;#U=null;#G=null;#x=null;#F=!1;#Y=0;#I=0;#K=!1;constructor(I,M){this.#e=I||{mode:"stream"},this.#t=M||{},this.#o=n(this.#t),this.#l=new L(4096),this.#T=this.#We();const S=(this.#t.config||{}).ingest;this.#F=!!S&&S.retainSource===!1,D(this.#e.open)||b("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const E=Number(this.#e.poll);Number.isFinite(E)&&E>0&&(this.#x=setInterval(()=>{this.#v||this.reload()},E),this.#x&&D(this.#x.unref)&&this.#x.unref()),this.#z()}#H(){const I=Number(this.#e.maxAge);return Number.isFinite(I)&&I>0?I:0}#z(){const I=this.#H();if(!I)return;const M=this.#e.ageBy;D(M)?this.#U=M:typeof M=="string"&&M?this.#U=S=>l(S,M):this.#U=null,this.#P=[],this.#L=setInterval(()=>{this.#v||this.#fe()&&(this.#q(),this.#ce())},W(I)),this.#L&&D(this.#L.unref)&&this.#L.unref()}#fe(){const I=this.#H();return!I||!this.#P?!1:this.#R?!0:this.#N<Date.now()-I*(1+T)}#ne(I,M){if(!this.#P)return;const S=this.#U?R(this.#U(M)):Date.now();this.#P[I]=S,Number.isNaN(S)||(S<this.#N&&(this.#N=S),S<Date.now()-this.#H()&&(this.#R=!0))}#pe(){return this.#be("groupBy",[]).length>0?!0:!!this.#be("pivotMode",!1)&&this.#be("pivotBy",[]).length>0}#Ie(){if(this.#g||this.#v)return;const I=this.#pe();if(I&&!this.#b){this.#b=w({mode:"memory",rows:this.#n},this.#Oe()),this.#j=!1;return}!I&&this.#b&&(this.#b.destroy(),this.#b=null)}#Oe(){if(this.#y)return this.#y;const I=this,M={liveIndices:()=>I.#me(),live:S=>I.#n[S]!==void 0,source:S=>I.#Se(S),get physical(){return I.#n.length}};return this.#F&&(M.column=S=>{const E=I.#t.store;return E&&D(E.column)?E.column(S):void 0}),this.#y=Object.create(this.#t,{store:{value:M,enumerable:!0,configurable:!0}}),this.#y}#me(){const I=new Uint32Array(this.#n.length);let M=0;for(let S=0;S<this.#n.length;S++)this.#n[S]!==void 0&&(I[M++]=S);return I.subarray(0,M)}#ye(){return this.#g?this.#g:this.#b?(this.#j&&(this.#j=!1,this.#b.setRows(this.#n)),this.#b):null}invalidate(I="filter"){if(this.#g){this.#g.invalidate(I);return}this.#Ie(),this.#b&&this.#b.invalidate(I),(I==="filter"||I==="sort")&&this.#Te()}count(){const I=this.#ye();return I?I.count():this.#r?this.#r.length:this.#S}matchCount(){const I=this.#ye();return I&&D(I.matchCount)?I.matchCount():this.#r?this.#r.length:this.#S}totalCount(){const I=this.#ye();return I&&D(I.totalCount)?I.totalCount():this.#S}unfilteredRows(){const I=this.#ye();if(I&&D(I.unfilteredRows))return I.unfilteredRows();const M=[];for(let S=0;S<this.#n.length;S++){if(!this.#n[S])continue;const E=this.#Re(S);E&&M.push(E)}return M}at(I){const M=this.#ye();if(M)return M.at(I);if(I<0||I>=this.count())return;const S=this.#r?this.#r.at(I):I,E=this.#Re(S);return E.index=I,E}byKey(I){const M=this.#ye();if(M)return M.byKey(I);const S=this.#a.get(I);return S===void 0?void 0:this.#Re(S)}leavesOf(I){const M=this.#ye();return M&&D(M.leavesOf)?M.leavesOf(I):[]}loaded(I){return I>=0&&I<this.count()}hint(I,M){if(this.#g){this.#g.hint(I,M);return}this.#Pe(),this.#p=Math.max(0,Math.floor(I))}#Pe(){this.#v||this.#We()===this.#T||this.reload()}display(){const I=this.#ye();return I?I.display():u(()=>this.count(),M=>this.at(M))}apply(I){if(this.#g)return this.#g.apply(I);const M={added:[],updated:[],removed:[]};if(!I)return M;if(I.update){let S=!1;for(const E of I.update){const U=this.#a.get(this.#o.keyOf(E,-1));if(U===void 0)continue;const K=this.#Be(U);this.#F?this.#ze(U,E):this.#n[U]=E,this.#l.delete(U),this.#B(U,K),this.#P&&(this.#ne(U,E),S=!0),this.#j=!0,M.updated.push(this.#Re(U))}S&&this.#q()}if(I.add&&I.add.length){const S=this.#D(I.add);for(const E of S)M.added.push(this.#Re(E))}return I.remove&&I.remove.length&&b("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#ce(),M}reload(I){this.#c.abortAll("reload"),this.#Ve(),this.#b&&(this.#b.destroy(),this.#b=null),this.#j=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#S=0,this.#E=0,this.#M=0,this.#P&&(this.#P=[]),this.#N=1/0,this.#R=!1,this.#w=!1,this.#O=!1,this.#u={loaded:0,estimated:void 0},this.#T=this.#We(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#v=!0,this.#x!==null&&(clearInterval(this.#x),this.#x=null),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#P=null,this.#c.abortAll("destroyed"),this.#Ve(),this.#f!==null&&(this.#k(this.#f),this.#f=null),this.#b&&(this.#b.destroy(),this.#b=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#O||this.#v||!D(this.#e.open))return;this.#O=!0;const I=this.#c.begin("stream");this.#Te(),this.#Ie();let M;try{M=this.#e.open({sort:this.#be("sort",[]),filters:this.#be("filters",null),quick:this.#be("quick","")||void 0,context:this.#be("context",null),signal:I.signal})}catch(E){this.#ke("source:error",{error:E});return}const S=D(M[Symbol.asyncIterator])?M[Symbol.asyncIterator]():M[Symbol.iterator]();this.#G=S;try{for(;;){const E=await S.next();if(!I.current||this.#v)return;if(E.done){this.#ie();return}if(await this.#de(E.value,I),!I.current||this.#v)return;if(E.value&&E.value.done){this.#ie();return}if(await this.#oe(),!I.current||this.#v)return}}catch(E){if(i(E))return;this.#ke("source:error",{error:E})}finally{I.settle()}}progress(){return{loaded:this.#u.loaded,estimated:this.#u.estimated,done:this.#w,live:this.#S,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const I=this.#ye();I&&(D(I.invalidateHandles)&&I.invalidateHandles(),D(I.invalidate)&&I.invalidate("sort"))}renderCount(){return this.#d}ingestStats(){return{worker:this.#Y,inline:this.#I,storeBacked:this.#F}}#de(I,M){if(!I)return;const S=I.rows;if(S&&S.length&&this.#Ce(S))return this.#J(I,M);const E=Z();S&&S.length&&(this.#D(S),this.#I++),this.#se(I),this.#h+=Z()-E,this.#ce()}#se(I){this.#u.loaded=I.progress&&typeof I.progress.loaded=="number"?I.progress.loaded:this.#n.length,I.progress&&typeof I.progress.estimated=="number"&&(this.#u.estimated=I.progress.estimated)}#Ce(I){if(this.#K||this.#g)return!1;const M=this.#W();if(!M)return!1;const S=this.#t.store;if(!S||!D(S.appendPacked))return!1;const E=this.#X();return!E||!p(E)?(this.#K=!0,c("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):I.length<M.threshold?!1:!this.#te(I)}#te(I){if(!this.#o.keyed)return!1;const M=new Set;for(let S=0;S<I.length;S++){const E=this.#o.keyOf(I[S],this.#n.length+S);if(E!=null){if(M.has(E)||this.#a.has(E))return!0;M.add(E)}}return!1}async#J(I,M){const S=I.rows,E=this.#W(),U=this.#X();let K;try{K=await E.columnize(U,S,{key:"ingest:stream",signal:M&&M.signal})}catch(ne){if(i(ne)||(b("source.stream.columnize","worker columnization failed; columnizing on the main thread",ne),this.#K=!0,M&&(!M.current||this.#v)))return;this.#D(S),this.#I++,this.#se(I),this.#ce();return}if(M&&(!M.current||this.#v))return;const q=this.#t.store,_=this.#F?void 0:S,{from:J}=q.appendPacked(K,_),ee=K.count|0;for(let ne=0;ne<ee;ne++){const oe=J+ne,ie=S[ne],ae=this.#o.keyed?this.#o.keyOf(ie,oe):null;if(this.#n[oe]=this.#F?k:ie,this.#S++,this.#ne(oe,ie),ae!==null&&this.#a.set(ae,oe),!this.#r||!this.#le(oe))continue;const ce=this.#C(oe);this.#r.insert(ce,oe),ce<=this.#p&&this.#m++}this.#j=!0,this.#q(),this.#Y++,this.#se(I),this.#ce()}#W(){const I=this.#t.ingestWorker;return D(I)?I():null}#X(){const I=this.#t.storeSchema;return D(I)?I():null}#D(I){const M=[],S=this.#t.store,E=new Array(I.length),U=[],K=new Set;for(let _=0;_<I.length;_++){const J=this.#o.keyed?this.#o.keyOf(I[_],this.#n.length+U.length):null;E[_]=J,!(J!==null&&(this.#a.has(J)||K.has(J)))&&(J!==null&&K.add(J),U.push(I[_]))}let q=U.length&&S&&D(S.append)?S.append(U).from:this.#n.length;for(let _=0;_<I.length;_++){const J=I[_],ee=E[_];if(ee!==null&&this.#a.has(ee)){const ie=this.#a.get(ee),ae=this.#Be(ie);this.#F||(this.#n[ie]=J,S&&D(S.setSource)&&S.setSource(ie,J)),this.#ze(ie,J),this.#l.delete(ie),this.#ne(ie,J),this.#B(ie,ae);continue}const ne=q++;if(this.#n[ne]=this.#F?k:J,this.#S++,this.#ne(ne,J),ee!==null&&this.#a.set(ee,ne),M.push(ne),!this.#r||!this.#le(ne))continue;const oe=this.#C(ne);this.#r.insert(oe,ne),oe<=this.#p&&this.#m++}return this.#j=!0,this.#q(),M}#Me(I){const M=this.#n[I];let S=!1;if(this.#r){const q=this.#Ee(I);q>=0&&q<=this.#p&&(S=!0)}else I<=this.#p&&(S=!0);const E=M===k?this.#Se(I):M,U=this.#o.keyed?this.#o.keyOf(E,I):null;U!==null&&this.#a.get(U)===I&&this.#a.delete(U),this.#n[I]=void 0,this.#P&&(this.#P[I]=NaN),this.#l.delete(I);const K=this.#t.store;return K&&D(K.remove)&&K.remove(I),this.#S--,S}#q(){let I=0,M=0;const S=this.#ve();I+=S.dropped,M+=S.aboveAnchor;const E=this.#re();I+=E.dropped,M+=E.aboveAnchor,I&&(this.#j=!0,this.#E+=I,this.#Te(),this.#m-=M,this.#ke("stream:evicted",{evicted:I,total:this.#E,live:this.#S}))}#re(){const I=this.#e.maxRows;if(!Number.isFinite(I)||I<=0||this.#S<=I)return{dropped:0,aboveAnchor:0};const M=Math.max(1,Math.floor(I*(1-T)));let S=0,E=0;for(;this.#S>M&&this.#M<this.#n.length;){const U=this.#M++;this.#n[U]!==void 0&&(this.#Me(U)&&E++,S++)}return{dropped:S,aboveAnchor:E}}#ve(){const I=this.#H();if(!I||!this.#P||!this.#fe())return{dropped:0,aboveAnchor:0};const M=Date.now()-I;let S=0,E=0,U=1/0;for(let K=this.#M;K<this.#n.length;K++){if(this.#n[K]===void 0)continue;const q=this.#P[K];if(!(Number.isNaN(q)||q===void 0)){if(q>=M){q<U&&(U=q);continue}this.#Me(K)&&E++,S++}}for(this.#N=U,this.#R=!1;this.#M<this.#n.length&&this.#n[this.#M]===void 0;)this.#M++;return{dropped:S,aboveAnchor:E}}#Ee(I){if(!this.#r)return I;for(let M=0;M<this.#r.length;M++)if(this.#r.at(M)===I)return M;return-1}#Te(){this.#s=this.#be("sort",[]),this.#i=this.#be("filters",null);const I=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#H()>0,M=this.#be("where",null),S=(this.#t.config||{}).hostFilter,E=!!(M&&M.active)||!!(S&&D(S.active)&&S.active());if(!(I||this.#s.length>0||!!this.#i||!!this.#be("quick","")||E)){this.#r=null;return}this.#r=new a(Math.max(64,this.#n.length+64));for(let K=0;K<this.#n.length;K++)this.#n[K]!==void 0&&this.#le(K)&&this.#r.insert(this.#C(K),K)}#le(I){const M=this.#Se(I);if(this.#i&&!this.#he(this.#i,M))return!1;const S=String(this.#be("quick","")||"").toLowerCase();if(S&&!this.#Ye(M).includes(S))return!1;const E=(this.#t.config||{}).hostFilter;if(E&&D(E.active)&&E.active()&&!E.passes(this.#Re(I)))return!1;const U=this.#be("where",null);if(U&&U.active){const K=this.#Re(I);if(!U.passes(K.data,K.key))return!1}return!0}#he(I,M){if(!I)return!0;const S=I;if(Array.isArray(S.conditions))return S.op==="or"?S.conditions.some(K=>this.#he(K,M)):S.op==="not"?!S.conditions.some(K=>this.#he(K,M)):S.conditions.every(K=>this.#he(K,M));const E=I,U=(this.#t.compute||{}).testValue;return D(U)?!!U(this.#Fe(M,E.col),E,(this.#t.config||{}).locale):(b("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#Be(I){if(!this.#r)return-1;if(!this.#s.length)return this.#Ee(I);let M=0,S=this.#r.length;for(;M<S;){const E=M+S>>>1;this.#V(this.#r.at(E),I)<0?M=E+1:S=E}for(let E=M;E<this.#r.length;E++){const U=this.#r.at(E);if(U===I)return E;if(this.#V(U,I)>0)break}return this.#Ee(I)}#B(I,M){if(!this.#r||!this.#s.length)return;const S=this.#le(I);if(M>=0&&this.#r.at(M)===I)this.#r.removeAt(M),M<=this.#p&&this.#m--;else if(M>=0)return;if(!S)return;const E=this.#C(I);this.#r.insert(E,I),E<=this.#p&&this.#m++}#C(I){if(!this.#r||!this.#s.length)return this.#r?this.#r.length:0;let M=0,S=this.#r.length;for(;M<S;){const E=M+S>>>1;this.#V(I,this.#r.at(E))<0?S=E:M=E+1}return M}#V(I,M){const S=this.#Se(I),E=this.#Se(M);for(const U of this.#s){const K=this.#_e(U.col),q=this.#Fe(S,U.col),_=this.#Fe(E,U.col),ee=(K&&K.value&&D(K.value.compare)?K.value.compare:P)(q,_);if(ee!==0)return U.dir==="desc"?-ee:ee}return 0}#ie(){this.#w=!0,this.#u.loaded=this.#u.loaded||this.#n.length;const I=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:g;!this.#F&&this.#n.length<I&&(this.#g=w({mode:"memory",rows:this.#n},this.#t),this.#L!==null&&(clearInterval(this.#L),this.#L=null),this.#b&&(this.#b.destroy(),this.#b=null)),this.#ce(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:I})}#ce(){this.#f!==null||this.#v||(this.#f=this.#we(()=>{this.#f=null,this.#d++;const I=this.#m;this.#m=0,this.#h=0,this.#ke("stream:chunk",{loaded:this.#u.loaded,estimated:this.#u.estimated,count:this.count(),renders:this.#d}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:I,anchor:this.#p}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#oe(){return this.#d===0||this.#h<this.#ge()?Promise.resolve():(this.#h=0,new Promise(I=>{const M=(this.#t.scheduler||{}).idle;D(M)?M(()=>I()):z(()=>I())}))}#ge(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:y}#we(I){const M=this.#t.scheduler||{};return D(M.frame)?M.frame(I):Y(I)}#k(I){const M=this.#t.scheduler||{};D(M.cancel)?M.cancel(I):B(I)}#Se(I){const M=this.#n[I];if(M!==void 0&&M!==k)return M;if(M===void 0)return;const S=this.#t.store;return S&&D(S.source)?S.source(I):void 0}#ze(I,M){const S=this.#t.store;if(!S||!D(S.set))return;const E=this.#X();if(Array.isArray(E))for(const U of E){if(!U||!U.id)continue;const K=D(U.read)?U.read:q=>l(q,U.field||U.id);S.set(U.id,I,K(M))}}#Re(I){let M=this.#l.get(I);return M||(M=this.#o.leaf(this.#Se(I),I),this.#l.set(I,M)),M}#Fe(I,M){const S=this.#_e(M);return S&&D(S.getValue)?S.getValue(I):I?.[M]}#Ye(I){const M=this.#t.columns,S=M&&D(M.all)?M.all():[],E=[];for(const U of S){const K=D(U.getValue)?U.getValue(I):void 0;K!=null&&K!==""&&E.push(String(K))}return E.join(" ").toLowerCase()}#_e(I){const M=this.#t.columns;return M&&D(M.get)?M.get(I):void 0}#Ve(){const I=this.#G;if(this.#G=null,I&&D(I.return))try{I.return()}catch{}}#We(){return v({context:this.#be("context",null)})}#be(I,M){const S=this.#t.state;if(S&&D(S[I])){const E=S[I]();return E??M}return M}#ke(I,M){const S=this.#t.emit;D(S)&&S(I,M)}}}),Be("packages/core/src/source/url.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return b}});const L=H("packages/core/src/internal/warn.js").warnOnce,X=H("packages/core/src/internal/predicates.js"),D=X.isObject,F=X.isFunction,Y=H("packages/core/src/internal/paths.js").getPath,z=H("packages/core/src/source/abort.js").isAbortError,G=500,P=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),O=Symbol("lattice.url.skip");function b(m,v={}){const h=D(v)?v:{},p=F(h.fetch)?h.fetch:typeof globalThis<"u"&&F(globalThis.fetch)?globalThis.fetch:null,g=h.format==="json"||h.format==="ndjson"?h.format:void 0,k=typeof h.rowsPath=="string"&&h.rowsPath?h.rowsPath:void 0,y=F(h.map)?h.map:void 0,T=D(h.headers)?h.headers:void 0,j=Number.isFinite(h.batchSize)&&h.batchSize>0?Math.floor(h.batchSize):G,N=h.lenient===!0,W=Number.isFinite(h.poll)&&h.poll>0?Math.floor(h.poll):void 0,R=typeof m=="string"&&m.length>0;R||L("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*x($={}){if(!R)return;if(!p)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const I=$&&$.signal;let M;try{M=await p(m,T?{signal:I,headers:T}:{signal:I})}catch(U){throw z(U)?U:new Error(`[lattice] createUrlSource: request to ${m} failed — ${U&&U.message||U}`)}if(!M||!M.ok){const U=M?M.status:"no response";throw new Error(`[lattice] createUrlSource: ${U} for ${m}`)}const S=c(m,g,M),E=M.body&&F(M.body.getReader)?M.body.getReader():null;try{if(!E){const q=await M.text();(S||r(q,m))==="ndjson"?yield*o(null,null,q,0,M,m,j,N):yield*u(q,m,k,y);return}const U=new TextDecoder("utf-8");if(S==="json"){yield*u(await n(E,U,""),m,k,y);return}if(S==="ndjson"){yield*o(E,U,"",0,M,m,j,N);return}const K=await t(E,U,m);K.format==="json"?yield*u(await n(E,U,K.seed),m,k,y):yield*o(E,U,K.seed,K.bytes,M,m,j,N)}finally{if(E&&F(E.cancel))try{await E.cancel()}catch{}}}const A={mode:"stream",open:x,autoStart:h.autoStart!==!1};return W!==void 0&&(A.poll=W),Number.isFinite(h.maxRows)&&(A.maxRows=h.maxRows),Number.isFinite(h.maxAge)&&(A.maxAge=h.maxAge),(typeof h.ageBy=="string"||F(h.ageBy))&&(A.ageBy=h.ageBy),Number.isFinite(h.coalesceMs)&&(A.coalesceMs=h.coalesceMs),Number.isFinite(h.promoteToMemoryBelow)&&(A.promoteToMemoryBelow=h.promoteToMemoryBelow),A}function c(m,v,h){if(v)return v;const p=d(m);if(p)return p;const g=h&&h.headers&&F(h.headers.get)?h.headers.get("content-type"):null;return l(g)}function d(m){const v=String(m).split(/[?#]/)[0].toLowerCase();if(v.endsWith(".ndjson")||v.endsWith(".jsonl"))return"ndjson";if(v.endsWith(".json"))return"json"}function l(m){if(!m)return;const v=m.split(";")[0].trim().toLowerCase();if(P.has(v))return"ndjson";if(v==="application/json"||v==="text/json"||v.endsWith("+json"))return"json"}function r(m,v){const h=m.replace(/^\s+/,""),p=i(h);if(p==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${v} — pass opts.format: 'json' | 'ndjson'.`);return p}async function t(m,v,h){let p="",g=0;for(;;){const{value:y,done:T}=await m.read();if(y&&(g+=y.byteLength,p+=v.decode(y,{stream:!0})),T){p+=v.decode();break}const j=p.replace(/^\s+/,"");if(j){if(j[0]==="[")return{format:"json",seed:p,bytes:g};if(j[0]!=="{"||p.indexOf(`
8
8
  `)!==-1)break}}const k=i(p.replace(/^\s+/,""));if(k==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${h} — pass opts.format: 'json' | 'ndjson'.`);return{format:k,seed:p,bytes:g}}function i(m){if(!m||m[0]==="[")return"json";if(m[0]!=="{")return"error";const v=m.indexOf(`
9
9
  `);if(v===-1)return"json";let h=m.slice(0,v);return h.endsWith("\r")&&(h=h.slice(0,-1)),s(h)?"ndjson":"json"}function s(m){try{return JSON.parse(m),!0}catch{return!1}}async function n(m,v,h){let p=h;for(;;){const{value:g,done:k}=await m.read();if(g&&(p+=v.decode(g,{stream:!0})),k)break}return p+=v.decode(),p}function*u(m,v,h,p){let g;try{g=JSON.parse(m)}catch(y){throw new Error(`[lattice] createUrlSource: ${v} is not valid JSON — ${y.message}`)}let k=h!==void 0?Y(g,h):g;if(p&&(k=p(k)),!Array.isArray(k)){const y=h!==void 0||p?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${v} did not resolve to an array${y}.`)}yield{rows:k,progress:{loaded:k.length,estimated:k.length}}}async function*o(m,v,h,p,g,k,y,T){const j=w(g);let N=h||"",W=p||0,R=0,x=0,A=[];function*$(){let M;for(;(M=N.indexOf(`
10
10
  `))!==-1;){const S=N.slice(0,M);N=N.slice(M+1),x++;const E=a(S,x,k,T);E!==O&&(A.push(E),A.length>=y&&(R+=A.length,yield f(A,R,j,W),A=[]))}}if(m){for(;;){const{value:M,done:S}=await m.read();if(M&&(W+=M.byteLength,N+=v.decode(M,{stream:!0}),yield*$()),S)break}N+=v.decode()}yield*$(),x++;const I=a(N,x,k,T);I!==O&&A.push(I),A.length&&(R+=A.length,yield f(A,R,j,W))}function a(m,v,h,p){let g=m;if(g.endsWith("\r")&&(g=g.slice(0,-1)),!g.trim())return O;try{return JSON.parse(g)}catch(k){if(p)return L(`source.url.badline.${h}`,`skipping a malformed NDJSON line (line ${v}) from ${h} — ${k.message}`),O;throw new Error(`[lattice] createUrlSource: malformed NDJSON at line ${v} of ${h} — ${k.message}`)}}function f(m,v,h,p){const g=h&&p>0&&v>0?Math.max(v,Math.round(h/(p/v))):void 0;return{rows:m,progress:{loaded:v,estimated:g}}}function w(m){const v=m&&m.headers&&F(m.headers.get)?m.headers.get("content-length"):null,h=v!=null?Number(v):NaN;return Number.isFinite(h)&&h>0?h:void 0}}),Be("packages/core/src/source/derive.js",function(e,H){"use strict";Object.defineProperty(e,"FOLLOW_MODES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"BUCKETS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"DERIVED_ROW_KEY",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"DERIVED_SOURCE_KEY",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"UNION_KEY_SEP",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"readPath",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"unnest",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"reduceValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"applyLimit",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"applyCumulative",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"groupRows",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"finishGroups",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"derive",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normalizeUnionSource",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"namespaceUnionKeys",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"joinRows",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"preGroup",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"buildJoinIndex",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"joinOne",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"joinKeyOf",{enumerable:!0,get:function(){return g}});const te=H("packages/core/src/internal/predicates.js"),L=te.isFunction,X=te.isObject,F=H("packages/core/src/compute/total.js").TOTAL_FNS,Z=Object.freeze(["filtered","all","selected","grouped"]),Y=Object.freeze(["day","week","month","quarter","year"]),B="__key",z="__source",G="";function P(k,y){if(!X(k)||typeof y!="string")return;if(!y.includes("."))return k[y];let T=k;for(const j of y.split(".")){if(!X(T))return;T=T[j]}return T}function O(k,y){const T=[];for(const j of k){const N=P(j,y);if(!(!Array.isArray(N)||!N.length))for(const W of N)T.push({...j,[y]:W})}return T}function b(k,y){const T=k instanceof Date?k:new Date(k),j=T.getTime();if(!Number.isFinite(j))return null;const N=T.getUTCFullYear(),W=T.getUTCMonth(),R=T.getUTCDate(),x=A=>A.toISOString().slice(0,10);switch(y){case"year":return x(new Date(Date.UTC(N,0,1)));case"quarter":return x(new Date(Date.UTC(N,Math.floor(W/3)*3,1)));case"month":return x(new Date(Date.UTC(N,W,1)));case"week":{const A=(T.getUTCDay()+6)%7;return x(new Date(Date.UTC(N,W,R-A)))}default:return x(new Date(Date.UTC(N,W,R)))}}function c(k,y,T){const j=y.map(N=>T&&T.of===N?b(P(k,N),T.by):P(k,N));return{key:j.map(N=>N==null?"\0":String(N)).join(""),values:j}}function d(k,y){const T=F[y];return T?T({get:j=>k[j]},t(k.length)):null}function l(k,y){return!y||typeof y.of!="string"||y.of===""||k&&k.includes(y.of)?k:[y.of,...k||[]]}function r(k,y){const T={},j=t(k.length);for(const[N,W]of Object.entries(y)){const R=W.fn||"count",x=F[R];if(!x){T[N]=null;continue}const A=W.of?k.map($=>P($,W.of)):[];T[N]=x({get:$=>A[$]},j)}return T}const t=(()=>{const k=new Map;return y=>{let T=k.get(y);if(!T){T=new Uint32Array(y);for(let j=0;j<y;j++)T[j]=j;k.size<512&&k.set(y,T)}return T}})();function i(k,y,T){if(!Number.isFinite(y)||y<=0)return k;if(!T)return k.slice(0,y);const j=new Map,N=[];for(const W of k){const R=String(P(W,T)),x=j.get(R)||0;x>=y||(j.set(R,x+1),N.push(W))}return N}function s(k,y){const T=k.reduce((R,x)=>R+(Number(P(x,y.of))||0),0);if(!T)return k;const j=T*y.upTo;let N=0;const W=[];for(const R of k)if(W.push(R),N+=Number(P(R,y.of))||0,N>=j)break;return W}function n(k,y){return!Array.isArray(y)||!y.length?k:[...k].sort((T,j)=>{for(const N of y){const W=P(T,N.col),R=P(j,N.col);if(W===R)continue;return W==null?1:R==null?-1:((typeof W=="number"&&typeof R=="number"?W<R:String(W)<String(R))?-1:1)*(N.dir==="desc"?-1:1)}return 0})}function u(k,y,T){const j=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,N=X(y.bucket)?y.bucket:null,W=l(j,N),R=new Map,x=new Map;if(!W)return{groups:R,rowGroup:x};for(const A of k){const{key:$,values:I}=c(A,W,N);let M=R.get($);M||(M={values:I,rows:new Map},R.set($,M));const S=T(A);M.rows.set(S,A),x.set(S,$)}return{groups:R,rowGroup:x}}function o(k,y,T=null,j=null){const N=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,W=X(y.bucket)?y.bucket:null,R=l(N,W);let x=[...k.entries()].map(([A,$])=>{if(T&&j&&!j.has(A)){const M=T.get(A);if(M)return M}const I={[B]:A};return R.forEach((M,S)=>{I[M.includes(".")?M.split(".").pop():M]=$.values[S]}),Object.assign(I,r([...$.rows.values()],y.select||{})),T&&T.set(A,I),I});return x=n(x,y.sort),X(y.cumulative)&&(x=s(x,y.cumulative)),i(x,y.limit,y.limitPer||null)}function a(k,y){const T=v(k,y),j=y.groupBy?Array.isArray(y.groupBy)?y.groupBy:[y.groupBy]:null,N=X(y.bucket)?y.bucket:null,W=l(j,N);let R;if(!W)R=T.map((x,A)=>({...x,[B]:String(P(x,y.rowKey||"id")??A)}));else{const x=new Map;for(const A of T){const{key:$,values:I}=c(A,W,N);let M=x.get($);M||(M={values:I,rows:[]},x.set($,M)),M.rows.push(A)}R=[...x.entries()].map(([A,$])=>{const I={[B]:A};return W.forEach((M,S)=>{I[M.includes(".")?M.split(".").pop():M]=$.values[S]}),Object.assign(I,r($.rows,y.select||{})),I})}return R=n(R,y.sort),X(y.cumulative)&&(R=s(R,y.cumulative)),i(R,y.limit,y.limitPer||null)}function f(k,y){const j=X(k)&&X(k.grid)?k:{grid:k};return{grid:X(j.grid)?j.grid:null,label:j.label!=null&&j.label!==""?String(j.label):String(y),follow:typeof j.follow=="string"?j.follow:void 0,map:L(j.map)?j.map:null}}function w(k){for(const y of k){const T=y[z];T!==void 0&&(y[B]=`${T}${G}${y[B]}`)}return k}function m(k,y){const T=y.on,j=X(T)?String(T.left||T.right||""):String(T||""),N=X(T)?String(T.right||T.left||""):String(T||"");if(!j||!N)return k;const W=y.index instanceof Map?y.index:h(Array.isArray(y.rows)?y.rows:[],N),R=Array.isArray(y.select)?y.select.map(String):null,x=y.prefix?String(y.prefix):"",A=String(y.type||"inner")==="left",$=[];for(const I of k){const M=P(I,j),S=M==null?void 0:W.get(String(M));if(!S){A&&$.push(I);continue}const E={...I},U=R||Object.keys(S);for(const K of U)!x&&K===j||(E[x?x+K:K]=P(S,K));$.push(E)}return $}function v(k,y){let T=Array.isArray(k)?k:[];return y.unnest&&(T=O(T,y.unnest)),X(y.join)&&(Array.isArray(y.join.rows)||y.join.index instanceof Map)&&(T=m(T,y.join)),L(y.where)&&(T=T.filter(j=>!!y.where(j))),T}function h(k,y){const T=new Map;for(const j of k){const N=P(j,y);if(N==null)continue;const W=String(N);T.has(W)||T.set(W,j)}return T}function p(k,y){const T=y.on,j=X(T)?String(T.left||T.right||""):String(T||""),N=X(T)?String(T.right||T.left||""):String(T||"");if(!j||!N)return k;const W=y.index instanceof Map?y.index:new Map,R=P(k,j),x=R==null?void 0:W.get(String(R));if(!x)return String(y.type||"inner")==="left"?k:null;const A=Array.isArray(y.select)?y.select.map(String):null,$=y.prefix?String(y.prefix):"",I={...k};for(const M of A||Object.keys(x))!$&&M===j||(I[$?$+M:M]=P(x,M));return I}function g(k,y){const T=P(k,y);return T==null?null:String(T)}}),Be("packages/core/src/source/derived.js",function(e,H){"use strict";Object.defineProperty(e,"IDLE_REFRESH_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"PROFILE_FIELDS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ALERT_THRESHOLDS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"STATISTICS_FNS",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"SERIES_METRICS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"PRODUCER_IGNORED_KEYS",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"profileAlerts",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"DerivedSource",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"createDerivedSource",{enumerable:!0,get:function(){return N}});const te=H("packages/core/src/internal/predicates.js"),L=te.isFunction,X=te.isObject,F=H("packages/core/src/internal/warn.js").warnOnce,Y=H("packages/core/src/source/memory.js").MemorySource,z=H("packages/core/src/source/settle.js").isPipelineSettle,G=H("packages/core/src/source/derive.js"),P=G.derive,O=G.preGroup,b=G.groupRows,c=G.finishGroups,d=G.readPath,l=G.buildJoinIndex,r=G.joinOne,t=G.joinKeyOf,i=G.FOLLOW_MODES,s=G.DERIVED_ROW_KEY,n=G.DERIVED_SOURCE_KEY,u=G.normalizeUnionSource,o=G.namespaceUnionKeys,a=16,f=Object.freeze(["column","rows","present","missing","numeric","distinct","min","max","mean","median","q1","q3","iqr","stddev","outliers","alerts","alertCount"]),w=Object.freeze({missing:.2,cardinality:.9,skew:1,outliers:.05}),m=Object.freeze(["correlation","series","datasetVsDataset"]),v=Object.freeze(["n","first","last","change","changePercent","volatility","annualisedVolatility","growth","maxDrawdown","maxDrawdownFrom","maxDrawdownTo","autocorrelation","upDays","downDays"]),h=Object.freeze(["unnest","join","where","bucket","groupBy","select","sort","limit","limitPer","cumulative"]);function p(W,R={}){const x={...w,...X(R)?R:{}},A=ee=>typeof ee=="number"&&Number.isFinite(ee)?ee:null,$=A(W.rows)??0,I=A(W.numeric)??0,M=A(W.missing)??0,S=A(W.distinct),E=A(W.mean),U=A(W.median),K=A(W.stddev),q=A(Array.isArray(W.outliers)?W.outliers.length:W.outliers),_=I>0,J=[];return S===0?["empty"]:(S===1&&J.push("constant"),$>0&&M/$>=x.missing&&J.push("high-missing"),!_&&S!==null&&$>1&&S===$&&M===0?J.push("unique"):S!==null&&$>0&&S/$>=x.cardinality&&J.push("high-cardinality"),_&&E!==null&&U!==null&&K!==null&&K>0&&Math.abs(3*(E-U)/K)>=x.skew&&J.push("skewed"),_&&q!==null&&q/I>=x.outliers&&J.push("outliers"),J)}class g extends Y{#e=null;#t={};#n=[];#r=null;#s=!1;#i={};#o=!1;#l=null;#a=null;#c=!1;#u=null;#f=!1;#d=null;constructor(R,x){super({mode:"memory",rows:[]},x),this.#i=x||{},this.#t=X(R)?R:{};const A=this.#t.from;if(Array.isArray(A)){if(this.#e=null,this.#d=this.#g(A),!this.#d.length){F("source.derived.from",'source.mode "derived" needs `from`: at least one grid to derive from.');return}this.#t.follow!==void 0&&F("source.derived.union.follow",'source.mode "derived": `follow` is ignored when `from` is a union of several grids (BACKLOG-0001045) — each entry carries its own `follow` instead.'),this.#t.crossFilter&&F("source.derived.union.crossfilter",'source.mode "derived": `crossFilter` is not supported when `from` is a union of several grids (BACKLOG-0001045) — it has no single target once there is more than one parent. Push a filter onto the individual source grid you mean instead.'),this.#t.statistics!==void 0&&(F("source.derived.union.statistics",'source.mode "derived": `statistics` is not supported when `from` is a union of several grids (BACKLOG-0001046) — a relational statistic reduces one grid\'s own columns, and a union has no single set of them. Derive the statistics of a single grid instead.'),this.#f=!0),this.#m(),this.#b(),this.refresh();return}if(this.#e=A||null,!this.#e){F("source.derived.from",'source.mode "derived" needs `from`: the grid to derive from.');return}this.#t.follow&&!i.includes(String(this.#t.follow))&&F(`source.derived.follow.${this.#t.follow}`,`unknown follow "${this.#t.follow}"; using "filtered". Known: ${i.join(", ")}.`),this.#h()||(this.#f=!0),this.#m(),this.#b(),this.refresh()}#h(){const R=this.#t.statistics;if(R===void 0)return!0;if(this.#t.profile!==void 0)return F("source.derived.producer.conflict",'source.mode "derived": `profile` and `statistics` are both terminal producers and cannot be used together — each replaces the pipeline with its own output builder. Declare one, or chain a second derived grid whose `from` is the first.'),!1;if(!X(R))return F("source.derived.statistics.shape",`source.mode "derived": \`statistics\` needs an object naming the statistic, e.g. \`{ fn: 'correlation', columns: ['a', 'b'] }\`. Known fn: ${m.join(", ")}.`),!1;const x=String(R.fn||"");return m.includes(x)?this.#p(x,R):(F(`source.derived.statistics.fn.${x}`,`source.mode "derived": unknown \`statistics.fn\` "${x}". Known: ${m.join(", ")}. Every *single-column* statistic is reached through \`select\` instead, e.g. \`select: { p95: { of: 'amount', fn: 'p95' } }\`.`),!1)}#p(R,x){if(R==="correlation"){if((Array.isArray(x.columns)?x.columns.filter(Boolean):[]).length<2)return F("source.derived.statistics.columns","source.mode \"derived\": `statistics: { fn: 'correlation' }` needs `columns`: at least two column ids to correlate pairwise."),!1;const $=x.orient===void 0?"pairs":String(x.orient);return $!=="pairs"&&$!=="matrix"&&F(`source.derived.statistics.orient.${$}`,`source.mode "derived": unknown \`statistics.orient\` "${$}" for \`fn: 'correlation'\`; using "pairs". Known: pairs, matrix.`),!0}return R==="series"?!x.of||!x.by?(F("source.derived.statistics.series","source.mode \"derived\": `statistics: { fn: 'series' }` needs both `of` (the column to summarise) and `by` (the column that orders it). `by` is never guessed — kernels see rows in arrival order, which is not the grid's sort."),!1):!0:X(x.with)?!0:(F("source.derived.statistics.with","source.mode \"derived\": `statistics: { fn: 'datasetVsDataset' }` needs `with`: the second grid to compare this one against."),!1)}#m(){const R=this.#t.statistics!==void 0?"statistics":this.#t.profile!==void 0?"profile":null;if(!R)return;const x=h.filter(A=>this.#t[A]!==void 0);x.length&&F(`source.derived.producer.ignored.${R}`,`source.mode "derived": \`${R}\` is a terminal producer and replaces the pipeline, so ${x.map(A=>`\`${A}\``).join(", ")} ${x.length>1?"are":"is"} ignored. Sort, filter or limit the derived grid itself, or chain a second derived grid whose \`from\` is this one.`)}#g(R){const x=this.#i&&this.#i.grid,A=new Set,$=[];return R.forEach((I,M)=>{const S=u(I,M);if(A.has(S.label)&&F(`source.derived.union.label.${S.label}`,`source.mode "derived": two union sources share the label "${S.label}"; give each a distinct \`label\` or __source/__key will not distinguish them.`),A.add(S.label),!S.grid){F(`source.derived.union.missing.${S.label}`,`source.mode "derived": union source "${S.label}" has no grid and was skipped.`),$.push(S);return}if(x&&L(S.grid.on)){const E=y(x,S.grid,[S.label]);if(E){F(`source.derived.union.cycle.${S.label}`,`source.mode "derived": union source "${S.label}" was refused — it derives from the grid being derived, directly or through a chain (${E.join(" → ")}). Remove it from \`from\`.`),$.push({...S,grid:null});return}}$.push(S)}),$}#b(){if(this.#d){this.#j(),this.#w();return}const R=this.#e;if(!R||!L(R.on))return;const x=String(this.#t.follow||"filtered"),A=["rows:changed"];(x==="filtered"||x==="grouped")&&A.push("filter:changed","model:changed"),x==="selected"&&A.push("selection:changed"),x==="grouped"&&A.push("column:grouped");for(const $ of A){const I=M=>{$==="rows:changed"&&k(M)||$==="model:changed"&&!z(M)||this.schedule($==="rows:changed"?M:null)};R.on($,I),this.#n.push(()=>L(R.off)&&R.off($,I))}this.#w(),this.#y()}#y(){const R=this.#t.statistics,x=X(R)?R.with:null;if(!X(x)||!L(x.on))return;const A=x;for(const $ of["rows:changed","filter:changed","model:changed"]){const I=M=>{$==="rows:changed"&&k(M)||$==="model:changed"&&!z(M)||this.schedule(null)};A.on($,I),this.#n.push(()=>L(A.off)&&A.off($,I))}}#j(){for(const R of this.#d){const x=R.grid;if(!x||!L(x.on))continue;const A=i.includes(String(R.follow))?String(R.follow):"filtered",$=["rows:changed"];(A==="filtered"||A==="grouped")&&$.push("filter:changed","model:changed"),A==="selected"&&$.push("selection:changed"),A==="grouped"&&$.push("column:grouped");for(const I of $){const M=S=>{I==="rows:changed"&&k(S)||I==="model:changed"&&!z(S)||this.schedule(null)};x.on(I,M),this.#n.push(()=>L(x.off)&&x.off(I,M))}}}#w(){const R=this.#t.join,x=R&&R.with;if(!x||!L(x.on))return;const $=String(R.follow||"all")==="all"?["rows:changed"]:["rows:changed","filter:changed","model:changed"];for(const I of $){const M=S=>{I==="rows:changed"&&k(S)||I==="model:changed"&&!z(S)||this.schedule({partner:!0})};x.on(I,M),this.#n.push(()=>L(x.off)&&x.off(I,M))}}#O(){const R=this.#t.join;if(!R||!R.with)return null;const x=R.on,A=X(x)?String(x.left||x.right||""):String(x||""),$=X(x)?String(x.right||x.left||""):String(x||"");return A&&$?{left:A,right:$}:null}#v(){const R=this.#O();if(!R)return this.#u=null,null;const x=this.#u;if(this.#u=l(this.#E(),R.right),!x)return null;const A=this.#t.join||{},$=Array.isArray(A.select)?A.select.map(String):null,I=E=>E?($||Object.keys(E)).map(K=>String(d(E,K))).join(""):null,M=new Set,S=new Set;for(const[E,U]of this.#u)I(U)!==I(x.get(E))&&(M.add(E),x.has(E)||S.add(E));for(const E of x.keys())this.#u.has(E)||M.add(E);return{affected:M,gained:S}}#T(R,x){const A=this.#l;if(!A||!A.leftByJoinKey)return null;const $=[];for(const I of R){const M=A.leftByJoinKey.get(I);if(M)for(const S of M){const E=A.rowData.get(S);E!==void 0&&$.push({key:S,data:E})}}return this.#N({updated:$,added:[],removed:[]},x)}#S(R,x){if(!this.#l||!this.#l.leftByJoinKey||R.unnest||R.where||String(R.follow||"filtered")==="grouped")return!1;const A=R.join||{};return String(A.type||"inner")==="left"?!0:x.size===0}#E(){const R=this.#t.join,x=R&&R.with;if(!x||!x.rows)return[];const A=[],$=I=>{I.group||A.push(T(I))};return String(R.follow||"all")==="filtered"&&L(x.rows.forEach)?x.rows.forEach($):L(x.rows.forEachAll)&&x.rows.forEachAll($),A}schedule(R){const x=this.#t.refresh===void 0?"idle":this.#t.refresh;if(x==="manual")return;if(x==="live"){this.refresh(R);return}const A=typeof x=="number"&&Number.isFinite(x)?x:a;if(this.#r){this.#c=!0;return}this.#c=!1,this.#r=setTimeout(()=>{this.#r=null,this.refresh(this.#c?null:R)},A)}refresh(R){if(!(this.#s||!this.#e&&!this.#d)){if(this.#o){F("source.derived.cycle","a derived grid is deriving from itself, directly or through a chain. The cycle was refused; check the `from` of each grid in the chain.");return}this.#o=!0;try{const x=this.#f?[]:this.#d?this.#t.profile?this.#Y():this.#F():this.#t.statistics!==void 0?this.#ne():this.#t.profile?this.#me():this.#M(R);this.setRows(x),this.invalidate("filter"),L(this.#i.emit)&&this.#i.emit("rows:changed",{derived:!0},"derived")}finally{this.#o=!1}}}#M(R){const A=X(R)&&R.partner===!0?this.#v():null,$=this.#U();if(A&&this.#l){if(!A.affected.size)return c(this.#l.groups,$,this.#l.reduced,new Set);if(this.#S($,A.gained)){const ne=this.#T(A.affected,$);if(ne)return c(this.#l.groups,$,this.#l.reduced,ne)}}const I=this.#P($,R);if(I&&this.#l){const ne=this.#N(I,$);return c(this.#l.groups,$,this.#l.reduced,ne)}const M=O(this.#I(),$);if(this.#a=this.#L(),!$.groupBy)return this.#l=null,P(M,$);const S=this.#R(),{groups:E,rowGroup:U}=b(M,$,S),K=new Map;for(const[ne,oe]of U){const ie=E.get(oe);ie&&K.set(ne,ie.rows.get(ne))}const q=new Map,_=this.#O(),J=new Map,ee=new Map;if(_)for(const[ne,oe]of K){const ie=t(oe,_.left);if(ie===null)continue;J.set(ne,ie);let ae=ee.get(ie);ae||(ae=new Set,ee.set(ie,ae)),ae.add(ne)}return this.#l={groups:E,rowGroup:U,rowData:K,reduced:q,leftJoinKey:J,leftByJoinKey:ee},c(E,$,q,null)}#P(R,x){if(!this.#l||!R.groupBy||R.unnest||R.where||String(R.follow||"filtered")==="grouped"||X(R.join)&&R.join.with&&!(R.join.index instanceof Map)||!X(x))return null;const A=Array.isArray(x.updated)?x.updated:null,$=Array.isArray(x.added)?x.added:null,I=Array.isArray(x.removed)?x.removed:null;if(!A&&!$&&!I)return null;const M=this.#a;if(M&&M.size&&String(R.follow||"filtered")!=="all"){if(x.edit===!0&&Array.isArray(x.columns)){for(const S of x.columns)if(M.has(String(S)))return null}for(const S of A||[]){const E=S&&S.key,U=E===void 0?void 0:this.#l.rowData.get(String(E)),K=T(S);for(const q of M)if(d(U,q)!==d(K,q))return null}}return{updated:A||[],added:$||[],removed:I||[]}}#N(R,x){const A=this.#l,$=this.#R(),I=new Set,M=X(x.join)&&x.join.index instanceof Map?x.join:null,S=this.#O(),E=K=>{const q=A.rowGroup.get(K);if(q===void 0)return;I.add(q);const _=A.groups.get(q);if(_&&(_.rows.delete(K),_.rows.size||A.groups.delete(q)),A.rowGroup.delete(K),A.rowData.delete(K),A.leftJoinKey){const J=A.leftJoinKey.get(K);if(J!==void 0){const ee=A.leftByJoinKey.get(J);ee&&(ee.delete(K),ee.size||A.leftByJoinKey.delete(J)),A.leftJoinKey.delete(K)}}},U=K=>{const q=M?r(K,M):K;if(!q)return;const _=$(q),J=b([q],x,$);for(const[ee,ne]of J.groups){let oe=A.groups.get(ee);oe||(oe={values:ne.values,rows:new Map},A.groups.set(ee,oe)),oe.rows.set(_,q),A.rowGroup.set(_,ee),I.add(ee)}if(A.rowData.set(_,q),S&&A.leftByJoinKey){const ee=t(q,S.left);if(ee!==null){A.leftJoinKey.set(_,ee);let ne=A.leftByJoinKey.get(ee);ne||(ne=new Set,A.leftByJoinKey.set(ee,ne)),ne.add(_)}}};for(const K of R.removed)E(String(K));for(const K of R.updated)E(String(K.key)),U(T(K));for(const K of R.added)U(T(K));return I}#R(){const R=this.#e,x=R&&R.config&&R.config.rowKey||"id";return A=>String(d(A,typeof x=="string"?x:"id")??"")}#L(){const R=this.#e,x=R&&R.state&&L(R.state.get)?R.state.get():null,A=new Set,$=I=>{if(I){if(Array.isArray(I.conditions)){I.conditions.forEach($);return}I.col&&A.add(String(I.col))}};return x&&$(x.filters),A}#U(){let R=this.#t;if(R.join&&R.join.with&&(this.#u||this.#v(),R={...R,join:{...R.join,index:this.#u}}),this.#d||String(R.follow||"filtered")!=="grouped")return R;const x=this.#e,A=x&&x.state&&L(x.state.get)?x.state.get():null,$=A&&Array.isArray(A.group)?A.group:[];return $.length?{...R,groupBy:[...$]}:R}#G(){const R=[];for(const x of this.#d)if(x.grid)try{const A=i.includes(String(x.follow))?String(x.follow):"filtered",$=this.#x(x.grid,A);for(const I of $){const M=x.map?x.map(I):I;X(M)&&R.push({...M,[n]:x.label})}}catch(A){F(`source.derived.union.failed.${x.label}`,`source.mode "derived": union source "${x.label}" failed to read (${A&&A.message?A.message:A}) and was skipped this pass.`)}return R}#x(R,x){if(!R||!R.rows)return[];if(x==="all"){const $=[];return L(R.rows.forEachAll)&&R.rows.forEachAll(I=>{I.group||$.push(T(I))}),$}if(x==="selected")return(R.selection&&L(R.selection.rows)?R.selection.rows():[]).filter(Boolean).map(T);const A=[];return L(R.rows.forEach)&&R.rows.forEach($=>{$.group||A.push(T($))}),A}#F(){const R=this.#U(),x=this.#G(),A=P(x,R);return R.groupBy?A:o(A)}#Y(){return F("source.derived.union.profile",'source.mode "derived": `profile` is not supported when `from` is a union of several grids (BACKLOG-0001045); profile a single grid instead.'),[]}#I(){const R=this.#e,x=String(this.#t.follow||"filtered");if(!R||!R.rows)return[];if(x==="all"){const I=[];return L(R.rows.forEachAll)&&R.rows.forEachAll(M=>{M.group||I.push(T(M))}),I}if(x==="selected")return(R.selection&&L(R.selection.rows)?R.selection.rows():[]).filter(Boolean).map(T);const A=this.#K(),$=[];return A&&this.#H().length&&L(R.rows.forEachExcept)?(R.rows.forEachExcept(A,I=>{I.group||$.push(T(I))}),$):(L(R.rows.forEach)&&R.rows.forEach(I=>{I.group||$.push(T(I))}),$)}#K(){const R=this.#t.crossFilter;if(!R||this.#d)return null;if(typeof R=="string")return R;if(R.col)return String(R.col);const x=this.#t.groupBy,A=Array.isArray(x)?x[0]:x;return A?String(A):null}#H(){const R=this.#K(),x=this.#e;if(!R||!x||!x.filters||!L(x.filters.get))return[];const A=j(x.filters.get(),R);return A?A.op==="in"&&Array.isArray(A.value)?A.value.map(String):A.op==="eq"&&A.value!==void 0?[String(A.value)]:[]:[]}#z(R){const x=this.#K(),A=this.#e;if(!x||!A||!A.filters||!L(A.filters.set))return;const $=this.#i.compute||{},I=L(A.filters.get)?A.filters.get():null,M=L($.pruneColumn)?$.pruneColumn(I,x):null;if(!R.length){A.filters.set(M||null);return}const S=R.length===1?{col:x,op:"eq",value:R[0]}:{col:x,op:"in",value:R.slice()},E=M?M.conditions&&M.op?M.conditions:[M]:[];A.filters.set(E.length?{op:"and",conditions:[...E,S]}:S)}crossFilter(){const R=this;return{enabled(){return!!R.#K()},column(){return R.#K()},get(){return R.#H()},set(x){const A=x==null?[]:(Array.isArray(x)?x:[x]).map($=>String($));R.#z(A)},toggle(x){const A=String(x),$=R.#H(),M=$.indexOf(A)>=0?$.filter(S=>S!==A):[...$,A];R.#z(M)},clear(){R.#z([])}}}#fe(R){const x=R&&R.rows;if(x&&L(x.matchCount)){const A=x.matchCount(),$=Number(A);if(A!==null&&Number.isFinite($))return $}if(x&&L(x.count)){const A=Number(x.count());if(Number.isFinite(A))return A}return 0}#ne(){const R=this.#e,x=this.#t.statistics;if(!R||!R.statistics||!X(x))return[];switch(String(x.fn)){case"correlation":return this.#pe(R,x);case"series":return this.#Ie(R,x);case"datasetVsDataset":return this.#Oe(R,x);default:return[]}}#pe(R,x){const A=x.columns.filter(Boolean).map(String),$=this.#fe(R),I=(M,S)=>{const E=R.statistics.correlation(M,S);return typeof E=="number"&&Number.isFinite(E)?E:null};if(String(x.orient||"pairs")!=="matrix"){const M=[];for(let S=0;S<A.length;S++)for(let E=S+1;E<A.length;E++)M.push({[s]:`${A[S]}${A[E]}`,a:A[S],b:A[E],coefficient:I(A[S],A[E]),n:$});return M}return A.map(M=>{const S={[s]:M,column:M};for(const E of A)S[E]=M===E?1:I(M,E);return S.n=$,S})}#Ie(R,x){const A=this.#fe(R),$={by:String(x.by)};x.periodsPerYear!==void 0&&($.periodsPerYear=Number(x.periodsPerYear));const I=R.statistics.series(String(x.of),$)||{};return v.map(M=>({[s]:M,metric:M,value:I[M]??null,n:A}))}#Oe(R,x){const A=x.with,$=Array.isArray(x.columns)?{columns:x.columns.map(String)}:void 0,I=R.statistics.datasetVsDataset(A,$);if(!X(I))return[];const S=(Array.isArray(I.ranked)?I.ranked:[]).map(K=>({[s]:String(K.column),column:K.column,measure:K.measure??null,magnitude:K.magnitude??null,distance:K.distance??null,direction:K.direction??null,nA:K.nA??null,nB:K.nB??null,reliable:K.reliable??null,unmatched:""})),E=I.unmatched,U=[["A",E&&E.onlyA],["B",E&&E.onlyB]];for(const[K,q]of U)for(const _ of q||[])S.push({[s]:`${K}${_}`,column:_,measure:null,magnitude:null,distance:null,direction:null,nA:null,nB:null,reliable:!1,unmatched:K});return S}#me(){const R=this.#e;if(!R||!R.statistics||!L(R.statistics.profile))return[];const A=(Array.isArray(this.#t.profile)?this.#t.profile:[this.#t.profile]).filter(Boolean).map(I=>{const M=R.statistics.profile(String(I))||{},S={[s]:String(I)};for(const U of f)S[U]=U==="column"?String(I):M[U]??null;S.outliers=Array.isArray(M.outliers)?M.outliers.length:M.outliers??null;const E=p({...M,rows:S.rows,outliers:S.outliers,numeric:M.numeric},this.#t.alerts);return S.alerts=E.join(", "),S.alertCount=E.length,S});if(this.#t.orient!=="metrics")return A;const $=A[0];return $?f.filter(I=>I!=="column").map(I=>({[s]:I,metric:I,value:$[I]})):[]}apply(R){const x=["add","update","remove"],A=[];for(const $ of x)for(const I of R&&R[$]||[])A.push({operation:$,id:I&&I.id,reason:"derived-read-only"});return A.length&&F("source.derived.readonly","a derived grid is read-only: its rows are computed from another grid. Write to the source grid instead, and the derived one follows."),{added:[],updated:[],removed:[],rejected:A}}destroy(){this.#s=!0,this.#r&&(clearTimeout(this.#r),this.#r=null),this.#K()&&this.#H().length&&this.#z([]);for(const R of this.#n)try{R()}catch{}this.#n=[],this.#e=null,this.#d=null,super.destroy()}}function k(W){return X(W)&&W.companion===!0}function y(W,R,x,A=new Set){if(R===W)return x;if(A.has(R))return null;A.add(R);let $=null;try{$=L(R.config)?R.config():null}catch{$=null}const I=$&&X($.source)?$.source:null;if(!I||I.mode!=="derived")return null;const M=I.from;if(Array.isArray(M)){for(let S=0;S<M.length;S++){const E=u(M[S],S);if(!E.grid||!L(E.grid.on))continue;const U=y(W,E.grid,[...x,E.label],A);if(U)return U}return null}return X(M)&&L(M.on)?y(W,M,[...x,"(from)"],A):null}function T(W){return X(W)&&"data"in W?W.data:W}function j(W,R){if(!W||typeof W!="object")return null;if(Array.isArray(W.conditions)){for(const A of W.conditions){const $=j(A,R);if($)return $}return null}return W.col===R?W:null}function N(W,R){return new g(W,R)}}),Be("packages/core/src/source/adapters/odata.js",function(e,H){"use strict";Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return f}});const L=H("packages/core/src/internal/warn.js").warnOnce,D=H("packages/core/src/source/filterwire.js").isGroup,F=Object.freeze(["eq","ne","gt","gte","lt","lte","contains","startsWith","endsWith","blank","notBlank","between","notBetween"]),Z=/^\d{4}-\d{2}-\d{2}$/,Y=/^\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/,B=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/;function z(w){const m=w instanceof Date?w:typeof w=="number"&&Number.isFinite(w)?new Date(w):typeof w=="string"&&B.test(w)?new Date(w):null;return m&&!Number.isNaN(m.getTime())?m:null}const G=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function P(w,m){throw typeof m=="string"&&G.test(m)?new Error(`odataAdapter: "${m}" needs a zone designator to be used as a ${w} value — add "Z" for UTC or a "+HH:MM"/"-HH:MM" offset. A date-time with no zone is ambiguous (whose local time?) and would otherwise silently become the wrong instant rather than the one intended.`):new Error(`odataAdapter: "${String(m)}" is not a usable ${w} value`)}function O(w){const m=z(w);return m||P("DateTimeOffset",w),m.toISOString()}function b(w){if(typeof w=="string"&&Z.test(w))return w;const m=z(w);return m||P("Date",w),m.toISOString().slice(0,10)}function c(w){if(typeof w=="string"&&Y.test(w))return w.length===5?`${w}:00`:w;if(typeof w=="number"&&Number.isFinite(w)&&w>=0&&w<864e5){const m=Math.floor(w),v=h=>String(h).padStart(2,"0");return`${v(Math.floor(m/36e5))}:${v(Math.floor(m%36e5/6e4))}:${v(Math.floor(m%6e4/1e3))}`}throw new Error(`odataAdapter: "${String(w)}" is not a usable TimeOfDay value`)}const d=Object.freeze({timestamp:O,datetime:O,date:b,dateString:b,time:c}),l=200,r=1e3,t=Object.freeze({eq:"eq",ne:"ne",gt:"gt",gte:"ge",lt:"lt",lte:"le"});function i(w,m){if(w==null)return"null";const v=m&&d[String(m)];return v?v(w):typeof w=="number"||typeof w=="boolean"?String(w):w instanceof Date?w.toISOString():`'${String(w).replace(/'/g,"''")}'`}function s(w){const m=String(w),v=/^[A-Za-z_][A-Za-z0-9_]*$/;if(!m||!m.split("/").every(h=>v.test(h)))throw new Error(`odataAdapter: "${m}" is not a usable column name`);return m}const n=Object.freeze({lo:{incl:"ge",excl:"gt"},hi:{incl:"le",excl:"lt"}});function u(w){const m=s(w.col),v=String(w.op),h=w.type;if(t[v])return`${m} ${t[v]} ${i(w.value,h)}`;if(v==="contains")return`contains(${m},${i(w.value,h)})`;if(v==="startsWith")return`startswith(${m},${i(w.value,h)})`;if(v==="endsWith")return`endswith(${m},${i(w.value,h)})`;if(v==="blank")return`(${m} eq null)`;if(v==="notBlank")return`(${m} ne null)`;if(v==="between"||v==="notBetween"){const p=Array.isArray(w.value)?w.value:[w.value,w.value],g=String(w.bounds||"[]"),k=g.charAt(0)==="("?n.lo.excl:n.lo.incl,y=g.charAt(1)===")"?n.hi.excl:n.hi.incl,T=`(${m} ${k} ${i(p[0],h)} and ${m} ${y} ${i(p[1],h)})`;return v==="between"?T:`(${m} eq null or not ${T})`}return null}function o(w){const m=String(w&&w.op);throw L(`source.odata.filter.refuse.${m}`,`a "${m}" filter condition cannot be written as an OData $filter expression, so the request was refused rather than sent without it — silently dropping it would have matched more or fewer rows than the filter asked for. Route this condition through a source that can pushdown-split it as residual (source.filter capability), or drop it from the tree before building the URL.`),new Error(`odataAdapter: a "${m}" filter condition cannot be expressed in OData and was refused`)}function a(w){if(!w)return"";if(!D(w)){const h=u(w);return h===null?o(w):h}const m=String(w.op)==="or"?" or ":" and ",v=(w.conditions||[]).map(h=>{if(D(h))return a(h);const p=u(h);return p===null?o(h):p}).filter(Boolean);return v.length?v.length===1?v[0]:`(${v.join(m)})`:""}function f(w={}){const m=String(w.url||""),v=w.fetch||(typeof fetch=="function"?fetch:null),h=w.count!==!1,p=s(w.key||"id"),g=w.edit===!0;return{name:"odata",capabilities:{filter:"tree",operators:F,sort:"multi",quick:w.search===!0,range:!0,total:h,mutate:g?{update:!0,delete:!0,append:!0,returning:"row"}:!1},urlFor(k){const y=[],T=(N,W)=>y.push(`${N}=${encodeURIComponent(W)}`),j=a(k.filters);return j&&T("$filter",j),k.sort&&k.sort.length&&T("$orderby",k.sort.map(N=>`${s(N.col)}${N.dir==="desc"?" desc":" asc"}`).join(",")),k.range&&(T("$skip",String(k.range.start)),T("$top",String(k.range.end-k.range.start))),k.quick&&T("$search",`"${String(k.quick).replace(/"/g,"")}"`),h&&T("$count","true"),y.length?`${m}?${y.join("&")}`:m},async execute(k,y){if(!v)throw new Error("odataAdapter needs a fetch implementation");const T={Accept:"application/json",...w.headers||{}},j=y&&y.signal,N=async A=>{const $=await v(A,{headers:T,signal:j});if(!$.ok)throw new Error(`OData request failed: ${$.status}`);return $.json()};let W=await N(this.urlFor(k)),R=W.value||W.rows||[];const x=W["@odata.count"]??W.count;if(!k.range){let A=W["@odata.nextLink"];for(;A&&R.length<l*r;)W=await N(A),R=R.concat(W.value||W.rows||[]),A=W["@odata.nextLink"]}return x==null?(h&&L("source.odata.nocount",`${m} was asked for $count=true and answered without an @odata.count, so the grid has no total for this query and will scroll open-ended rather than present the page size as the whole. The endpoint does not support $count, or filters it out.`),{rows:R}):{rows:R,total:Number(x)}},urlForKey(k){return`${m}(${i(k)})`},async mutate(k,y){if(!v)throw new Error("odataAdapter needs a fetch implementation");if(!k||k.kind!=="update"&&k.kind!=="delete"&&k.kind!=="append")throw new Error(`odataAdapter: mutation kind "${k&&k.kind}" is not supported (update, delete and append are wired)`);const T={Accept:"application/json","Content-Type":"application/json",...w.headers||{}},j=y&&y.signal;if(k.kind==="delete"){const A=Array.isArray(k.keys)&&k.keys.length?k.keys[0]:k.key;if(A==null)throw new Error("odataAdapter: a delete needs a row key");const $=await v(this.urlForKey(A),{method:"DELETE",headers:T,signal:j});if(!$.ok)throw new Error(`OData delete failed: ${$.status}`);return{ok:!0}}if(k.kind==="append"){const A=Array.isArray(k.rows)?k.rows.filter(E=>E&&typeof E=="object"):[];if(A.length!==1)throw new Error("odataAdapter: an append needs exactly one row object (OData creates one entity per POST)");const $=await v(m,{method:"POST",headers:T,signal:j,body:JSON.stringify(A[0])});if(!$.ok)throw new Error(`OData add-row failed: ${$.status}`);const I=$.status===204?null:await $.json().catch(()=>null),M=I&&typeof I=="object"&&"value"in I?I.value:I;if(!M||typeof M!="object")throw new Error("odataAdapter: the POST returned no created entity to rekey the appended row by. Have the service return the created entity (Prefer: return=representation).");const S=M[p];if(S==null)throw new Error(`odataAdapter: the created entity carried no ${p} to rekey the appended row by.`);return{ok:!0,keys:[String(S)],rows:[M]}}const N=this.urlForKey(k.key),W=await v(N,{method:"PATCH",headers:T,signal:j,body:JSON.stringify(k.patch||{})});if(!W.ok)throw new Error(`OData update failed: ${W.status}`);if(W.status===204)return{ok:!0};const R=await W.json(),x=R&&typeof R=="object"&&"value"in R?R.value:R;return x==null?{ok:!0}:{ok:!0,rows:[x]}}}}}),Be("packages/core/src/source/adapters/rest.js",function(e,H){"use strict";Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(e,"DEFAULT_VERBS",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return X}});const te=Object.freeze({offset:"offset",limit:"limit",sort:"sort",order:"order",filter:"filter",search:"q"}),L=Object.freeze({update:"PATCH",delete:"DELETE",append:"POST"});function X(D={}){const F=String(D.url||""),Z=D.fetch||(typeof fetch=="function"?fetch:null),Y={...te,...D.params||{}},B=D.encodeFilter||(r=>JSON.stringify(r)),z=D.rows||(r=>Array.isArray(r)?r:r.rows||r.data||[]),G=D.total||((r,t)=>Array.isArray(r)?t.length:r.total??r.count??t.length),P=D.edit===!0,O=D.returning==="row"?"row":D.returning==="key"?"key":"none",b=D.keyField||"id",c=D.writeUrlFor||(r=>`${F}/${encodeURIComponent(String(r.key??(r.keys&&r.keys[0])))}`),d=D.encodeMutation||(r=>{const t=L[r.kind];if(r.kind==="update")return{method:t,url:c(r),headers:{"Content-Type":"application/json"},body:JSON.stringify(r.patch||{})};if(r.kind==="append"){const i=Array.isArray(r.rows)?r.rows:r.rows?[r.rows]:[];return{method:t,url:F,headers:{"Content-Type":"application/json"},body:JSON.stringify(i.length===1?i[0]:i)}}return{method:t,url:c(r)}}),l=D.writeRow||(r=>{if(r===null||typeof r!="object")return null;if(Array.isArray(r))return r.length?r[0]:null;const t=r;return t.row??t.data??r});return{name:"rest",capabilities:{range:!0,total:!0,sort:"multi",filter:!1,quick:!1,mutate:P?{update:!0,delete:!0,append:!0,returning:O}:!1,...D.capabilities||{},...D.operators?{filter:"tree",operators:D.operators}:{}},urlFor(r){const t=new URLSearchParams;r.range&&(t.set(Y.offset,String(r.range.start)),t.set(Y.limit,String(r.range.end-r.range.start))),r.sort&&r.sort.length&&(t.set(Y.sort,r.sort.map(s=>s.col).join(",")),t.set(Y.order,r.sort.map(s=>s.dir||"asc").join(","))),r.filters&&t.set(Y.filter,B(r.filters)),r.quick&&t.set(Y.search,String(r.quick));const i=t.toString();return i?`${F}?${i}`:F},async execute(r,t){if(!Z)throw new Error("restAdapter needs a fetch implementation");const i=await Z(this.urlFor(r),{headers:{Accept:"application/json",...D.headers||{}},signal:t&&t.signal});if(!i.ok)throw new Error(`request failed: ${i.status}`);const s=await i.json(),n=z(s);return{rows:n,total:G(s,n)}},writeUrlFor(r){return c(r)},encodeMutation(r){return d(r)},async mutate(r,t){if(!Z)throw new Error("restAdapter needs a fetch implementation");if(!r||r.kind!=="update"&&r.kind!=="delete"&&r.kind!=="append")throw new Error(`restAdapter: mutation kind "${r&&r.kind}" is not supported (update, delete and append are wired)`);const i=d(r);if(!i||!i.url||!i.method)throw new Error("restAdapter: encodeMutation must return { method, url }");const s={Accept:"application/json",...D.headers||{},...i.headers||{}},n=await Z(i.url,{method:i.method,headers:s,signal:t&&t.signal,...i.body!==void 0?{body:i.body}:{}});if(!n.ok)throw new Error(`REST ${r.kind} failed: ${n.status}`);if(r.kind==="append"){if(O==="none")return{ok:!0};if(n.status===204)throw new Error("restAdapter: the add-row POST returned 204 with no body, so the appended row has no server key to rekey by. Declare returning: 'row'/'key' and have the endpoint return the created row.");const a=await n.json(),f=l(a),w=f&&typeof f=="object"?f[b]:void 0;if(w==null)throw new Error(`restAdapter: the add-row response carried no ${b} to rekey the appended row by. Point \`keyField\` at the primary key the endpoint returns, or override \`writeRow\`.`);return O==="row"?{ok:!0,keys:[String(w)],rows:[f]}:{ok:!0,keys:[String(w)]}}if(O!=="row"||n.status===204)return{ok:!0};const u=await n.json(),o=l(u);return o==null?{ok:!0}:{ok:!0,rows:[o]}}}}}),Be("packages/core/src/source/adapters/dfql.js",function(e,H){"use strict";Object.defineProperty(e,"DFQL_BASE",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"DFQL_WRITE_URL",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return P}});const L=H("packages/core/src/internal/predicates.js").isFunction,D=H("packages/core/src/internal/warn.js").warnOnce,F="https://rest.demandflow.com",Z="https://stream.demandflow.com/dfql",Y=Object.freeze(["id","created","updated","ownerId","entity"]);function B(O){const b={},c=[];for(const[d,l]of Object.entries(O||{})){if(Y.includes(d)){c.push(d);continue}b[d]=l}return c.length&&D("source.dfql.protected",`a DFQL update tried to write protected field(s) ${c.join(", ")}; they are server-assigned and immutable, so they were dropped from the PATCH.`),b}function z(O){if(!O||typeof O!="object"||Array.isArray(O))return["fields (must be an object)"];const b=O,c=[];return(typeof b.entity!="string"||!b.entity)&&c.push("entity (uppercase code)"),Number.isFinite(Number(b.level))||c.push("level (numeric)"),(typeof b.comboKey!="string"||!b.comboKey.endsWith("|ENT:"))&&c.push("comboKey (a string ending '|ENT:')"),c}async function G(O){const b=[],c=t=>{const i=t.trim();if(i)try{b.push(JSON.parse(i))}catch{}};if(!O.body||typeof O.body.getReader!="function")return(await O.text()).split(`